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, *changed_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 void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
521 static void _changed_job(void *data);
522 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
523 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
524 static Eina_Bool _item_single_select_up(Widget_Data *wd);
525 static Eina_Bool _item_single_select_down(Widget_Data *wd);
526 static Eina_Bool _event_hook(Evas_Object *obj,
528 Evas_Callback_Type type,
530 static Eina_Bool _deselect_all_items(Widget_Data *wd);
531 static void _pan_calculate(Evas_Object *obj);
532 // TODO : refactoring
533 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
534 static unsigned int current_time_get();
535 static Eina_Bool _item_moving_effect_timer_cb(void *data);
536 static int _item_flip_effect_show(Elm_Genlist_Item *it);
537 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
538 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
539 static void _effect_item_unrealize(Elm_Genlist_Item *it);
540 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
541 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
542 static void _create_sweep_objs(Elm_Genlist_Item *it);
543 static void _delete_sweep_objs(Elm_Genlist_Item *it);
544 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
545 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
546 static void _group_items_recalc(void *data);
547 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items);
548 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
549 static void _item_auto_scroll(void *data);
551 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
554 _event_hook(Evas_Object *obj,
555 Evas_Object *src __UNUSED__,
556 Evas_Callback_Type type,
559 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
560 Evas_Event_Key_Down *ev = event_info;
561 Widget_Data *wd = elm_widget_data_get(obj);
562 if (!wd) return EINA_FALSE;
563 if (!wd->items) return EINA_FALSE;
564 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
565 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
567 Elm_Genlist_Item *it = NULL;
570 Evas_Coord step_x = 0;
571 Evas_Coord step_y = 0;
574 Evas_Coord page_x = 0;
575 Evas_Coord page_y = 0;
577 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
578 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
579 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
580 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
582 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
586 else if ((!strcmp(ev->keyname, "Right")) ||
587 (!strcmp(ev->keyname, "KP_Right")))
591 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
593 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
594 (_item_multi_select_up(wd)))
595 || (_item_single_select_up(wd)))
597 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
603 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
605 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
606 (_item_multi_select_down(wd)))
607 || (_item_single_select_down(wd)))
609 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
615 else if ((!strcmp(ev->keyname, "Home")) ||
616 (!strcmp(ev->keyname, "KP_Home")))
618 it = elm_genlist_first_item_get(obj);
619 elm_genlist_item_bring_in(it);
620 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
623 else if ((!strcmp(ev->keyname, "End")) ||
624 (!strcmp(ev->keyname, "KP_End")))
626 it = elm_genlist_last_item_get(obj);
627 elm_genlist_item_bring_in(it);
628 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
631 else if ((!strcmp(ev->keyname, "Prior")) ||
632 (!strcmp(ev->keyname, "KP_Prior")))
635 y -= -(page_y * v_h) / 100;
639 else if ((!strcmp(ev->keyname, "Next")) ||
640 (!strcmp(ev->keyname, "KP_Next")))
643 y += -(page_y * v_h) / 100;
647 else if(((!strcmp(ev->keyname, "Return")) ||
648 (!strcmp(ev->keyname, "KP_Enter")) ||
649 (!strcmp(ev->keyname, "space")))
650 && (!wd->multi) && (wd->selected))
652 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
653 elm_genlist_item_expanded_set(it,
654 !elm_genlist_item_expanded_get(it));
656 else if (!strcmp(ev->keyname, "Escape"))
658 if (!_deselect_all_items(wd)) return EINA_FALSE;
659 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
662 else return EINA_FALSE;
664 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
665 elm_smart_scroller_child_pos_set(wd->scr, x, y);
670 _deselect_all_items(Widget_Data *wd)
672 if (!wd->selected) return EINA_FALSE;
674 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
680 _item_multi_select_up(Widget_Data *wd)
682 if (!wd->selected) return EINA_FALSE;
683 if (!wd->multi) return EINA_FALSE;
685 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
686 if (!prev) return EINA_TRUE;
688 if (elm_genlist_item_selected_get(prev))
690 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
691 wd->last_selected_item = prev;
692 elm_genlist_item_show(wd->last_selected_item);
696 elm_genlist_item_selected_set(prev, EINA_TRUE);
697 elm_genlist_item_show(prev);
703 _item_multi_select_down(Widget_Data *wd)
705 if (!wd->selected) return EINA_FALSE;
706 if (!wd->multi) return EINA_FALSE;
708 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
709 if (!next) return EINA_TRUE;
711 if (elm_genlist_item_selected_get(next))
713 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
714 wd->last_selected_item = next;
715 elm_genlist_item_show(wd->last_selected_item);
719 elm_genlist_item_selected_set(next, EINA_TRUE);
720 elm_genlist_item_show(next);
726 _item_single_select_up(Widget_Data *wd)
728 Elm_Genlist_Item *prev;
731 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
732 while ((prev) && (prev->delete_me))
733 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
735 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
737 if (!prev) return EINA_FALSE;
739 _deselect_all_items(wd);
741 elm_genlist_item_selected_set(prev, EINA_TRUE);
742 elm_genlist_item_show(prev);
747 _item_single_select_down(Widget_Data *wd)
749 Elm_Genlist_Item *next;
752 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
753 while ((next) && (next->delete_me))
754 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
756 else next = elm_genlist_item_next_get(wd->last_selected_item);
758 if (!next) return EINA_FALSE;
760 _deselect_all_items(wd);
762 elm_genlist_item_selected_set(next, EINA_TRUE);
763 elm_genlist_item_show(next);
768 _on_focus_hook(void *data __UNUSED__,
771 Widget_Data *wd = elm_widget_data_get(obj);
773 if (elm_widget_focus_get(obj))
775 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
776 evas_object_focus_set(wd->obj, EINA_TRUE);
777 if ((wd->selected) && (!wd->last_selected_item))
778 wd->last_selected_item = eina_list_data_get(wd->selected);
782 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
783 evas_object_focus_set(wd->obj, EINA_FALSE);
788 _del_hook(Evas_Object *obj)
790 Widget_Data *wd = elm_widget_data_get(obj);
792 _item_cache_zero(wd);
793 if (wd->calc_job) ecore_job_del(wd->calc_job);
794 if (wd->update_job) ecore_job_del(wd->update_job);
795 if (wd->changed_job) ecore_job_del(wd->changed_job);
796 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
797 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
798 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
799 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, ELM_GENLIST_EDIT_MODE_NONE, NULL);
804 _del_pre_hook(Evas_Object *obj)
806 Widget_Data *wd = elm_widget_data_get(obj);
808 evas_object_del(wd->pan_smart);
809 wd->pan_smart = NULL;
810 elm_genlist_clear(obj);
814 _theme_hook(Evas_Object *obj)
816 Widget_Data *wd = elm_widget_data_get(obj);
819 _item_cache_zero(wd);
820 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
821 elm_widget_style_get(obj));
822 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
823 wd->item_width = wd->item_height = 0;
824 wd->minw = wd->minh = wd->realminw = 0;
825 EINA_INLIST_FOREACH(wd->blocks, itb)
828 Elm_Genlist_Item *it;
830 if (itb->realized) _item_block_unrealize(itb);
831 EINA_LIST_FOREACH(itb->items, l, it)
832 it->mincalcd = EINA_FALSE;
834 itb->changed = EINA_TRUE;
836 if (wd->calc_job) ecore_job_del(wd->calc_job);
837 wd->calc_job = ecore_job_add(_calc_job, wd);
842 _show_region_hook(void *data, Evas_Object *obj)
844 Widget_Data *wd = elm_widget_data_get(data);
845 Evas_Coord x, y, w, h;
847 elm_widget_show_region_get(obj, &x, &y, &w, &h);
850 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
854 _sizing_eval(Evas_Object *obj)
856 Widget_Data *wd = elm_widget_data_get(obj);
857 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
859 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
860 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
862 if (wd->height_for_width)
866 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
867 if ((vw != 0) && (vw != wd->prev_viewport_w))
871 wd->prev_viewport_w = vw;
872 EINA_INLIST_FOREACH(wd->blocks, itb)
874 itb->must_recalc = EINA_TRUE;
876 if (wd->calc_job) ecore_job_del(wd->calc_job);
877 wd->calc_job = ecore_job_add(_calc_job, wd);
880 if (wd->mode == ELM_LIST_LIMIT)
882 Evas_Coord vmw, vmh, vw, vh;
886 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
887 if ((minw > 0) && (vw < minw)) vw = minw;
888 else if ((maxw > 0) && (vw > maxw))
890 edje_object_size_min_calc
891 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
898 edje_object_size_min_calc
899 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
903 evas_object_size_hint_min_set(obj, minw, minh);
904 evas_object_size_hint_max_set(obj, maxw, maxh);
908 _item_hilight(Elm_Genlist_Item *it)
910 const char *selectraise;
911 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
912 (it->disabled)) return;
913 if ((!it->sweeped) && (!it->wd->edit_mode))
914 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
915 selectraise = edje_object_data_get(it->base.view, "selectraise");
916 if ((selectraise) && (!strcmp(selectraise, "on")))
918 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
919 if ((it->group_item) && (it->group_item->realized))
920 evas_object_raise(it->group_item->base.view);
922 it->hilighted = EINA_TRUE;
923 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
927 _item_block_del(Elm_Genlist_Item *it)
930 Item_Block *itb = it->block;
932 itb->items = eina_list_remove(itb->items, it);
934 itb->changed = EINA_TRUE;
935 if (!it->wd->reorder_deleted)
937 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
938 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
942 il = EINA_INLIST_GET(itb);
943 Item_Block *itbn = (Item_Block *)(il->next);
945 it->parent->items = eina_list_remove(it->parent->items, it);
947 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
949 if (itbn) itbn->changed = EINA_TRUE;
953 if (itb->count < itb->wd->max_items_per_block/2)
955 il = EINA_INLIST_GET(itb);
956 Item_Block *itbp = (Item_Block *)(il->prev);
957 Item_Block *itbn = (Item_Block *)(il->next);
958 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
960 Elm_Genlist_Item *it2;
962 EINA_LIST_FREE(itb->items, it2)
965 itbp->items = eina_list_append(itbp->items, it2);
967 itbp->changed = EINA_TRUE;
969 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
970 EINA_INLIST_GET(itb));
973 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
977 Eina_List *last = eina_list_last(itb->items);
978 Elm_Genlist_Item *it2 = last->data;
981 itb->items = eina_list_remove_list(itb->items, last);
982 itbn->items = eina_list_prepend(itbn->items, it2);
984 itbn->changed = EINA_TRUE;
987 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
995 _item_subitems_clear(Elm_Genlist_Item *it)
998 Eina_List *tl = NULL, *l;
999 Elm_Genlist_Item *it2;
1001 EINA_LIST_FOREACH(it->items, l, it2)
1002 tl = eina_list_append(tl, it2);
1004 EINA_LIST_FREE(tl, it2)
1005 elm_genlist_item_del(it2);
1009 _item_del(Elm_Genlist_Item *it)
1011 elm_widget_item_pre_notify_del(it);
1012 elm_genlist_item_subitems_clear(it);
1013 it->wd->walking -= it->walking;
1014 if (it->wd->show_item == it) it->wd->show_item = NULL;
1015 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1016 if (it->realized) _item_unrealize(it);
1017 if (it->effect_item_realized) _effect_item_unrealize(it);
1018 if (it->block) _item_block_del(it);
1019 if ((!it->delete_me) && (it->itc->func.del))
1020 it->itc->func.del((void *)it->base.data, it->base.widget);
1021 it->delete_me = EINA_TRUE;
1023 it->wd->queue = eina_list_remove(it->wd->queue, it);
1025 if (it->wd->anchor_item == it)
1027 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1028 if (!it->wd->anchor_item)
1029 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1032 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1034 it->parent->items = eina_list_remove(it->parent->items, it);
1035 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1036 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1037 if (it->long_timer) ecore_timer_del(it->long_timer);
1038 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1040 if (it->tooltip.del_cb)
1041 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1043 elm_widget_item_del(it);
1044 it->wd->total_num--; // todo : remove
1048 _item_select(Elm_Genlist_Item *it)
1050 if ((it->wd->no_select) || (it->delete_me)) return;
1051 if (it == it->wd->select_all_item)
1053 if(it->wd->select_all_check)
1054 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE);
1056 _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE);
1061 if (it->wd->always_select) goto call;
1064 it->selected = EINA_TRUE;
1065 it->wd->selected = eina_list_append(it->wd->selected, it);
1069 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1071 evas_object_smart_callback_call(it->base.widget, "selected", it);
1074 if ((it->wd->clear_me) && (!it->wd->walking))
1076 elm_genlist_clear(it->base.widget);
1081 if ((!it->walking) && (it->delete_me))
1083 if (!it->relcount) _item_del(it);
1086 if (it && it->wd) it->wd->last_selected_item = it;
1090 _item_unselect(Elm_Genlist_Item *it)
1092 const char *stacking, *selectraise;
1094 if (it == it->wd->select_all_item) return;
1095 if ((it->delete_me) || (!it->hilighted)) return;
1097 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1098 stacking = edje_object_data_get(it->base.view, "stacking");
1099 selectraise = edje_object_data_get(it->base.view, "selectraise");
1100 if ((selectraise) && (!strcmp(selectraise, "on")))
1102 if ((stacking) && (!strcmp(stacking, "below")))
1103 evas_object_lower(it->base.view);
1105 it->hilighted = EINA_FALSE;
1108 it->selected = EINA_FALSE;
1109 it->wd->selected = eina_list_remove(it->wd->selected, it);
1110 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1115 _mouse_move(void *data,
1116 Evas *evas __UNUSED__,
1120 Elm_Genlist_Item *it = data;
1121 Evas_Event_Mouse_Move *ev = event_info;
1122 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1124 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1126 if (!it->wd->on_hold)
1128 it->wd->on_hold = EINA_TRUE;
1129 if (!it->wd->wasselected)
1133 if (it->wd->multitouched)
1135 it->wd->cur_x = ev->cur.canvas.x;
1136 it->wd->cur_y = ev->cur.canvas.y;
1139 if ((it->dragging) && (it->down))
1141 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1144 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1145 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1146 if (abs((it->wd->history[it->wd->movements].x -
1147 it->wd->history[0].x)) > 40)
1148 it->wd->swipe = EINA_TRUE;
1150 it->wd->movements++;
1154 ecore_timer_del(it->long_timer);
1155 it->long_timer = NULL;
1157 evas_object_smart_callback_call(it->base.widget, "drag", it);
1160 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1164 ecore_timer_del(it->long_timer);
1165 it->long_timer = NULL;
1167 if (it->wd->reorder_mode && it->wd->reorder_it)
1169 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1170 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1171 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1172 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1174 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1175 if (it->wd->select_all_item)
1176 sel_all_h = it->wd->select_all_item->h;
1177 if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1178 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);
1179 else _effect_item_controls(it, it->scrl_x, it_y);
1181 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1182 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1186 if (!it->display_only)
1187 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1188 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1189 x = ev->cur.canvas.x - x;
1190 y = ev->cur.canvas.y - y;
1193 if (adx < 0) adx = -dx;
1196 if (ady < 0) ady = -dy;
1199 if ((adx > minw) || (ady > minh))
1201 it->dragging = EINA_TRUE;
1204 ecore_timer_del(it->long_timer);
1205 it->long_timer = NULL;
1207 if (!it->wd->wasselected)
1212 evas_object_smart_callback_call(it->base.widget,
1213 "drag,start,up", it);
1218 evas_object_smart_callback_call(it->base.widget,
1219 "drag,start,left", it);
1220 _item_slide(it, EINA_FALSE);
1224 evas_object_smart_callback_call(it->base.widget,
1225 "drag,start,right", it);
1226 _item_slide(it, EINA_TRUE);
1233 evas_object_smart_callback_call(it->base.widget,
1234 "drag,start,down", it);
1239 evas_object_smart_callback_call(it->base.widget,
1240 "drag,start,left", it);
1241 _item_slide(it, EINA_FALSE);
1245 evas_object_smart_callback_call(it->base.widget,
1246 "drag,start,right", it);
1247 _item_slide(it, EINA_TRUE);
1255 _long_press(void *data)
1257 Elm_Genlist_Item *it = data;
1258 Elm_Genlist_Item *it_tmp;
1259 static Eina_Bool done = EINA_FALSE;
1260 //static Eina_Bool contracted = EINA_FALSE;
1264 it->long_timer = NULL;
1265 if ((it->disabled) || (it->dragging) || (it->display_only))
1266 return ECORE_CALLBACK_CANCEL;
1267 it->wd->longpressed = EINA_TRUE;
1268 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1269 if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1271 it->wd->reorder_it = it;
1272 it->wd->reorder_start_y = 0;
1273 evas_object_raise(it->edit_obj);
1274 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1275 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1277 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1282 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1284 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1286 _item_unselect(it_tmp);
1298 EINA_LIST_FOREACH(it->items, l, it_tmp)
1300 if (elm_genlist_item_expanded_get(it_tmp))
1302 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1303 return ECORE_CALLBACK_RENEW;
1307 if (elm_genlist_item_expanded_get(it)) {
1308 elm_genlist_item_expanded_set(it, EINA_FALSE);
1309 return ECORE_CALLBACK_RENEW;
1311 if (it->wd->edit_field && it->renamed)
1312 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1315 return ECORE_CALLBACK_CANCEL;
1319 _swipe(Elm_Genlist_Item *it)
1324 it->wd->swipe = EINA_FALSE;
1325 for (i = 0; i < it->wd->movements; i++)
1327 sum += it->wd->history[i].x;
1328 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1331 sum /= it->wd->movements;
1332 if (abs(sum - it->wd->history[0].x) <= 10) return;
1333 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1337 _swipe_cancel(void *data)
1339 Elm_Genlist_Item *it = data;
1341 if (!it) return ECORE_CALLBACK_CANCEL;
1342 it->wd->swipe = EINA_FALSE;
1343 it->wd->movements = 0;
1344 return ECORE_CALLBACK_RENEW;
1348 _multi_cancel(void *data)
1350 Widget_Data *wd = data;
1352 if (!wd) return ECORE_CALLBACK_CANCEL;
1353 wd->multi_timeout = EINA_TRUE;
1354 return ECORE_CALLBACK_RENEW;
1358 _multi_touch_gesture_eval(void *data)
1360 Elm_Genlist_Item *it = data;
1362 it->wd->multitouched = EINA_FALSE;
1363 if (it->wd->multi_timer)
1365 ecore_timer_del(it->wd->multi_timer);
1366 it->wd->multi_timer = NULL;
1368 if (it->wd->multi_timeout)
1370 it->wd->multi_timeout = EINA_FALSE;
1374 Evas_Coord minw = 0, minh = 0;
1375 Evas_Coord off_x, off_y, off_mx, off_my;
1377 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1378 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1379 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1380 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1381 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1383 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1385 if ((off_x + off_mx) > (off_y + off_my))
1387 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,right", it);
1390 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1391 evas_object_smart_callback_call(it->base.widget,
1392 "multi,swipe,left", it);
1393 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1394 evas_object_smart_callback_call(it->base.widget,
1395 "multi,pinch,out", it);
1397 evas_object_smart_callback_call(it->base.widget,
1398 "multi,pinch,in", it);
1402 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,down", it);
1405 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1406 evas_object_smart_callback_call(it->base.widget,
1407 "multi,swipe,up", it);
1408 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1409 evas_object_smart_callback_call(it->base.widget,
1410 "multi,pinch,out", it);
1412 evas_object_smart_callback_call(it->base.widget,
1413 "multi,pinch,in", it);
1416 it->wd->multi_timeout = EINA_FALSE;
1420 _multi_down(void *data,
1421 Evas *evas __UNUSED__,
1422 Evas_Object *obj __UNUSED__,
1425 Elm_Genlist_Item *it = data;
1426 Evas_Event_Multi_Down *ev = event_info;
1428 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1429 it->wd->multi_device = ev->device;
1430 it->wd->multi_down = EINA_TRUE;
1431 it->wd->multitouched = EINA_TRUE;
1432 it->wd->prev_mx = ev->canvas.x;
1433 it->wd->prev_my = ev->canvas.y;
1434 if (!it->wd->wasselected) _item_unselect(it);
1435 it->wd->wasselected = EINA_FALSE;
1436 it->wd->longpressed = EINA_FALSE;
1439 ecore_timer_del(it->long_timer);
1440 it->long_timer = NULL;
1444 it->dragging = EINA_FALSE;
1445 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1447 if (it->swipe_timer)
1449 ecore_timer_del(it->swipe_timer);
1450 it->swipe_timer = NULL;
1452 if (it->wd->on_hold)
1454 it->wd->swipe = EINA_FALSE;
1455 it->wd->movements = 0;
1456 it->wd->on_hold = EINA_FALSE;
1461 _multi_up(void *data,
1462 Evas *evas __UNUSED__,
1463 Evas_Object *obj __UNUSED__,
1466 Elm_Genlist_Item *it = data;
1467 Evas_Event_Multi_Up *ev = event_info;
1469 if (it->wd->multi_device != ev->device) return;
1470 it->wd->multi_device = 0;
1471 it->wd->multi_down = EINA_FALSE;
1472 if (it->wd->mouse_down) return;
1473 _multi_touch_gesture_eval(data);
1477 _multi_move(void *data,
1478 Evas *evas __UNUSED__,
1479 Evas_Object *obj __UNUSED__,
1482 Elm_Genlist_Item *it = data;
1483 Evas_Event_Multi_Move *ev = event_info;
1485 if (it->wd->multi_device != ev->device) return;
1486 it->wd->cur_mx = ev->cur.canvas.x;
1487 it->wd->cur_my = ev->cur.canvas.y;
1491 _mouse_down(void *data,
1492 Evas *evas __UNUSED__,
1496 Elm_Genlist_Item *it = data;
1497 Evas_Event_Mouse_Down *ev = event_info;
1500 if (ev->button != 1) return;
1501 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1503 it->wd->on_hold = EINA_TRUE;
1506 if (it->wd->edit_field && !it->renamed)
1507 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1508 it->down = EINA_TRUE;
1509 it->dragging = EINA_FALSE;
1510 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1511 it->dx = ev->canvas.x - x;
1512 it->dy = ev->canvas.y - y;
1513 it->wd->mouse_down = EINA_TRUE;
1514 if (!it->wd->multitouched)
1516 it->wd->prev_x = ev->canvas.x;
1517 it->wd->prev_y = ev->canvas.y;
1518 it->wd->multi_timeout = EINA_FALSE;
1519 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1520 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1522 it->wd->longpressed = EINA_FALSE;
1523 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1524 else it->wd->on_hold = EINA_FALSE;
1525 if (it->wd->on_hold) return;
1526 it->wd->wasselected = it->selected;
1528 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1529 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1530 if (it->long_timer) ecore_timer_del(it->long_timer);
1531 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1532 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1534 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1537 it->long_timer = NULL;
1538 it->wd->swipe = EINA_FALSE;
1539 it->wd->movements = 0;
1543 _mouse_up(void *data,
1544 Evas *evas __UNUSED__,
1545 Evas_Object *obj __UNUSED__,
1548 Elm_Genlist_Item *it = data;
1549 Evas_Event_Mouse_Up *ev = event_info;
1550 Eina_Bool dragged = EINA_FALSE;
1552 if (ev->button != 1) return;
1553 it->down = EINA_FALSE;
1554 it->wd->mouse_down = EINA_FALSE;
1555 if (it->wd->multitouched)
1557 if (it->wd->multi_down) return;
1558 _multi_touch_gesture_eval(data);
1561 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1562 else it->wd->on_hold = EINA_FALSE;
1565 ecore_timer_del(it->long_timer);
1566 it->long_timer = NULL;
1570 it->dragging = EINA_FALSE;
1571 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1574 if (it->swipe_timer)
1576 ecore_timer_del(it->swipe_timer);
1577 it->swipe_timer = NULL;
1579 if (it->wd->multi_timer)
1581 ecore_timer_del(it->wd->multi_timer);
1582 it->wd->multi_timer = NULL;
1583 it->wd->multi_timeout = EINA_FALSE;
1585 if (it->wd->on_hold)
1587 if (it->wd->swipe) _swipe(data);
1588 it->wd->longpressed = EINA_FALSE;
1589 it->wd->on_hold = EINA_FALSE;
1592 if (it->wd->reorder_mode)
1594 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1595 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1598 Evas_Coord ox,oy,oh,ow;
1599 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1600 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1601 if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h;
1602 if (it->wd->reorder_rel)
1604 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1606 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1607 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1609 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1612 it->wd->reorder_deleted = EINA_FALSE;
1613 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1614 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1615 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1618 if (it->wd->longpressed)
1620 it->wd->longpressed = EINA_FALSE;
1621 if (!it->wd->wasselected)
1623 it->wd->wasselected = EINA_FALSE;
1628 if (it->want_unrealize)
1630 _item_unrealize(it);
1631 if (it->block->want_unrealize)
1632 _item_block_unrealize(it->block);
1635 if ((it->disabled) || (dragged) || (it->display_only)) return;
1636 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1639 if ((!it->selected) && (!it->sweeped))
1644 else _item_unselect(it);
1650 Widget_Data *wd = it->wd;
1653 while (wd->selected) _item_unselect(wd->selected->data);
1658 const Eina_List *l, *l_next;
1659 Elm_Genlist_Item *it2;
1661 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1662 if (it2 != it) _item_unselect(it2);
1663 //_item_hilight(it);
1675 _signal_expand_toggle(void *data,
1676 Evas_Object *obj __UNUSED__,
1677 const char *emission __UNUSED__,
1678 const char *source __UNUSED__)
1680 Elm_Genlist_Item *it = data;
1683 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1685 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1689 _signal_expand(void *data,
1690 Evas_Object *obj __UNUSED__,
1691 const char *emission __UNUSED__,
1692 const char *source __UNUSED__)
1694 Elm_Genlist_Item *it = data;
1697 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1701 _signal_contract(void *data,
1702 Evas_Object *obj __UNUSED__,
1703 const char *emission __UNUSED__,
1704 const char *source __UNUSED__)
1706 Elm_Genlist_Item *it = data;
1709 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1713 _item_cache_clean(Widget_Data *wd)
1715 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1719 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1720 wd->item_cache = eina_inlist_remove(wd->item_cache,
1721 wd->item_cache->last);
1722 wd->item_cache_count--;
1723 if (itc->spacer) evas_object_del(itc->spacer);
1724 if (itc->base_view) evas_object_del(itc->base_view);
1725 if (itc->item_style) eina_stringshare_del(itc->item_style);
1731 _item_cache_zero(Widget_Data *wd)
1733 int pmax = wd->item_cache_max;
1734 wd->item_cache_max = 0;
1735 _item_cache_clean(wd);
1736 wd->item_cache_max = pmax;
1740 _item_cache_add(Elm_Genlist_Item *it)
1744 if (it->wd->item_cache_max <= 0)
1746 evas_object_del(it->base.view);
1747 it->base.view = NULL;
1748 evas_object_del(it->spacer);
1753 it->wd->item_cache_count++;
1754 itc = calloc(1, sizeof(Item_Cache));
1756 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1757 EINA_INLIST_GET(itc));
1758 itc->spacer = it->spacer;
1760 itc->base_view = it->base.view;
1761 it->base.view = NULL;
1762 evas_object_hide(itc->base_view);
1763 evas_object_move(itc->base_view, -9999, -9999);
1764 itc->item_style = eina_stringshare_add(it->itc->item_style);
1765 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1766 itc->compress = (it->wd->compress);
1767 itc->odd = (it->order_num_in & 0x1);
1768 itc->selected = it->selected;
1769 itc->disabled = it->disabled;
1770 itc->expanded = it->expanded;
1773 ecore_timer_del(it->long_timer);
1774 it->long_timer = NULL;
1776 if (it->swipe_timer)
1778 ecore_timer_del(it->swipe_timer);
1779 it->swipe_timer = NULL;
1781 // FIXME: other callbacks?
1782 edje_object_signal_callback_del_full(itc->base_view,
1783 "elm,action,expand,toggle",
1784 "elm", _signal_expand_toggle, it);
1785 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1787 _signal_expand, it);
1788 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1789 "elm", _signal_contract, it);
1790 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1792 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1794 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1796 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1798 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1800 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1802 _item_cache_clean(it->wd);
1806 _item_cache_find(Elm_Genlist_Item *it)
1809 Eina_Bool tree = 0, odd;
1811 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1812 odd = (it->order_num_in & 0x1);
1813 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1815 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1817 if ((itc->tree == tree) &&
1818 (itc->odd == odd) &&
1819 (itc->compress == it->wd->compress) &&
1820 (!strcmp(it->itc->item_style, itc->item_style)))
1822 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1823 EINA_INLIST_GET(itc));
1824 it->wd->item_cache_count--;
1832 _item_cache_free(Item_Cache *itc)
1834 if (itc->spacer) evas_object_del(itc->spacer);
1835 if (itc->base_view) evas_object_del(itc->base_view);
1836 if (itc->item_style) eina_stringshare_del(itc->item_style);
1841 _item_realize(Elm_Genlist_Item *it,
1845 Elm_Genlist_Item *it2;
1846 const char *stacking;
1847 const char *treesize;
1849 int depth, tsize = 20;
1850 Item_Cache *itc = NULL;
1852 if ((it->realized) || (it->delete_me)) return;
1853 it->order_num_in = in;
1854 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1856 it->nocache = EINA_FALSE;
1858 itc = _item_cache_find(it);
1859 if ((!it->wd->effect_mode) && (itc))
1861 it->base.view = itc->base_view;
1862 itc->base_view = NULL;
1863 it->spacer = itc->spacer;
1868 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1869 edje_object_scale_set(it->base.view,
1870 elm_widget_scale_get(it->base.widget) *
1871 _elm_config->scale);
1872 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1873 elm_widget_sub_object_add(it->base.widget, it->base.view);
1875 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1876 strncpy(buf, "tree", sizeof(buf));
1877 else strncpy(buf, "item", sizeof(buf));
1878 if (it->wd->compress)
1879 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1881 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1882 strncat(buf, "/", sizeof(buf) - strlen(buf));
1883 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1885 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1886 elm_widget_style_get(it->base.widget));
1888 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1889 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1890 elm_widget_sub_object_add(it->base.widget, it->spacer);
1892 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1894 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1896 it->expanded_depth = depth;
1897 treesize = edje_object_data_get(it->base.view, "treesize");
1898 if (treesize) tsize = atoi(treesize);
1899 evas_object_size_hint_min_set(it->spacer,
1900 (depth * tsize) * _elm_config->scale, 1);
1901 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1904 edje_object_signal_callback_add(it->base.view,
1905 "elm,action,expand,toggle",
1906 "elm", _signal_expand_toggle, it);
1907 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1908 "elm", _signal_expand, it);
1909 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1910 "elm", _signal_contract, it);
1911 stacking = edje_object_data_get(it->base.view, "stacking");
1914 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1915 else if (!strcmp(stacking, "above"))
1916 evas_object_raise(it->base.view);
1918 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1920 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1922 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1924 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1926 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1928 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1932 if (it->selected != itc->selected)
1934 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1935 edje_object_signal_emit(it->base.view,
1936 "elm,state,selected", "elm");
1938 if (it->disabled != itc->disabled)
1941 edje_object_signal_emit(it->base.view,
1942 "elm,state,disabled", "elm");
1944 if (it->expanded != itc->expanded)
1947 edje_object_signal_emit(it->base.view,
1948 "elm,state,expanded", "elm");
1953 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1954 edje_object_signal_emit(it->base.view,
1955 "elm,state,selected", "elm");
1957 edje_object_signal_emit(it->base.view,
1958 "elm,state,disabled", "elm");
1960 edje_object_signal_emit(it->base.view,
1961 "elm,state,expanded", "elm");
1965 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1967 /* homogenous genlist shortcut */
1968 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1970 it->w = it->minw = it->wd->group_item_width;
1971 it->h = it->minh = it->wd->group_item_height;
1972 it->mincalcd = EINA_TRUE;
1974 else if (!it->mincalcd)
1976 it->w = it->minw = it->wd->item_width;
1977 it->h = it->minh = it->wd->item_height;
1978 it->mincalcd = EINA_TRUE;
1983 if (it->itc->func.label_get)
1989 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1991 EINA_LIST_FOREACH(it->labels, l, key)
1993 char *s = it->itc->func.label_get
1994 ((void *)it->base.data, it->base.widget, l->data);
1998 edje_object_part_text_set(it->base.view, l->data, s);
2002 edje_object_part_text_set(it->base.view, l->data, "");
2005 if (it->itc->func.icon_get)
2011 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2013 EINA_LIST_FOREACH(it->icons, l, key)
2015 Evas_Object *ic = it->itc->func.icon_get
2016 ((void *)it->base.data, it->base.widget, l->data);
2020 it->icon_objs = eina_list_append(it->icon_objs, ic);
2021 edje_object_part_swallow(it->base.view, key, ic);
2022 evas_object_show(ic);
2023 elm_widget_sub_object_add(it->base.widget, ic);
2024 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2028 if (it->itc->func.state_get)
2034 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2036 EINA_LIST_FOREACH(it->states, l, key)
2038 Eina_Bool on = it->itc->func.state_get
2039 ((void *)it->base.data, it->base.widget, l->data);
2043 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2044 edje_object_signal_emit(it->base.view, buf, "elm");
2048 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2049 edje_object_signal_emit(it->base.view, buf, "elm");
2054 _create_sweep_objs(it);
2057 Evas_Coord mw = -1, mh = -1;
2059 if (it->wd->height_for_width) mw = it->wd->w;
2061 if (!it->display_only)
2062 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2063 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2064 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2066 if (!it->display_only)
2067 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2068 it->w = it->minw = mw;
2069 it->h = it->minh = mh;
2070 it->mincalcd = EINA_TRUE;
2072 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2074 it->wd->group_item_width = mw;
2075 it->wd->group_item_height = mh;
2077 else if ((it->wd->homogeneous))
2078 // if ((!in) && (it->wd->homogeneous))
2080 it->wd->item_width = mw;
2081 it->wd->item_height = mh;
2083 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2085 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2087 it->wd->group_item_width = mw;
2088 it->wd->group_item_height = mh;
2092 if (!calc) evas_object_show(it->base.view);
2095 if (it->tooltip.content_cb)
2097 elm_widget_item_tooltip_content_cb_set(it,
2098 it->tooltip.content_cb,
2099 it->tooltip.data, NULL);
2100 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2103 if (it->mouse_cursor)
2104 elm_widget_item_cursor_set(it, it->mouse_cursor);
2106 it->realized = EINA_TRUE;
2107 it->want_unrealize = EINA_FALSE;
2109 if (itc) _item_cache_free(itc);
2110 evas_object_smart_callback_call(it->base.widget, "realized", it);
2111 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))))
2113 _effect_item_realize(it, EINA_FALSE);
2114 edje_object_message_signal_process(it->edit_obj);
2119 _item_unrealize(Elm_Genlist_Item *it)
2123 if (!it->realized) return;
2124 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2125 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2128 ecore_timer_del(it->long_timer);
2129 it->long_timer = NULL;
2131 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2133 it->sweeped = EINA_FALSE;
2134 it->wassweeped = EINA_FALSE;
2135 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2136 _delete_sweep_objs(it);
2137 evas_object_del(it->base.view);
2138 it->base.view = NULL;
2139 evas_object_del(it->spacer);
2143 _item_cache_add(it);
2144 elm_widget_stringlist_free(it->labels);
2146 elm_widget_stringlist_free(it->icons);
2148 elm_widget_stringlist_free(it->states);
2150 EINA_LIST_FREE(it->icon_objs, icon)
2151 evas_object_del(icon);
2154 it->realized = EINA_FALSE;
2155 it->want_unrealize = EINA_FALSE;
2156 if (it->wd->edit_field && it->renamed)
2157 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
2158 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2162 _item_block_recalc(Item_Block *itb,
2168 Elm_Genlist_Item *it;
2169 Evas_Coord minw = 0, minh = 0;
2170 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2174 EINA_LIST_FOREACH(itb->items, l, it)
2176 if (it->delete_me) continue;
2177 showme |= it->showme;
2182 if (!it->mincalcd) changed = EINA_TRUE;
2185 _item_realize(it, in, 1);
2186 _item_unrealize(it);
2191 _item_realize(it, in, 1);
2192 _item_unrealize(it);
2196 _item_realize(it, in, 0);
2198 if (minw < it->minw) minw = it->minw;
2206 itb->changed = EINA_FALSE;
2207 /* force an evas norender to garbage collect deleted objects */
2208 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2213 _item_block_realize(Item_Block *itb,
2218 Elm_Genlist_Item *it;
2220 if (itb->realized) return;
2221 EINA_LIST_FOREACH(itb->items, l, it)
2223 if (it->delete_me) continue;
2224 if (full) _item_realize(it, in, 0);
2227 itb->realized = EINA_TRUE;
2228 itb->want_unrealize = EINA_FALSE;
2232 _item_block_unrealize(Item_Block *itb)
2235 Elm_Genlist_Item *it;
2236 Eina_Bool dragging = EINA_FALSE;
2238 if (!itb->realized) return;
2239 EINA_LIST_FOREACH(itb->items, l, it)
2241 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2245 dragging = EINA_TRUE;
2246 it->want_unrealize = EINA_TRUE;
2249 _item_unrealize(it);
2254 itb->realized = EINA_FALSE;
2255 itb->want_unrealize = EINA_TRUE;
2258 itb->want_unrealize = EINA_FALSE;
2262 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2264 Evas_Coord rox, roy, row, roh;
2265 Eina_Bool top = EINA_FALSE;
2266 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2267 if (!reorder_it) return 0;
2269 Evas_Coord ox,oy,oh,ow;
2270 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2271 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2273 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2275 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2276 if (it->block->count == 1)
2277 it->wd->reorder_rel = it;
2279 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2281 it->block->reorder_offset = it->wd->reorder_it->h;
2284 it->block->reorder_offset = 0;
2286 it->scrl_y += it->block->reorder_offset;
2288 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2289 rox, roy+roh/2, row, 1));
2292 it->wd->reorder_rel = it;
2293 it->scrl_y+=it->wd->reorder_it->h;
2294 return it->wd->reorder_it->h;
2301 _reorder_item_moving_effect_timer_cb(void *data)
2303 Elm_Genlist_Item *it = data;
2304 Eina_Bool down = EINA_FALSE;
2305 double time = 0.4, t;
2307 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2310 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2314 if (it->old_scrl_y < it->scrl_y)
2316 it->old_scrl_y += y;
2319 else if (it->old_scrl_y > it->scrl_y)
2321 it->old_scrl_y -= y;
2325 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2327 _group_items_recalc(it->wd);
2328 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2330 it->old_scrl_y = it->scrl_y;
2331 it->move_effect_me = EINA_FALSE;
2332 it->wd->item_moving_effect_timer = NULL;
2333 return ECORE_CALLBACK_CANCEL;
2335 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2337 it->old_scrl_y = it->scrl_y;
2338 it->move_effect_me = EINA_FALSE;
2339 it->wd->item_moving_effect_timer = NULL;
2340 return ECORE_CALLBACK_CANCEL;
2342 return ECORE_CALLBACK_RENEW;
2346 _item_block_position(Item_Block *itb,
2350 Elm_Genlist_Item *it;
2351 Elm_Genlist_Item *git;
2352 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2355 Elm_Genlist_Item *select_all_item = NULL;
2357 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2358 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2361 if (itb->wd->select_all_item &&
2362 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2364 if (itb->wd->select_all_check)
2365 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
2367 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
2369 select_all_item = itb->wd->select_all_item;
2371 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2372 evas_object_move(select_all_item->base.view, ox, oy);
2373 evas_object_raise(select_all_item->base.view);
2375 y = select_all_item->h;
2376 sel_all_h = select_all_item->h;
2379 EINA_LIST_FOREACH(itb->items, l, it)
2381 if (it->delete_me) continue;
2382 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2387 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2388 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2390 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2391 cvx, cvy, cvw, cvh));
2392 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2394 if ((itb->realized) && (!it->realized))
2396 if (vis) _item_realize(it, in, 0);
2402 if(it->wd->reorder_mode)
2403 y += _get_space_for_reorder_item(it);
2404 git = it->group_item;
2407 git->scrl_x = it->scrl_x;
2408 if (git->scrl_y < oy + sel_all_h)
2409 git->scrl_y = oy + sel_all_h;
2410 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2411 git->scrl_y = (it->scrl_y + it->h) - git->h;
2412 git->want_realize = EINA_TRUE;
2414 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2416 if (!it->move_effect_me)
2418 it->move_effect_me = EINA_TRUE;
2419 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2423 if (!it->move_effect_me )
2424 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))
2426 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2428 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2432 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2433 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2434 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)))
2435 evas_object_show(it->base.view);
2437 evas_object_hide(it->base.view);
2439 it->old_scrl_x = it->scrl_x;
2440 it->old_scrl_y = it->scrl_y;
2445 if (!it->dragging) _item_unrealize(it);
2452 if (vis) it->want_realize = EINA_TRUE;
2459 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2461 Elm_Genlist_Item *it = data;
2463 it->mincalcd = EINA_FALSE;
2464 it->block->updateme = EINA_TRUE;
2465 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2466 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2470 _group_items_recalc(void *data)
2472 Widget_Data *wd = data;
2474 Elm_Genlist_Item *git;
2476 EINA_LIST_FOREACH(wd->group_items, l, git)
2478 if (git->want_realize)
2481 _item_realize(git, 0, 0);
2482 evas_object_resize(git->base.view, wd->minw, git->h);
2483 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2484 evas_object_show(git->base.view);
2485 evas_object_raise(git->base.view);
2487 else if (!git->want_realize && git->realized)
2490 _item_unrealize(git);
2496 _must_recalc_idler(void *data)
2498 Widget_Data *wd = data;
2499 if (wd->calc_job) ecore_job_del(wd->calc_job);
2500 wd->calc_job = ecore_job_add(_calc_job, wd);
2501 wd->must_recalc_idler = NULL;
2502 return ECORE_CALLBACK_CANCEL;
2506 _calc_job(void *data)
2508 Widget_Data *wd = data;
2510 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2511 Item_Block *chb = NULL;
2512 int in = 0, minw_change = 0;
2513 Eina_Bool changed = EINA_FALSE;
2515 Eina_Bool did_must_recalc = EINA_FALSE;
2518 t0 = ecore_time_get();
2519 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2523 // if (wd->height_for_width) changed = EINA_TRUE;
2526 EINA_INLIST_FOREACH(wd->blocks, itb)
2528 Eina_Bool showme = EINA_FALSE;
2531 showme = itb->showme;
2532 itb->showme = EINA_FALSE;
2535 if (itb->realized) _item_block_unrealize(itb);
2537 if ((itb->changed) || (changed) ||
2538 ((itb->must_recalc) && (!did_must_recalc)))
2540 if ((changed) || (itb->must_recalc))
2543 Elm_Genlist_Item *it;
2544 EINA_LIST_FOREACH(itb->items, l, it)
2545 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2546 itb->changed = EINA_TRUE;
2547 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2548 itb->must_recalc = EINA_FALSE;
2550 if (itb->realized) _item_block_unrealize(itb);
2551 showme = _item_block_recalc(itb, in, 0, 1);
2557 if (minw == -1) minw = itb->minw;
2558 else if ((!itb->must_recalc) && (minw < itb->minw))
2567 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2569 wd->show_item->showme = EINA_FALSE;
2571 elm_smart_scroller_region_bring_in(wd->scr,
2573 wd->show_item->block->x,
2575 wd->show_item->block->y,
2576 wd->show_item->block->w,
2579 elm_smart_scroller_child_region_show(wd->scr,
2581 wd->show_item->block->x,
2583 wd->show_item->block->y,
2584 wd->show_item->block->w,
2586 wd->show_item = NULL;
2591 EINA_INLIST_FOREACH(wd->blocks, itb)
2597 if ((chb) && (EINA_INLIST_GET(chb)->next))
2599 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2601 if (itb->realized) _item_block_unrealize(itb);
2604 wd->realminw = minw;
2605 if (minw < wd->w) minw = wd->w;
2606 if ((minw != wd->minw) || (minh != wd->minh) || (wd->select_all_item))
2610 if (wd->select_all_item)
2611 wd->minh += wd->select_all_item->h;
2612 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2613 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2614 _sizing_eval(wd->obj);
2616 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2618 Elm_Genlist_Item *it;
2621 it = wd->anchor_item;
2622 it_y = wd->anchor_y;
2623 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2624 it->block->y + it->y + it_y);
2625 wd->anchor_item = it;
2626 wd->anchor_y = it_y;
2630 t = ecore_time_get();
2631 if (did_must_recalc)
2633 if (!wd->must_recalc_idler)
2634 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2636 wd->calc_job = NULL;
2637 evas_object_smart_changed(wd->pan_smart);
2641 _update_job(void *data)
2643 Widget_Data *wd = data;
2646 int num, num0, position = 0, recalc = 0;
2648 wd->update_job = NULL;
2650 EINA_INLIST_FOREACH(wd->blocks, itb)
2652 Evas_Coord itminw, itminh;
2653 Elm_Genlist_Item *it;
2659 _item_block_position(itb, num);
2664 EINA_LIST_FOREACH(itb->items, l2, it)
2671 it->updateme = EINA_FALSE;
2674 _item_unrealize(it);
2675 _item_realize(it, num, 0);
2680 _item_realize(it, num, 1);
2681 _item_unrealize(it);
2683 if ((it->minw != itminw) || (it->minh != itminh))
2688 itb->updateme = EINA_FALSE;
2692 itb->changed = EINA_TRUE;
2693 _item_block_recalc(itb, num0, 0, 1);
2694 _item_block_position(itb, num0);
2699 if (wd->calc_job) ecore_job_del(wd->calc_job);
2700 wd->calc_job = ecore_job_add(_calc_job, wd);
2705 _changed_job(void *data)
2707 Widget_Data *wd = data; Eina_List *l2;
2709 int num, num0, position = 0, recalc = 0;
2711 wd->changed_job = NULL;
2713 EINA_INLIST_FOREACH(wd->blocks, itb)
2715 Evas_Coord itminw, itminh;
2716 Elm_Genlist_Item *it;
2722 _item_block_position(itb, num);
2727 EINA_LIST_FOREACH(itb->items, l2, it)
2731 Evas_Coord mw = -1, mh = -1;
2735 if (it->wd->height_for_width) mw = it->wd->w;
2736 if (!it->display_only)
2737 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2738 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2739 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2740 if (!it->display_only)
2741 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2742 it->w = it->minw = mw;
2743 it->h = it->minh = mh;
2744 it->mincalcd = EINA_TRUE;
2746 //if ((it->minw != itminw) || (it->minh != itminh))
2747 if ((it->minh != itminh))
2752 itb->updateme = EINA_FALSE;
2756 itb->changed = EINA_TRUE;
2757 _item_block_recalc(itb, num0, 0, 1);
2758 _item_block_position(itb, num0);
2763 if (wd->calc_job) ecore_job_del(wd->calc_job);
2764 wd->calc_job = ecore_job_add(_calc_job, wd);
2769 _pan_set(Evas_Object *obj,
2773 Pan *sd = evas_object_smart_data_get(obj);
2776 // Evas_Coord ow, oh;
2777 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2778 // ow = sd->wd->minw - ow;
2779 // if (ow < 0) ow = 0;
2780 // oh = sd->wd->minh - oh;
2781 // if (oh < 0) oh = 0;
2782 // if (x < 0) x = 0;
2783 // if (y < 0) y = 0;
2784 // if (x > ow) x = ow;
2785 // if (y > oh) y = oh;
2786 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2791 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2793 if ((itb->y + itb->h) > y)
2795 Elm_Genlist_Item *it;
2798 EINA_LIST_FOREACH(itb->items, l2, it)
2800 if ((itb->y + it->y) >= y)
2802 sd->wd->anchor_item = it;
2803 sd->wd->anchor_y = -(itb->y + it->y - y);
2811 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2815 _pan_get(Evas_Object *obj,
2819 Pan *sd = evas_object_smart_data_get(obj);
2821 if (x) *x = sd->wd->pan_x;
2822 if (y) *y = sd->wd->pan_y;
2826 _pan_max_get(Evas_Object *obj,
2830 Pan *sd = evas_object_smart_data_get(obj);
2833 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2834 ow = sd->wd->minw - ow;
2836 oh = sd->wd->minh - oh;
2843 _pan_min_get(Evas_Object *obj __UNUSED__,
2852 _pan_child_size_get(Evas_Object *obj,
2856 Pan *sd = evas_object_smart_data_get(obj);
2858 if (w) *w = sd->wd->minw;
2859 if (h) *h = sd->wd->minh;
2863 _pan_add(Evas_Object *obj)
2866 Evas_Object_Smart_Clipped_Data *cd;
2869 cd = evas_object_smart_data_get(obj);
2872 sd->__clipped_data = *cd;
2874 evas_object_smart_data_set(obj, sd);
2878 _pan_del(Evas_Object *obj)
2880 Pan *sd = evas_object_smart_data_get(obj);
2885 ecore_job_del(sd->resize_job);
2886 sd->resize_job = NULL;
2892 _pan_resize_job(void *data)
2895 _sizing_eval(sd->wd->obj);
2896 sd->resize_job = NULL;
2900 _pan_resize(Evas_Object *obj,
2904 Pan *sd = evas_object_smart_data_get(obj);
2907 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2908 if ((ow == w) && (oh == h)) return;
2909 if ((sd->wd->height_for_width) && (ow != w))
2911 if (sd->resize_job) ecore_job_del(sd->resize_job);
2912 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2914 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2915 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2919 _pan_calculate(Evas_Object *obj)
2921 Pan *sd = evas_object_smart_data_get(obj);
2923 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2924 static Evas_Coord old_pan_y = 0;
2926 Elm_Genlist_Item *git;
2929 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2930 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2931 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2933 git->want_realize = EINA_FALSE;
2935 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2937 itb->w = sd->wd->minw;
2938 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2939 itb->y - sd->wd->pan_y + oy,
2941 cvx, cvy, cvw, cvh))
2943 if ((!itb->realized) || (itb->changed))
2944 _item_block_realize(itb, in, 0);
2945 _item_block_position(itb, in);
2949 if (itb->realized) _item_block_unrealize(itb);
2953 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2954 _group_items_recalc(sd->wd);
2956 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2958 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2959 else sd->wd->reorder_pan_move = EINA_FALSE;
2960 evas_object_raise(sd->wd->reorder_it->edit_obj);
2961 old_pan_y = sd->wd->pan_y;
2964 if (sd->wd->effect_mode &&
2965 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2966 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2967 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2969 if (!sd->wd->item_moving_effect_timer)
2971 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2972 _item_flip_effect_show(sd->wd->expand_item);
2974 evas_object_raise(sd->wd->alpha_bg);
2975 evas_object_show(sd->wd->alpha_bg);
2976 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2977 sd->wd->start_time = current_time_get();
2978 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2981 else _item_auto_scroll(sd->wd);
2982 if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view);
2986 _pan_move(Evas_Object *obj,
2987 Evas_Coord x __UNUSED__,
2988 Evas_Coord y __UNUSED__)
2990 Pan *sd = evas_object_smart_data_get(obj);
2992 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2993 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2997 _hold_on(void *data __UNUSED__,
2999 void *event_info __UNUSED__)
3001 Widget_Data *wd = elm_widget_data_get(obj);
3003 elm_smart_scroller_hold_set(wd->scr, 1);
3007 _hold_off(void *data __UNUSED__,
3009 void *event_info __UNUSED__)
3011 Widget_Data *wd = elm_widget_data_get(obj);
3013 elm_smart_scroller_hold_set(wd->scr, 0);
3017 _freeze_on(void *data __UNUSED__,
3019 void *event_info __UNUSED__)
3021 Widget_Data *wd = elm_widget_data_get(obj);
3023 elm_smart_scroller_freeze_set(wd->scr, 1);
3027 _freeze_off(void *data __UNUSED__,
3029 void *event_info __UNUSED__)
3031 Widget_Data *wd = elm_widget_data_get(obj);
3033 elm_smart_scroller_freeze_set(wd->scr, 0);
3037 _scroll_edge_left(void *data,
3038 Evas_Object *scr __UNUSED__,
3039 void *event_info __UNUSED__)
3041 Evas_Object *obj = data;
3042 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3046 _scroll_edge_right(void *data,
3047 Evas_Object *scr __UNUSED__,
3048 void *event_info __UNUSED__)
3050 Evas_Object *obj = data;
3051 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3055 _scroll_edge_top(void *data,
3056 Evas_Object *scr __UNUSED__,
3057 void *event_info __UNUSED__)
3059 Evas_Object *obj = data;
3060 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3064 _scroll_edge_bottom(void *data,
3065 Evas_Object *scr __UNUSED__,
3066 void *event_info __UNUSED__)
3068 Evas_Object *obj = data;
3069 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3073 * Add a new Genlist object
3075 * @param parent The parent object
3076 * @return The new object or NULL if it cannot be created
3081 elm_genlist_add(Evas_Object *parent)
3086 Evas_Coord minw, minh;
3087 static Evas_Smart *smart = NULL;
3089 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3093 static Evas_Smart_Class sc;
3095 evas_object_smart_clipped_smart_set(&_pan_sc);
3097 sc.name = "elm_genlist_pan";
3098 sc.version = EVAS_SMART_CLASS_VERSION;
3101 sc.resize = _pan_resize;
3102 sc.move = _pan_move;
3103 sc.calculate = _pan_calculate;
3104 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3106 wd = ELM_NEW(Widget_Data);
3107 e = evas_object_evas_get(parent);
3108 if (!e) return NULL;
3109 obj = elm_widget_add(e);
3110 ELM_SET_WIDTYPE(widtype, "genlist");
3111 elm_widget_type_set(obj, "genlist");
3112 elm_widget_sub_object_add(parent, obj);
3113 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3114 elm_widget_data_set(obj, wd);
3115 elm_widget_del_hook_set(obj, _del_hook);
3116 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3117 elm_widget_theme_hook_set(obj, _theme_hook);
3118 elm_widget_can_focus_set(obj, EINA_TRUE);
3119 elm_widget_event_hook_set(obj, _event_hook);
3120 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3122 wd->scr = elm_smart_scroller_add(e);
3123 elm_smart_scroller_widget_set(wd->scr, obj);
3124 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3125 elm_widget_style_get(obj));
3126 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3127 _elm_config->thumbscroll_bounce_enable);
3128 elm_widget_resize_object_set(obj, wd->scr);
3130 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3131 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3133 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3134 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3138 wd->mode = ELM_LIST_SCROLL;
3139 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3140 wd->item_cache_max = wd->max_items_per_block * 2;
3141 wd->longpress_timeout = _elm_config->longpress_timeout;
3142 //wd->effect_mode = _elm_config->effect_enable;
3143 // wd->effect_mode = EINA_TRUE;
3145 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3146 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3147 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3148 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3150 wd->pan_smart = evas_object_smart_add(e, smart);
3151 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3154 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3155 _pan_set, _pan_get, _pan_max_get,
3156 _pan_min_get, _pan_child_size_get);
3158 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3160 evas_object_size_hint_min_set(obj, minw, minh);
3166 static Elm_Genlist_Item *
3167 _item_new(Widget_Data *wd,
3168 const Elm_Genlist_Item_Class *itc,
3170 Elm_Genlist_Item *parent,
3171 Elm_Genlist_Item_Flags flags,
3173 const void *func_data)
3175 Elm_Genlist_Item *it;
3177 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3178 if (!it) return NULL;
3181 it->base.data = data;
3182 it->parent = parent;
3184 it->func.func = func;
3185 it->func.data = func_data;
3186 it->mouse_cursor = NULL;
3187 it->expanded_depth = 0;
3188 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3189 if ((!it->parent) && (it->wd->select_all_item))
3190 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE);
3191 it->num = ++wd->total_num; // todo : remov
3196 _item_block_add(Widget_Data *wd,
3197 Elm_Genlist_Item *it)
3199 Item_Block *itb = NULL;
3206 itb = calloc(1, sizeof(Item_Block));
3209 if (!it->rel->block)
3212 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3213 itb->items = eina_list_append(itb->items, it);
3219 wd->blocks = eina_inlist_prepend_relative
3220 (wd->blocks, EINA_INLIST_GET(itb),
3221 EINA_INLIST_GET(it->rel->block));
3223 eina_list_prepend_relative(itb->items, it, it->rel);
3227 wd->blocks = eina_inlist_append_relative
3228 (wd->blocks, EINA_INLIST_GET(itb),
3229 EINA_INLIST_GET(it->rel->block));
3231 eina_list_append_relative(itb->items, it, it->rel);
3241 itb = (Item_Block *)(wd->blocks);
3242 if (itb->count >= wd->max_items_per_block)
3244 itb = calloc(1, sizeof(Item_Block));
3248 eina_inlist_prepend(wd->blocks,
3249 EINA_INLIST_GET(itb));
3254 itb = calloc(1, sizeof(Item_Block));
3258 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3260 itb->items = eina_list_prepend(itb->items, it);
3266 itb = (Item_Block *)(wd->blocks->last);
3267 if (itb->count >= wd->max_items_per_block)
3269 itb = calloc(1, sizeof(Item_Block));
3273 eina_inlist_append(wd->blocks,
3274 EINA_INLIST_GET(itb));
3279 itb = calloc(1, sizeof(Item_Block));
3283 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3285 itb->items = eina_list_append(itb->items, it);
3291 itb = it->rel->block;
3292 if (!itb) goto newblock;
3294 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3296 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3299 itb->changed = EINA_TRUE;
3301 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3302 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3305 it->rel->relcount--;
3306 if ((it->rel->delete_me) && (!it->rel->relcount))
3310 if (itb->count > itb->wd->max_items_per_block)
3314 Elm_Genlist_Item *it2;
3316 newc = itb->count / 2;
3317 itb2 = calloc(1, sizeof(Item_Block));
3321 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3322 EINA_INLIST_GET(itb));
3323 itb2->changed = EINA_TRUE;
3324 while ((itb->count > newc) && (itb->items))
3328 l = eina_list_last(itb->items);
3330 itb->items = eina_list_remove_list(itb->items, l);
3333 itb2->items = eina_list_prepend(itb2->items, it2);
3341 _queue_proecess(Widget_Data *wd,
3345 Eina_Bool showme = EINA_FALSE;
3348 t0 = ecore_time_get();
3349 for (n = 0; (wd->queue) && (n < 128); n++)
3351 Elm_Genlist_Item *it;
3353 it = wd->queue->data;
3354 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3355 it->queued = EINA_FALSE;
3356 _item_block_add(wd, it);
3357 t = ecore_time_get();
3358 if (it->block->changed)
3360 showme = _item_block_recalc(it->block, it->block->num, 1,
3362 it->block->changed = 0;
3364 if (showme) it->block->showme = EINA_TRUE;
3365 if (eina_inlist_count(wd->blocks) > 1)
3367 if ((t - t0) > (ecore_animator_frametime_get())) break;
3374 _item_idler(void *data)
3376 Widget_Data *wd = data;
3379 //static double q_start = 0.0;
3380 //if (q_start == 0.0) q_start = ecore_time_get();
3383 if (_queue_proecess(wd, 1) > 0)
3385 if (wd->calc_job) ecore_job_del(wd->calc_job);
3386 wd->calc_job = ecore_job_add(_calc_job, wd);
3391 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3393 wd->queue_idler = NULL;
3394 return ECORE_CALLBACK_CANCEL;
3396 return ECORE_CALLBACK_RENEW;
3400 _item_queue(Widget_Data *wd,
3401 Elm_Genlist_Item *it)
3403 if (it->queued) return;
3404 it->queued = EINA_TRUE;
3405 wd->queue = eina_list_append(wd->queue, it);
3406 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3408 if (wd->queue_idler)
3410 ecore_idler_del(wd->queue_idler);
3411 wd->queue_idler = NULL;
3413 _queue_proecess(wd, 0);
3415 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3419 * Append item to the end of the genlist
3421 * This appends the given item to the end of the list or the end of
3422 * the children if the parent is given.
3424 * @param obj The genlist object
3425 * @param itc The item class for the item
3426 * @param data The item data
3427 * @param parent The parent item, or NULL if none
3428 * @param flags Item flags
3429 * @param func Convenience function called when item selected
3430 * @param func_data Data passed to @p func above.
3431 * @return A handle to the item added or NULL if not possible
3435 EAPI Elm_Genlist_Item *
3436 elm_genlist_item_append(Evas_Object *obj,
3437 const Elm_Genlist_Item_Class *itc,
3439 Elm_Genlist_Item *parent,
3440 Elm_Genlist_Item_Flags flags,
3442 const void *func_data)
3444 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3445 Widget_Data *wd = elm_widget_data_get(obj);
3446 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3448 if (!wd) return NULL;
3449 if (!it) return NULL;
3452 if (flags & ELM_GENLIST_ITEM_GROUP)
3453 wd->group_items = eina_list_append(wd->group_items, it);
3454 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3459 Elm_Genlist_Item *it2 = NULL;
3460 Eina_List *ll = eina_list_last(it->parent->items);
3461 if (ll) it2 = ll->data;
3462 it->parent->items = eina_list_append(it->parent->items, it);
3463 if (!it2) it2 = it->parent;
3465 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3466 EINA_INLIST_GET(it2));
3468 it->rel->relcount++;
3470 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3471 it->group_item = parent;
3472 else if (it->parent->group_item)
3473 it->group_item = it->parent->group_item;
3475 it->before = EINA_FALSE;
3476 _item_queue(wd, it);
3481 * Prepend item at start of the genlist
3483 * This adds an item to the beginning of the list or beginning of the
3484 * children of the parent if given.
3486 * @param obj The genlist object
3487 * @param itc The item class for the item
3488 * @param data The item data
3489 * @param parent The parent item, or NULL if none
3490 * @param flags Item flags
3491 * @param func Convenience function called when item selected
3492 * @param func_data Data passed to @p func above.
3493 * @return A handle to the item added or NULL if not possible
3497 EAPI Elm_Genlist_Item *
3498 elm_genlist_item_prepend(Evas_Object *obj,
3499 const Elm_Genlist_Item_Class *itc,
3501 Elm_Genlist_Item *parent,
3502 Elm_Genlist_Item_Flags flags,
3504 const void *func_data)
3506 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3507 Widget_Data *wd = elm_widget_data_get(obj);
3508 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3510 if (!wd) return NULL;
3511 if (!it) return NULL;
3514 if (flags & ELM_GENLIST_ITEM_GROUP)
3515 wd->group_items = eina_list_prepend(wd->group_items, it);
3516 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3521 Elm_Genlist_Item *it2 = NULL;
3522 Eina_List *ll = it->parent->items;
3523 if (ll) it2 = ll->data;
3524 it->parent->items = eina_list_prepend(it->parent->items, it);
3525 if (!it2) it2 = it->parent;
3527 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3528 EINA_INLIST_GET(it2));
3530 it->rel->relcount++;
3532 it->before = EINA_TRUE;
3533 _item_queue(wd, it);
3538 * Insert item before another in the genlist
3540 * This inserts an item before another in the list. It will be in the
3541 * same tree level or group as the item it is inseted before.
3543 * @param obj The genlist object
3544 * @param itc The item class for the item
3545 * @param data The item data
3546 * @param before The item to insert before
3547 * @param flags Item flags
3548 * @param func Convenience function called when item selected
3549 * @param func_data Data passed to @p func above.
3550 * @return A handle to the item added or NULL if not possible
3554 EAPI Elm_Genlist_Item *
3555 elm_genlist_item_insert_before(Evas_Object *obj,
3556 const Elm_Genlist_Item_Class *itc,
3558 Elm_Genlist_Item *parent,
3559 Elm_Genlist_Item *before,
3560 Elm_Genlist_Item_Flags flags,
3562 const void *func_data)
3564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3565 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3566 Widget_Data *wd = elm_widget_data_get(obj);
3567 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3569 if (!wd) return NULL;
3570 if (!it) return NULL;
3573 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3576 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3577 EINA_INLIST_GET(before));
3579 it->rel->relcount++;
3580 it->before = EINA_TRUE;
3581 _item_queue(wd, it);
3586 * Insert an item after another in the genlst
3588 * This inserts an item after another in the list. It will be in the
3589 * same tree level or group as the item it is inseted after.
3591 * @param obj The genlist object
3592 * @param itc The item class for the item
3593 * @param data The item data
3594 * @param after The item to insert after
3595 * @param flags Item flags
3596 * @param func Convenience function called when item selected
3597 * @param func_data Data passed to @p func above.
3598 * @return A handle to the item added or NULL if not possible
3602 EAPI Elm_Genlist_Item *
3603 elm_genlist_item_insert_after(Evas_Object *obj,
3604 const Elm_Genlist_Item_Class *itc,
3606 Elm_Genlist_Item *parent,
3607 Elm_Genlist_Item *after,
3608 Elm_Genlist_Item_Flags flags,
3610 const void *func_data)
3612 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3613 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3614 Widget_Data *wd = elm_widget_data_get(obj);
3615 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3617 if (!wd) return NULL;
3618 if (!it) return NULL;
3619 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3620 EINA_INLIST_GET(after));
3623 it->parent->items = eina_list_append_relative(it->parent->items, it,
3627 it->rel->relcount++;
3628 it->before = EINA_FALSE;
3629 _item_queue(wd, it);
3636 * This clears all items in the list, leaving it empty.
3638 * @param obj The genlist object
3643 elm_genlist_clear(Evas_Object *obj)
3645 ELM_CHECK_WIDTYPE(obj, widtype);
3646 Widget_Data *wd = elm_widget_data_get(obj);
3648 if (wd->walking > 0)
3650 Elm_Genlist_Item *it;
3652 wd->clear_me = EINA_TRUE;
3653 EINA_INLIST_FOREACH(wd->items, it)
3655 it->delete_me = EINA_TRUE;
3659 wd->clear_me = EINA_FALSE;
3662 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3663 it->nocache = EINA_TRUE;
3664 it->hilighted = EINA_FALSE;
3666 if (wd->anchor_item == it)
3668 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3669 if (!wd->anchor_item)
3671 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3674 wd->items = eina_inlist_remove(wd->items, wd->items);
3675 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3676 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3677 elm_widget_item_pre_notify_del(it);
3678 if (it->effect_item_realized) _effect_item_unrealize(it);
3679 if (it->realized) _item_unrealize(it);
3680 if (it->itc->func.del)
3681 it->itc->func.del((void *)it->base.data, it->base.widget);
3682 if (it->long_timer) ecore_timer_del(it->long_timer);
3683 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3684 elm_widget_item_del(it);
3686 wd->anchor_item = NULL;
3689 Item_Block *itb = (Item_Block *)(wd->blocks);
3691 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3692 if (itb->items) eina_list_free(itb->items);
3697 ecore_job_del(wd->calc_job);
3698 wd->calc_job = NULL;
3700 if (wd->queue_idler)
3702 ecore_idler_del(wd->queue_idler);
3703 wd->queue_idler = NULL;
3705 if (wd->must_recalc_idler)
3707 ecore_idler_del(wd->must_recalc_idler);
3708 wd->must_recalc_idler = NULL;
3712 eina_list_free(wd->queue);
3717 eina_list_free(wd->selected);
3718 wd->selected = NULL;
3722 Evas_Object *editfield;
3723 EINA_LIST_FREE(wd->edit_field, editfield)
3724 evas_object_del(editfield);
3725 wd->edit_field = NULL;
3727 if (wd->item_moving_effect_timer)
3729 ecore_animator_del(wd->item_moving_effect_timer);
3730 wd->item_moving_effect_timer = NULL;
3732 wd->show_item = NULL;
3739 evas_object_del(wd->alpha_bg);
3740 wd->alpha_bg = NULL;
3744 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3745 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3751 * Enable or disable multi-select in the genlist
3753 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3754 * the list. This allows more than 1 item to be selected.
3756 * @param obj The genlist object
3757 * @param multi Multi-select enable/disable
3762 elm_genlist_multi_select_set(Evas_Object *obj,
3765 ELM_CHECK_WIDTYPE(obj, widtype);
3766 Widget_Data *wd = elm_widget_data_get(obj);
3772 * Gets if multi-select in genlist is enable or disable
3774 * @param obj The genlist object
3775 * @return Multi-select enable/disable
3776 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3781 elm_genlist_multi_select_get(const Evas_Object *obj)
3783 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3784 Widget_Data *wd = elm_widget_data_get(obj);
3785 if (!wd) return EINA_FALSE;
3790 * Get the selectd item in the genlist
3792 * This gets the selected item in the list (if multi-select is enabled
3793 * only the first item in the list is selected - which is not very
3794 * useful, so see elm_genlist_selected_items_get() for when
3795 * multi-select is used).
3797 * If no item is selected, NULL is returned.
3799 * @param obj The genlist object
3800 * @return The selected item, or NULL if none.
3804 EAPI Elm_Genlist_Item *
3805 elm_genlist_selected_item_get(const Evas_Object *obj)
3807 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3808 Widget_Data *wd = elm_widget_data_get(obj);
3809 if (!wd) return NULL;
3810 if (wd->selected) return wd->selected->data;
3815 * Get a list of selected items in the genlist
3817 * This returns a list of the selected items. This list pointer is
3818 * only valid so long as no items are selected or unselected (or
3819 * unselected implicitly by deletion). The list contains
3820 * Elm_Genlist_Item pointers.
3822 * @param obj The genlist object
3823 * @return The list of selected items, nor NULL if none are selected.
3827 EAPI const Eina_List *
3828 elm_genlist_selected_items_get(const Evas_Object *obj)
3830 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3831 Widget_Data *wd = elm_widget_data_get(obj);
3832 if (!wd) return NULL;
3833 return wd->selected;
3837 * Get a list of realized items in genlist
3839 * This returns a list of the realized items in the genlist. The list
3840 * contains Elm_Genlist_Item pointers. The list must be freed by the
3841 * caller when done with eina_list_free(). The item pointers in the
3842 * list are only valid so long as those items are not deleted or the
3843 * genlist is not deleted.
3845 * @param obj The genlist object
3846 * @return The list of realized items, nor NULL if none are realized.
3851 elm_genlist_realized_items_get(const Evas_Object *obj)
3853 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3854 Widget_Data *wd = elm_widget_data_get(obj);
3855 Eina_List *list = NULL;
3857 Eina_Bool done = EINA_FALSE;
3858 if (!wd) return NULL;
3859 EINA_INLIST_FOREACH(wd->blocks, itb)
3864 Elm_Genlist_Item *it;
3867 EINA_LIST_FOREACH(itb->items, l, it)
3869 if (it->realized) list = eina_list_append(list, it);
3881 * Get the item that is at the x, y canvas coords
3883 * This returns the item at the given coordinates (which are canvas
3884 * relative not object-relative). If an item is at that coordinate,
3885 * that item handle is returned, and if @p posret is not NULL, the
3886 * integer pointed to is set to a value of -1, 0 or 1, depending if
3887 * the coordinate is on the upper portion of that item (-1), on the
3888 * middle section (0) or on the lower part (1). If NULL is returned as
3889 * an item (no item found there), then posret may indicate -1 or 1
3890 * based if the coordinate is above or below all items respectively in
3893 * @param it The item
3894 * @param x The input x coordinate
3895 * @param y The input y coordinate
3896 * @param posret The position relative to the item returned here
3897 * @return The item at the coordinates or NULL if none
3901 EAPI Elm_Genlist_Item *
3902 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3907 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3908 Widget_Data *wd = elm_widget_data_get(obj);
3909 Evas_Coord ox, oy, ow, oh;
3912 if (!wd) return NULL;
3913 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3915 EINA_INLIST_FOREACH(wd->blocks, itb)
3918 Elm_Genlist_Item *it;
3920 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3921 oy + itb->y - itb->wd->pan_y,
3922 itb->w, itb->h, x, y, 1, 1))
3924 EINA_LIST_FOREACH(itb->items, l, it)
3926 Evas_Coord itx, ity;
3928 itx = ox + itb->x + it->x - itb->wd->pan_x;
3929 ity = oy + itb->y + it->y - itb->wd->pan_y;
3930 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3934 if (y <= (ity + (it->h / 4))) *posret = -1;
3935 else if (y >= (ity + it->h - (it->h / 4)))
3941 lasty = ity + it->h;
3946 if (y > lasty) *posret = 1;
3953 * Get the first item in the genlist
3955 * This returns the first item in the list.
3957 * @param obj The genlist object
3958 * @return The first item, or NULL if none
3962 EAPI Elm_Genlist_Item *
3963 elm_genlist_first_item_get(const Evas_Object *obj)
3965 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3966 Widget_Data *wd = elm_widget_data_get(obj);
3967 if (!wd) return NULL;
3968 if (!wd->items) return NULL;
3969 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3970 while ((it) && (it->delete_me))
3971 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3976 * Get the last item in the genlist
3978 * This returns the last item in the list.
3980 * @return The last item, or NULL if none
3984 EAPI Elm_Genlist_Item *
3985 elm_genlist_last_item_get(const Evas_Object *obj)
3987 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3988 Widget_Data *wd = elm_widget_data_get(obj);
3989 if (!wd) return NULL;
3990 if (!wd->items) return NULL;
3991 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3992 while ((it) && (it->delete_me))
3993 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3998 * Get the next item in the genlist
4000 * This returns the item after the item @p it.
4002 * @param it The item
4003 * @return The item after @p it, or NULL if none
4007 EAPI Elm_Genlist_Item *
4008 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4010 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4013 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4014 if ((it) && (!it->delete_me)) break;
4016 return (Elm_Genlist_Item *)it;
4020 * Get the previous item in the genlist
4022 * This returns the item before the item @p it.
4024 * @param it The item
4025 * @return The item before @p it, or NULL if none
4029 EAPI Elm_Genlist_Item *
4030 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4032 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4035 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4036 if ((it) && (!it->delete_me)) break;
4038 return (Elm_Genlist_Item *)it;
4042 * Get the genlist object from an item
4044 * This returns the genlist object itself that an item belongs to.
4046 * @param it The item
4047 * @return The genlist object
4052 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4054 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4055 return it->base.widget;
4059 * Get the parent item of the given item
4061 * This returns the parent item of the item @p it given.
4063 * @param it The item
4064 * @return The parent of the item or NULL if none
4068 EAPI Elm_Genlist_Item *
4069 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4071 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4076 * Clear all sub-items (children) of the given item
4078 * This clears all items that are children (or their descendants) of the
4081 * @param it The item
4086 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4088 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4089 Elm_Genlist_Item *it2;
4092 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4093 _item_subitems_clear(it);
4096 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4097 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4099 it->wd->expand_item = it;
4100 _item_flip_effect_show(it);
4101 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4102 it->wd->expand_item_end = y + h;
4106 it2 = elm_genlist_item_next_get(it2);
4108 } while (it2->expanded_depth > it->expanded_depth);
4110 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4112 it->wd->expand_item_gap = 0;
4114 evas_object_raise(it->wd->alpha_bg);
4115 evas_object_show(it->wd->alpha_bg);
4117 it->wd->start_time = current_time_get();
4118 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4121 _item_subitems_clear(it);
4126 * Set the selected state of an item
4128 * This sets the selected state (1 selected, 0 not selected) of the given
4131 * @param it The item
4132 * @param selected The selected state
4137 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4140 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4141 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4143 if (it->delete_me) return;
4144 selected = !!selected;
4145 if (it->selected == selected) return;
4151 while (wd->selected)
4152 _item_unselect(wd->selected->data);
4162 * Get the selected state of an item
4164 * This gets the selected state of an item (1 selected, 0 not selected).
4166 * @param it The item
4167 * @return The selected state
4172 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4174 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4175 return it->selected;
4179 * Sets the expanded state of an item (if it's a parent)
4181 * This expands or contracts a parent item (thus showing or hiding the
4184 * @param it The item
4185 * @param expanded The expanded state (1 expanded, 0 not expanded).
4190 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4193 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4194 if (it->expanded == expanded) return;
4195 it->expanded = expanded;
4196 it->wd->expand_item = it;
4198 if(it->wd->effect_mode && !it->wd->alpha_bg)
4199 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4203 it->wd->auto_scrolled = EINA_FALSE;
4204 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4206 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4207 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4211 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4213 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4214 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4219 * Get the expanded state of an item
4221 * This gets the expanded state of an item
4223 * @param it The item
4224 * @return Thre expanded state
4229 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4232 return it->expanded;
4236 * Get the depth of expanded item
4238 * @param it The genlist item object
4239 * @return The depth of expanded item
4244 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4246 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4247 return it->expanded_depth;
4251 * Sets the disabled state of an item.
4253 * A disabled item cannot be selected or unselected. It will also
4254 * change appearance to appear disabled. This sets the disabled state
4255 * (1 disabled, 0 not disabled).
4257 * @param it The item
4258 * @param disabled The disabled state
4263 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4266 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4267 if (it->disabled == disabled) return;
4268 if (it->delete_me) return;
4269 it->disabled = disabled;
4273 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4275 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4280 * Get the disabled state of an item
4282 * This gets the disabled state of the given item.
4284 * @param it The item
4285 * @return The disabled state
4290 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4292 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4293 if (it->delete_me) return EINA_FALSE;
4294 return it->disabled;
4298 * Sets the display only state of an item.
4300 * A display only item cannot be selected or unselected. It is for
4301 * display only and not selecting or otherwise clicking, dragging
4302 * etc. by the user, thus finger size rules will not be applied to
4305 * @param it The item
4306 * @param display_only The display only state
4311 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4312 Eina_Bool display_only)
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4315 if (!it->block) return;
4316 if (it->display_only == display_only) return;
4317 if (it->delete_me) return;
4318 it->display_only = display_only;
4319 it->mincalcd = EINA_FALSE;
4320 it->updateme = EINA_TRUE;
4321 it->block->updateme = EINA_TRUE;
4322 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4323 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4327 * Get the display only state of an item
4329 * This gets the display only state of the given item.
4331 * @param it The item
4332 * @return The display only state
4337 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4340 if (it->delete_me) return EINA_FALSE;
4341 return it->display_only;
4345 * Show the given item
4347 * This causes genlist to jump to the given item @p it and show it (by
4348 * scrolling), if it is not fully visible.
4350 * @param it The item
4355 elm_genlist_item_show(Elm_Genlist_Item *it)
4357 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4358 Evas_Coord gith = 0;
4359 if (it->delete_me) return;
4360 if ((it->queued) || (!it->mincalcd))
4362 it->wd->show_item = it;
4363 it->wd->bring_in = EINA_TRUE;
4364 it->showme = EINA_TRUE;
4367 if (it->wd->show_item)
4369 it->wd->show_item->showme = EINA_FALSE;
4370 it->wd->show_item = NULL;
4372 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4373 gith = it->group_item->h;
4374 elm_smart_scroller_child_region_show(it->wd->scr,
4375 it->x + it->block->x,
4376 it->y + it->block->y - gith,
4377 it->block->w, it->h);
4381 * Bring in the given item
4383 * This causes genlist to jump to the given item @p it and show it (by
4384 * scrolling), if it is not fully visible. This may use animation to
4385 * do so and take a period of time
4387 * @param it The item
4392 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4394 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4395 Evas_Coord gith = 0;
4396 if (it->delete_me) return;
4397 if ((it->queued) || (!it->mincalcd))
4399 it->wd->show_item = it;
4400 it->wd->bring_in = EINA_TRUE;
4401 it->showme = EINA_TRUE;
4404 if (it->wd->show_item)
4406 it->wd->show_item->showme = EINA_FALSE;
4407 it->wd->show_item = NULL;
4409 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4410 gith = it->group_item->h;
4411 elm_smart_scroller_region_bring_in(it->wd->scr,
4412 it->x + it->block->x,
4413 it->y + it->block->y - gith,
4414 it->block->w, it->h);
4418 * Show the given item at the top
4420 * This causes genlist to jump to the given item @p it and show it (by
4421 * scrolling), if it is not fully visible.
4423 * @param it The item
4428 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4430 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4432 Evas_Coord gith = 0;
4434 if (it->delete_me) return;
4435 if ((it->queued) || (!it->mincalcd))
4437 it->wd->show_item = it;
4438 it->wd->bring_in = EINA_TRUE;
4439 it->showme = EINA_TRUE;
4442 if (it->wd->show_item)
4444 it->wd->show_item->showme = EINA_FALSE;
4445 it->wd->show_item = NULL;
4447 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4448 if (it->group_item) gith = it->group_item->h;
4449 elm_smart_scroller_child_region_show(it->wd->scr,
4450 it->x + it->block->x,
4451 it->y + it->block->y - gith,
4456 * Bring in the given item at the top
4458 * This causes genlist to jump to the given item @p it and show it (by
4459 * scrolling), if it is not fully visible. This may use animation to
4460 * do so and take a period of time
4462 * @param it The item
4467 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4469 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4471 Evas_Coord gith = 0;
4473 if (it->delete_me) return;
4474 if ((it->queued) || (!it->mincalcd))
4476 it->wd->show_item = it;
4477 it->wd->bring_in = EINA_TRUE;
4478 it->showme = EINA_TRUE;
4481 if (it->wd->show_item)
4483 it->wd->show_item->showme = EINA_FALSE;
4484 it->wd->show_item = NULL;
4486 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4487 if (it->group_item) gith = it->group_item->h;
4488 elm_smart_scroller_region_bring_in(it->wd->scr,
4489 it->x + it->block->x,
4490 it->y + it->block->y - gith,
4495 * Show the given item at the middle
4497 * This causes genlist to jump to the given item @p it and show it (by
4498 * scrolling), if it is not fully visible.
4500 * @param it The item
4505 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4507 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4510 if (it->delete_me) return;
4511 if ((it->queued) || (!it->mincalcd))
4513 it->wd->show_item = it;
4514 it->wd->bring_in = EINA_TRUE;
4515 it->showme = EINA_TRUE;
4518 if (it->wd->show_item)
4520 it->wd->show_item->showme = EINA_FALSE;
4521 it->wd->show_item = NULL;
4523 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4524 elm_smart_scroller_child_region_show(it->wd->scr,
4525 it->x + it->block->x,
4526 it->y + it->block->y - oh / 2 +
4527 it->h / 2, it->block->w, oh);
4531 * Bring in the given item at the middle
4533 * This causes genlist to jump to the given item @p it and show it (by
4534 * scrolling), if it is not fully visible. This may use animation to
4535 * do so and take a period of time
4537 * @param it The item
4542 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4547 if (it->delete_me) return;
4548 if ((it->queued) || (!it->mincalcd))
4550 it->wd->show_item = it;
4551 it->wd->bring_in = EINA_TRUE;
4552 it->showme = EINA_TRUE;
4555 if (it->wd->show_item)
4557 it->wd->show_item->showme = EINA_FALSE;
4558 it->wd->show_item = NULL;
4560 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4561 elm_smart_scroller_region_bring_in(it->wd->scr,
4562 it->x + it->block->x,
4563 it->y + it->block->y - oh / 2 + it->h / 2,
4568 * Delete a given item
4570 * This deletes the item from genlist and calls the genlist item del
4571 * class callback defined in the item class, if it is set. This clears all
4572 * subitems if it is a tree.
4574 * @param it The item
4579 elm_genlist_item_del(Elm_Genlist_Item *it)
4581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4582 if ((it->relcount > 0) || (it->walking > 0))
4584 elm_widget_item_pre_notify_del(it);
4585 elm_genlist_item_subitems_clear(it);
4586 it->delete_me = EINA_TRUE;
4587 if (it->wd->show_item == it) it->wd->show_item = NULL;
4589 it->wd->selected = eina_list_remove(it->wd->selected,
4593 if (it->realized) _item_unrealize(it);
4594 if (it->effect_item_realized) _effect_item_unrealize(it);
4595 it->block->changed = EINA_TRUE;
4596 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4597 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4599 // if (it->itc->func.del)
4600 // it->itc->func.del((void *)it->base.data, it->base.widget);
4607 * Set the data item from the genlist item
4609 * This set the data value passed on the elm_genlist_item_append() and
4610 * related item addition calls. This function will also call
4611 * elm_genlist_item_update() so the item will be updated to reflect the
4614 * @param it The item
4615 * @param data The new data pointer to set
4620 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4623 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4624 elm_widget_item_data_set(it, data);
4625 elm_genlist_item_update(it);
4629 * Get the data item from the genlist item
4631 * This returns the data value passed on the elm_genlist_item_append()
4632 * and related item addition calls and elm_genlist_item_data_set().
4634 * @param it The item
4635 * @return The data pointer provided when created
4640 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4642 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4643 return elm_widget_item_data_get(it);
4647 * Tells genlist to "orphan" icons fetchs by the item class
4649 * This instructs genlist to release references to icons in the item,
4650 * meaning that they will no longer be managed by genlist and are
4651 * floating "orphans" that can be re-used elsewhere if the user wants
4654 * @param it The item
4659 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4662 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4663 EINA_LIST_FREE(it->icon_objs, icon)
4665 elm_widget_sub_object_del(it->base.widget, icon);
4666 evas_object_smart_member_del(icon);
4667 evas_object_hide(icon);
4672 * Get the real evas object of the genlist item
4674 * This returns the actual evas object used for the specified genlist
4675 * item. This may be NULL as it may not be created, and may be deleted
4676 * at any time by genlist. Do not modify this object (move, resize,
4677 * show, hide etc.) as genlist is controlling it. This function is for
4678 * querying, emitting custom signals or hooking lower level callbacks
4679 * for events. Do not delete this object under any circumstances.
4681 * @param it The item
4682 * @return The object pointer
4686 EAPI const Evas_Object *
4687 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4689 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4690 return it->base.view;
4694 * Update the contents of an item
4696 * This updates an item by calling all the item class functions again
4697 * to get the icons, labels and states. Use this when the original
4698 * item data has changed and the changes are desired to be reflected.
4700 * @param it The item
4705 elm_genlist_item_update(Elm_Genlist_Item *it)
4707 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4708 if (!it->block) return;
4709 if (it->delete_me) return;
4710 it->mincalcd = EINA_FALSE;
4711 it->updateme = EINA_TRUE;
4712 it->block->updateme = EINA_TRUE;
4713 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4714 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4718 * Update the item class of an item
4720 * @param it The item
4721 * @parem itc The item class for the item
4726 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4727 const Elm_Genlist_Item_Class *itc)
4729 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4730 if (!it->block) return;
4731 EINA_SAFETY_ON_NULL_RETURN(itc);
4732 if (it->delete_me) return;
4734 it->nocache = EINA_TRUE;
4735 elm_genlist_item_update(it);
4738 static Evas_Object *
4739 _elm_genlist_item_label_create(void *data,
4741 void *item __UNUSED__)
4743 Evas_Object *label = elm_label_add(obj);
4746 elm_object_style_set(label, "tooltip");
4747 elm_label_label_set(label, data);
4752 _elm_genlist_item_label_del_cb(void *data,
4753 Evas_Object *obj __UNUSED__,
4754 void *event_info __UNUSED__)
4756 eina_stringshare_del(data);
4760 * Set the text to be shown in the genlist item.
4762 * @param item Target item
4763 * @param text The text to set in the content
4765 * Setup the text as tooltip to object. The item can have only one
4766 * tooltip, so any previous tooltip data is removed.
4771 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4774 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4775 text = eina_stringshare_add(text);
4776 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4778 _elm_genlist_item_label_del_cb);
4782 * Set the content to be shown in the tooltip item
4784 * Setup the tooltip to item. The item can have only one tooltip, so
4785 * any previous tooltip data is removed. @p func(with @p data) will be
4786 * called every time that need to show the tooltip and it should return a
4787 * valid Evas_Object. This object is then managed fully by tooltip
4788 * system and is deleted when the tooltip is gone.
4790 * @param item the genlist item being attached by a tooltip.
4791 * @param func the function used to create the tooltip contents.
4792 * @param data what to provide to @a func as callback data/context.
4793 * @param del_cb called when data is not needed anymore, either when
4794 * another callback replaces @func, the tooltip is unset with
4795 * elm_genlist_item_tooltip_unset() or the owner @a item
4796 * dies. This callback receives as the first parameter the
4797 * given @a data, and @c event_info is the item.
4802 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4803 Elm_Tooltip_Item_Content_Cb func,
4805 Evas_Smart_Cb del_cb)
4807 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4809 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4812 if (item->tooltip.del_cb)
4813 item->tooltip.del_cb((void *)item->tooltip.data,
4814 item->base.widget, item);
4816 item->tooltip.content_cb = func;
4817 item->tooltip.data = data;
4818 item->tooltip.del_cb = del_cb;
4820 if (item->base.view)
4822 elm_widget_item_tooltip_content_cb_set(item,
4823 item->tooltip.content_cb,
4824 item->tooltip.data, NULL);
4825 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4831 if (del_cb) del_cb((void *)data, NULL, NULL);
4835 * Unset tooltip from item
4837 * @param item genlist item to remove previously set tooltip.
4839 * Remove tooltip from item. The callback provided as del_cb to
4840 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4841 * it is not used anymore.
4843 * @see elm_genlist_item_tooltip_content_cb_set()
4848 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4850 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4851 if ((item->base.view) && (item->tooltip.content_cb))
4852 elm_widget_item_tooltip_unset(item);
4854 if (item->tooltip.del_cb)
4855 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4856 item->tooltip.del_cb = NULL;
4857 item->tooltip.content_cb = NULL;
4858 item->tooltip.data = NULL;
4859 if (item->tooltip.style)
4860 elm_genlist_item_tooltip_style_set(item, NULL);
4864 * Sets a different style for this item tooltip.
4866 * @note before you set a style you should define a tooltip with
4867 * elm_genlist_item_tooltip_content_cb_set() or
4868 * elm_genlist_item_tooltip_text_set()
4870 * @param item genlist item with tooltip already set.
4871 * @param style the theme style to use (default, transparent, ...)
4876 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4879 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4880 eina_stringshare_replace(&item->tooltip.style, style);
4881 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4885 * Get the style for this item tooltip.
4887 * @param item genlist item with tooltip already set.
4888 * @return style the theme style in use, defaults to "default". If the
4889 * object does not have a tooltip set, then NULL is returned.
4894 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4896 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4897 return item->tooltip.style;
4901 * Set the cursor to be shown when mouse is over the genlist item
4903 * @param item Target item
4904 * @param cursor the cursor name to be used.
4906 * @see elm_object_cursor_set()
4910 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4913 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4914 eina_stringshare_replace(&item->mouse_cursor, cursor);
4915 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4919 * Get the cursor to be shown when mouse is over the genlist item
4921 * @param item genlist item with cursor already set.
4922 * @return the cursor name.
4927 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4929 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4930 return elm_widget_item_cursor_get(item);
4934 * Unset the cursor to be shown when mouse is over the genlist item
4936 * @param item Target item
4938 * @see elm_object_cursor_unset()
4942 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4944 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4945 if (!item->mouse_cursor)
4948 if (item->base.view)
4949 elm_widget_item_cursor_unset(item);
4951 eina_stringshare_del(item->mouse_cursor);
4952 item->mouse_cursor = NULL;
4956 * Sets a different style for this item cursor.
4958 * @note before you set a style you should define a cursor with
4959 * elm_genlist_item_cursor_set()
4961 * @param item genlist item with cursor already set.
4962 * @param style the theme style to use (default, transparent, ...)
4967 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4970 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4971 elm_widget_item_cursor_style_set(item, style);
4975 * Get the style for this item cursor.
4977 * @param item genlist item with cursor already set.
4978 * @return style the theme style in use, defaults to "default". If the
4979 * object does not have a cursor set, then NULL is returned.
4984 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4986 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4987 return elm_widget_item_cursor_style_get(item);
4991 * Set if the cursor set should be searched on the theme or should use
4992 * the provided by the engine, only.
4994 * @note before you set if should look on theme you should define a
4995 * cursor with elm_object_cursor_set(). By default it will only look
4996 * for cursors provided by the engine.
4998 * @param item widget item with cursor already set.
4999 * @param engine_only boolean to define it cursors should be looked
5000 * only between the provided by the engine or searched on widget's
5006 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5007 Eina_Bool engine_only)
5009 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5010 elm_widget_item_cursor_engine_only_set(item, engine_only);
5014 * Get the cursor engine only usage for this item cursor.
5016 * @param item widget item with cursor already set.
5017 * @return engine_only boolean to define it cursors should be looked
5018 * only between the provided by the engine or searched on widget's
5019 * theme as well. If the object does not have a cursor set, then
5020 * EINA_FALSE is returned.
5025 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5027 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5028 return elm_widget_item_cursor_engine_only_get(item);
5032 * This sets the horizontal stretching mode
5034 * This sets the mode used for sizing items horizontally. Valid modes
5035 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5036 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5037 * the scroller will scroll horizontally. Otherwise items are expanded
5038 * to fill the width of the viewport of the scroller. If it is
5039 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5040 * limited to that size.
5042 * @param obj The genlist object
5043 * @param mode The mode to use
5048 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5051 ELM_CHECK_WIDTYPE(obj, widtype);
5052 Widget_Data *wd = elm_widget_data_get(obj);
5054 if (wd->mode == mode) return;
5060 * Gets the horizontal stretching mode
5062 * @param obj The genlist object
5063 * @return The mode to use
5064 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5069 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5071 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5072 Widget_Data *wd = elm_widget_data_get(obj);
5073 if (!wd) return ELM_LIST_LAST;
5078 * Set the always select mode.
5080 * Items will only call their selection func and callback when first
5081 * becoming selected. Any further clicks will do nothing, unless you
5082 * enable always select with elm_genlist_always_select_mode_set().
5083 * This means even if selected, every click will make the selected
5084 * callbacks be called.
5086 * @param obj The genlist object
5087 * @param always_select The always select mode
5088 * (EINA_TRUE = on, EINA_FALSE = off)
5093 elm_genlist_always_select_mode_set(Evas_Object *obj,
5094 Eina_Bool always_select)
5096 ELM_CHECK_WIDTYPE(obj, widtype);
5097 Widget_Data *wd = elm_widget_data_get(obj);
5099 wd->always_select = always_select;
5103 * Get the always select mode.
5105 * @param obj The genlist object
5106 * @return The always select mode
5107 * (EINA_TRUE = on, EINA_FALSE = off)
5112 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5114 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5115 Widget_Data *wd = elm_widget_data_get(obj);
5116 if (!wd) return EINA_FALSE;
5117 return wd->always_select;
5121 * Set no select mode
5123 * This will turn off the ability to select items entirely and they
5124 * will neither appear selected nor call selected callback functions.
5126 * @param obj The genlist object
5127 * @param no_select The no select mode
5128 * (EINA_TRUE = on, EINA_FALSE = off)
5133 elm_genlist_no_select_mode_set(Evas_Object *obj,
5134 Eina_Bool no_select)
5136 ELM_CHECK_WIDTYPE(obj, widtype);
5137 Widget_Data *wd = elm_widget_data_get(obj);
5139 wd->no_select = no_select;
5143 * Gets no select mode
5145 * @param obj The genlist object
5146 * @return The no select mode
5147 * (EINA_TRUE = on, EINA_FALSE = off)
5152 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5154 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5155 Widget_Data *wd = elm_widget_data_get(obj);
5156 if (!wd) return EINA_FALSE;
5157 return wd->no_select;
5163 * This will enable the compress mode where items are "compressed"
5164 * horizontally to fit the genlist scrollable viewport width. This is
5165 * special for genlist. Do not rely on
5166 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5167 * work as genlist needs to handle it specially.
5169 * @param obj The genlist object
5170 * @param compress The compress mode
5171 * (EINA_TRUE = on, EINA_FALSE = off)
5176 elm_genlist_compress_mode_set(Evas_Object *obj,
5179 ELM_CHECK_WIDTYPE(obj, widtype);
5180 Widget_Data *wd = elm_widget_data_get(obj);
5182 wd->compress = compress;
5186 * Get the compress mode
5188 * @param obj The genlist object
5189 * @return The compress mode
5190 * (EINA_TRUE = on, EINA_FALSE = off)
5195 elm_genlist_compress_mode_get(const Evas_Object *obj)
5197 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5198 Widget_Data *wd = elm_widget_data_get(obj);
5199 if (!wd) return EINA_FALSE;
5200 return wd->compress;
5204 * Set height-for-width mode
5206 * With height-for-width mode the item width will be fixed (restricted
5207 * to a minimum of) to the list width when calculating its size in
5208 * order to allow the height to be calculated based on it. This allows,
5209 * for instance, text block to wrap lines if the Edje part is
5210 * configured with "text.min: 0 1".
5212 * @note This mode will make list resize slower as it will have to
5213 * recalculate every item height again whenever the list width
5216 * @note When height-for-width mode is enabled, it also enables
5217 * compress mode (see elm_genlist_compress_mode_set()) and
5218 * disables homogeneous (see elm_genlist_homogeneous_set()).
5220 * @param obj The genlist object
5221 * @param setting The height-for-width mode (EINA_TRUE = on,
5227 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5228 Eina_Bool height_for_width)
5230 ELM_CHECK_WIDTYPE(obj, widtype);
5231 Widget_Data *wd = elm_widget_data_get(obj);
5233 wd->height_for_width = !!height_for_width;
5234 if (wd->height_for_width)
5236 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5237 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5242 * Get the height-for-width mode
5244 * @param obj The genlist object
5245 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5251 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5253 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5254 Widget_Data *wd = elm_widget_data_get(obj);
5255 if (!wd) return EINA_FALSE;
5256 return wd->height_for_width;
5262 * This will enable or disable the scroller bounce mode for the
5263 * genlist. See elm_scroller_bounce_set() for details
5265 * @param obj The genlist object
5266 * @param h_bounce Allow bounce horizontally
5267 * @param v_bounce Allow bounce vertically
5272 elm_genlist_bounce_set(Evas_Object *obj,
5276 ELM_CHECK_WIDTYPE(obj, widtype);
5277 Widget_Data *wd = elm_widget_data_get(obj);
5279 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5283 * Get the bounce mode
5285 * @param obj The genlist object
5286 * @param h_bounce Allow bounce horizontally
5287 * @param v_bounce Allow bounce vertically
5292 elm_genlist_bounce_get(const Evas_Object *obj,
5293 Eina_Bool *h_bounce,
5294 Eina_Bool *v_bounce)
5296 ELM_CHECK_WIDTYPE(obj, widtype);
5297 Widget_Data *wd = elm_widget_data_get(obj);
5299 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5303 * Set homogenous mode
5305 * This will enable the homogeneous mode where items are of the same
5306 * height and width so that genlist may do the lazy-loading at its
5307 * maximum. This implies 'compressed' mode.
5309 * @param obj The genlist object
5310 * @param homogeneous Assume the items within the genlist are of the
5311 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5316 elm_genlist_homogeneous_set(Evas_Object *obj,
5317 Eina_Bool homogeneous)
5319 ELM_CHECK_WIDTYPE(obj, widtype);
5320 Widget_Data *wd = elm_widget_data_get(obj);
5322 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5323 wd->homogeneous = homogeneous;
5327 * Get the homogenous mode
5329 * @param obj The genlist object
5330 * @return Assume the items within the genlist are of the same height
5331 * and width (EINA_TRUE = on, EINA_FALSE = off)
5336 elm_genlist_homogeneous_get(const Evas_Object *obj)
5338 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5339 Widget_Data *wd = elm_widget_data_get(obj);
5340 if (!wd) return EINA_FALSE;
5341 return wd->homogeneous;
5345 * Set the maximum number of items within an item block
5347 * This will configure the block count to tune to the target with
5348 * particular performance matrix.
5350 * @param obj The genlist object
5351 * @param n Maximum number of items within an item block
5356 elm_genlist_block_count_set(Evas_Object *obj,
5359 ELM_CHECK_WIDTYPE(obj, widtype);
5360 Widget_Data *wd = elm_widget_data_get(obj);
5362 wd->max_items_per_block = n;
5363 wd->item_cache_max = wd->max_items_per_block * 2;
5364 _item_cache_clean(wd);
5368 * Get the maximum number of items within an item block
5370 * @param obj The genlist object
5371 * @return Maximum number of items within an item block
5376 elm_genlist_block_count_get(const Evas_Object *obj)
5378 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5379 Widget_Data *wd = elm_widget_data_get(obj);
5381 return wd->max_items_per_block;
5385 * Set the timeout in seconds for the longpress event
5387 * @param obj The genlist object
5388 * @param timeout timeout in seconds
5393 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5396 ELM_CHECK_WIDTYPE(obj, widtype);
5397 Widget_Data *wd = elm_widget_data_get(obj);
5399 wd->longpress_timeout = timeout;
5403 * Get the timeout in seconds for the longpress event
5405 * @param obj The genlist object
5406 * @return timeout in seconds
5411 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5413 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5414 Widget_Data *wd = elm_widget_data_get(obj);
5416 return wd->longpress_timeout;
5420 * Set the scrollbar policy
5422 * This sets the scrollbar visibility policy for the given genlist
5423 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5424 * made visible if it is needed, and otherwise kept hidden.
5425 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5426 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5427 * respectively for the horizontal and vertical scrollbars.
5429 * @param obj The genlist object
5430 * @param policy_h Horizontal scrollbar policy
5431 * @param policy_v Vertical scrollbar policy
5436 elm_genlist_scroller_policy_set(Evas_Object *obj,
5437 Elm_Scroller_Policy policy_h,
5438 Elm_Scroller_Policy policy_v)
5440 ELM_CHECK_WIDTYPE(obj, widtype);
5441 Widget_Data *wd = elm_widget_data_get(obj);
5443 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5444 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5447 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5451 * Get the scrollbar policy
5453 * @param obj The genlist object
5454 * @param policy_h Horizontal scrollbar policy
5455 * @param policy_v Vertical scrollbar policy
5460 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5461 Elm_Scroller_Policy *policy_h,
5462 Elm_Scroller_Policy *policy_v)
5464 ELM_CHECK_WIDTYPE(obj, widtype);
5465 Widget_Data *wd = elm_widget_data_get(obj);
5466 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5467 if ((!wd) || (!wd->scr)) return;
5468 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5469 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5470 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5473 /****************************************************************************/
5478 * @param obj The genlist object
5479 * @param reorder_mode The reorder mode
5480 * (EINA_TRUE = on, EINA_FALSE = off)
5485 elm_genlist_reorder_mode_set(Evas_Object *obj,
5486 Eina_Bool reorder_mode)
5488 ELM_CHECK_WIDTYPE(obj, widtype);
5489 Widget_Data *wd = elm_widget_data_get(obj);
5491 wd->reorder_mode = reorder_mode;
5495 * Get the reorder mode
5497 * @param obj The genlist object
5498 * @return The reorder mode
5499 * (EINA_TRUE = on, EINA_FALSE = off)
5504 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5506 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5507 Widget_Data *wd = elm_widget_data_get(obj);
5508 if (!wd) return EINA_FALSE;
5509 return wd->reorder_mode;
5513 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5519 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5525 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5530 if (it->wd->ed->ec->move)
5531 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5533 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5534 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5535 it->wd->reorder_deleted = EINA_TRUE;
5536 _item_block_del(it);
5538 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5540 it->rel->relcount++;
5541 it->before = EINA_FALSE;
5542 _item_queue(it->wd, it);
5546 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5549 if (!before) return;
5551 if (it->wd->ed->ec->move)
5552 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5554 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5555 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5556 it->wd->reorder_deleted = EINA_TRUE;
5557 _item_block_del(it);
5558 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5560 it->rel->relcount++;
5561 it->before = EINA_TRUE;
5562 _item_queue(it->wd, it);
5566 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5568 ELM_CHECK_WIDTYPE(obj, widtype);
5569 Widget_Data *wd = elm_widget_data_get(obj);
5571 wd->effect_mode = emode;
5572 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5573 // evas_object_resize(wd->point_rect, 10, 25);
5574 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5575 // evas_object_show(wd->point_rect);
5576 // evas_object_hide(wd->point_rect);
5580 _create_tray_alpha_bg(const Evas_Object *obj)
5582 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5583 Widget_Data *wd = elm_widget_data_get(obj);
5584 if (!wd) return NULL;
5586 Evas_Object *bg = NULL;
5587 Evas_Coord ox, oy, ow, oh;
5589 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5590 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5591 evas_object_color_set(bg,0,0,0,0);
5592 evas_object_resize(bg , ow, oh);
5593 evas_object_move(bg , ox, oy);
5594 evas_object_show(bg);
5595 evas_object_hide(bg);
5602 struct timeval timev;
5604 gettimeofday(&timev, NULL);
5605 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5608 // added for item moving animation.
5610 _item_moving_effect_timer_cb(void *data)
5612 Widget_Data *wd = data;
5613 if (!wd) return EINA_FALSE;
5615 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5616 Elm_Genlist_Item *it, *it2;
5618 double time = 0.4, t;
5620 Eina_Bool check, end = EINA_FALSE;
5621 // static Eina_Bool first = EINA_TRUE;
5624 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5626 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5627 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5628 if (t > time) end = EINA_TRUE;
5629 EINA_INLIST_FOREACH(wd->blocks, itb)
5632 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5633 itb->y - wd->pan_y + oy,
5635 cvx, cvy, cvw, cvh))
5637 EINA_LIST_FOREACH(itb->items, l, it)
5639 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5644 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5650 //printf(" s: %d %d ", oy, oh);
5651 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5652 dy = it->scrl_y - it->old_scrl_y;
5653 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5655 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5656 if(wd->expand_item_end < it->old_scrl_y)
5657 dy = wd->expand_item_gap;
5659 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5661 if (wd->expand_item_end < it->old_scrl_y)
5662 dy = wd->expand_item_gap;
5665 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5672 if (!it->old_scrl_y)
5673 it->old_scrl_y = it->scrl_y;
5676 if (it->old_scrl_y + y < oy + oh)
5678 if (!it->realized) _item_realize(it, in, 0);
5680 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5681 it->old_scrl_y = it->scrl_y - y;
5684 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5685 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5687 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5690 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5691 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5692 evas_object_show(it->base.view);
5693 evas_object_raise(it->base.view);
5696 if(wd->select_all_item) evas_object_raise(wd->select_all_item->base.view);
5697 if (it->group_item) evas_object_raise(it->group_item->base.view);
5700 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5702 it2 = elm_genlist_item_prev_get(it);
5705 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5707 if(!it2->effect_done)
5709 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5710 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5711 evas_object_show(it2->base.view);
5712 it2->effect_done = EINA_TRUE;
5716 it2 = elm_genlist_item_prev_get(it2);
5719 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5721 it2 = elm_genlist_item_prev_get(it);
5724 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5726 if(!it2->effect_done)
5728 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5729 it2->effect_done = EINA_TRUE;
5734 it2 = elm_genlist_item_prev_get(it2);
5740 // first = EINA_FALSE;
5744 if (wd->item_moving_effect_timer)
5746 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5747 _item_subitems_clear(wd->expand_item);
5748 EINA_INLIST_FOREACH(wd->blocks, itb)
5750 EINA_LIST_FOREACH(itb->items, l, it)
5752 it->effect_done = EINA_TRUE;
5753 it->list_expanded = 0;
5754 it->old_scrl_y = it->scrl_y;
5758 //evas_render(evas_object_evas_get(wd->obj));
5759 wd->item_moving_effect_timer = NULL;
5760 // first = EINA_TRUE;
5762 _item_auto_scroll(wd);
5763 evas_object_lower(wd->alpha_bg);
5764 evas_object_hide(wd->alpha_bg);
5765 if (wd->calc_job) ecore_job_del(wd->calc_job);
5766 wd->calc_job = ecore_job_add(_calc_job, wd);
5767 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5768 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5770 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5771 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5772 return ECORE_CALLBACK_CANCEL;
5774 return ECORE_CALLBACK_RENEW;
5778 _emit_contract(Elm_Genlist_Item *it)
5780 Elm_Genlist_Item *it2;
5783 // printf("%p is emited contract\n", it);
5784 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5785 it->effect_done = EINA_FALSE;
5787 EINA_LIST_FOREACH(it->items, l, it2)
5789 _emit_contract(it2);
5792 // added for item moving animation.
5794 _item_flip_effect_show(Elm_Genlist_Item *it)
5796 Elm_Genlist_Item *it2;
5798 Widget_Data *wd = it->wd;
5799 Eina_Bool check = EINA_FALSE;
5801 it2 = elm_genlist_item_next_get(it);
5804 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5805 it2 = elm_genlist_item_next_get(it2);
5807 EINA_LIST_FOREACH(it->items, l, it2)
5809 if (it2->parent && it == it2->parent)
5811 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5813 edje_object_signal_emit(it2->base.view, "flip_item", "");
5815 evas_object_move(it2->base.view, -9999, -9999);
5817 evas_object_show(it2->base.view);
5819 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5820 _emit_contract(it2);
5824 return ECORE_CALLBACK_CANCEL;
5829 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5831 printf("!!! NOW FIXING \n");
5836 * Set pinch zoom mode
5838 * @param obj The genlist object
5840 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5845 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5847 printf("!!! NOW FIXING \n");
5851 * Get pinch zoom mode
5853 * @param obj The genlist object
5854 * @return The pinch mode
5855 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5860 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5862 printf("!!! NOW FIXING \n");
5867 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5869 printf("!!! NOW FIXING \n");
5873 ////////////////////////////////////////////////////////////////////////
5875 ////////////////////////////////////////////////////////////////////////
5877 _effect_item_update(Elm_Genlist_Item *it)
5879 if (it->edit_select_check)
5881 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5885 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5890 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5893 if (edit_select_check_state)
5895 it->edit_select_check = EINA_TRUE;
5896 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5900 it->edit_select_check = EINA_FALSE;
5901 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5903 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5904 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5908 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5911 Eina_List *tl = NULL, *l;
5912 Elm_Genlist_Item *it2;
5914 EINA_LIST_FOREACH(it->items, l, it2)
5915 tl = eina_list_append(tl, it2);
5916 EINA_LIST_FREE(tl, it2)
5917 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5921 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5924 Elm_Genlist_Item *tmp_it;
5925 Eina_Bool parent_check = EINA_TRUE;
5927 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5929 if (tmp_it->parent && it->parent)
5930 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5934 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5935 else it->parent->edit_select_check = EINA_FALSE;
5940 _effect_item_update(it->parent);
5941 return _edit_parent_items_checkbox_set(it->parent);
5946 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items)
5948 if (!select_all_it || !select_all_it->wd) return;
5950 Eina_Bool old_check_state;
5951 Elm_Genlist_Item *it;
5952 Widget_Data *wd = select_all_it->wd;
5954 wd->select_all_check = checked;
5955 if (wd->select_all_check)
5956 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_check", "elm");
5958 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_uncheck", "elm");
5962 EINA_INLIST_FOREACH(wd->items, it)
5964 old_check_state = it->edit_select_check;
5965 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5966 else it->edit_select_check = EINA_FALSE;
5968 // TODO : check this
5969 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5970 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5974 if (wd->ed->ec->item_selected)
5975 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
5977 if (wd->calc_job) ecore_job_del(wd->calc_job);
5978 wd->calc_job = ecore_job_add(_calc_job, wd);
5982 _checkbox_item_select_process(Elm_Genlist_Item *it)
5984 Elm_Genlist_Item *tmp_it;
5985 Eina_Bool old_check_state;
5986 int check_cnt = 0, total_cnt = 0;
5989 _edit_item_checkbox_set(it, it->edit_select_check);
5990 _edit_subitems_checkbox_set(it);
5991 _edit_parent_items_checkbox_set(it);
5993 if (it->wd->ed) it->wd->ed->del_item = it;
5995 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5997 if (tmp_it->edit_select_check) check_cnt++;
6001 if (it->wd->select_all_item)
6003 old_check_state = it->wd->select_all_check;
6004 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
6005 else it->wd->select_all_check = EINA_FALSE;
6007 if (check_cnt == total_cnt)
6009 it->wd->select_all_check = EINA_TRUE;
6010 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
6014 it->wd->select_all_check = EINA_FALSE;
6015 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
6021 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
6023 Elm_Genlist_Item *it = data;
6025 it->edit_select_check = !it->edit_select_check;
6026 _checkbox_item_select_process(it);
6030 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
6032 Elm_Genlist_Item *select_all_it = data;
6033 Widget_Data *wd = select_all_it->wd;
6036 _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE);
6041 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
6043 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6045 evas_object_resize(it->edit_obj,it->w, it->h);
6046 evas_object_move(it->edit_obj, itx, ity);
6048 if (it->wd->select_all_check)
6049 it->edit_select_check = EINA_TRUE;
6052 if (it->edit_select_check)
6054 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
6058 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6064 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
6066 if ((it->effect_item_realized) || (it->delete_me)) return;
6067 int itmode = 0, pad = 0;
6068 const char *pad_str;
6070 it->pad_left = it->pad_right = 0;
6072 if (it->itc->func.editmode_get)
6073 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
6074 itmode &= it->wd->edit_mode;
6076 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6077 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
6079 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6080 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6081 _elm_config->scale);
6082 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6083 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6085 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6086 else strncpy(buf, "item", sizeof(buf));
6087 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6089 strncat(buf, "/", sizeof(buf) - strlen(buf));
6091 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
6093 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
6094 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6098 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6101 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6102 if (pad_str) pad = atoi(pad_str);
6104 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6106 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable_effect", "elm");
6107 else edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6109 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6110 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6111 "elm", _checkbox_item_select_cb);
6113 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,select",
6114 "elm", _checkbox_item_select_cb, it);
6115 it->pad_left += pad * _elm_config->scale;
6119 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6121 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6122 "elm", _checkbox_item_select_cb);
6125 if (effect_on && itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6127 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm");
6128 edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6130 else if (itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6131 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm");
6133 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6135 if (it->itc->func.icon_get)
6140 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6141 EINA_LIST_FOREACH(it->icons, l, key)
6143 Evas_Object *ic = it->itc->func.icon_get
6144 (it->base.data, it->base.widget, l->data);
6148 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6149 edje_object_part_swallow(it->edit_obj, key, ic);
6150 evas_object_show(ic);
6151 elm_widget_sub_object_add(it->base.widget, ic);
6156 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6157 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6158 evas_object_show(it->edit_obj);
6160 it->effect_item_realized = EINA_TRUE;
6161 it->want_unrealize = EINA_FALSE;
6165 _effect_item_unrealize(Elm_Genlist_Item *it)
6169 if (!it->effect_item_realized) return;
6170 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6172 it->pad_left = it->pad_right = 0;
6173 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6174 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6175 edje_object_message_signal_process(it->edit_obj);
6176 edje_object_part_unswallow(it->edit_obj, it->base.view);
6177 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6178 elm_widget_sub_object_add(it->base.widget, it->base.view);
6179 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6180 // _item_cache_add(it);
6181 evas_object_del(it->edit_obj);
6182 it->edit_obj = NULL;
6183 EINA_LIST_FREE(it->edit_icon_objs, icon)
6184 evas_object_del(icon);
6186 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6187 it->effect_item_realized = EINA_FALSE;
6191 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6193 fprintf(stderr, "=================> Caution!!! <========================\n");
6194 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6195 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6196 fprintf(stderr, "=======================================================\n");
6198 elm_genlist_edit_mode_set(obj, emode, edit_class);
6202 * Get Genlist edit mode
6204 * @param obj The genlist object
6205 * @return The edit mode status
6206 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6211 elm_genlist_edit_mode_get(const Evas_Object *obj)
6213 ELM_CHECK_WIDTYPE(obj, widtype);
6214 Widget_Data *wd = elm_widget_data_get(obj);
6215 if (!wd) return EINA_FALSE;
6217 if (wd->edit_mode) return EINA_TRUE;
6218 else return EINA_FALSE;
6222 * Set Genlist edit mode
6224 * This sets Genlist edit mode.
6226 * @param obj The Genlist object
6227 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6228 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6233 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6235 ELM_CHECK_WIDTYPE(obj, widtype);
6238 Eina_Bool done = EINA_FALSE;
6239 static Elm_Genlist_Item_Class itc;
6241 Elm_Genlist_Item *it;
6243 Widget_Data *wd = elm_widget_data_get(obj);
6245 if (wd->edit_mode == emode) return;
6247 wd->edit_mode = emode;
6249 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6250 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6253 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6255 EINA_INLIST_FOREACH(wd->blocks, itb)
6260 EINA_LIST_FOREACH(itb->items, l, it)
6262 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6264 it->pad_left = it->pad_right = 0;
6265 _effect_item_unrealize(it);
6275 EINA_INLIST_FOREACH(wd->items, it)
6277 it->edit_select_check = EINA_FALSE;
6279 if (wd->ed) free (wd->ed);
6281 wd->reorder_mode = EINA_FALSE;
6282 if (wd->select_all_item)
6284 wd->select_all_check = EINA_FALSE;
6285 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down);
6286 elm_widget_item_pre_notify_del(wd->select_all_item);
6287 _item_unrealize(wd->select_all_item);
6288 elm_widget_item_del(wd->select_all_item);
6290 wd->select_all_item = NULL;
6293 Evas_Object *editfield;
6294 EINA_LIST_FREE(wd->edit_field, editfield)
6295 evas_object_del(editfield);
6296 wd->edit_field = NULL;
6298 _item_cache_zero(wd);
6302 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6303 wd->reorder_mode = EINA_TRUE;
6306 wd->ed = calloc(1, sizeof(Edit_Data));
6308 wd->ed->ec = edit_class;
6310 EINA_INLIST_FOREACH(wd->blocks, itb)
6315 EINA_LIST_FOREACH(itb->items, l, it)
6317 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6319 if(it->selected) _item_unselect(it);
6320 _effect_item_realize(it, EINA_TRUE);
6330 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6332 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6333 itc.item_style = edit_class->select_all_item_style;
6335 itc.item_style = "select_all";
6336 itc.func.label_get = NULL;
6337 itc.func.icon_get = NULL;
6338 itc.func.del = NULL;
6339 itc.func.editmode_get = NULL;
6340 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6343 if (!wd->select_all_item) return;
6345 _item_realize(wd->select_all_item, 0, 0);
6346 edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down, wd->select_all_item);
6348 wd->select_all_item->rel = NULL;
6349 wd->select_all_item->block = NULL;
6353 if (wd->calc_job) ecore_job_del(wd->calc_job);
6354 wd->calc_job = ecore_job_add(_calc_job, wd);
6358 * Delete selected items in genlist edit mode.
6360 * @param obj The genlist object
6365 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6367 ELM_CHECK_WIDTYPE(obj, widtype);
6368 Widget_Data *wd = elm_widget_data_get(obj);
6370 if (!wd->blocks) return;
6371 Elm_Genlist_Item *it;
6372 Eina_List *edit_selected_list, *l;
6376 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
6379 if (wd->edit_field) return;
6380 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
6381 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy,&cvw, &cvh);
6382 EINA_INLIST_FOREACH(wd->blocks, itb)
6384 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
6385 itb->y - wd->pan_y + oy,
6387 cvx, cvy, cvw, cvh))
6388 EINA_LIST_FOREACH(itb->items, l, it)
6390 it->old_scrl_y =itb->y + it->y - it->wd->pan_y + oy;
6393 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6394 cnt = eina_list_count(edit_selected_list);
6395 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6397 wd->expand_item_gap = wd->expand_item_end = 0;
6398 EINA_LIST_FOREACH(edit_selected_list, l, it)
6400 if (it->flags != ELM_GENLIST_ITEM_GROUP)
6402 it->wd->expand_item_gap += it->h * -1;
6403 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
6404 cvx, cvy, cvw, cvh));
6405 if (!it->wd->expand_item_end && vis ) it->wd->expand_item_end = it->old_scrl_y;
6406 it->wd->expand_item = elm_genlist_item_prev_get(it);
6407 elm_genlist_item_del(it);
6410 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE;
6411 eina_list_free(edit_selected_list);
6413 evas_render(evas_object_evas_get(wd->obj));
6414 if (wd->calc_job) ecore_job_del(wd->calc_job);
6415 wd->calc_job = ecore_job_add(_calc_job, wd);
6419 elm_genlist_selected_items_del(Evas_Object *obj)
6421 fprintf(stderr, "=================> Caution!!! <========================\n");
6422 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6423 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6424 fprintf(stderr, "=======================================================\n");
6425 elm_genlist_edit_selected_items_del(obj);
6429 * Get a list of selected items in genlist
6431 * This returns a list of the selected items in the genlist. The list
6432 * contains Elm_Genlist_Item pointers. The list must be freed by the
6433 * caller when done with eina_list_free(). The item pointers in the list
6434 * are only vallid so long as those items are not deleted or the genlist is
6437 * @param obj The genlist object
6438 * @return The list of selected items, nor NULL if none are selected.
6443 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6445 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6446 Widget_Data *wd = elm_widget_data_get(obj);
6447 Eina_List *list = NULL;
6448 Elm_Genlist_Item *it;
6449 if (!wd) return NULL;
6451 EINA_INLIST_FOREACH(wd->items, it)
6453 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6459 // TODO : add comment
6461 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6464 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6465 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6467 selected = !!selected;
6468 if (it->edit_select_check == selected) return;
6470 it->edit_select_check = selected;
6471 _checkbox_item_select_process(it);
6474 // TODO : add comment
6475 EAPI const Eina_Bool
6476 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6478 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6479 return it->edit_select_check;
6483 * Set a given item's rename mode
6485 * This renames the item's label from genlist
6487 * @param it The item
6488 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6493 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6495 if (!it) return NULL;
6496 if (it->wd->queue_idler) return NULL;
6498 const Eina_List *l, *list, *l2;
6499 const char *label, *rename_swallow_part;
6501 Eina_Bool done = EINA_FALSE;
6502 int label_cnt = 0 , swallow_part_cnt = 0;
6505 Evas_Object *editfield;
6506 Evas_Object *entry = NULL;
6507 int edit_field_cnt = 0;
6509 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6514 Elm_Genlist_Item *it;
6516 EINA_LIST_FOREACH(itb->items, l, it)
6520 it->renamed = EINA_FALSE;
6521 if (it->selected) _item_unselect(it);
6522 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6524 entry = elm_editfield_entry_get(editfield);
6525 const char *text = elm_entry_entry_get(entry);
6526 if (it->itc->func.label_changed)
6527 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6529 EINA_LIST_FREE(it->wd->edit_field, editfield)
6530 evas_object_del(editfield);
6531 it->wd->edit_field = NULL;
6533 if (it->wd->edit_mode)
6535 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6536 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6537 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6538 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6541 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6554 it->renamed = EINA_TRUE;
6555 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6557 it->wd->edit_mode = 0xF0;
6558 _effect_item_realize(it, EINA_TRUE);
6559 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6562 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6563 EINA_LIST_FOREACH(it->labels, list, label)
6565 if (it->itc->func.label_get)
6567 swallow_part_cnt = 0;
6569 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6570 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6572 if (label_cnt == swallow_part_cnt)
6574 editfield = elm_editfield_add(it->base.widget);
6575 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6577 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6578 elm_editfield_eraser_set(editfield, EINA_TRUE);
6579 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6580 elm_widget_sub_object_add(it->edit_obj, editfield);
6582 evas_object_show(editfield);
6584 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6587 entry = elm_editfield_entry_get(editfield);
6588 elm_entry_entry_set(entry,s);
6589 elm_entry_cursor_end_set(entry);
6593 elm_editfield_guide_text_set(editfield, "Text Input");
6600 elm_widget_focused_object_clear(elm_widget_focused_object_get(it->wd->obj));
6601 elm_widget_focus_set(editfield, EINA_TRUE);
6607 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6609 Elm_Genlist_Item *it = data;
6611 _delete_sweep_objs(it);
6615 _scr_hold_timer_cb(void *data)
6617 Elm_Genlist_Item *it = data;
6618 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6619 it->wd->scr_hold_timer = NULL;
6620 return ECORE_CALLBACK_CANCEL;
6624 _delete_sweep_objs(Elm_Genlist_Item *it)
6628 elm_widget_stringlist_free(it->sweep_labels);
6629 it->sweep_labels = NULL;
6630 elm_widget_stringlist_free(it->sweep_icons);
6631 it->sweep_icons = NULL;
6632 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6633 evas_object_del(ic);
6637 _create_sweep_objs(Elm_Genlist_Item *it)
6643 if (it->itc->func.label_get)
6646 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6648 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6650 char *s = it->itc->func.label_get
6651 ((void *)it->base.data, it->base.widget, l->data);
6655 edje_object_part_text_set(it->base.view, l->data, s);
6660 if (it->itc->func.icon_get)
6663 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6665 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6667 ic = it->itc->func.icon_get
6668 ((void *)it->base.data, it->base.widget, l->data);
6672 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6673 edje_object_part_swallow(it->base.view, key, ic);
6674 evas_object_show(ic);
6675 elm_widget_sub_object_add(it->base.widget, ic);
6682 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6685 Elm_Genlist_Item *it2;
6686 const char *allow_slide;
6688 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6689 if ((!allow_slide) || (atoi(allow_slide) != 1))
6694 if (it->sweeped) return;
6695 if (it->wd->scr_hold_timer)
6697 ecore_timer_del(it->wd->scr_hold_timer);
6698 it->wd->scr_hold_timer = NULL;
6700 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6701 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6703 _delete_sweep_objs(it);
6704 _create_sweep_objs(it);
6705 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6706 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6707 it->wassweeped = EINA_TRUE;
6708 it->sweeped = EINA_TRUE;
6710 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6714 it2->sweeped = EINA_FALSE;
6715 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6716 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6717 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6723 if (!it->sweeped) return;
6724 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6725 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6726 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6727 it->sweeped = EINA_FALSE;
6732 _item_auto_scroll(void *data)
6734 Widget_Data *wd = data;
6737 if ((wd->expand_item) && (!wd->auto_scrolled))
6739 Elm_Genlist_Item *it;
6741 Evas_Coord ox, oy, ow, oh;
6742 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6744 wd->auto_scrolled = EINA_TRUE;
6745 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6747 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6749 elm_genlist_item_bring_in(it);