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;
357 Eina_Bool contracting : 1;
360 Eina_List *edit_field;
361 Elm_Genlist_Item *select_all_item;
362 Eina_List *sweeped_items;
363 Ecore_Timer *scr_hold_timer;
365 int group_item_width;
366 int group_item_height;
367 Elm_Genlist_Item *reorder_it, *reorder_rel;
368 Evas_Coord reorder_start_y;
369 Ecore_Animator *item_moving_effect_timer;
370 Evas_Object *alpha_bg;
371 Elm_Genlist_Item *expand_item;
372 Evas_Coord expand_item_end;
373 Evas_Coord expand_item_gap;
374 int move_effect_mode;
375 unsigned int start_time;
376 Elm_Genlist_Item *head_item, *tail_item;
377 Elm_Genlist_Item *rename_it;
387 Evas_Coord x, y, w, h, minw, minh;
388 Eina_Bool want_unrealize : 1;
389 Eina_Bool realized : 1;
390 Eina_Bool changed : 1;
391 Eina_Bool updateme : 1;
392 Eina_Bool showme : 1;
393 Eina_Bool must_recalc : 1;
397 struct _Elm_Genlist_Item
399 Elm_Widget_Item base;
404 Evas_Coord x, y, w, h, minw, minh;
405 const Elm_Genlist_Item_Class *itc;
406 Elm_Genlist_Item *parent;
407 Elm_Genlist_Item *group_item;
408 Elm_Genlist_Item_Flags flags;
416 Eina_List *labels, *icons, *states, *icon_objs;
417 Ecore_Timer *long_timer;
418 Ecore_Timer *swipe_timer;
420 Evas_Coord scrl_x, scrl_y;
422 Elm_Genlist_Item *rel;
427 Elm_Tooltip_Item_Content_Cb content_cb;
428 Evas_Smart_Cb del_cb;
432 const char *mouse_cursor;
439 Eina_Bool before : 1;
441 Eina_Bool want_unrealize : 1;
442 Eina_Bool want_realize : 1;
443 Eina_Bool realized : 1;
444 Eina_Bool selected : 1;
445 Eina_Bool hilighted : 1;
446 Eina_Bool expanded : 1;
447 Eina_Bool disabled : 1;
448 Eina_Bool display_only : 1;
449 Eina_Bool mincalcd : 1;
450 Eina_Bool queued : 1;
451 Eina_Bool showme : 1;
452 Eina_Bool delete_me : 1;
454 Eina_Bool dragging : 1;
455 Eina_Bool updateme : 1;
456 Eina_Bool nocache : 1;
459 Eina_Bool move_effect_me : 1;
460 Eina_Bool effect_done : 1;
461 Eina_Bool reordering : 1;
462 Eina_Bool edit_select_check: 1;
463 Eina_Bool renamed : 1;
464 Eina_Bool effect_item_realized : 1;
465 Eina_Bool sweeped : 1;
466 Eina_Bool wassweeped : 1;
467 Eina_List *edit_icon_objs;
468 Evas_Object *edit_obj;
469 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
471 Ecore_Animator *item_moving_effect_timer;
472 Evas_Coord old_scrl_x, old_scrl_y;
473 Evas_Coord pad_left, pad_right;
481 Evas_Object *base_view, *spacer;
483 const char *item_style; // it->itc->item_style
484 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
485 Eina_Bool compress : 1; // it->wd->compress
486 Eina_Bool odd : 1; // in & 0x1
488 Eina_Bool selected : 1; // it->selected
489 Eina_Bool disabled : 1; // it->disabled
490 Eina_Bool expanded : 1; // it->expanded
495 Elm_Genlist_Edit_Class *ec;
496 Elm_Genlist_Item *del_item;
497 Elm_Genlist_Item *reorder_item;
498 Elm_Genlist_Item *reorder_rel;
499 Evas_Object *del_confirm;
502 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
503 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
507 Evas_Object_Smart_Clipped_Data __clipped_data;
509 Ecore_Job *resize_job;
512 static const char *widtype = NULL;
513 static void _item_cache_zero(Widget_Data *wd);
514 static void _del_hook(Evas_Object *obj);
515 static void _theme_hook(Evas_Object *obj);
516 static void _show_region_hook(void *data, Evas_Object *obj);
517 static void _sizing_eval(Evas_Object *obj);
518 static void _item_unrealize(Elm_Genlist_Item *it);
519 static void _item_block_unrealize(Item_Block *itb);
520 static void _calc_job(void *data);
521 static void _on_focus_hook(void *data,
523 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
524 static void _changed_job(void *data);
525 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
526 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
527 static Eina_Bool _item_single_select_up(Widget_Data *wd);
528 static Eina_Bool _item_single_select_down(Widget_Data *wd);
529 static Eina_Bool _event_hook(Evas_Object *obj,
531 Evas_Callback_Type type,
533 static Eina_Bool _deselect_all_items(Widget_Data *wd);
534 static void _pan_calculate(Evas_Object *obj);
535 // TODO : refactoring
536 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
537 static unsigned int current_time_get();
538 static Eina_Bool _item_moving_effect_timer_cb(void *data);
539 static int _item_flip_effect_show(Elm_Genlist_Item *it);
540 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
541 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
542 static void _effect_item_unrealize(Elm_Genlist_Item *it);
543 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
544 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
545 static void _create_sweep_objs(Elm_Genlist_Item *it);
546 static void _delete_sweep_objs(Elm_Genlist_Item *it);
547 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
548 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
549 static void _group_items_recalc(void *data);
550 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items);
551 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
552 static void _item_auto_scroll(void *data);
554 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
557 _event_hook(Evas_Object *obj,
558 Evas_Object *src __UNUSED__,
559 Evas_Callback_Type type,
562 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
563 Evas_Event_Key_Down *ev = event_info;
564 Widget_Data *wd = elm_widget_data_get(obj);
565 if (!wd) return EINA_FALSE;
566 if (!wd->items) return EINA_FALSE;
567 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
568 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
570 Elm_Genlist_Item *it = NULL;
573 Evas_Coord step_x = 0;
574 Evas_Coord step_y = 0;
577 Evas_Coord page_x = 0;
578 Evas_Coord page_y = 0;
580 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
581 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
582 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
583 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
585 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
589 else if ((!strcmp(ev->keyname, "Right")) ||
590 (!strcmp(ev->keyname, "KP_Right")))
594 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
596 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
597 (_item_multi_select_up(wd)))
598 || (_item_single_select_up(wd)))
600 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
606 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
608 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
609 (_item_multi_select_down(wd)))
610 || (_item_single_select_down(wd)))
612 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
618 else if ((!strcmp(ev->keyname, "Home")) ||
619 (!strcmp(ev->keyname, "KP_Home")))
621 it = elm_genlist_first_item_get(obj);
622 elm_genlist_item_bring_in(it);
623 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
626 else if ((!strcmp(ev->keyname, "End")) ||
627 (!strcmp(ev->keyname, "KP_End")))
629 it = elm_genlist_last_item_get(obj);
630 elm_genlist_item_bring_in(it);
631 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
634 else if ((!strcmp(ev->keyname, "Prior")) ||
635 (!strcmp(ev->keyname, "KP_Prior")))
638 y -= -(page_y * v_h) / 100;
642 else if ((!strcmp(ev->keyname, "Next")) ||
643 (!strcmp(ev->keyname, "KP_Next")))
646 y += -(page_y * v_h) / 100;
650 else if(((!strcmp(ev->keyname, "Return")) ||
651 (!strcmp(ev->keyname, "KP_Enter")) ||
652 (!strcmp(ev->keyname, "space")))
653 && (!wd->multi) && (wd->selected))
655 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
656 elm_genlist_item_expanded_set(it,
657 !elm_genlist_item_expanded_get(it));
659 else if (!strcmp(ev->keyname, "Escape"))
661 if (!_deselect_all_items(wd)) return EINA_FALSE;
662 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
665 else return EINA_FALSE;
667 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
668 elm_smart_scroller_child_pos_set(wd->scr, x, y);
673 _deselect_all_items(Widget_Data *wd)
675 if (!wd->selected) return EINA_FALSE;
677 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
683 _item_multi_select_up(Widget_Data *wd)
685 if (!wd->selected) return EINA_FALSE;
686 if (!wd->multi) return EINA_FALSE;
688 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
689 if (!prev) return EINA_TRUE;
691 if (elm_genlist_item_selected_get(prev))
693 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
694 wd->last_selected_item = prev;
695 elm_genlist_item_show(wd->last_selected_item);
699 elm_genlist_item_selected_set(prev, EINA_TRUE);
700 elm_genlist_item_show(prev);
706 _item_multi_select_down(Widget_Data *wd)
708 if (!wd->selected) return EINA_FALSE;
709 if (!wd->multi) return EINA_FALSE;
711 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
712 if (!next) return EINA_TRUE;
714 if (elm_genlist_item_selected_get(next))
716 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
717 wd->last_selected_item = next;
718 elm_genlist_item_show(wd->last_selected_item);
722 elm_genlist_item_selected_set(next, EINA_TRUE);
723 elm_genlist_item_show(next);
729 _item_single_select_up(Widget_Data *wd)
731 Elm_Genlist_Item *prev;
734 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
735 while ((prev) && (prev->delete_me))
736 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
738 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
740 if (!prev) return EINA_FALSE;
742 _deselect_all_items(wd);
744 elm_genlist_item_selected_set(prev, EINA_TRUE);
745 elm_genlist_item_show(prev);
750 _item_single_select_down(Widget_Data *wd)
752 Elm_Genlist_Item *next;
755 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
756 while ((next) && (next->delete_me))
757 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
759 else next = elm_genlist_item_next_get(wd->last_selected_item);
761 if (!next) return EINA_FALSE;
763 _deselect_all_items(wd);
765 elm_genlist_item_selected_set(next, EINA_TRUE);
766 elm_genlist_item_show(next);
771 _on_focus_hook(void *data __UNUSED__,
774 Widget_Data *wd = elm_widget_data_get(obj);
776 if (elm_widget_focus_get(obj))
778 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
779 evas_object_focus_set(wd->obj, EINA_TRUE);
780 if ((wd->selected) && (!wd->last_selected_item))
781 wd->last_selected_item = eina_list_data_get(wd->selected);
785 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
786 evas_object_focus_set(wd->obj, EINA_FALSE);
791 _del_hook(Evas_Object *obj)
793 Widget_Data *wd = elm_widget_data_get(obj);
795 _item_cache_zero(wd);
796 if (wd->calc_job) ecore_job_del(wd->calc_job);
797 if (wd->update_job) ecore_job_del(wd->update_job);
798 if (wd->changed_job) ecore_job_del(wd->changed_job);
799 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
800 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
801 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
806 _del_pre_hook(Evas_Object *obj)
808 Widget_Data *wd = elm_widget_data_get(obj);
810 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, ELM_GENLIST_EDIT_MODE_NONE, NULL);
811 evas_object_del(wd->pan_smart);
812 wd->pan_smart = NULL;
813 elm_genlist_clear(obj);
817 _theme_hook(Evas_Object *obj)
819 Widget_Data *wd = elm_widget_data_get(obj);
822 _item_cache_zero(wd);
823 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
824 elm_widget_style_get(obj));
825 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
826 wd->item_width = wd->item_height = 0;
827 wd->minw = wd->minh = wd->realminw = 0;
828 EINA_INLIST_FOREACH(wd->blocks, itb)
831 Elm_Genlist_Item *it;
833 if (itb->realized) _item_block_unrealize(itb);
834 EINA_LIST_FOREACH(itb->items, l, it)
835 it->mincalcd = EINA_FALSE;
837 itb->changed = EINA_TRUE;
839 if (wd->calc_job) ecore_job_del(wd->calc_job);
840 wd->calc_job = ecore_job_add(_calc_job, wd);
845 _show_region_hook(void *data, Evas_Object *obj)
847 Widget_Data *wd = elm_widget_data_get(data);
848 Evas_Coord x, y, w, h;
850 elm_widget_show_region_get(obj, &x, &y, &w, &h);
853 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
857 _sizing_eval(Evas_Object *obj)
859 Widget_Data *wd = elm_widget_data_get(obj);
860 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
862 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
863 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
865 if (wd->height_for_width)
869 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
870 if ((vw != 0) && (vw != wd->prev_viewport_w))
874 wd->prev_viewport_w = vw;
875 EINA_INLIST_FOREACH(wd->blocks, itb)
877 itb->must_recalc = EINA_TRUE;
879 if (wd->calc_job) ecore_job_del(wd->calc_job);
880 wd->calc_job = ecore_job_add(_calc_job, wd);
883 if (wd->mode == ELM_LIST_LIMIT)
885 Evas_Coord vmw, vmh, vw, vh;
889 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
890 if ((minw > 0) && (vw < minw)) vw = minw;
891 else if ((maxw > 0) && (vw > maxw))
893 edje_object_size_min_calc
894 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
901 edje_object_size_min_calc
902 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
906 evas_object_size_hint_min_set(obj, minw, minh);
907 evas_object_size_hint_max_set(obj, maxw, maxh);
911 _item_hilight(Elm_Genlist_Item *it)
913 const char *selectraise;
914 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) || (it->disabled) || (it->display_only)) return;
915 if ((!it->sweeped) && (!it->wd->edit_mode))
916 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
917 selectraise = edje_object_data_get(it->base.view, "selectraise");
918 if ((selectraise) && (!strcmp(selectraise, "on")))
920 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
921 if ((it->group_item) && (it->group_item->realized))
922 evas_object_raise(it->group_item->base.view);
924 it->hilighted = EINA_TRUE;
925 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
929 _item_block_del(Elm_Genlist_Item *it)
932 Item_Block *itb = it->block;
934 itb->items = eina_list_remove(itb->items, it);
936 itb->changed = EINA_TRUE;
937 if (!it->wd->reorder_deleted)
939 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
940 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
944 il = EINA_INLIST_GET(itb);
945 Item_Block *itbn = (Item_Block *)(il->next);
947 it->parent->items = eina_list_remove(it->parent->items, it);
949 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
951 if (itbn) itbn->changed = EINA_TRUE;
955 if (itb->count < itb->wd->max_items_per_block/2)
957 il = EINA_INLIST_GET(itb);
958 Item_Block *itbp = (Item_Block *)(il->prev);
959 Item_Block *itbn = (Item_Block *)(il->next);
960 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
962 Elm_Genlist_Item *it2;
964 EINA_LIST_FREE(itb->items, it2)
967 itbp->items = eina_list_append(itbp->items, it2);
969 itbp->changed = EINA_TRUE;
971 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
972 EINA_INLIST_GET(itb));
975 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
979 Eina_List *last = eina_list_last(itb->items);
980 Elm_Genlist_Item *it2 = last->data;
983 itb->items = eina_list_remove_list(itb->items, last);
984 itbn->items = eina_list_prepend(itbn->items, it2);
986 itbn->changed = EINA_TRUE;
989 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
997 _item_subitems_clear(Elm_Genlist_Item *it)
1000 Eina_List *tl = NULL, *l;
1001 Elm_Genlist_Item *it2;
1003 EINA_LIST_FOREACH(it->items, l, it2)
1004 tl = eina_list_append(tl, it2);
1006 EINA_LIST_FREE(tl, it2)
1007 elm_genlist_item_del(it2);
1011 _item_del(Elm_Genlist_Item *it)
1013 elm_widget_item_pre_notify_del(it);
1014 elm_genlist_item_subitems_clear(it);
1015 it->wd->walking -= it->walking;
1016 if (it->wd->show_item == it) it->wd->show_item = NULL;
1017 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1018 if (it->realized) _item_unrealize(it);
1019 if (it->effect_item_realized) _effect_item_unrealize(it);
1020 if (it->block) _item_block_del(it);
1021 if ((!it->delete_me) && (it->itc->func.del))
1022 it->itc->func.del((void *)it->base.data, it->base.widget);
1023 it->delete_me = EINA_TRUE;
1025 it->wd->queue = eina_list_remove(it->wd->queue, it);
1027 if (it->wd->anchor_item == it)
1029 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1030 if (!it->wd->anchor_item)
1031 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1034 if (it->flags != ELM_GENLIST_ITEM_HEAD)
1035 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1037 it->parent->items = eina_list_remove(it->parent->items, it);
1038 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1039 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1040 if (it->long_timer) ecore_timer_del(it->long_timer);
1041 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1043 if (it->tooltip.del_cb)
1044 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1045 if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL;
1047 elm_widget_item_del(it);
1048 it->wd->total_num--; // todo : remove
1052 _item_select(Elm_Genlist_Item *it)
1054 if ((it->wd->no_select) || (it->delete_me)) return;
1055 if (it == it->wd->select_all_item)
1057 if(it->wd->select_all_check)
1058 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE);
1060 _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE);
1065 if (it->wd->always_select) goto call;
1068 it->selected = EINA_TRUE;
1069 it->wd->selected = eina_list_append(it->wd->selected, it);
1073 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1075 evas_object_smart_callback_call(it->base.widget, "selected", it);
1078 if ((it->wd->clear_me) && (!it->wd->walking))
1080 elm_genlist_clear(it->base.widget);
1085 if ((!it->walking) && (it->delete_me))
1087 if (!it->relcount) _item_del(it);
1090 if (it && it->wd) it->wd->last_selected_item = it;
1094 _item_unselect(Elm_Genlist_Item *it)
1096 const char *stacking, *selectraise;
1098 if (it == it->wd->select_all_item) return;
1099 if ((it->delete_me) || (!it->hilighted)) return;
1101 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1102 stacking = edje_object_data_get(it->base.view, "stacking");
1103 selectraise = edje_object_data_get(it->base.view, "selectraise");
1104 if ((selectraise) && (!strcmp(selectraise, "on")))
1106 if ((stacking) && (!strcmp(stacking, "below")))
1107 evas_object_lower(it->base.view);
1109 it->hilighted = EINA_FALSE;
1112 it->selected = EINA_FALSE;
1113 it->wd->selected = eina_list_remove(it->wd->selected, it);
1114 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1119 _mouse_move(void *data,
1120 Evas *evas __UNUSED__,
1124 Elm_Genlist_Item *it = data;
1125 Evas_Event_Mouse_Move *ev = event_info;
1126 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1128 if (it->renamed) return;
1129 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1131 if (!it->wd->on_hold)
1133 it->wd->on_hold = EINA_TRUE;
1134 if (!it->wd->wasselected)
1138 if (it->wd->multitouched)
1140 it->wd->cur_x = ev->cur.canvas.x;
1141 it->wd->cur_y = ev->cur.canvas.y;
1144 if ((it->dragging) && (it->down))
1146 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1149 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1150 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1151 if (abs((it->wd->history[it->wd->movements].x -
1152 it->wd->history[0].x)) > 40)
1153 it->wd->swipe = EINA_TRUE;
1155 it->wd->movements++;
1159 ecore_timer_del(it->long_timer);
1160 it->long_timer = NULL;
1162 evas_object_smart_callback_call(it->base.widget, "drag", it);
1165 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1169 ecore_timer_del(it->long_timer);
1170 it->long_timer = NULL;
1172 if (it->wd->reorder_mode && it->wd->reorder_it)
1174 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1175 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1176 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1177 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1179 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1180 if (it->wd->head_item)
1181 sel_all_h = it->wd->head_item->h;
1182 if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1183 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);
1184 else _effect_item_controls(it, it->scrl_x, it_y);
1186 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1187 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1191 if (!it->display_only)
1192 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1193 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1194 x = ev->cur.canvas.x - x;
1195 y = ev->cur.canvas.y - y;
1198 if (adx < 0) adx = -dx;
1201 if (ady < 0) ady = -dy;
1204 if ((adx > minw) || (ady > minh))
1206 it->dragging = EINA_TRUE;
1209 ecore_timer_del(it->long_timer);
1210 it->long_timer = NULL;
1212 if (!it->wd->wasselected)
1217 evas_object_smart_callback_call(it->base.widget,
1218 "drag,start,up", it);
1223 evas_object_smart_callback_call(it->base.widget,
1224 "drag,start,left", it);
1225 _item_slide(it, EINA_FALSE);
1229 evas_object_smart_callback_call(it->base.widget,
1230 "drag,start,right", it);
1231 _item_slide(it, EINA_TRUE);
1238 evas_object_smart_callback_call(it->base.widget,
1239 "drag,start,down", it);
1244 evas_object_smart_callback_call(it->base.widget,
1245 "drag,start,left", it);
1246 _item_slide(it, EINA_FALSE);
1250 evas_object_smart_callback_call(it->base.widget,
1251 "drag,start,right", it);
1252 _item_slide(it, EINA_TRUE);
1260 _long_press(void *data)
1262 Elm_Genlist_Item *it = data;
1263 Elm_Genlist_Item *it_tmp;
1264 static Eina_Bool done = EINA_FALSE;
1265 //static Eina_Bool contracted = EINA_FALSE;
1269 it->long_timer = NULL;
1270 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1271 return ECORE_CALLBACK_CANCEL;
1272 it->wd->longpressed = EINA_TRUE;
1273 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1274 if ((it->wd->reorder_mode) && (it != it->wd->head_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1276 it->wd->reorder_it = it;
1277 it->wd->reorder_start_y = 0;
1278 evas_object_raise(it->edit_obj);
1279 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1280 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1282 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1287 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1289 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1291 _item_unselect(it_tmp);
1303 EINA_LIST_FOREACH(it->items, l, it_tmp)
1305 if (elm_genlist_item_expanded_get(it_tmp))
1307 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1308 return ECORE_CALLBACK_RENEW;
1312 if (elm_genlist_item_expanded_get(it)) {
1313 elm_genlist_item_expanded_set(it, EINA_FALSE);
1314 return ECORE_CALLBACK_RENEW;
1316 if (it->wd->edit_field && it->renamed)
1317 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1320 return ECORE_CALLBACK_CANCEL;
1324 _swipe(Elm_Genlist_Item *it)
1329 it->wd->swipe = EINA_FALSE;
1330 for (i = 0; i < it->wd->movements; i++)
1332 sum += it->wd->history[i].x;
1333 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1336 sum /= it->wd->movements;
1337 if (abs(sum - it->wd->history[0].x) <= 10) return;
1338 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1342 _swipe_cancel(void *data)
1344 Elm_Genlist_Item *it = data;
1346 if (!it) return ECORE_CALLBACK_CANCEL;
1347 it->wd->swipe = EINA_FALSE;
1348 it->wd->movements = 0;
1349 return ECORE_CALLBACK_RENEW;
1353 _multi_cancel(void *data)
1355 Widget_Data *wd = data;
1357 if (!wd) return ECORE_CALLBACK_CANCEL;
1358 wd->multi_timeout = EINA_TRUE;
1359 return ECORE_CALLBACK_RENEW;
1363 _multi_touch_gesture_eval(void *data)
1365 Elm_Genlist_Item *it = data;
1367 it->wd->multitouched = EINA_FALSE;
1368 if (it->wd->multi_timer)
1370 ecore_timer_del(it->wd->multi_timer);
1371 it->wd->multi_timer = NULL;
1373 if (it->wd->multi_timeout)
1375 it->wd->multi_timeout = EINA_FALSE;
1379 Evas_Coord minw = 0, minh = 0;
1380 Evas_Coord off_x, off_y, off_mx, off_my;
1382 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1383 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1384 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1385 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1386 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1388 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1390 if ((off_x + off_mx) > (off_y + off_my))
1392 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1393 evas_object_smart_callback_call(it->base.widget,
1394 "multi,swipe,right", it);
1395 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1396 evas_object_smart_callback_call(it->base.widget,
1397 "multi,swipe,left", it);
1398 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1399 evas_object_smart_callback_call(it->base.widget,
1400 "multi,pinch,out", it);
1402 evas_object_smart_callback_call(it->base.widget,
1403 "multi,pinch,in", it);
1407 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1408 evas_object_smart_callback_call(it->base.widget,
1409 "multi,swipe,down", it);
1410 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1411 evas_object_smart_callback_call(it->base.widget,
1412 "multi,swipe,up", it);
1413 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1414 evas_object_smart_callback_call(it->base.widget,
1415 "multi,pinch,out", it);
1417 evas_object_smart_callback_call(it->base.widget,
1418 "multi,pinch,in", it);
1421 it->wd->multi_timeout = EINA_FALSE;
1425 _multi_down(void *data,
1426 Evas *evas __UNUSED__,
1427 Evas_Object *obj __UNUSED__,
1430 Elm_Genlist_Item *it = data;
1431 Evas_Event_Multi_Down *ev = event_info;
1433 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1434 it->wd->multi_device = ev->device;
1435 it->wd->multi_down = EINA_TRUE;
1436 it->wd->multitouched = EINA_TRUE;
1437 it->wd->prev_mx = ev->canvas.x;
1438 it->wd->prev_my = ev->canvas.y;
1439 if (!it->wd->wasselected) _item_unselect(it);
1440 it->wd->wasselected = EINA_FALSE;
1441 it->wd->longpressed = EINA_FALSE;
1444 ecore_timer_del(it->long_timer);
1445 it->long_timer = NULL;
1449 it->dragging = EINA_FALSE;
1450 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1452 if (it->swipe_timer)
1454 ecore_timer_del(it->swipe_timer);
1455 it->swipe_timer = NULL;
1457 if (it->wd->on_hold)
1459 it->wd->swipe = EINA_FALSE;
1460 it->wd->movements = 0;
1461 it->wd->on_hold = EINA_FALSE;
1466 _multi_up(void *data,
1467 Evas *evas __UNUSED__,
1468 Evas_Object *obj __UNUSED__,
1471 Elm_Genlist_Item *it = data;
1472 Evas_Event_Multi_Up *ev = event_info;
1474 if (it->wd->multi_device != ev->device) return;
1475 it->wd->multi_device = 0;
1476 it->wd->multi_down = EINA_FALSE;
1477 if (it->wd->mouse_down) return;
1478 _multi_touch_gesture_eval(data);
1482 _multi_move(void *data,
1483 Evas *evas __UNUSED__,
1484 Evas_Object *obj __UNUSED__,
1487 Elm_Genlist_Item *it = data;
1488 Evas_Event_Multi_Move *ev = event_info;
1490 if (it->wd->multi_device != ev->device) return;
1491 it->wd->cur_mx = ev->cur.canvas.x;
1492 it->wd->cur_my = ev->cur.canvas.y;
1496 _mouse_down(void *data,
1497 Evas *evas __UNUSED__,
1501 Elm_Genlist_Item *it = data;
1502 Evas_Event_Mouse_Down *ev = event_info;
1505 if (it->renamed) return;
1506 if (ev->button != 1) return;
1507 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1509 it->wd->on_hold = EINA_TRUE;
1511 if (it->wd->rename_it) elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1512 it->down = EINA_TRUE;
1513 it->dragging = EINA_FALSE;
1514 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1515 it->dx = ev->canvas.x - x;
1516 it->dy = ev->canvas.y - y;
1517 it->wd->mouse_down = EINA_TRUE;
1518 if (!it->wd->multitouched)
1520 it->wd->prev_x = ev->canvas.x;
1521 it->wd->prev_y = ev->canvas.y;
1522 it->wd->multi_timeout = EINA_FALSE;
1523 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1524 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1526 it->wd->longpressed = EINA_FALSE;
1527 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1528 else it->wd->on_hold = EINA_FALSE;
1529 if (it->wd->on_hold) return;
1530 it->wd->wasselected = it->selected;
1532 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1533 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1534 if (it->long_timer) ecore_timer_del(it->long_timer);
1535 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1536 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1538 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1541 it->long_timer = NULL;
1542 it->wd->swipe = EINA_FALSE;
1543 it->wd->movements = 0;
1547 _mouse_up(void *data,
1548 Evas *evas __UNUSED__,
1549 Evas_Object *obj __UNUSED__,
1552 Elm_Genlist_Item *it = data;
1553 Evas_Event_Mouse_Up *ev = event_info;
1554 Eina_Bool dragged = EINA_FALSE;
1556 if (it->renamed) return;
1557 if (ev->button != 1) return;
1558 it->down = EINA_FALSE;
1559 it->wd->mouse_down = EINA_FALSE;
1560 if (it->wd->multitouched)
1562 if (it->wd->multi_down) return;
1563 _multi_touch_gesture_eval(data);
1566 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1567 else it->wd->on_hold = EINA_FALSE;
1570 ecore_timer_del(it->long_timer);
1571 it->long_timer = NULL;
1575 it->dragging = EINA_FALSE;
1576 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1579 if (it->swipe_timer)
1581 ecore_timer_del(it->swipe_timer);
1582 it->swipe_timer = NULL;
1584 if (it->wd->multi_timer)
1586 ecore_timer_del(it->wd->multi_timer);
1587 it->wd->multi_timer = NULL;
1588 it->wd->multi_timeout = EINA_FALSE;
1590 if (it->wd->on_hold)
1592 if (it->wd->swipe) _swipe(data);
1593 it->wd->longpressed = EINA_FALSE;
1594 it->wd->on_hold = EINA_FALSE;
1597 if (it->wd->reorder_mode)
1599 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1600 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1603 Evas_Coord ox,oy,oh,ow;
1604 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1605 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1606 if (it->wd->head_item) sel_all_h = it->wd->head_item->h;
1607 if (it->wd->reorder_rel)
1609 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1611 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1612 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1614 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1617 it->wd->reorder_deleted = EINA_FALSE;
1618 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1619 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1620 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1623 if (it->wd->longpressed)
1625 it->wd->longpressed = EINA_FALSE;
1626 if (!it->wd->wasselected)
1628 it->wd->wasselected = EINA_FALSE;
1633 if (it->want_unrealize)
1635 _item_unrealize(it);
1636 if (it->block->want_unrealize)
1637 _item_block_unrealize(it->block);
1640 if ((it->disabled) || (dragged) || (it->display_only)) return;
1641 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1644 if ((!it->selected) && (!it->sweeped))
1649 else _item_unselect(it);
1655 Widget_Data *wd = it->wd;
1658 while (wd->selected) _item_unselect(wd->selected->data);
1663 const Eina_List *l, *l_next;
1664 Elm_Genlist_Item *it2;
1666 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1667 if (it2 != it) _item_unselect(it2);
1668 //_item_hilight(it);
1680 _signal_expand_toggle(void *data,
1681 Evas_Object *obj __UNUSED__,
1682 const char *emission __UNUSED__,
1683 const char *source __UNUSED__)
1685 Elm_Genlist_Item *it = data;
1688 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1690 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1694 _signal_expand(void *data,
1695 Evas_Object *obj __UNUSED__,
1696 const char *emission __UNUSED__,
1697 const char *source __UNUSED__)
1699 Elm_Genlist_Item *it = data;
1702 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1706 _signal_contract(void *data,
1707 Evas_Object *obj __UNUSED__,
1708 const char *emission __UNUSED__,
1709 const char *source __UNUSED__)
1711 Elm_Genlist_Item *it = data;
1714 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1718 _item_cache_clean(Widget_Data *wd)
1720 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1724 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1725 wd->item_cache = eina_inlist_remove(wd->item_cache,
1726 wd->item_cache->last);
1727 wd->item_cache_count--;
1728 if (itc->spacer) evas_object_del(itc->spacer);
1729 if (itc->base_view) evas_object_del(itc->base_view);
1730 if (itc->item_style) eina_stringshare_del(itc->item_style);
1736 _item_cache_zero(Widget_Data *wd)
1738 int pmax = wd->item_cache_max;
1739 wd->item_cache_max = 0;
1740 _item_cache_clean(wd);
1741 wd->item_cache_max = pmax;
1745 _item_cache_add(Elm_Genlist_Item *it)
1749 if (it->wd->item_cache_max <= 0)
1751 evas_object_del(it->base.view);
1752 it->base.view = NULL;
1753 evas_object_del(it->spacer);
1758 it->wd->item_cache_count++;
1759 itc = calloc(1, sizeof(Item_Cache));
1761 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1762 EINA_INLIST_GET(itc));
1763 itc->spacer = it->spacer;
1765 itc->base_view = it->base.view;
1766 it->base.view = NULL;
1767 evas_object_hide(itc->base_view);
1768 evas_object_move(itc->base_view, -9999, -9999);
1769 itc->item_style = eina_stringshare_add(it->itc->item_style);
1770 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1771 itc->compress = (it->wd->compress);
1772 itc->odd = (it->order_num_in & 0x1);
1773 itc->selected = it->selected;
1774 itc->disabled = it->disabled;
1775 itc->expanded = it->expanded;
1778 ecore_timer_del(it->long_timer);
1779 it->long_timer = NULL;
1781 if (it->swipe_timer)
1783 ecore_timer_del(it->swipe_timer);
1784 it->swipe_timer = NULL;
1786 // FIXME: other callbacks?
1787 edje_object_signal_callback_del_full(itc->base_view,
1788 "elm,action,expand,toggle",
1789 "elm", _signal_expand_toggle, it);
1790 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1792 _signal_expand, it);
1793 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1794 "elm", _signal_contract, it);
1795 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1797 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1799 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1801 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1803 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1805 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1807 _item_cache_clean(it->wd);
1811 _item_cache_find(Elm_Genlist_Item *it)
1814 Eina_Bool tree = 0, odd;
1816 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1817 odd = (it->order_num_in & 0x1);
1818 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1820 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1822 if ((itc->tree == tree) &&
1823 (itc->odd == odd) &&
1824 (itc->compress == it->wd->compress) &&
1825 (!strcmp(it->itc->item_style, itc->item_style)))
1827 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1828 EINA_INLIST_GET(itc));
1829 it->wd->item_cache_count--;
1837 _item_cache_free(Item_Cache *itc)
1839 if (itc->spacer) evas_object_del(itc->spacer);
1840 if (itc->base_view) evas_object_del(itc->base_view);
1841 if (itc->item_style) eina_stringshare_del(itc->item_style);
1846 _item_realize(Elm_Genlist_Item *it,
1850 Elm_Genlist_Item *it2;
1851 const char *stacking;
1852 const char *treesize;
1854 int depth, tsize = 20;
1855 Item_Cache *itc = NULL;
1857 if ((it->realized) || (it->delete_me)) return;
1858 it->order_num_in = in;
1859 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1861 it->nocache = EINA_FALSE;
1863 itc = _item_cache_find(it);
1864 if ((!it->wd->effect_mode) && (itc))
1866 it->base.view = itc->base_view;
1867 itc->base_view = NULL;
1868 it->spacer = itc->spacer;
1873 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1874 edje_object_scale_set(it->base.view,
1875 elm_widget_scale_get(it->base.widget) *
1876 _elm_config->scale);
1877 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1878 elm_widget_sub_object_add(it->base.widget, it->base.view);
1880 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1881 strncpy(buf, "tree", sizeof(buf));
1882 else strncpy(buf, "item", sizeof(buf));
1883 if (it->wd->compress)
1884 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1886 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1887 strncat(buf, "/", sizeof(buf) - strlen(buf));
1888 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1890 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1891 elm_widget_style_get(it->base.widget));
1893 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1894 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1895 elm_widget_sub_object_add(it->base.widget, it->spacer);
1897 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1899 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1901 it->expanded_depth = depth;
1902 treesize = edje_object_data_get(it->base.view, "treesize");
1903 if (treesize) tsize = atoi(treesize);
1904 evas_object_size_hint_min_set(it->spacer,
1905 (depth * tsize) * _elm_config->scale, 1);
1906 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1909 edje_object_signal_callback_add(it->base.view,
1910 "elm,action,expand,toggle",
1911 "elm", _signal_expand_toggle, it);
1912 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1913 "elm", _signal_expand, it);
1914 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1915 "elm", _signal_contract, it);
1916 stacking = edje_object_data_get(it->base.view, "stacking");
1919 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1920 else if (!strcmp(stacking, "above"))
1921 evas_object_raise(it->base.view);
1923 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1925 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1927 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1929 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1931 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1933 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1937 if (it->selected != itc->selected)
1939 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1940 edje_object_signal_emit(it->base.view,
1941 "elm,state,selected", "elm");
1943 if (it->disabled != itc->disabled)
1946 edje_object_signal_emit(it->base.view,
1947 "elm,state,disabled", "elm");
1949 if (it->expanded != itc->expanded)
1952 edje_object_signal_emit(it->base.view,
1953 "elm,state,expanded", "elm");
1958 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1959 edje_object_signal_emit(it->base.view,
1960 "elm,state,selected", "elm");
1962 edje_object_signal_emit(it->base.view,
1963 "elm,state,disabled", "elm");
1965 edje_object_signal_emit(it->base.view,
1966 "elm,state,expanded", "elm");
1970 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1972 /* homogenous genlist shortcut */
1973 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1975 it->w = it->minw = it->wd->group_item_width;
1976 it->h = it->minh = it->wd->group_item_height;
1977 it->mincalcd = EINA_TRUE;
1979 else if (!it->mincalcd)
1981 it->w = it->minw = it->wd->item_width;
1982 it->h = it->minh = it->wd->item_height;
1983 it->mincalcd = EINA_TRUE;
1988 if (it->itc->func.label_get)
1994 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1996 EINA_LIST_FOREACH(it->labels, l, key)
1998 char *s = it->itc->func.label_get
1999 ((void *)it->base.data, it->base.widget, l->data);
2003 edje_object_part_text_set(it->base.view, l->data, s);
2007 edje_object_part_text_set(it->base.view, l->data, "");
2010 if (it->itc->func.icon_get)
2016 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2018 EINA_LIST_FOREACH(it->icons, l, key)
2020 Evas_Object *ic = it->itc->func.icon_get
2021 ((void *)it->base.data, it->base.widget, l->data);
2025 it->icon_objs = eina_list_append(it->icon_objs, ic);
2026 edje_object_part_swallow(it->base.view, key, ic);
2027 evas_object_show(ic);
2028 elm_widget_sub_object_add(it->base.widget, ic);
2029 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2032 if (it->wd->rename_it && it->renamed)
2035 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2036 EINA_LIST_FOREACH(it->icons, l, key)
2038 Evas_Object *ic = it->itc->func.icon_get
2039 ((void *)it->base.data, it->base.widget, l->data);
2042 it->icon_objs = eina_list_append(it->icon_objs, ic);
2043 edje_object_part_swallow(it->base.view, key, ic);
2044 evas_object_show(ic);
2045 elm_widget_sub_object_add(it->base.widget, ic);
2050 if (it->itc->func.state_get)
2056 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2058 EINA_LIST_FOREACH(it->states, l, key)
2060 Eina_Bool on = it->itc->func.state_get
2061 ((void *)it->base.data, it->base.widget, l->data);
2065 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2066 edje_object_signal_emit(it->base.view, buf, "elm");
2070 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2071 edje_object_signal_emit(it->base.view, buf, "elm");
2076 _create_sweep_objs(it);
2079 Evas_Coord mw = -1, mh = -1;
2081 if (it->wd->height_for_width) mw = it->wd->w;
2083 if (!it->display_only)
2084 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2085 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2086 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2088 if (!it->display_only)
2089 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2090 it->w = it->minw = mw;
2091 it->h = it->minh = mh;
2092 it->mincalcd = EINA_TRUE;
2094 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2096 it->wd->group_item_width = mw;
2097 it->wd->group_item_height = mh;
2099 else if ((it->wd->homogeneous))
2100 // if ((!in) && (it->wd->homogeneous))
2102 it->wd->item_width = mw;
2103 it->wd->item_height = mh;
2105 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2107 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2109 it->wd->group_item_width = mw;
2110 it->wd->group_item_height = mh;
2114 if (!calc) evas_object_show(it->base.view);
2117 if (it->tooltip.content_cb)
2119 elm_widget_item_tooltip_content_cb_set(it,
2120 it->tooltip.content_cb,
2121 it->tooltip.data, NULL);
2122 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2125 if (it->mouse_cursor)
2126 elm_widget_item_cursor_set(it, it->mouse_cursor);
2128 it->realized = EINA_TRUE;
2129 it->want_unrealize = EINA_FALSE;
2131 if (itc) _item_cache_free(itc);
2132 evas_object_smart_callback_call(it->base.widget, "realized", it);
2133 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->flags != ELM_GENLIST_ITEM_HEAD))
2135 if (it->itc->edit_item_style )
2137 _effect_item_realize(it, EINA_FALSE);
2138 edje_object_message_signal_process(it->edit_obj);
2143 _item_unrealize(Elm_Genlist_Item *it)
2147 if (!it->realized) return;
2148 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2149 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2152 ecore_timer_del(it->long_timer);
2153 it->long_timer = NULL;
2155 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2157 it->sweeped = EINA_FALSE;
2158 it->wassweeped = EINA_FALSE;
2159 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2160 _delete_sweep_objs(it);
2161 evas_object_del(it->base.view);
2162 it->base.view = NULL;
2163 evas_object_del(it->spacer);
2167 _item_cache_add(it);
2168 elm_widget_stringlist_free(it->labels);
2170 elm_widget_stringlist_free(it->icons);
2172 elm_widget_stringlist_free(it->states);
2174 EINA_LIST_FREE(it->icon_objs, icon)
2175 evas_object_del(icon);
2178 it->realized = EINA_FALSE;
2179 it->want_unrealize = EINA_FALSE;
2180 if (it->wd->edit_field && it->renamed)
2181 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
2182 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2186 _item_block_recalc(Item_Block *itb,
2192 Elm_Genlist_Item *it;
2193 Evas_Coord minw = 0, minh = 0;
2194 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2198 EINA_LIST_FOREACH(itb->items, l, it)
2200 if (it->delete_me) continue;
2201 showme |= it->showme;
2206 if (!it->mincalcd) changed = EINA_TRUE;
2209 _item_realize(it, in, 1);
2210 _item_unrealize(it);
2215 _item_realize(it, in, 1);
2216 if (!it->wd->contracting) _item_unrealize(it);
2220 _item_realize(it, in, 0);
2222 if (minw < it->minw) minw = it->minw;
2230 itb->changed = EINA_FALSE;
2231 /* force an evas norender to garbage collect deleted objects */
2232 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2237 _item_block_realize(Item_Block *itb,
2242 Elm_Genlist_Item *it;
2244 if (itb->realized) return;
2245 EINA_LIST_FOREACH(itb->items, l, it)
2247 if (it->delete_me) continue;
2248 if (full) _item_realize(it, in, 0);
2251 itb->realized = EINA_TRUE;
2252 itb->want_unrealize = EINA_FALSE;
2256 _item_block_unrealize(Item_Block *itb)
2259 Elm_Genlist_Item *it;
2260 Eina_Bool dragging = EINA_FALSE;
2262 if (!itb->realized) return;
2263 EINA_LIST_FOREACH(itb->items, l, it)
2265 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2269 dragging = EINA_TRUE;
2270 it->want_unrealize = EINA_TRUE;
2273 if (!it->wd->contracting) _item_unrealize(it);
2278 itb->realized = EINA_FALSE;
2279 itb->want_unrealize = EINA_TRUE;
2282 itb->want_unrealize = EINA_FALSE;
2286 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2288 Evas_Coord rox, roy, row, roh;
2289 Eina_Bool top = EINA_FALSE;
2290 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2291 if (!reorder_it) return 0;
2293 Evas_Coord ox,oy,oh,ow;
2294 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2295 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2297 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2299 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2300 if (it->block->count == 1)
2301 it->wd->reorder_rel = it;
2303 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2305 it->block->reorder_offset = it->wd->reorder_it->h;
2308 it->block->reorder_offset = 0;
2310 it->scrl_y += it->block->reorder_offset;
2312 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2313 rox, roy+roh/2, row, 1));
2316 it->wd->reorder_rel = it;
2317 it->scrl_y+=it->wd->reorder_it->h;
2318 return it->wd->reorder_it->h;
2325 _reorder_item_moving_effect_timer_cb(void *data)
2327 Elm_Genlist_Item *it = data;
2328 Eina_Bool down = EINA_FALSE;
2329 double time = 0.4, t;
2331 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2334 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2338 if (it->old_scrl_y < it->scrl_y)
2340 it->old_scrl_y += y;
2343 else if (it->old_scrl_y > it->scrl_y)
2345 it->old_scrl_y -= y;
2349 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2351 _group_items_recalc(it->wd);
2352 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2354 it->old_scrl_y = it->scrl_y;
2355 it->move_effect_me = EINA_FALSE;
2356 it->wd->item_moving_effect_timer = NULL;
2357 return ECORE_CALLBACK_CANCEL;
2359 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2361 it->old_scrl_y = it->scrl_y;
2362 it->move_effect_me = EINA_FALSE;
2363 it->wd->item_moving_effect_timer = NULL;
2364 return ECORE_CALLBACK_CANCEL;
2366 return ECORE_CALLBACK_RENEW;
2370 _item_block_position(Item_Block *itb,
2374 Elm_Genlist_Item *it;
2375 Elm_Genlist_Item *git;
2376 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2379 Elm_Genlist_Item *head_item = itb->wd->head_item;
2381 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2382 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2387 if (!head_item->realized)
2389 _item_realize(head_item, 0, 0);
2390 itb->wd->minh += itb->wd->head_item->h;
2392 evas_object_resize(head_item->base.view, itb->w, head_item->h);
2393 evas_object_move(head_item->base.view, ox, oy);
2394 evas_object_raise(head_item->base.view);
2397 sel_all_h = head_item->h;
2399 EINA_LIST_FOREACH(itb->items, l, it)
2401 if (it->delete_me) continue;
2402 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2407 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2408 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2410 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2411 cvx, cvy, cvw, cvh));
2412 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2414 if ((itb->realized) && (!it->realized))
2418 _item_realize(it, in, 0);
2421 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2422 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2430 if(it->wd->reorder_mode)
2431 y += _get_space_for_reorder_item(it);
2432 git = it->group_item;
2435 git->scrl_x = it->scrl_x;
2436 if (git->scrl_y < oy + sel_all_h)
2437 git->scrl_y = oy + sel_all_h;
2438 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2439 git->scrl_y = (it->scrl_y + it->h) - git->h;
2440 git->want_realize = EINA_TRUE;
2442 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2444 if (!it->move_effect_me)
2446 it->move_effect_me = EINA_TRUE;
2447 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2451 if (!it->move_effect_me )
2452 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))
2454 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2456 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2460 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2461 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2462 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)))
2463 evas_object_show(it->base.view);
2465 evas_object_hide(it->base.view);
2467 it->old_scrl_x = it->scrl_x;
2468 it->old_scrl_y = it->scrl_y;
2473 if (!it->dragging) _item_unrealize(it);
2480 if (vis) it->want_realize = EINA_TRUE;
2487 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2489 Elm_Genlist_Item *it = data;
2491 it->mincalcd = EINA_FALSE;
2492 it->block->updateme = EINA_TRUE;
2493 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2494 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2498 _group_items_recalc(void *data)
2500 Widget_Data *wd = data;
2502 Elm_Genlist_Item *git;
2504 EINA_LIST_FOREACH(wd->group_items, l, git)
2506 if (git->want_realize)
2509 _item_realize(git, 0, 0);
2510 evas_object_resize(git->base.view, wd->minw, git->h);
2511 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2512 evas_object_show(git->base.view);
2513 evas_object_raise(git->base.view);
2515 else if (!git->want_realize && git->realized)
2518 _item_unrealize(git);
2524 _must_recalc_idler(void *data)
2526 Widget_Data *wd = data;
2527 if (wd->calc_job) ecore_job_del(wd->calc_job);
2528 wd->calc_job = ecore_job_add(_calc_job, wd);
2529 wd->must_recalc_idler = NULL;
2530 return ECORE_CALLBACK_CANCEL;
2534 _calc_job(void *data)
2536 Widget_Data *wd = data;
2538 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2539 Item_Block *chb = NULL;
2540 int in = 0, minw_change = 0;
2541 Eina_Bool changed = EINA_FALSE;
2543 Eina_Bool did_must_recalc = EINA_FALSE;
2546 t0 = ecore_time_get();
2547 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2551 // if (wd->height_for_width) changed = EINA_TRUE;
2554 EINA_INLIST_FOREACH(wd->blocks, itb)
2556 Eina_Bool showme = EINA_FALSE;
2559 showme = itb->showme;
2560 itb->showme = EINA_FALSE;
2563 if (itb->realized) _item_block_unrealize(itb);
2565 if ((itb->changed) || (changed) ||
2566 ((itb->must_recalc) && (!did_must_recalc)))
2568 if ((changed) || (itb->must_recalc))
2571 Elm_Genlist_Item *it;
2572 EINA_LIST_FOREACH(itb->items, l, it)
2573 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2574 itb->changed = EINA_TRUE;
2575 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2576 itb->must_recalc = EINA_FALSE;
2578 if (itb->realized) _item_block_unrealize(itb);
2579 showme = _item_block_recalc(itb, in, 0, 1);
2585 if (minw == -1) minw = itb->minw;
2586 else if ((!itb->must_recalc) && (minw < itb->minw))
2595 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2597 wd->show_item->showme = EINA_FALSE;
2599 elm_smart_scroller_region_bring_in(wd->scr,
2601 wd->show_item->block->x,
2603 wd->show_item->block->y,
2604 wd->show_item->block->w,
2607 elm_smart_scroller_child_region_show(wd->scr,
2609 wd->show_item->block->x,
2611 wd->show_item->block->y,
2612 wd->show_item->block->w,
2614 wd->show_item = NULL;
2619 EINA_INLIST_FOREACH(wd->blocks, itb)
2625 if ((chb) && (EINA_INLIST_GET(chb)->next))
2627 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2629 if (itb->realized) _item_block_unrealize(itb);
2632 wd->realminw = minw;
2633 if (minw < wd->w) minw = wd->w;
2634 if ((minw != wd->minw) || (minh != wd->minh) || (wd->head_item))
2638 if (wd->head_item) wd->minh += wd->head_item->h;
2639 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2640 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2641 _sizing_eval(wd->obj);
2643 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2645 Elm_Genlist_Item *it;
2648 it = wd->anchor_item;
2649 it_y = wd->anchor_y;
2650 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2651 it->block->y + it->y + it_y);
2652 wd->anchor_item = it;
2653 wd->anchor_y = it_y;
2657 t = ecore_time_get();
2658 if (did_must_recalc)
2660 if (!wd->must_recalc_idler)
2661 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2663 wd->calc_job = NULL;
2664 evas_object_smart_changed(wd->pan_smart);
2668 _update_job(void *data)
2670 Widget_Data *wd = data;
2673 int num, num0, position = 0, recalc = 0;
2675 wd->update_job = NULL;
2679 _item_unrealize(wd->head_item);
2680 _item_realize(wd->head_item, 0, 0);
2681 position = EINA_TRUE;
2683 EINA_INLIST_FOREACH(wd->blocks, itb)
2685 Evas_Coord itminw, itminh;
2686 Elm_Genlist_Item *it;
2692 _item_block_position(itb, num);
2697 EINA_LIST_FOREACH(itb->items, l2, it)
2704 it->updateme = EINA_FALSE;
2707 _item_unrealize(it);
2708 _item_realize(it, num, 0);
2713 _item_realize(it, num, 1);
2714 _item_unrealize(it);
2716 if ((it->minw != itminw) || (it->minh != itminh))
2721 itb->updateme = EINA_FALSE;
2725 itb->changed = EINA_TRUE;
2726 _item_block_recalc(itb, num0, 0, 1);
2727 _item_block_position(itb, num0);
2732 if (wd->calc_job) ecore_job_del(wd->calc_job);
2733 wd->calc_job = ecore_job_add(_calc_job, wd);
2738 _changed_job(void *data)
2740 Widget_Data *wd = data; Eina_List *l2;
2742 int num, num0, position = 0, recalc = 0;
2744 wd->changed_job = NULL;
2746 EINA_INLIST_FOREACH(wd->blocks, itb)
2748 Evas_Coord itminw, itminh;
2749 Elm_Genlist_Item *it;
2755 _item_block_position(itb, num);
2760 EINA_LIST_FOREACH(itb->items, l2, it)
2764 Evas_Coord mw = -1, mh = -1;
2768 if (it->wd->height_for_width) mw = it->wd->w;
2769 if (!it->display_only)
2770 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2771 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2772 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2773 if (!it->display_only)
2774 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2775 it->w = it->minw = mw;
2776 it->h = it->minh = mh;
2777 it->mincalcd = EINA_TRUE;
2779 //if ((it->minw != itminw) || (it->minh != itminh))
2780 if ((it->minh != itminh))
2785 itb->updateme = EINA_FALSE;
2789 itb->changed = EINA_TRUE;
2790 _item_block_recalc(itb, num0, 0, 1);
2791 _item_block_position(itb, num0);
2796 if (wd->calc_job) ecore_job_del(wd->calc_job);
2797 wd->calc_job = ecore_job_add(_calc_job, wd);
2802 _pan_set(Evas_Object *obj,
2806 Pan *sd = evas_object_smart_data_get(obj);
2809 // Evas_Coord ow, oh;
2810 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2811 // ow = sd->wd->minw - ow;
2812 // if (ow < 0) ow = 0;
2813 // oh = sd->wd->minh - oh;
2814 // if (oh < 0) oh = 0;
2815 // if (x < 0) x = 0;
2816 // if (y < 0) y = 0;
2817 // if (x > ow) x = ow;
2818 // if (y > oh) y = oh;
2819 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2824 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2826 if ((itb->y + itb->h) > y)
2828 Elm_Genlist_Item *it;
2831 EINA_LIST_FOREACH(itb->items, l2, it)
2833 if ((itb->y + it->y) >= y)
2835 sd->wd->anchor_item = it;
2836 sd->wd->anchor_y = -(itb->y + it->y - y);
2844 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2848 _pan_get(Evas_Object *obj,
2852 Pan *sd = evas_object_smart_data_get(obj);
2854 if (x) *x = sd->wd->pan_x;
2855 if (y) *y = sd->wd->pan_y;
2859 _pan_max_get(Evas_Object *obj,
2863 Pan *sd = evas_object_smart_data_get(obj);
2866 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2867 ow = sd->wd->minw - ow;
2869 oh = sd->wd->minh - oh;
2876 _pan_min_get(Evas_Object *obj __UNUSED__,
2885 _pan_child_size_get(Evas_Object *obj,
2889 Pan *sd = evas_object_smart_data_get(obj);
2891 if (w) *w = sd->wd->minw;
2892 if (h) *h = sd->wd->minh;
2896 _pan_add(Evas_Object *obj)
2899 Evas_Object_Smart_Clipped_Data *cd;
2902 cd = evas_object_smart_data_get(obj);
2905 sd->__clipped_data = *cd;
2907 evas_object_smart_data_set(obj, sd);
2911 _pan_del(Evas_Object *obj)
2913 Pan *sd = evas_object_smart_data_get(obj);
2918 ecore_job_del(sd->resize_job);
2919 sd->resize_job = NULL;
2925 _pan_resize_job(void *data)
2928 _sizing_eval(sd->wd->obj);
2929 sd->resize_job = NULL;
2933 _pan_resize(Evas_Object *obj,
2937 Pan *sd = evas_object_smart_data_get(obj);
2940 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2941 if ((ow == w) && (oh == h)) return;
2942 if ((sd->wd->height_for_width) && (ow != w))
2944 if (sd->resize_job) ecore_job_del(sd->resize_job);
2945 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2947 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2948 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2952 _pan_calculate(Evas_Object *obj)
2954 Pan *sd = evas_object_smart_data_get(obj);
2956 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2957 static Evas_Coord old_pan_y = 0;
2959 Elm_Genlist_Item *git;
2962 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2963 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2964 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2966 git->want_realize = EINA_FALSE;
2968 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2970 itb->w = sd->wd->minw;
2971 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2972 itb->y - sd->wd->pan_y + oy,
2974 cvx, cvy, cvw, cvh))
2976 if ((!itb->realized) || (itb->changed))
2977 _item_block_realize(itb, in, 0);
2978 _item_block_position(itb, in);
2982 if (itb->realized) _item_block_unrealize(itb);
2986 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2987 _group_items_recalc(sd->wd);
2989 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2991 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2992 else sd->wd->reorder_pan_move = EINA_FALSE;
2993 evas_object_raise(sd->wd->reorder_it->edit_obj);
2994 old_pan_y = sd->wd->pan_y;
2997 if (sd->wd->effect_mode &&
2998 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2999 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3000 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3002 if (!sd->wd->item_moving_effect_timer)
3004 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3005 _item_flip_effect_show(sd->wd->expand_item);
3007 evas_object_raise(sd->wd->alpha_bg);
3008 evas_object_show(sd->wd->alpha_bg);
3009 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3010 sd->wd->start_time = current_time_get();
3011 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3014 else _item_auto_scroll(sd->wd);
3015 if (sd->wd->head_item) evas_object_raise(sd->wd->head_item->base.view);
3016 sd->wd->contracting = EINA_FALSE;
3020 _pan_move(Evas_Object *obj,
3021 Evas_Coord x __UNUSED__,
3022 Evas_Coord y __UNUSED__)
3024 Pan *sd = evas_object_smart_data_get(obj);
3026 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3027 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3031 _hold_on(void *data __UNUSED__,
3033 void *event_info __UNUSED__)
3035 Widget_Data *wd = elm_widget_data_get(obj);
3037 elm_smart_scroller_hold_set(wd->scr, 1);
3041 _hold_off(void *data __UNUSED__,
3043 void *event_info __UNUSED__)
3045 Widget_Data *wd = elm_widget_data_get(obj);
3047 elm_smart_scroller_hold_set(wd->scr, 0);
3051 _freeze_on(void *data __UNUSED__,
3053 void *event_info __UNUSED__)
3055 Widget_Data *wd = elm_widget_data_get(obj);
3057 elm_smart_scroller_freeze_set(wd->scr, 1);
3061 _freeze_off(void *data __UNUSED__,
3063 void *event_info __UNUSED__)
3065 Widget_Data *wd = elm_widget_data_get(obj);
3067 elm_smart_scroller_freeze_set(wd->scr, 0);
3071 _scroll_edge_left(void *data,
3072 Evas_Object *scr __UNUSED__,
3073 void *event_info __UNUSED__)
3075 Evas_Object *obj = data;
3076 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3080 _scroll_edge_right(void *data,
3081 Evas_Object *scr __UNUSED__,
3082 void *event_info __UNUSED__)
3084 Evas_Object *obj = data;
3085 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3089 _scroll_edge_top(void *data,
3090 Evas_Object *scr __UNUSED__,
3091 void *event_info __UNUSED__)
3093 Evas_Object *obj = data;
3094 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3098 _scroll_edge_bottom(void *data,
3099 Evas_Object *scr __UNUSED__,
3100 void *event_info __UNUSED__)
3102 Evas_Object *obj = data;
3103 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3107 * Add a new Genlist object
3109 * @param parent The parent object
3110 * @return The new object or NULL if it cannot be created
3115 elm_genlist_add(Evas_Object *parent)
3120 Evas_Coord minw, minh;
3121 static Evas_Smart *smart = NULL;
3123 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3127 static Evas_Smart_Class sc;
3129 evas_object_smart_clipped_smart_set(&_pan_sc);
3131 sc.name = "elm_genlist_pan";
3132 sc.version = EVAS_SMART_CLASS_VERSION;
3135 sc.resize = _pan_resize;
3136 sc.move = _pan_move;
3137 sc.calculate = _pan_calculate;
3138 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3140 wd = ELM_NEW(Widget_Data);
3141 e = evas_object_evas_get(parent);
3142 if (!e) return NULL;
3143 obj = elm_widget_add(e);
3144 ELM_SET_WIDTYPE(widtype, "genlist");
3145 elm_widget_type_set(obj, "genlist");
3146 elm_widget_sub_object_add(parent, obj);
3147 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3148 elm_widget_data_set(obj, wd);
3149 elm_widget_del_hook_set(obj, _del_hook);
3150 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3151 elm_widget_theme_hook_set(obj, _theme_hook);
3152 elm_widget_can_focus_set(obj, EINA_TRUE);
3153 elm_widget_event_hook_set(obj, _event_hook);
3154 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3156 wd->scr = elm_smart_scroller_add(e);
3157 elm_smart_scroller_widget_set(wd->scr, obj);
3158 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3159 elm_widget_style_get(obj));
3160 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3161 _elm_config->thumbscroll_bounce_enable);
3162 elm_widget_resize_object_set(obj, wd->scr);
3164 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3165 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3167 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3168 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3172 wd->mode = ELM_LIST_SCROLL;
3173 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3174 wd->item_cache_max = wd->max_items_per_block * 2;
3175 wd->longpress_timeout = _elm_config->longpress_timeout;
3176 //wd->effect_mode = _elm_config->effect_enable;
3177 // wd->effect_mode = EINA_TRUE;
3179 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3180 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3181 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3182 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3184 wd->pan_smart = evas_object_smart_add(e, smart);
3185 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3188 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3189 _pan_set, _pan_get, _pan_max_get,
3190 _pan_min_get, _pan_child_size_get);
3192 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3194 evas_object_size_hint_min_set(obj, minw, minh);
3200 static Elm_Genlist_Item *
3201 _item_new(Widget_Data *wd,
3202 const Elm_Genlist_Item_Class *itc,
3204 Elm_Genlist_Item *parent,
3205 Elm_Genlist_Item_Flags flags,
3207 const void *func_data)
3209 Elm_Genlist_Item *it;
3211 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3212 if (!it) return NULL;
3215 it->base.data = data;
3216 it->parent = parent;
3218 it->func.func = func;
3219 it->func.data = func_data;
3220 it->mouse_cursor = NULL;
3221 it->expanded_depth = 0;
3222 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3223 if ((!it->parent) && (it->wd->select_all_item))
3224 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE);
3225 it->num = ++wd->total_num; // todo : remov
3230 _item_block_add(Widget_Data *wd,
3231 Elm_Genlist_Item *it)
3233 Item_Block *itb = NULL;
3240 itb = calloc(1, sizeof(Item_Block));
3243 if (!it->rel->block)
3246 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3247 itb->items = eina_list_append(itb->items, it);
3253 wd->blocks = eina_inlist_prepend_relative
3254 (wd->blocks, EINA_INLIST_GET(itb),
3255 EINA_INLIST_GET(it->rel->block));
3257 eina_list_prepend_relative(itb->items, it, it->rel);
3261 wd->blocks = eina_inlist_append_relative
3262 (wd->blocks, EINA_INLIST_GET(itb),
3263 EINA_INLIST_GET(it->rel->block));
3265 eina_list_append_relative(itb->items, it, it->rel);
3275 itb = (Item_Block *)(wd->blocks);
3276 if (itb->count >= wd->max_items_per_block)
3278 itb = calloc(1, sizeof(Item_Block));
3282 eina_inlist_prepend(wd->blocks,
3283 EINA_INLIST_GET(itb));
3288 itb = calloc(1, sizeof(Item_Block));
3292 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3294 itb->items = eina_list_prepend(itb->items, it);
3300 itb = (Item_Block *)(wd->blocks->last);
3301 if (itb->count >= wd->max_items_per_block)
3303 itb = calloc(1, sizeof(Item_Block));
3307 eina_inlist_append(wd->blocks,
3308 EINA_INLIST_GET(itb));
3313 itb = calloc(1, sizeof(Item_Block));
3317 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3319 itb->items = eina_list_append(itb->items, it);
3325 itb = it->rel->block;
3326 if (!itb) goto newblock;
3328 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3330 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3333 itb->changed = EINA_TRUE;
3335 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3336 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3339 it->rel->relcount--;
3340 if ((it->rel->delete_me) && (!it->rel->relcount))
3344 if (itb->count > itb->wd->max_items_per_block)
3348 Elm_Genlist_Item *it2;
3350 newc = itb->count / 2;
3351 itb2 = calloc(1, sizeof(Item_Block));
3355 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3356 EINA_INLIST_GET(itb));
3357 itb2->changed = EINA_TRUE;
3358 while ((itb->count > newc) && (itb->items))
3362 l = eina_list_last(itb->items);
3364 itb->items = eina_list_remove_list(itb->items, l);
3367 itb2->items = eina_list_prepend(itb2->items, it2);
3375 _queue_proecess(Widget_Data *wd,
3379 Eina_Bool showme = EINA_FALSE;
3382 t0 = ecore_time_get();
3383 for (n = 0; (wd->queue) && (n < 128); n++)
3385 Elm_Genlist_Item *it;
3387 it = wd->queue->data;
3388 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3389 it->queued = EINA_FALSE;
3390 _item_block_add(wd, it);
3391 t = ecore_time_get();
3392 if (it->block->changed)
3394 showme = _item_block_recalc(it->block, it->block->num, 1,
3396 it->block->changed = 0;
3398 if (showme) it->block->showme = EINA_TRUE;
3399 if (eina_inlist_count(wd->blocks) > 1)
3401 if ((t - t0) > (ecore_animator_frametime_get())) break;
3408 _item_idler(void *data)
3410 Widget_Data *wd = data;
3413 //static double q_start = 0.0;
3414 //if (q_start == 0.0) q_start = ecore_time_get();
3417 if (_queue_proecess(wd, 1) > 0)
3419 if (wd->calc_job) ecore_job_del(wd->calc_job);
3420 wd->calc_job = ecore_job_add(_calc_job, wd);
3425 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3427 wd->queue_idler = NULL;
3428 return ECORE_CALLBACK_CANCEL;
3430 return ECORE_CALLBACK_RENEW;
3434 _item_queue(Widget_Data *wd,
3435 Elm_Genlist_Item *it)
3437 if (it->queued) return;
3438 it->queued = EINA_TRUE;
3439 wd->queue = eina_list_append(wd->queue, it);
3440 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3442 if (wd->queue_idler)
3444 ecore_idler_del(wd->queue_idler);
3445 wd->queue_idler = NULL;
3447 _queue_proecess(wd, 0);
3449 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3453 * Append item to the end of the genlist
3455 * This appends the given item to the end of the list or the end of
3456 * the children if the parent is given.
3458 * @param obj The genlist object
3459 * @param itc The item class for the item
3460 * @param data The item data
3461 * @param parent The parent item, or NULL if none
3462 * @param flags Item flags
3463 * @param func Convenience function called when item selected
3464 * @param func_data Data passed to @p func above.
3465 * @return A handle to the item added or NULL if not possible
3469 EAPI Elm_Genlist_Item *
3470 elm_genlist_item_append(Evas_Object *obj,
3471 const Elm_Genlist_Item_Class *itc,
3473 Elm_Genlist_Item *parent,
3474 Elm_Genlist_Item_Flags flags,
3476 const void *func_data)
3478 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3479 Widget_Data *wd = elm_widget_data_get(obj);
3480 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3482 if (!wd) return NULL;
3483 if (!it) return NULL;
3486 if (flags & ELM_GENLIST_ITEM_HEAD) wd->head_item = it;
3489 if (flags & ELM_GENLIST_ITEM_GROUP)
3490 wd->group_items = eina_list_append(wd->group_items, it);
3491 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3497 Elm_Genlist_Item *it2 = NULL;
3498 Eina_List *ll = eina_list_last(it->parent->items);
3499 if (ll) it2 = ll->data;
3500 it->parent->items = eina_list_append(it->parent->items, it);
3501 if (!it2) it2 = it->parent;
3503 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3504 EINA_INLIST_GET(it2));
3506 it->rel->relcount++;
3508 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3509 it->group_item = parent;
3510 else if (it->parent->group_item)
3511 it->group_item = it->parent->group_item;
3513 it->before = EINA_FALSE;
3514 if (flags != ELM_GENLIST_ITEM_HEAD) _item_queue(wd, it);
3520 * Prepend item at start of the genlist
3522 * This adds an item to the beginning of the list or beginning of the
3523 * children of the parent if given.
3525 * @param obj The genlist object
3526 * @param itc The item class for the item
3527 * @param data The item data
3528 * @param parent The parent item, or NULL if none
3529 * @param flags Item flags
3530 * @param func Convenience function called when item selected
3531 * @param func_data Data passed to @p func above.
3532 * @return A handle to the item added or NULL if not possible
3536 EAPI Elm_Genlist_Item *
3537 elm_genlist_item_prepend(Evas_Object *obj,
3538 const Elm_Genlist_Item_Class *itc,
3540 Elm_Genlist_Item *parent,
3541 Elm_Genlist_Item_Flags flags,
3543 const void *func_data)
3545 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3546 Widget_Data *wd = elm_widget_data_get(obj);
3547 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3549 if (!wd) return NULL;
3550 if (!it) return NULL;
3553 if (flags & ELM_GENLIST_ITEM_GROUP)
3554 wd->group_items = eina_list_prepend(wd->group_items, it);
3555 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3560 Elm_Genlist_Item *it2 = NULL;
3561 Eina_List *ll = it->parent->items;
3562 if (ll) it2 = ll->data;
3563 it->parent->items = eina_list_prepend(it->parent->items, it);
3564 if (!it2) it2 = it->parent;
3566 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3567 EINA_INLIST_GET(it2));
3569 it->rel->relcount++;
3571 it->before = EINA_TRUE;
3572 _item_queue(wd, it);
3577 * Insert item before another in the genlist
3579 * This inserts an item before another in the list. It will be in the
3580 * same tree level or group as the item it is inseted before.
3582 * @param obj The genlist object
3583 * @param itc The item class for the item
3584 * @param data The item data
3585 * @param before The item to insert before
3586 * @param flags Item flags
3587 * @param func Convenience function called when item selected
3588 * @param func_data Data passed to @p func above.
3589 * @return A handle to the item added or NULL if not possible
3593 EAPI Elm_Genlist_Item *
3594 elm_genlist_item_insert_before(Evas_Object *obj,
3595 const Elm_Genlist_Item_Class *itc,
3597 Elm_Genlist_Item *parent,
3598 Elm_Genlist_Item *before,
3599 Elm_Genlist_Item_Flags flags,
3601 const void *func_data)
3603 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3604 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3605 Widget_Data *wd = elm_widget_data_get(obj);
3606 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3608 if (!wd) return NULL;
3609 if (!it) return NULL;
3612 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3615 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3616 EINA_INLIST_GET(before));
3618 it->rel->relcount++;
3619 it->before = EINA_TRUE;
3620 _item_queue(wd, it);
3625 * Insert an item after another in the genlst
3627 * This inserts an item after another in the list. It will be in the
3628 * same tree level or group as the item it is inseted after.
3630 * @param obj The genlist object
3631 * @param itc The item class for the item
3632 * @param data The item data
3633 * @param after The item to insert after
3634 * @param flags Item flags
3635 * @param func Convenience function called when item selected
3636 * @param func_data Data passed to @p func above.
3637 * @return A handle to the item added or NULL if not possible
3641 EAPI Elm_Genlist_Item *
3642 elm_genlist_item_insert_after(Evas_Object *obj,
3643 const Elm_Genlist_Item_Class *itc,
3645 Elm_Genlist_Item *parent,
3646 Elm_Genlist_Item *after,
3647 Elm_Genlist_Item_Flags flags,
3649 const void *func_data)
3651 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3652 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3653 Widget_Data *wd = elm_widget_data_get(obj);
3654 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3656 if (!wd) return NULL;
3657 if (!it) return NULL;
3658 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3659 EINA_INLIST_GET(after));
3662 it->parent->items = eina_list_append_relative(it->parent->items, it,
3666 it->rel->relcount++;
3667 it->before = EINA_FALSE;
3668 _item_queue(wd, it);
3675 * This clears all items in the list, leaving it empty.
3677 * @param obj The genlist object
3682 elm_genlist_clear(Evas_Object *obj)
3684 ELM_CHECK_WIDTYPE(obj, widtype);
3685 Widget_Data *wd = elm_widget_data_get(obj);
3687 if (wd->walking > 0)
3689 Elm_Genlist_Item *it;
3691 wd->clear_me = EINA_TRUE;
3692 EINA_INLIST_FOREACH(wd->items, it)
3694 it->delete_me = EINA_TRUE;
3698 wd->clear_me = EINA_FALSE;
3701 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3702 it->nocache = EINA_TRUE;
3703 it->hilighted = EINA_FALSE;
3705 if (wd->anchor_item == it)
3707 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3708 if (!wd->anchor_item)
3710 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3713 wd->items = eina_inlist_remove(wd->items, wd->items);
3714 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3715 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3716 if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL;
3717 elm_widget_item_pre_notify_del(it);
3718 if (it->effect_item_realized) _effect_item_unrealize(it);
3719 if (it->realized) _item_unrealize(it);
3720 if (it->itc->func.del)
3721 it->itc->func.del((void *)it->base.data, it->base.widget);
3722 if (it->long_timer) ecore_timer_del(it->long_timer);
3723 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3724 elm_widget_item_del(it);
3726 wd->anchor_item = NULL;
3729 Item_Block *itb = (Item_Block *)(wd->blocks);
3731 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3732 if (itb->items) eina_list_free(itb->items);
3737 ecore_job_del(wd->calc_job);
3738 wd->calc_job = NULL;
3740 if (wd->queue_idler)
3742 ecore_idler_del(wd->queue_idler);
3743 wd->queue_idler = NULL;
3745 if (wd->must_recalc_idler)
3747 ecore_idler_del(wd->must_recalc_idler);
3748 wd->must_recalc_idler = NULL;
3752 eina_list_free(wd->queue);
3757 eina_list_free(wd->selected);
3758 wd->selected = NULL;
3762 Evas_Object *editfield;
3763 EINA_LIST_FREE(wd->edit_field, editfield)
3764 evas_object_del(editfield);
3765 wd->edit_field = NULL;
3767 if (wd->item_moving_effect_timer)
3769 ecore_animator_del(wd->item_moving_effect_timer);
3770 wd->item_moving_effect_timer = NULL;
3772 wd->show_item = NULL;
3779 evas_object_del(wd->alpha_bg);
3780 wd->alpha_bg = NULL;
3784 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3785 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3791 * Enable or disable multi-select in the genlist
3793 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3794 * the list. This allows more than 1 item to be selected.
3796 * @param obj The genlist object
3797 * @param multi Multi-select enable/disable
3802 elm_genlist_multi_select_set(Evas_Object *obj,
3805 ELM_CHECK_WIDTYPE(obj, widtype);
3806 Widget_Data *wd = elm_widget_data_get(obj);
3812 * Gets if multi-select in genlist is enable or disable
3814 * @param obj The genlist object
3815 * @return Multi-select enable/disable
3816 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3821 elm_genlist_multi_select_get(const Evas_Object *obj)
3823 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3824 Widget_Data *wd = elm_widget_data_get(obj);
3825 if (!wd) return EINA_FALSE;
3830 * Get the selectd item in the genlist
3832 * This gets the selected item in the list (if multi-select is enabled
3833 * only the first item in the list is selected - which is not very
3834 * useful, so see elm_genlist_selected_items_get() for when
3835 * multi-select is used).
3837 * If no item is selected, NULL is returned.
3839 * @param obj The genlist object
3840 * @return The selected item, or NULL if none.
3844 EAPI Elm_Genlist_Item *
3845 elm_genlist_selected_item_get(const Evas_Object *obj)
3847 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3848 Widget_Data *wd = elm_widget_data_get(obj);
3849 if (!wd) return NULL;
3850 if (wd->selected) return wd->selected->data;
3855 * Get a list of selected items in the genlist
3857 * This returns a list of the selected items. This list pointer is
3858 * only valid so long as no items are selected or unselected (or
3859 * unselected implicitly by deletion). The list contains
3860 * Elm_Genlist_Item pointers.
3862 * @param obj The genlist object
3863 * @return The list of selected items, nor NULL if none are selected.
3867 EAPI const Eina_List *
3868 elm_genlist_selected_items_get(const Evas_Object *obj)
3870 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3871 Widget_Data *wd = elm_widget_data_get(obj);
3872 if (!wd) return NULL;
3873 return wd->selected;
3877 * Get a list of realized items in genlist
3879 * This returns a list of the realized items in the genlist. The list
3880 * contains Elm_Genlist_Item pointers. The list must be freed by the
3881 * caller when done with eina_list_free(). The item pointers in the
3882 * list are only valid so long as those items are not deleted or the
3883 * genlist is not deleted.
3885 * @param obj The genlist object
3886 * @return The list of realized items, nor NULL if none are realized.
3891 elm_genlist_realized_items_get(const Evas_Object *obj)
3893 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3894 Widget_Data *wd = elm_widget_data_get(obj);
3895 Eina_List *list = NULL;
3897 Eina_Bool done = EINA_FALSE;
3898 if (!wd) return NULL;
3899 EINA_INLIST_FOREACH(wd->blocks, itb)
3904 Elm_Genlist_Item *it;
3907 EINA_LIST_FOREACH(itb->items, l, it)
3909 if (it->realized) list = eina_list_append(list, it);
3921 * Get the item that is at the x, y canvas coords
3923 * This returns the item at the given coordinates (which are canvas
3924 * relative not object-relative). If an item is at that coordinate,
3925 * that item handle is returned, and if @p posret is not NULL, the
3926 * integer pointed to is set to a value of -1, 0 or 1, depending if
3927 * the coordinate is on the upper portion of that item (-1), on the
3928 * middle section (0) or on the lower part (1). If NULL is returned as
3929 * an item (no item found there), then posret may indicate -1 or 1
3930 * based if the coordinate is above or below all items respectively in
3933 * @param it The item
3934 * @param x The input x coordinate
3935 * @param y The input y coordinate
3936 * @param posret The position relative to the item returned here
3937 * @return The item at the coordinates or NULL if none
3941 EAPI Elm_Genlist_Item *
3942 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3947 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3948 Widget_Data *wd = elm_widget_data_get(obj);
3949 Evas_Coord ox, oy, ow, oh;
3950 Evas_Coord head_y = 0;
3953 if (!wd) return NULL;
3954 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3957 if (wd->head_item) head_y = wd->head_item->h;
3958 EINA_INLIST_FOREACH(wd->blocks, itb)
3961 Elm_Genlist_Item *it;
3963 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3964 oy + itb->y + head_y - itb->wd->pan_y ,
3965 itb->w, itb->h, x, y, 1, 1))
3967 EINA_LIST_FOREACH(itb->items, l, it)
3969 Evas_Coord itx, ity;
3971 itx = ox + itb->x + it->x - itb->wd->pan_x;
3972 ity = oy + itb->y + it->y - itb->wd->pan_y;
3973 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3977 if (y <= (ity + (it->h / 4))) *posret = -1;
3978 else if (y >= (ity + it->h - (it->h / 4)))
3984 lasty = ity + it->h;
3989 if (y > lasty) *posret = 1;
3996 * Get the first item in the genlist
3998 * This returns the first item in the list.
4000 * @param obj The genlist object
4001 * @return The first item, or NULL if none
4005 EAPI Elm_Genlist_Item *
4006 elm_genlist_first_item_get(const Evas_Object *obj)
4008 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4009 Widget_Data *wd = elm_widget_data_get(obj);
4010 if (!wd) return NULL;
4011 if (!wd->items) return NULL;
4012 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4013 while ((it) && (it->delete_me))
4014 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4019 * Get the last item in the genlist
4021 * This returns the last item in the list.
4023 * @return The last item, or NULL if none
4027 EAPI Elm_Genlist_Item *
4028 elm_genlist_last_item_get(const Evas_Object *obj)
4030 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4031 Widget_Data *wd = elm_widget_data_get(obj);
4032 if (!wd) return NULL;
4033 if (!wd->items) return NULL;
4034 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4035 while ((it) && (it->delete_me))
4036 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4041 * Get the next item in the genlist
4043 * This returns the item after the item @p it.
4045 * @param it The item
4046 * @return The item after @p it, or NULL if none
4050 EAPI Elm_Genlist_Item *
4051 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4053 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4056 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4057 if ((it) && (!it->delete_me)) break;
4059 return (Elm_Genlist_Item *)it;
4063 * Get the previous item in the genlist
4065 * This returns the item before the item @p it.
4067 * @param it The item
4068 * @return The item before @p it, or NULL if none
4072 EAPI Elm_Genlist_Item *
4073 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4075 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4078 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4079 if ((it) && (!it->delete_me)) break;
4081 return (Elm_Genlist_Item *)it;
4085 * Get the genlist object from an item
4087 * This returns the genlist object itself that an item belongs to.
4089 * @param it The item
4090 * @return The genlist object
4095 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4097 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4098 return it->base.widget;
4102 * Get the parent item of the given item
4104 * This returns the parent item of the item @p it given.
4106 * @param it The item
4107 * @return The parent of the item or NULL if none
4111 EAPI Elm_Genlist_Item *
4112 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4114 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4119 * Clear all sub-items (children) of the given item
4121 * This clears all items that are children (or their descendants) of the
4124 * @param it The item
4129 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4131 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4132 Elm_Genlist_Item *it2;
4135 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4136 _item_subitems_clear(it);
4139 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4140 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4142 it->wd->expand_item = it;
4143 _item_flip_effect_show(it);
4144 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4145 it->wd->expand_item_end = y + h;
4149 it2 = elm_genlist_item_next_get(it2);
4151 } while (it2->expanded_depth > it->expanded_depth);
4153 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4155 it->wd->expand_item_gap = 0;
4157 evas_object_raise(it->wd->alpha_bg);
4158 evas_object_show(it->wd->alpha_bg);
4160 it->wd->start_time = current_time_get();
4161 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4164 _item_subitems_clear(it);
4169 * Set the selected state of an item
4171 * This sets the selected state (1 selected, 0 not selected) of the given
4174 * @param it The item
4175 * @param selected The selected state
4180 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4183 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4184 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4186 if (it->delete_me) return;
4187 selected = !!selected;
4188 if (it->selected == selected) return;
4194 while (wd->selected)
4195 _item_unselect(wd->selected->data);
4205 * Get the selected state of an item
4207 * This gets the selected state of an item (1 selected, 0 not selected).
4209 * @param it The item
4210 * @return The selected state
4215 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4217 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4218 return it->selected;
4222 * Sets the expanded state of an item (if it's a parent)
4224 * This expands or contracts a parent item (thus showing or hiding the
4227 * @param it The item
4228 * @param expanded The expanded state (1 expanded, 0 not expanded).
4233 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4236 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4237 if (it->expanded == expanded) return;
4238 it->expanded = expanded;
4239 it->wd->expand_item = it;
4241 if(it->wd->effect_mode && !it->wd->alpha_bg)
4242 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4246 it->wd->auto_scrolled = EINA_FALSE;
4247 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4249 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4250 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4254 it->wd->contracting = EINA_TRUE;
4255 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4257 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4258 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4263 * Get the expanded state of an item
4265 * This gets the expanded state of an item
4267 * @param it The item
4268 * @return Thre expanded state
4273 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4275 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4276 return it->expanded;
4280 * Get the depth of expanded item
4282 * @param it The genlist item object
4283 * @return The depth of expanded item
4288 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4290 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4291 return it->expanded_depth;
4295 * Sets the disabled state of an item.
4297 * A disabled item cannot be selected or unselected. It will also
4298 * change appearance to appear disabled. This sets the disabled state
4299 * (1 disabled, 0 not disabled).
4301 * @param it The item
4302 * @param disabled The disabled state
4307 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4310 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4311 if (it->disabled == disabled) return;
4312 if (it->delete_me) return;
4313 it->disabled = disabled;
4317 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4319 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4324 * Get the disabled state of an item
4326 * This gets the disabled state of the given item.
4328 * @param it The item
4329 * @return The disabled state
4334 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4336 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4337 if (it->delete_me) return EINA_FALSE;
4338 return it->disabled;
4342 * Sets the display only state of an item.
4344 * A display only item cannot be selected or unselected. It is for
4345 * display only and not selecting or otherwise clicking, dragging
4346 * etc. by the user, thus finger size rules will not be applied to
4349 * @param it The item
4350 * @param display_only The display only state
4355 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4356 Eina_Bool display_only)
4358 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4359 if (it->display_only == display_only) return;
4360 if (it->delete_me) return;
4361 it->display_only = display_only;
4362 it->mincalcd = EINA_FALSE;
4363 it->updateme = EINA_TRUE;
4364 if (it->block) it->block->updateme = EINA_TRUE;
4365 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4366 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4370 * Get the display only state of an item
4372 * This gets the display only state of the given item.
4374 * @param it The item
4375 * @return The display only state
4380 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4382 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4383 if (it->delete_me) return EINA_FALSE;
4384 return it->display_only;
4388 * Show the given item
4390 * This causes genlist to jump to the given item @p it and show it (by
4391 * scrolling), if it is not fully visible.
4393 * @param it The item
4398 elm_genlist_item_show(Elm_Genlist_Item *it)
4400 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4401 Evas_Coord gith = 0;
4402 if (it->delete_me) return;
4403 if ((it->queued) || (!it->mincalcd))
4405 it->wd->show_item = it;
4406 it->wd->bring_in = EINA_TRUE;
4407 it->showme = EINA_TRUE;
4410 if (it->wd->show_item)
4412 it->wd->show_item->showme = EINA_FALSE;
4413 it->wd->show_item = NULL;
4415 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4416 gith = it->group_item->h;
4417 elm_smart_scroller_child_region_show(it->wd->scr,
4418 it->x + it->block->x,
4419 it->y + it->block->y - gith,
4420 it->block->w, it->h);
4424 * Bring in the given item
4426 * This causes genlist to jump to the given item @p it and show it (by
4427 * scrolling), if it is not fully visible. This may use animation to
4428 * do so and take a period of time
4430 * @param it The item
4435 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4437 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4438 Evas_Coord gith = 0;
4439 if (it->delete_me) return;
4440 if ((it->queued) || (!it->mincalcd))
4442 it->wd->show_item = it;
4443 it->wd->bring_in = EINA_TRUE;
4444 it->showme = EINA_TRUE;
4447 if (it->wd->show_item)
4449 it->wd->show_item->showme = EINA_FALSE;
4450 it->wd->show_item = NULL;
4452 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4453 gith = it->group_item->h;
4454 elm_smart_scroller_region_bring_in(it->wd->scr,
4455 it->x + it->block->x,
4456 it->y + it->block->y - gith,
4457 it->block->w, it->h);
4461 * Show the given item at the top
4463 * This causes genlist to jump to the given item @p it and show it (by
4464 * scrolling), if it is not fully visible.
4466 * @param it The item
4471 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4473 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4475 Evas_Coord gith = 0;
4477 if (it->delete_me) return;
4478 if ((it->queued) || (!it->mincalcd))
4480 it->wd->show_item = it;
4481 it->wd->bring_in = EINA_TRUE;
4482 it->showme = EINA_TRUE;
4485 if (it->wd->show_item)
4487 it->wd->show_item->showme = EINA_FALSE;
4488 it->wd->show_item = NULL;
4490 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4491 if (it->group_item) gith = it->group_item->h;
4492 elm_smart_scroller_child_region_show(it->wd->scr,
4493 it->x + it->block->x,
4494 it->y + it->block->y - gith,
4499 * Bring in the given item at the top
4501 * This causes genlist to jump to the given item @p it and show it (by
4502 * scrolling), if it is not fully visible. This may use animation to
4503 * do so and take a period of time
4505 * @param it The item
4510 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4512 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4514 Evas_Coord gith = 0;
4516 if (it->delete_me) return;
4517 if ((it->queued) || (!it->mincalcd))
4519 it->wd->show_item = it;
4520 it->wd->bring_in = EINA_TRUE;
4521 it->showme = EINA_TRUE;
4524 if (it->wd->show_item)
4526 it->wd->show_item->showme = EINA_FALSE;
4527 it->wd->show_item = NULL;
4529 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4530 if (it->group_item) gith = it->group_item->h;
4531 elm_smart_scroller_region_bring_in(it->wd->scr,
4532 it->x + it->block->x,
4533 it->y + it->block->y - gith,
4538 * Show the given item at the middle
4540 * This causes genlist to jump to the given item @p it and show it (by
4541 * scrolling), if it is not fully visible.
4543 * @param it The item
4548 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4550 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4553 if (it->delete_me) return;
4554 if ((it->queued) || (!it->mincalcd))
4556 it->wd->show_item = it;
4557 it->wd->bring_in = EINA_TRUE;
4558 it->showme = EINA_TRUE;
4561 if (it->wd->show_item)
4563 it->wd->show_item->showme = EINA_FALSE;
4564 it->wd->show_item = NULL;
4566 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4567 elm_smart_scroller_child_region_show(it->wd->scr,
4568 it->x + it->block->x,
4569 it->y + it->block->y - oh / 2 +
4570 it->h / 2, it->block->w, oh);
4574 * Bring in the given item at the middle
4576 * This causes genlist to jump to the given item @p it and show it (by
4577 * scrolling), if it is not fully visible. This may use animation to
4578 * do so and take a period of time
4580 * @param it The item
4585 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4587 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4590 if (it->delete_me) return;
4591 if ((it->queued) || (!it->mincalcd))
4593 it->wd->show_item = it;
4594 it->wd->bring_in = EINA_TRUE;
4595 it->showme = EINA_TRUE;
4598 if (it->wd->show_item)
4600 it->wd->show_item->showme = EINA_FALSE;
4601 it->wd->show_item = NULL;
4603 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4604 elm_smart_scroller_region_bring_in(it->wd->scr,
4605 it->x + it->block->x,
4606 it->y + it->block->y - oh / 2 + it->h / 2,
4611 * Delete a given item
4613 * This deletes the item from genlist and calls the genlist item del
4614 * class callback defined in the item class, if it is set. This clears all
4615 * subitems if it is a tree.
4617 * @param it The item
4622 elm_genlist_item_del(Elm_Genlist_Item *it)
4624 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4625 if ((it->relcount > 0) || (it->walking > 0))
4627 elm_widget_item_pre_notify_del(it);
4628 elm_genlist_item_subitems_clear(it);
4629 it->delete_me = EINA_TRUE;
4630 if (it->wd->show_item == it) it->wd->show_item = NULL;
4632 it->wd->selected = eina_list_remove(it->wd->selected,
4636 if (it->realized) _item_unrealize(it);
4637 if (it->effect_item_realized) _effect_item_unrealize(it);
4638 it->block->changed = EINA_TRUE;
4639 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4640 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4642 // if (it->itc->func.del)
4643 // it->itc->func.del((void *)it->base.data, it->base.widget);
4650 * Set the data item from the genlist item
4652 * This set the data value passed on the elm_genlist_item_append() and
4653 * related item addition calls. This function will also call
4654 * elm_genlist_item_update() so the item will be updated to reflect the
4657 * @param it The item
4658 * @param data The new data pointer to set
4663 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4666 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4667 elm_widget_item_data_set(it, data);
4668 elm_genlist_item_update(it);
4672 * Get the data item from the genlist item
4674 * This returns the data value passed on the elm_genlist_item_append()
4675 * and related item addition calls and elm_genlist_item_data_set().
4677 * @param it The item
4678 * @return The data pointer provided when created
4683 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4685 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4686 return elm_widget_item_data_get(it);
4690 * Tells genlist to "orphan" icons fetchs by the item class
4692 * This instructs genlist to release references to icons in the item,
4693 * meaning that they will no longer be managed by genlist and are
4694 * floating "orphans" that can be re-used elsewhere if the user wants
4697 * @param it The item
4702 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4705 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4706 EINA_LIST_FREE(it->icon_objs, icon)
4708 elm_widget_sub_object_del(it->base.widget, icon);
4709 evas_object_smart_member_del(icon);
4710 evas_object_hide(icon);
4715 * Get the real evas object of the genlist item
4717 * This returns the actual evas object used for the specified genlist
4718 * item. This may be NULL as it may not be created, and may be deleted
4719 * at any time by genlist. Do not modify this object (move, resize,
4720 * show, hide etc.) as genlist is controlling it. This function is for
4721 * querying, emitting custom signals or hooking lower level callbacks
4722 * for events. Do not delete this object under any circumstances.
4724 * @param it The item
4725 * @return The object pointer
4729 EAPI const Evas_Object *
4730 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4732 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4733 return it->base.view;
4737 * Update the contents of an item
4739 * This updates an item by calling all the item class functions again
4740 * to get the icons, labels and states. Use this when the original
4741 * item data has changed and the changes are desired to be reflected.
4743 * @param it The item
4748 elm_genlist_item_update(Elm_Genlist_Item *it)
4750 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4751 if (it->flags != ELM_GENLIST_ITEM_HEAD)
4753 if (!it->block) return;
4754 if (it->delete_me) return;
4755 it->mincalcd = EINA_FALSE;
4756 it->updateme = EINA_TRUE;
4757 it->block->updateme = EINA_TRUE;
4759 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4760 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4764 * Update the item class of an item
4766 * @param it The item
4767 * @parem itc The item class for the item
4772 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4773 const Elm_Genlist_Item_Class *itc)
4775 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4776 if (!it->block) return;
4777 EINA_SAFETY_ON_NULL_RETURN(itc);
4778 if (it->delete_me) return;
4780 it->nocache = EINA_TRUE;
4781 elm_genlist_item_update(it);
4784 static Evas_Object *
4785 _elm_genlist_item_label_create(void *data,
4787 void *item __UNUSED__)
4789 Evas_Object *label = elm_label_add(obj);
4792 elm_object_style_set(label, "tooltip");
4793 elm_label_label_set(label, data);
4798 _elm_genlist_item_label_del_cb(void *data,
4799 Evas_Object *obj __UNUSED__,
4800 void *event_info __UNUSED__)
4802 eina_stringshare_del(data);
4806 * Set the text to be shown in the genlist item.
4808 * @param item Target item
4809 * @param text The text to set in the content
4811 * Setup the text as tooltip to object. The item can have only one
4812 * tooltip, so any previous tooltip data is removed.
4817 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4820 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4821 text = eina_stringshare_add(text);
4822 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4824 _elm_genlist_item_label_del_cb);
4828 * Set the content to be shown in the tooltip item
4830 * Setup the tooltip to item. The item can have only one tooltip, so
4831 * any previous tooltip data is removed. @p func(with @p data) will be
4832 * called every time that need to show the tooltip and it should return a
4833 * valid Evas_Object. This object is then managed fully by tooltip
4834 * system and is deleted when the tooltip is gone.
4836 * @param item the genlist item being attached by a tooltip.
4837 * @param func the function used to create the tooltip contents.
4838 * @param data what to provide to @a func as callback data/context.
4839 * @param del_cb called when data is not needed anymore, either when
4840 * another callback replaces @func, the tooltip is unset with
4841 * elm_genlist_item_tooltip_unset() or the owner @a item
4842 * dies. This callback receives as the first parameter the
4843 * given @a data, and @c event_info is the item.
4848 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4849 Elm_Tooltip_Item_Content_Cb func,
4851 Evas_Smart_Cb del_cb)
4853 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4855 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4858 if (item->tooltip.del_cb)
4859 item->tooltip.del_cb((void *)item->tooltip.data,
4860 item->base.widget, item);
4862 item->tooltip.content_cb = func;
4863 item->tooltip.data = data;
4864 item->tooltip.del_cb = del_cb;
4866 if (item->base.view)
4868 elm_widget_item_tooltip_content_cb_set(item,
4869 item->tooltip.content_cb,
4870 item->tooltip.data, NULL);
4871 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4877 if (del_cb) del_cb((void *)data, NULL, NULL);
4881 * Unset tooltip from item
4883 * @param item genlist item to remove previously set tooltip.
4885 * Remove tooltip from item. The callback provided as del_cb to
4886 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4887 * it is not used anymore.
4889 * @see elm_genlist_item_tooltip_content_cb_set()
4894 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4896 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4897 if ((item->base.view) && (item->tooltip.content_cb))
4898 elm_widget_item_tooltip_unset(item);
4900 if (item->tooltip.del_cb)
4901 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4902 item->tooltip.del_cb = NULL;
4903 item->tooltip.content_cb = NULL;
4904 item->tooltip.data = NULL;
4905 if (item->tooltip.style)
4906 elm_genlist_item_tooltip_style_set(item, NULL);
4910 * Sets a different style for this item tooltip.
4912 * @note before you set a style you should define a tooltip with
4913 * elm_genlist_item_tooltip_content_cb_set() or
4914 * elm_genlist_item_tooltip_text_set()
4916 * @param item genlist item with tooltip already set.
4917 * @param style the theme style to use (default, transparent, ...)
4922 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4926 eina_stringshare_replace(&item->tooltip.style, style);
4927 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4931 * Get the style for this item tooltip.
4933 * @param item genlist item with tooltip already set.
4934 * @return style the theme style in use, defaults to "default". If the
4935 * object does not have a tooltip set, then NULL is returned.
4940 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4942 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4943 return item->tooltip.style;
4947 * Set the cursor to be shown when mouse is over the genlist item
4949 * @param item Target item
4950 * @param cursor the cursor name to be used.
4952 * @see elm_object_cursor_set()
4956 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4959 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4960 eina_stringshare_replace(&item->mouse_cursor, cursor);
4961 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4965 * Get the cursor to be shown when mouse is over the genlist item
4967 * @param item genlist item with cursor already set.
4968 * @return the cursor name.
4973 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4975 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4976 return elm_widget_item_cursor_get(item);
4980 * Unset the cursor to be shown when mouse is over the genlist item
4982 * @param item Target item
4984 * @see elm_object_cursor_unset()
4988 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4990 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4991 if (!item->mouse_cursor)
4994 if (item->base.view)
4995 elm_widget_item_cursor_unset(item);
4997 eina_stringshare_del(item->mouse_cursor);
4998 item->mouse_cursor = NULL;
5002 * Sets a different style for this item cursor.
5004 * @note before you set a style you should define a cursor with
5005 * elm_genlist_item_cursor_set()
5007 * @param item genlist item with cursor already set.
5008 * @param style the theme style to use (default, transparent, ...)
5013 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5016 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5017 elm_widget_item_cursor_style_set(item, style);
5021 * Get the style for this item cursor.
5023 * @param item genlist item with cursor already set.
5024 * @return style the theme style in use, defaults to "default". If the
5025 * object does not have a cursor set, then NULL is returned.
5030 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5032 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5033 return elm_widget_item_cursor_style_get(item);
5037 * Set if the cursor set should be searched on the theme or should use
5038 * the provided by the engine, only.
5040 * @note before you set if should look on theme you should define a
5041 * cursor with elm_object_cursor_set(). By default it will only look
5042 * for cursors provided by the engine.
5044 * @param item widget item with cursor already set.
5045 * @param engine_only boolean to define it cursors should be looked
5046 * only between the provided by the engine or searched on widget's
5052 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5053 Eina_Bool engine_only)
5055 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5056 elm_widget_item_cursor_engine_only_set(item, engine_only);
5060 * Get the cursor engine only usage for this item cursor.
5062 * @param item widget item with cursor already set.
5063 * @return engine_only boolean to define it cursors should be looked
5064 * only between the provided by the engine or searched on widget's
5065 * theme as well. If the object does not have a cursor set, then
5066 * EINA_FALSE is returned.
5071 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5073 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5074 return elm_widget_item_cursor_engine_only_get(item);
5078 * This sets the horizontal stretching mode
5080 * This sets the mode used for sizing items horizontally. Valid modes
5081 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5082 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5083 * the scroller will scroll horizontally. Otherwise items are expanded
5084 * to fill the width of the viewport of the scroller. If it is
5085 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5086 * limited to that size.
5088 * @param obj The genlist object
5089 * @param mode The mode to use
5094 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5097 ELM_CHECK_WIDTYPE(obj, widtype);
5098 Widget_Data *wd = elm_widget_data_get(obj);
5100 if (wd->mode == mode) return;
5106 * Gets the horizontal stretching mode
5108 * @param obj The genlist object
5109 * @return The mode to use
5110 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5115 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5117 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5118 Widget_Data *wd = elm_widget_data_get(obj);
5119 if (!wd) return ELM_LIST_LAST;
5124 * Set the always select mode.
5126 * Items will only call their selection func and callback when first
5127 * becoming selected. Any further clicks will do nothing, unless you
5128 * enable always select with elm_genlist_always_select_mode_set().
5129 * This means even if selected, every click will make the selected
5130 * callbacks be called.
5132 * @param obj The genlist object
5133 * @param always_select The always select mode
5134 * (EINA_TRUE = on, EINA_FALSE = off)
5139 elm_genlist_always_select_mode_set(Evas_Object *obj,
5140 Eina_Bool always_select)
5142 ELM_CHECK_WIDTYPE(obj, widtype);
5143 Widget_Data *wd = elm_widget_data_get(obj);
5145 wd->always_select = always_select;
5149 * Get the always select mode.
5151 * @param obj The genlist object
5152 * @return The always select mode
5153 * (EINA_TRUE = on, EINA_FALSE = off)
5158 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5160 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5161 Widget_Data *wd = elm_widget_data_get(obj);
5162 if (!wd) return EINA_FALSE;
5163 return wd->always_select;
5167 * Set no select mode
5169 * This will turn off the ability to select items entirely and they
5170 * will neither appear selected nor call selected callback functions.
5172 * @param obj The genlist object
5173 * @param no_select The no select mode
5174 * (EINA_TRUE = on, EINA_FALSE = off)
5179 elm_genlist_no_select_mode_set(Evas_Object *obj,
5180 Eina_Bool no_select)
5182 ELM_CHECK_WIDTYPE(obj, widtype);
5183 Widget_Data *wd = elm_widget_data_get(obj);
5185 wd->no_select = no_select;
5189 * Gets no select mode
5191 * @param obj The genlist object
5192 * @return The no select mode
5193 * (EINA_TRUE = on, EINA_FALSE = off)
5198 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5200 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5201 Widget_Data *wd = elm_widget_data_get(obj);
5202 if (!wd) return EINA_FALSE;
5203 return wd->no_select;
5209 * This will enable the compress mode where items are "compressed"
5210 * horizontally to fit the genlist scrollable viewport width. This is
5211 * special for genlist. Do not rely on
5212 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5213 * work as genlist needs to handle it specially.
5215 * @param obj The genlist object
5216 * @param compress The compress mode
5217 * (EINA_TRUE = on, EINA_FALSE = off)
5222 elm_genlist_compress_mode_set(Evas_Object *obj,
5225 ELM_CHECK_WIDTYPE(obj, widtype);
5226 Widget_Data *wd = elm_widget_data_get(obj);
5228 wd->compress = compress;
5232 * Get the compress mode
5234 * @param obj The genlist object
5235 * @return The compress mode
5236 * (EINA_TRUE = on, EINA_FALSE = off)
5241 elm_genlist_compress_mode_get(const Evas_Object *obj)
5243 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5244 Widget_Data *wd = elm_widget_data_get(obj);
5245 if (!wd) return EINA_FALSE;
5246 return wd->compress;
5250 * Set height-for-width mode
5252 * With height-for-width mode the item width will be fixed (restricted
5253 * to a minimum of) to the list width when calculating its size in
5254 * order to allow the height to be calculated based on it. This allows,
5255 * for instance, text block to wrap lines if the Edje part is
5256 * configured with "text.min: 0 1".
5258 * @note This mode will make list resize slower as it will have to
5259 * recalculate every item height again whenever the list width
5262 * @note When height-for-width mode is enabled, it also enables
5263 * compress mode (see elm_genlist_compress_mode_set()) and
5264 * disables homogeneous (see elm_genlist_homogeneous_set()).
5266 * @param obj The genlist object
5267 * @param setting The height-for-width mode (EINA_TRUE = on,
5273 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5274 Eina_Bool height_for_width)
5276 ELM_CHECK_WIDTYPE(obj, widtype);
5277 Widget_Data *wd = elm_widget_data_get(obj);
5279 wd->height_for_width = !!height_for_width;
5280 if (wd->height_for_width)
5282 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5283 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5288 * Get the height-for-width mode
5290 * @param obj The genlist object
5291 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5297 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5299 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5300 Widget_Data *wd = elm_widget_data_get(obj);
5301 if (!wd) return EINA_FALSE;
5302 return wd->height_for_width;
5308 * This will enable or disable the scroller bounce mode for the
5309 * genlist. See elm_scroller_bounce_set() for details
5311 * @param obj The genlist object
5312 * @param h_bounce Allow bounce horizontally
5313 * @param v_bounce Allow bounce vertically
5318 elm_genlist_bounce_set(Evas_Object *obj,
5322 ELM_CHECK_WIDTYPE(obj, widtype);
5323 Widget_Data *wd = elm_widget_data_get(obj);
5325 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5329 * Get the bounce mode
5331 * @param obj The genlist object
5332 * @param h_bounce Allow bounce horizontally
5333 * @param v_bounce Allow bounce vertically
5338 elm_genlist_bounce_get(const Evas_Object *obj,
5339 Eina_Bool *h_bounce,
5340 Eina_Bool *v_bounce)
5342 ELM_CHECK_WIDTYPE(obj, widtype);
5343 Widget_Data *wd = elm_widget_data_get(obj);
5345 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5349 * Set homogenous mode
5351 * This will enable the homogeneous mode where items are of the same
5352 * height and width so that genlist may do the lazy-loading at its
5353 * maximum. This implies 'compressed' mode.
5355 * @param obj The genlist object
5356 * @param homogeneous Assume the items within the genlist are of the
5357 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5362 elm_genlist_homogeneous_set(Evas_Object *obj,
5363 Eina_Bool homogeneous)
5365 ELM_CHECK_WIDTYPE(obj, widtype);
5366 Widget_Data *wd = elm_widget_data_get(obj);
5368 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5369 wd->homogeneous = homogeneous;
5373 * Get the homogenous mode
5375 * @param obj The genlist object
5376 * @return Assume the items within the genlist are of the same height
5377 * and width (EINA_TRUE = on, EINA_FALSE = off)
5382 elm_genlist_homogeneous_get(const Evas_Object *obj)
5384 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5385 Widget_Data *wd = elm_widget_data_get(obj);
5386 if (!wd) return EINA_FALSE;
5387 return wd->homogeneous;
5391 * Set the maximum number of items within an item block
5393 * This will configure the block count to tune to the target with
5394 * particular performance matrix.
5396 * @param obj The genlist object
5397 * @param n Maximum number of items within an item block
5402 elm_genlist_block_count_set(Evas_Object *obj,
5405 ELM_CHECK_WIDTYPE(obj, widtype);
5406 Widget_Data *wd = elm_widget_data_get(obj);
5408 wd->max_items_per_block = n;
5409 wd->item_cache_max = wd->max_items_per_block * 2;
5410 _item_cache_clean(wd);
5414 * Get the maximum number of items within an item block
5416 * @param obj The genlist object
5417 * @return Maximum number of items within an item block
5422 elm_genlist_block_count_get(const Evas_Object *obj)
5424 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5425 Widget_Data *wd = elm_widget_data_get(obj);
5427 return wd->max_items_per_block;
5431 * Set the timeout in seconds for the longpress event
5433 * @param obj The genlist object
5434 * @param timeout timeout in seconds
5439 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5442 ELM_CHECK_WIDTYPE(obj, widtype);
5443 Widget_Data *wd = elm_widget_data_get(obj);
5445 wd->longpress_timeout = timeout;
5449 * Get the timeout in seconds for the longpress event
5451 * @param obj The genlist object
5452 * @return timeout in seconds
5457 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5459 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5460 Widget_Data *wd = elm_widget_data_get(obj);
5462 return wd->longpress_timeout;
5466 * Set the scrollbar policy
5468 * This sets the scrollbar visibility policy for the given genlist
5469 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5470 * made visible if it is needed, and otherwise kept hidden.
5471 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5472 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5473 * respectively for the horizontal and vertical scrollbars.
5475 * @param obj The genlist object
5476 * @param policy_h Horizontal scrollbar policy
5477 * @param policy_v Vertical scrollbar policy
5482 elm_genlist_scroller_policy_set(Evas_Object *obj,
5483 Elm_Scroller_Policy policy_h,
5484 Elm_Scroller_Policy policy_v)
5486 ELM_CHECK_WIDTYPE(obj, widtype);
5487 Widget_Data *wd = elm_widget_data_get(obj);
5489 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5490 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5493 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5497 * Get the scrollbar policy
5499 * @param obj The genlist object
5500 * @param policy_h Horizontal scrollbar policy
5501 * @param policy_v Vertical scrollbar policy
5506 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5507 Elm_Scroller_Policy *policy_h,
5508 Elm_Scroller_Policy *policy_v)
5510 ELM_CHECK_WIDTYPE(obj, widtype);
5511 Widget_Data *wd = elm_widget_data_get(obj);
5512 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5513 if ((!wd) || (!wd->scr)) return;
5514 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5515 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5516 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5519 /****************************************************************************/
5524 * @param obj The genlist object
5525 * @param reorder_mode The reorder mode
5526 * (EINA_TRUE = on, EINA_FALSE = off)
5531 elm_genlist_reorder_mode_set(Evas_Object *obj,
5532 Eina_Bool reorder_mode)
5534 ELM_CHECK_WIDTYPE(obj, widtype);
5535 Widget_Data *wd = elm_widget_data_get(obj);
5537 wd->reorder_mode = reorder_mode;
5541 * Get the reorder mode
5543 * @param obj The genlist object
5544 * @return The reorder mode
5545 * (EINA_TRUE = on, EINA_FALSE = off)
5550 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5552 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5553 Widget_Data *wd = elm_widget_data_get(obj);
5554 if (!wd) return EINA_FALSE;
5555 return wd->reorder_mode;
5559 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5565 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5571 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5576 if (it->wd->ed->ec->move)
5577 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5579 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5580 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5581 it->wd->reorder_deleted = EINA_TRUE;
5582 _item_block_del(it);
5584 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5586 it->rel->relcount++;
5587 it->before = EINA_FALSE;
5588 _item_queue(it->wd, it);
5592 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5595 if (!before) return;
5597 if (it->wd->ed->ec->move)
5598 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5600 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5601 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5602 it->wd->reorder_deleted = EINA_TRUE;
5603 _item_block_del(it);
5604 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5606 it->rel->relcount++;
5607 it->before = EINA_TRUE;
5608 _item_queue(it->wd, it);
5612 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5614 ELM_CHECK_WIDTYPE(obj, widtype);
5615 Widget_Data *wd = elm_widget_data_get(obj);
5617 wd->effect_mode = emode;
5618 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5619 // evas_object_resize(wd->point_rect, 10, 25);
5620 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5621 // evas_object_show(wd->point_rect);
5622 // evas_object_hide(wd->point_rect);
5626 _create_tray_alpha_bg(const Evas_Object *obj)
5628 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5629 Widget_Data *wd = elm_widget_data_get(obj);
5630 if (!wd) return NULL;
5632 Evas_Object *bg = NULL;
5633 Evas_Coord ox, oy, ow, oh;
5635 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5636 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5637 evas_object_color_set(bg,0,0,0,0);
5638 evas_object_resize(bg , ow, oh);
5639 evas_object_move(bg , ox, oy);
5640 evas_object_show(bg);
5641 evas_object_hide(bg);
5648 struct timeval timev;
5650 gettimeofday(&timev, NULL);
5651 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5654 // added for item moving animation.
5656 _item_moving_effect_timer_cb(void *data)
5658 Widget_Data *wd = data;
5659 if (!wd) return EINA_FALSE;
5661 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5662 Elm_Genlist_Item *it, *it2;
5664 double time = 0.4, t;
5666 Eina_Bool check, end = EINA_FALSE;
5667 // static Eina_Bool first = EINA_TRUE;
5670 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5672 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5673 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5674 if (t > time) end = EINA_TRUE;
5675 EINA_INLIST_FOREACH(wd->blocks, itb)
5678 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5679 itb->y - wd->pan_y + oy,
5681 cvx, cvy, cvw, cvh))
5683 EINA_LIST_FOREACH(itb->items, l, it)
5685 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5690 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5696 //printf(" s: %d %d ", oy, oh);
5697 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5698 dy = it->scrl_y - it->old_scrl_y;
5699 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5701 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5702 if(wd->expand_item_end < it->old_scrl_y)
5703 dy = wd->expand_item_gap;
5705 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5707 if (wd->expand_item_end < it->old_scrl_y)
5708 dy = wd->expand_item_gap;
5711 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5718 if (!it->old_scrl_y)
5719 it->old_scrl_y = it->scrl_y;
5722 if (it->old_scrl_y + y < oy + oh)
5724 if (!it->realized) _item_realize(it, in, 0);
5726 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5727 it->old_scrl_y = it->scrl_y - y;
5730 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5731 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5733 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5736 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5737 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5738 evas_object_show(it->base.view);
5739 evas_object_raise(it->base.view);
5742 if(wd->head_item) evas_object_raise(wd->head_item->base.view);
5743 if (it->group_item) evas_object_raise(it->group_item->base.view);
5746 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5748 it2 = elm_genlist_item_prev_get(it);
5751 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5753 if(!it2->effect_done)
5755 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5756 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5757 evas_object_show(it2->base.view);
5758 it2->effect_done = EINA_TRUE;
5762 it2 = elm_genlist_item_prev_get(it2);
5765 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5767 it2 = elm_genlist_item_prev_get(it);
5770 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5772 if(!it2->effect_done)
5774 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5775 it2->effect_done = EINA_TRUE;
5780 it2 = elm_genlist_item_prev_get(it2);
5786 // first = EINA_FALSE;
5790 if (wd->item_moving_effect_timer)
5792 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5793 _item_subitems_clear(wd->expand_item);
5794 EINA_INLIST_FOREACH(wd->blocks, itb)
5796 EINA_LIST_FOREACH(itb->items, l, it)
5798 it->effect_done = EINA_TRUE;
5799 it->list_expanded = 0;
5800 it->old_scrl_y = it->scrl_y;
5804 //evas_render(evas_object_evas_get(wd->obj));
5805 wd->item_moving_effect_timer = NULL;
5806 // first = EINA_TRUE;
5808 _item_auto_scroll(wd);
5809 evas_object_lower(wd->alpha_bg);
5810 evas_object_hide(wd->alpha_bg);
5811 if (wd->calc_job) ecore_job_del(wd->calc_job);
5812 wd->calc_job = ecore_job_add(_calc_job, wd);
5813 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5814 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5816 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5817 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5818 return ECORE_CALLBACK_CANCEL;
5820 return ECORE_CALLBACK_RENEW;
5824 _emit_contract(Elm_Genlist_Item *it)
5826 Elm_Genlist_Item *it2;
5829 // printf("%p is emited contract\n", it);
5830 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5831 it->effect_done = EINA_FALSE;
5833 EINA_LIST_FOREACH(it->items, l, it2)
5835 _emit_contract(it2);
5838 // added for item moving animation.
5840 _item_flip_effect_show(Elm_Genlist_Item *it)
5842 Elm_Genlist_Item *it2;
5844 Widget_Data *wd = it->wd;
5845 Eina_Bool check = EINA_FALSE;
5847 it2 = elm_genlist_item_next_get(it);
5850 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5851 it2 = elm_genlist_item_next_get(it2);
5853 EINA_LIST_FOREACH(it->items, l, it2)
5855 if (it2->parent && it == it2->parent)
5857 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5859 edje_object_signal_emit(it2->base.view, "flip_item", "");
5861 evas_object_move(it2->base.view, -9999, -9999);
5863 evas_object_show(it2->base.view);
5865 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5866 _emit_contract(it2);
5870 return ECORE_CALLBACK_CANCEL;
5875 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5877 printf("!!! NOW FIXING \n");
5882 * Set pinch zoom mode
5884 * @param obj The genlist object
5886 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5891 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5893 printf("!!! NOW FIXING \n");
5897 * Get pinch zoom mode
5899 * @param obj The genlist object
5900 * @return The pinch mode
5901 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5906 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5908 printf("!!! NOW FIXING \n");
5913 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5915 printf("!!! NOW FIXING \n");
5919 ////////////////////////////////////////////////////////////////////////
5921 ////////////////////////////////////////////////////////////////////////
5923 _effect_item_update(Elm_Genlist_Item *it)
5925 if (it->edit_select_check)
5927 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5931 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5936 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5939 if (edit_select_check_state)
5941 it->edit_select_check = EINA_TRUE;
5942 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5946 it->edit_select_check = EINA_FALSE;
5947 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5949 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5950 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5954 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5957 Eina_List *tl = NULL, *l;
5958 Elm_Genlist_Item *it2;
5960 EINA_LIST_FOREACH(it->items, l, it2)
5961 tl = eina_list_append(tl, it2);
5962 EINA_LIST_FREE(tl, it2)
5963 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5967 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5970 Elm_Genlist_Item *tmp_it;
5971 Eina_Bool parent_check = EINA_TRUE;
5973 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5975 if (tmp_it->parent && it->parent)
5976 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5980 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5981 else it->parent->edit_select_check = EINA_FALSE;
5986 _effect_item_update(it->parent);
5987 return _edit_parent_items_checkbox_set(it->parent);
5992 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items)
5994 if (!select_all_it || !select_all_it->wd) return;
5996 Eina_Bool old_check_state;
5997 Elm_Genlist_Item *it;
5998 Widget_Data *wd = select_all_it->wd;
6000 wd->select_all_check = checked;
6001 if (wd->select_all_check)
6002 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_check", "elm");
6004 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_uncheck", "elm");
6008 EINA_INLIST_FOREACH(wd->items, it)
6010 old_check_state = it->edit_select_check;
6011 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
6012 else it->edit_select_check = EINA_FALSE;
6014 // TODO : check this
6015 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
6016 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
6020 if (wd->ed->ec->item_selected)
6021 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
6023 if (wd->calc_job) ecore_job_del(wd->calc_job);
6024 wd->calc_job = ecore_job_add(_calc_job, wd);
6028 _checkbox_item_select_process(Elm_Genlist_Item *it)
6030 Elm_Genlist_Item *tmp_it;
6031 Eina_Bool old_check_state;
6032 int check_cnt = 0, total_cnt = 0;
6035 _edit_item_checkbox_set(it, it->edit_select_check);
6036 _edit_subitems_checkbox_set(it);
6037 _edit_parent_items_checkbox_set(it);
6039 if (it->wd->ed) it->wd->ed->del_item = it;
6041 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
6043 if (tmp_it->edit_select_check) check_cnt++;
6047 if (it->wd->select_all_item)
6049 old_check_state = it->wd->select_all_check;
6050 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
6051 else it->wd->select_all_check = EINA_FALSE;
6053 if (check_cnt == total_cnt)
6055 it->wd->select_all_check = EINA_TRUE;
6056 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
6060 it->wd->select_all_check = EINA_FALSE;
6061 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
6067 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
6069 Elm_Genlist_Item *it = data;
6071 it->edit_select_check = !it->edit_select_check;
6072 _checkbox_item_select_process(it);
6076 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
6078 Elm_Genlist_Item *select_all_it = data;
6079 Widget_Data *wd = select_all_it->wd;
6082 _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE);
6087 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
6089 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6091 evas_object_resize(it->edit_obj,it->w, it->h);
6092 evas_object_move(it->edit_obj, itx, ity);
6094 if (it->wd->select_all_check)
6095 it->edit_select_check = EINA_TRUE;
6098 if (it->edit_select_check)
6100 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
6104 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6110 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
6112 if ((it->effect_item_realized) || (it->delete_me)) return;
6113 int itmode = 0, pad = 0;
6114 const char *pad_str;
6116 it->pad_left = it->pad_right = 0;
6118 if (it->itc->func.editmode_get)
6119 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
6120 itmode &= it->wd->edit_mode;
6122 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6123 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
6125 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6126 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6127 _elm_config->scale);
6128 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6129 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6131 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6132 else strncpy(buf, "item", sizeof(buf));
6133 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6135 strncat(buf, "/", sizeof(buf) - strlen(buf));
6137 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
6139 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
6140 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6144 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6147 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6148 if (pad_str) pad = atoi(pad_str);
6150 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6152 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable_effect", "elm");
6153 else edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6155 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6156 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6157 "elm", _checkbox_item_select_cb);
6159 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,select",
6160 "elm", _checkbox_item_select_cb, it);
6161 it->pad_left += pad * _elm_config->scale;
6165 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6167 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6168 "elm", _checkbox_item_select_cb);
6171 if (effect_on && itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6173 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm");
6174 edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6176 else if (itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6177 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm");
6179 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6181 if (it->itc->func.icon_get)
6186 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6187 EINA_LIST_FOREACH(it->icons, l, key)
6189 Evas_Object *ic = it->itc->func.icon_get
6190 (it->base.data, it->base.widget, l->data);
6194 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6195 edje_object_part_swallow(it->edit_obj, key, ic);
6196 evas_object_show(ic);
6197 elm_widget_sub_object_add(it->base.widget, ic);
6202 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6203 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6204 evas_object_show(it->edit_obj);
6206 it->effect_item_realized = EINA_TRUE;
6207 it->want_unrealize = EINA_FALSE;
6211 _effect_item_unrealize(Elm_Genlist_Item *it)
6215 if (!it->effect_item_realized) return;
6216 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6218 it->pad_left = it->pad_right = 0;
6219 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6220 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6221 edje_object_message_signal_process(it->edit_obj);
6222 edje_object_part_unswallow(it->edit_obj, it->base.view);
6223 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6224 elm_widget_sub_object_add(it->base.widget, it->base.view);
6225 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6226 // _item_cache_add(it);
6227 evas_object_del(it->edit_obj);
6228 it->edit_obj = NULL;
6229 EINA_LIST_FREE(it->edit_icon_objs, icon)
6230 evas_object_del(icon);
6232 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6233 it->effect_item_realized = EINA_FALSE;
6237 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6239 fprintf(stderr, "=================> Caution!!! <========================\n");
6240 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6241 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6242 fprintf(stderr, "=======================================================\n");
6244 elm_genlist_edit_mode_set(obj, emode, edit_class);
6248 * Get Genlist edit mode
6250 * @param obj The genlist object
6251 * @return The edit mode status
6252 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6257 elm_genlist_edit_mode_get(const Evas_Object *obj)
6259 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
6260 Widget_Data *wd = elm_widget_data_get(obj);
6261 if (!wd) return EINA_FALSE;
6263 if (wd->edit_mode) return EINA_TRUE;
6264 else return EINA_FALSE;
6268 * Set Genlist edit mode
6270 * This sets Genlist edit mode.
6272 * @param obj The Genlist object
6273 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6274 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6279 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6281 ELM_CHECK_WIDTYPE(obj, widtype);
6284 Eina_Bool done = EINA_FALSE;
6285 static Elm_Genlist_Item_Class itc;
6287 Elm_Genlist_Item *it;
6289 Widget_Data *wd = elm_widget_data_get(obj);
6291 if (wd->edit_mode == emode) return;
6293 wd->edit_mode = emode;
6295 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6296 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6299 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6301 EINA_INLIST_FOREACH(wd->blocks, itb)
6306 EINA_LIST_FOREACH(itb->items, l, it)
6308 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6310 it->pad_left = it->pad_right = 0;
6311 _effect_item_unrealize(it);
6321 EINA_INLIST_FOREACH(wd->items, it)
6323 it->edit_select_check = EINA_FALSE;
6325 if (wd->ed) free (wd->ed);
6327 wd->reorder_mode = EINA_FALSE;
6328 if (wd->select_all_item)
6330 wd->select_all_check = EINA_FALSE;
6331 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down);
6332 elm_widget_item_pre_notify_del(wd->select_all_item);
6333 _item_unrealize(wd->select_all_item);
6334 elm_widget_item_del(wd->select_all_item);
6336 wd->select_all_item = NULL;
6339 Evas_Object *editfield;
6340 EINA_LIST_FREE(wd->edit_field, editfield)
6341 evas_object_del(editfield);
6342 wd->edit_field = NULL;
6344 _item_cache_zero(wd);
6348 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6349 wd->reorder_mode = EINA_TRUE;
6352 wd->ed = calloc(1, sizeof(Edit_Data));
6354 wd->ed->ec = edit_class;
6356 EINA_INLIST_FOREACH(wd->blocks, itb)
6361 EINA_LIST_FOREACH(itb->items, l, it)
6363 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6365 if(it->selected) _item_unselect(it);
6366 _effect_item_realize(it, EINA_TRUE);
6376 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6378 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6379 itc.item_style = edit_class->select_all_item_style;
6381 itc.item_style = "select_all";
6382 itc.func.label_get = NULL;
6383 itc.func.icon_get = NULL;
6384 itc.func.del = NULL;
6385 itc.func.editmode_get = NULL;
6386 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6389 if (!wd->select_all_item) return;
6391 _item_realize(wd->select_all_item, 0, 0);
6392 edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down, wd->select_all_item);
6394 wd->select_all_item->rel = NULL;
6395 wd->select_all_item->block = NULL;
6399 if (wd->calc_job) ecore_job_del(wd->calc_job);
6400 wd->calc_job = ecore_job_add(_calc_job, wd);
6404 * Delete selected items in genlist edit mode.
6406 * @param obj The genlist object
6411 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6413 ELM_CHECK_WIDTYPE(obj, widtype);
6414 Widget_Data *wd = elm_widget_data_get(obj);
6416 if (!wd->blocks) return;
6417 Elm_Genlist_Item *it;
6418 Eina_List *edit_selected_list, *l;
6422 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
6425 if (wd->edit_field) return;
6426 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
6427 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy,&cvw, &cvh);
6428 EINA_INLIST_FOREACH(wd->blocks, itb)
6430 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
6431 itb->y - wd->pan_y + oy,
6433 cvx, cvy, cvw, cvh))
6434 EINA_LIST_FOREACH(itb->items, l, it)
6436 it->old_scrl_y =itb->y + it->y - it->wd->pan_y + oy;
6439 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6440 cnt = eina_list_count(edit_selected_list);
6441 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6443 wd->expand_item_gap = wd->expand_item_end = 0;
6444 EINA_LIST_FOREACH(edit_selected_list, l, it)
6446 if (it->flags != ELM_GENLIST_ITEM_GROUP)
6448 it->wd->expand_item_gap += it->h * -1;
6449 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
6450 cvx, cvy, cvw, cvh));
6451 if (!it->wd->expand_item_end && vis ) it->wd->expand_item_end = it->old_scrl_y;
6452 it->wd->expand_item = elm_genlist_item_prev_get(it);
6453 elm_genlist_item_del(it);
6456 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE;
6457 eina_list_free(edit_selected_list);
6459 evas_render(evas_object_evas_get(wd->obj));
6460 if (wd->calc_job) ecore_job_del(wd->calc_job);
6461 wd->calc_job = ecore_job_add(_calc_job, wd);
6465 elm_genlist_selected_items_del(Evas_Object *obj)
6467 fprintf(stderr, "=================> Caution!!! <========================\n");
6468 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6469 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6470 fprintf(stderr, "=======================================================\n");
6471 elm_genlist_edit_selected_items_del(obj);
6475 * Get a list of selected items in genlist
6477 * This returns a list of the selected items in the genlist. The list
6478 * contains Elm_Genlist_Item pointers. The list must be freed by the
6479 * caller when done with eina_list_free(). The item pointers in the list
6480 * are only vallid so long as those items are not deleted or the genlist is
6483 * @param obj The genlist object
6484 * @return The list of selected items, nor NULL if none are selected.
6489 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6491 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6492 Widget_Data *wd = elm_widget_data_get(obj);
6493 Eina_List *list = NULL;
6494 Elm_Genlist_Item *it;
6495 if (!wd) return NULL;
6497 EINA_INLIST_FOREACH(wd->items, it)
6499 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6505 // TODO : add comment
6507 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6510 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6511 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6513 selected = !!selected;
6514 if (it->edit_select_check == selected) return;
6516 it->edit_select_check = selected;
6517 _checkbox_item_select_process(it);
6520 // TODO : add comment
6522 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6524 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6525 return it->edit_select_check;
6529 * Set a given item's rename mode
6531 * This renames the item's label from genlist
6533 * @param it The item
6534 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6539 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
6545 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6550 Elm_Genlist_Item *it;
6552 EINA_LIST_FOREACH(itb->items, l, it)
6556 it->renamed = EINA_FALSE;
6557 it->nocache = EINA_TRUE;
6558 it->wd->rename_it = NULL;
6559 elm_genlist_item_update(it);
6567 it->renamed = EINA_TRUE;
6568 it->wd->rename_it = it;
6569 it->nocache = EINA_TRUE;
6570 if (it->selected) _item_unselect(it);
6572 _item_unrealize(it);
6573 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
6574 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
6579 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
6581 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6582 return item->renamed;
6585 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6587 Elm_Genlist_Item *it = data;
6589 _delete_sweep_objs(it);
6593 _scr_hold_timer_cb(void *data)
6595 Elm_Genlist_Item *it = data;
6596 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6597 it->wd->scr_hold_timer = NULL;
6598 return ECORE_CALLBACK_CANCEL;
6602 _delete_sweep_objs(Elm_Genlist_Item *it)
6606 elm_widget_stringlist_free(it->sweep_labels);
6607 it->sweep_labels = NULL;
6608 elm_widget_stringlist_free(it->sweep_icons);
6609 it->sweep_icons = NULL;
6610 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6611 evas_object_del(ic);
6615 _create_sweep_objs(Elm_Genlist_Item *it)
6621 if (it->itc->func.label_get)
6624 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6626 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6628 char *s = it->itc->func.label_get
6629 ((void *)it->base.data, it->base.widget, l->data);
6633 edje_object_part_text_set(it->base.view, l->data, s);
6638 if (it->itc->func.icon_get)
6641 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6643 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6645 ic = it->itc->func.icon_get
6646 ((void *)it->base.data, it->base.widget, l->data);
6650 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6651 edje_object_part_swallow(it->base.view, key, ic);
6652 evas_object_show(ic);
6653 elm_widget_sub_object_add(it->base.widget, ic);
6660 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6663 Elm_Genlist_Item *it2;
6664 const char *allow_slide;
6666 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6667 if ((!allow_slide) || (atoi(allow_slide) != 1))
6672 if (it->sweeped) return;
6673 if (it->wd->scr_hold_timer)
6675 ecore_timer_del(it->wd->scr_hold_timer);
6676 it->wd->scr_hold_timer = NULL;
6678 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6679 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6681 _delete_sweep_objs(it);
6682 _create_sweep_objs(it);
6683 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6684 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6685 it->wassweeped = EINA_TRUE;
6686 it->sweeped = EINA_TRUE;
6688 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6692 it2->sweeped = EINA_FALSE;
6693 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6694 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6695 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6701 if (!it->sweeped) return;
6702 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6703 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6704 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6705 it->sweeped = EINA_FALSE;
6710 _item_auto_scroll(void *data)
6712 Widget_Data *wd = data;
6715 if ((wd->expand_item) && (!wd->auto_scrolled))
6717 Elm_Genlist_Item *it;
6719 Evas_Coord ox, oy, ow, oh;
6720 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6722 wd->auto_scrolled = EINA_TRUE;
6723 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6725 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6727 elm_genlist_item_bring_in(it);
6734 elm_genlist_item_flags_get(const Elm_Genlist_Item *item)
6736 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6741 elm_genlist_realized_items_update(const Evas_Object *obj)
6743 ELM_CHECK_WIDTYPE(obj, widtype);
6745 Eina_List *list, *l;
6746 Elm_Genlist_Item *it;
6748 list = elm_genlist_realized_items_get(obj);
6749 EINA_LIST_FOREACH(list, l, it)
6750 elm_genlist_item_update(it);