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;
290 typedef enum _Elm_Genlist_Item_Move_effect_Mode
292 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
293 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
294 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 3),
297 } Elm_Genlist_Item_Move_effect_Mode;
301 Evas_Object *obj, *scr, *pan_smart;
302 Eina_Inlist *items, *blocks;
303 Eina_List *group_items;
305 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
306 Ecore_Job *calc_job, *update_job, *changed_job;
307 Ecore_Idler *queue_idler;
308 Ecore_Idler *must_recalc_idler;
309 Eina_List *queue, *selected;
310 Elm_Genlist_Item *show_item;
311 Elm_Genlist_Item *last_selected_item;
312 Eina_Inlist *item_cache;
313 Elm_Genlist_Item *anchor_item;
316 Ecore_Timer *multi_timer;
317 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
318 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
319 Eina_Bool mouse_down : 1;
320 Eina_Bool multi_down : 1;
321 Eina_Bool multi_timeout : 1;
322 Eina_Bool multitouched : 1;
323 Eina_Bool on_hold : 1;
325 Eina_Bool always_select : 1;
326 Eina_Bool longpressed : 1;
327 Eina_Bool wasselected : 1;
328 Eina_Bool no_select : 1;
329 Eina_Bool bring_in : 1;
330 Eina_Bool compress : 1;
331 Eina_Bool height_for_width : 1;
332 Eina_Bool homogeneous : 1;
333 Eina_Bool clear_me : 1;
338 } history[SWIPE_MOVES];
340 int item_cache_count;
346 int max_items_per_block;
347 double longpress_timeout;
349 // TODO : refactoring
350 Eina_Bool reorder_mode : 1;
351 Eina_Bool reorder_pan_move : 1;
352 Eina_Bool reorder_deleted : 1;
353 Eina_Bool effect_mode : 1;
354 Eina_Bool auto_scrolled : 1;
355 Eina_Bool contracting : 1;
357 Eina_List *sweeped_items;
358 Ecore_Timer *scr_hold_timer;
360 int group_item_width;
361 int group_item_height;
362 Elm_Genlist_Item *reorder_it, *reorder_rel;
363 Evas_Coord reorder_start_y;
364 Ecore_Animator *item_moving_effect_timer;
365 Evas_Object *alpha_bg;
366 Elm_Genlist_Item *expand_item;
367 Evas_Coord expand_item_end;
368 Evas_Coord expand_item_gap;
369 int move_effect_mode;
370 unsigned int start_time;
371 Elm_Genlist_Item *head_item, *tail_item;
372 Elm_Genlist_Item *rename_it;
382 Evas_Coord x, y, w, h, minw, minh;
383 Eina_Bool want_unrealize : 1;
384 Eina_Bool realized : 1;
385 Eina_Bool changed : 1;
386 Eina_Bool updateme : 1;
387 Eina_Bool showme : 1;
388 Eina_Bool must_recalc : 1;
392 struct _Elm_Genlist_Item
394 Elm_Widget_Item base;
399 Evas_Coord x, y, w, h, minw, minh;
400 const Elm_Genlist_Item_Class *itc;
401 Elm_Genlist_Item *parent;
402 Elm_Genlist_Item *group_item;
403 Elm_Genlist_Item_Flags flags;
411 Eina_List *labels, *icons, *states, *icon_objs;
412 Ecore_Timer *long_timer;
413 Ecore_Timer *swipe_timer;
415 Evas_Coord scrl_x, scrl_y;
417 Elm_Genlist_Item *rel;
422 Elm_Tooltip_Item_Content_Cb content_cb;
423 Evas_Smart_Cb del_cb;
427 const char *mouse_cursor;
434 Eina_Bool before : 1;
436 Eina_Bool want_unrealize : 1;
437 Eina_Bool want_realize : 1;
438 Eina_Bool realized : 1;
439 Eina_Bool selected : 1;
440 Eina_Bool hilighted : 1;
441 Eina_Bool expanded : 1;
442 Eina_Bool disabled : 1;
443 Eina_Bool display_only : 1;
444 Eina_Bool mincalcd : 1;
445 Eina_Bool queued : 1;
446 Eina_Bool showme : 1;
447 Eina_Bool delete_me : 1;
449 Eina_Bool dragging : 1;
450 Eina_Bool updateme : 1;
451 Eina_Bool nocache : 1;
454 Eina_Bool move_effect_me : 1;
455 Eina_Bool effect_done : 1;
456 Eina_Bool reordering : 1;
457 Eina_Bool renamed : 1;
458 Eina_Bool effect_item_realized : 1;
459 Eina_Bool sweeped : 1;
460 Eina_Bool wassweeped : 1;
461 Eina_List *edit_icon_objs;
462 Evas_Object *edit_obj;
463 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
465 Ecore_Animator *item_moving_effect_timer;
466 Evas_Coord old_scrl_x, old_scrl_y;
467 Evas_Coord pad_left, pad_right;
474 Evas_Object *base_view, *spacer;
476 const char *item_style; // it->itc->item_style
477 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
478 Eina_Bool compress : 1; // it->wd->compress
479 Eina_Bool odd : 1; // in & 0x1
481 Eina_Bool selected : 1; // it->selected
482 Eina_Bool disabled : 1; // it->disabled
483 Eina_Bool expanded : 1; // it->expanded
486 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
487 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
491 Evas_Object_Smart_Clipped_Data __clipped_data;
493 Ecore_Job *resize_job;
496 static const char *widtype = NULL;
497 static void _item_cache_zero(Widget_Data *wd);
498 static void _del_hook(Evas_Object *obj);
499 static void _theme_hook(Evas_Object *obj);
500 static void _show_region_hook(void *data, Evas_Object *obj);
501 static void _sizing_eval(Evas_Object *obj);
502 static void _item_unrealize(Elm_Genlist_Item *it);
503 static void _item_block_unrealize(Item_Block *itb);
504 static void _calc_job(void *data);
505 static void _on_focus_hook(void *data,
507 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
508 static void _changed_job(void *data);
509 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
510 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
511 static Eina_Bool _item_single_select_up(Widget_Data *wd);
512 static Eina_Bool _item_single_select_down(Widget_Data *wd);
513 static Eina_Bool _event_hook(Evas_Object *obj,
515 Evas_Callback_Type type,
517 static Eina_Bool _deselect_all_items(Widget_Data *wd);
518 static void _pan_calculate(Evas_Object *obj);
519 // TODO : refactoring
520 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
521 static unsigned int current_time_get();
522 static Eina_Bool _item_moving_effect_timer_cb(void *data);
523 static int _item_flip_effect_show(Elm_Genlist_Item *it);
524 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
525 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
526 static void _effect_item_unrealize(Elm_Genlist_Item *it);
527 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
528 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
529 static void _create_sweep_objs(Elm_Genlist_Item *it);
530 static void _delete_sweep_objs(Elm_Genlist_Item *it);
531 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
532 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
533 static void _group_items_recalc(void *data);
534 static void _item_auto_scroll(void *data);
536 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
539 _event_hook(Evas_Object *obj,
540 Evas_Object *src __UNUSED__,
541 Evas_Callback_Type type,
544 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
545 Evas_Event_Key_Down *ev = event_info;
546 Widget_Data *wd = elm_widget_data_get(obj);
547 if (!wd) return EINA_FALSE;
548 if (!wd->items) return EINA_FALSE;
549 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
550 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
552 Elm_Genlist_Item *it = NULL;
555 Evas_Coord step_x = 0;
556 Evas_Coord step_y = 0;
559 Evas_Coord page_x = 0;
560 Evas_Coord page_y = 0;
562 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
563 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
564 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
565 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
567 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
571 else if ((!strcmp(ev->keyname, "Right")) ||
572 (!strcmp(ev->keyname, "KP_Right")))
576 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
578 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
579 (_item_multi_select_up(wd)))
580 || (_item_single_select_up(wd)))
582 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
588 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
590 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
591 (_item_multi_select_down(wd)))
592 || (_item_single_select_down(wd)))
594 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
600 else if ((!strcmp(ev->keyname, "Home")) ||
601 (!strcmp(ev->keyname, "KP_Home")))
603 it = elm_genlist_first_item_get(obj);
604 elm_genlist_item_bring_in(it);
605 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
608 else if ((!strcmp(ev->keyname, "End")) ||
609 (!strcmp(ev->keyname, "KP_End")))
611 it = elm_genlist_last_item_get(obj);
612 elm_genlist_item_bring_in(it);
613 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
616 else if ((!strcmp(ev->keyname, "Prior")) ||
617 (!strcmp(ev->keyname, "KP_Prior")))
620 y -= -(page_y * v_h) / 100;
624 else if ((!strcmp(ev->keyname, "Next")) ||
625 (!strcmp(ev->keyname, "KP_Next")))
628 y += -(page_y * v_h) / 100;
632 else if(((!strcmp(ev->keyname, "Return")) ||
633 (!strcmp(ev->keyname, "KP_Enter")) ||
634 (!strcmp(ev->keyname, "space")))
635 && (!wd->multi) && (wd->selected))
637 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
638 elm_genlist_item_expanded_set(it,
639 !elm_genlist_item_expanded_get(it));
641 else if (!strcmp(ev->keyname, "Escape"))
643 if (!_deselect_all_items(wd)) return EINA_FALSE;
644 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
647 else return EINA_FALSE;
649 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
650 elm_smart_scroller_child_pos_set(wd->scr, x, y);
655 _deselect_all_items(Widget_Data *wd)
657 if (!wd->selected) return EINA_FALSE;
659 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
665 _item_multi_select_up(Widget_Data *wd)
667 if (!wd->selected) return EINA_FALSE;
668 if (!wd->multi) return EINA_FALSE;
670 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
671 if (!prev) return EINA_TRUE;
673 if (elm_genlist_item_selected_get(prev))
675 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
676 wd->last_selected_item = prev;
677 elm_genlist_item_show(wd->last_selected_item);
681 elm_genlist_item_selected_set(prev, EINA_TRUE);
682 elm_genlist_item_show(prev);
688 _item_multi_select_down(Widget_Data *wd)
690 if (!wd->selected) return EINA_FALSE;
691 if (!wd->multi) return EINA_FALSE;
693 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
694 if (!next) return EINA_TRUE;
696 if (elm_genlist_item_selected_get(next))
698 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
699 wd->last_selected_item = next;
700 elm_genlist_item_show(wd->last_selected_item);
704 elm_genlist_item_selected_set(next, EINA_TRUE);
705 elm_genlist_item_show(next);
711 _item_single_select_up(Widget_Data *wd)
713 Elm_Genlist_Item *prev;
716 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
717 while ((prev) && (prev->delete_me))
718 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
720 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
722 if (!prev) return EINA_FALSE;
724 _deselect_all_items(wd);
726 elm_genlist_item_selected_set(prev, EINA_TRUE);
727 elm_genlist_item_show(prev);
732 _item_single_select_down(Widget_Data *wd)
734 Elm_Genlist_Item *next;
737 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
738 while ((next) && (next->delete_me))
739 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
741 else next = elm_genlist_item_next_get(wd->last_selected_item);
743 if (!next) return EINA_FALSE;
745 _deselect_all_items(wd);
747 elm_genlist_item_selected_set(next, EINA_TRUE);
748 elm_genlist_item_show(next);
753 _on_focus_hook(void *data __UNUSED__,
756 Widget_Data *wd = elm_widget_data_get(obj);
758 if (elm_widget_focus_get(obj))
760 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
761 evas_object_focus_set(wd->obj, EINA_TRUE);
762 if ((wd->selected) && (!wd->last_selected_item))
763 wd->last_selected_item = eina_list_data_get(wd->selected);
767 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
768 evas_object_focus_set(wd->obj, EINA_FALSE);
773 _del_hook(Evas_Object *obj)
775 Widget_Data *wd = elm_widget_data_get(obj);
777 _item_cache_zero(wd);
778 if (wd->calc_job) ecore_job_del(wd->calc_job);
779 if (wd->update_job) ecore_job_del(wd->update_job);
780 if (wd->changed_job) ecore_job_del(wd->changed_job);
781 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
782 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
783 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
788 _del_pre_hook(Evas_Object *obj)
790 Widget_Data *wd = elm_widget_data_get(obj);
792 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
793 evas_object_del(wd->pan_smart);
794 wd->pan_smart = NULL;
795 elm_genlist_clear(obj);
799 _theme_hook(Evas_Object *obj)
801 Widget_Data *wd = elm_widget_data_get(obj);
804 _item_cache_zero(wd);
805 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
806 elm_widget_style_get(obj));
807 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
808 wd->item_width = wd->item_height = 0;
809 wd->minw = wd->minh = wd->realminw = 0;
810 EINA_INLIST_FOREACH(wd->blocks, itb)
813 Elm_Genlist_Item *it;
815 if (itb->realized) _item_block_unrealize(itb);
816 EINA_LIST_FOREACH(itb->items, l, it)
817 it->mincalcd = EINA_FALSE;
819 itb->changed = EINA_TRUE;
821 if (wd->calc_job) ecore_job_del(wd->calc_job);
822 wd->calc_job = ecore_job_add(_calc_job, wd);
827 _show_region_hook(void *data, Evas_Object *obj)
829 Widget_Data *wd = elm_widget_data_get(data);
830 Evas_Coord x, y, w, h;
832 elm_widget_show_region_get(obj, &x, &y, &w, &h);
835 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
839 _sizing_eval(Evas_Object *obj)
841 Widget_Data *wd = elm_widget_data_get(obj);
842 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
844 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
845 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
847 if (wd->height_for_width)
851 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
852 if ((vw != 0) && (vw != wd->prev_viewport_w))
856 wd->prev_viewport_w = vw;
857 EINA_INLIST_FOREACH(wd->blocks, itb)
859 itb->must_recalc = EINA_TRUE;
861 if (wd->calc_job) ecore_job_del(wd->calc_job);
862 wd->calc_job = ecore_job_add(_calc_job, wd);
865 if (wd->mode == ELM_LIST_LIMIT)
867 Evas_Coord vmw, vmh, vw, vh;
871 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
872 if ((minw > 0) && (vw < minw)) vw = minw;
873 else if ((maxw > 0) && (vw > maxw))
875 edje_object_size_min_calc
876 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
883 edje_object_size_min_calc
884 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
888 evas_object_size_hint_min_set(obj, minw, minh);
889 evas_object_size_hint_max_set(obj, maxw, maxh);
893 _item_hilight(Elm_Genlist_Item *it)
895 const char *selectraise;
896 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) || (it->disabled) || (it->display_only)) return;
897 if ((!it->sweeped) && (!it->wd->edit_mode))
898 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
899 selectraise = edje_object_data_get(it->base.view, "selectraise");
900 if ((selectraise) && (!strcmp(selectraise, "on")))
902 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
903 if ((it->group_item) && (it->group_item->realized))
904 evas_object_raise(it->group_item->base.view);
906 it->hilighted = EINA_TRUE;
910 _item_block_del(Elm_Genlist_Item *it)
913 Item_Block *itb = it->block;
915 itb->items = eina_list_remove(itb->items, it);
917 itb->changed = EINA_TRUE;
918 if (!it->wd->reorder_deleted)
920 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
921 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
925 il = EINA_INLIST_GET(itb);
926 Item_Block *itbn = (Item_Block *)(il->next);
928 it->parent->items = eina_list_remove(it->parent->items, it);
930 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
932 if (itbn) itbn->changed = EINA_TRUE;
936 if (itb->count < itb->wd->max_items_per_block/2)
938 il = EINA_INLIST_GET(itb);
939 Item_Block *itbp = (Item_Block *)(il->prev);
940 Item_Block *itbn = (Item_Block *)(il->next);
941 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
943 Elm_Genlist_Item *it2;
945 EINA_LIST_FREE(itb->items, it2)
948 itbp->items = eina_list_append(itbp->items, it2);
950 itbp->changed = EINA_TRUE;
952 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
953 EINA_INLIST_GET(itb));
956 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
960 Eina_List *last = eina_list_last(itb->items);
961 Elm_Genlist_Item *it2 = last->data;
964 itb->items = eina_list_remove_list(itb->items, last);
965 itbn->items = eina_list_prepend(itbn->items, it2);
967 itbn->changed = EINA_TRUE;
970 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
978 _item_subitems_clear(Elm_Genlist_Item *it)
981 Eina_List *tl = NULL, *l;
982 Elm_Genlist_Item *it2;
984 EINA_LIST_FOREACH(it->items, l, it2)
985 tl = eina_list_append(tl, it2);
987 EINA_LIST_FREE(tl, it2)
988 elm_genlist_item_del(it2);
992 _item_del(Elm_Genlist_Item *it)
994 elm_widget_item_pre_notify_del(it);
995 elm_genlist_item_subitems_clear(it);
996 it->wd->walking -= it->walking;
997 if (it->wd->show_item == it) it->wd->show_item = NULL;
998 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
999 if (it->realized) _item_unrealize(it);
1000 if (it->effect_item_realized) _effect_item_unrealize(it);
1001 if (it->block) _item_block_del(it);
1002 if ((!it->delete_me) && (it->itc->func.del))
1003 it->itc->func.del((void *)it->base.data, it->base.widget);
1004 it->delete_me = EINA_TRUE;
1006 it->wd->queue = eina_list_remove(it->wd->queue, it);
1008 if (it->wd->anchor_item == it)
1010 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1011 if (!it->wd->anchor_item)
1012 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1015 if (it->flags != ELM_GENLIST_ITEM_HEAD)
1016 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1018 it->parent->items = eina_list_remove(it->parent->items, it);
1019 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1020 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1021 if (it->long_timer) ecore_timer_del(it->long_timer);
1022 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1024 if (it->tooltip.del_cb)
1025 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1026 if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL;
1028 elm_widget_item_del(it);
1029 it->wd->total_num--; // todo : remove
1033 _item_select(Elm_Genlist_Item *it)
1035 if ((it->wd->no_select) || (it->delete_me)) return;
1038 if (it->wd->always_select) goto call;
1041 it->selected = EINA_TRUE;
1042 it->wd->selected = eina_list_append(it->wd->selected, it);
1046 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1048 evas_object_smart_callback_call(it->base.widget, "selected", it);
1051 if ((it->wd->clear_me) && (!it->wd->walking))
1053 elm_genlist_clear(it->base.widget);
1058 if ((!it->walking) && (it->delete_me))
1060 if (!it->relcount) _item_del(it);
1063 if (it && it->wd) it->wd->last_selected_item = it;
1067 _item_unselect(Elm_Genlist_Item *it)
1069 const char *stacking, *selectraise;
1071 if ((it->delete_me) || (!it->hilighted)) return;
1073 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1074 stacking = edje_object_data_get(it->base.view, "stacking");
1075 selectraise = edje_object_data_get(it->base.view, "selectraise");
1076 if ((selectraise) && (!strcmp(selectraise, "on")))
1078 if ((stacking) && (!strcmp(stacking, "below")))
1079 evas_object_lower(it->base.view);
1081 it->hilighted = EINA_FALSE;
1084 it->selected = EINA_FALSE;
1085 it->wd->selected = eina_list_remove(it->wd->selected, it);
1086 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1091 _mouse_move(void *data,
1092 Evas *evas __UNUSED__,
1096 Elm_Genlist_Item *it = data;
1097 Evas_Event_Mouse_Move *ev = event_info;
1098 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1100 if (it->renamed) return;
1101 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1103 if (!it->wd->on_hold)
1105 it->wd->on_hold = EINA_TRUE;
1106 if (!it->wd->wasselected)
1110 if (it->wd->multitouched)
1112 it->wd->cur_x = ev->cur.canvas.x;
1113 it->wd->cur_y = ev->cur.canvas.y;
1116 if ((it->dragging) && (it->down))
1118 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1121 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1122 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1123 if (abs((it->wd->history[it->wd->movements].x -
1124 it->wd->history[0].x)) > 40)
1125 it->wd->swipe = EINA_TRUE;
1127 it->wd->movements++;
1131 ecore_timer_del(it->long_timer);
1132 it->long_timer = NULL;
1134 evas_object_smart_callback_call(it->base.widget, "drag", it);
1137 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1141 ecore_timer_del(it->long_timer);
1142 it->long_timer = NULL;
1144 if (it->wd->reorder_mode && it->wd->reorder_it)
1146 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1147 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1148 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1149 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1151 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1152 if (it->wd->head_item)
1153 sel_all_h = it->wd->head_item->h;
1154 if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1155 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);
1156 else _effect_item_controls(it, it->scrl_x, it_y);
1158 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1159 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1163 if (!it->display_only)
1164 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1165 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1166 x = ev->cur.canvas.x - x;
1167 y = ev->cur.canvas.y - y;
1170 if (adx < 0) adx = -dx;
1173 if (ady < 0) ady = -dy;
1176 if ((adx > minw) || (ady > minh))
1178 it->dragging = EINA_TRUE;
1181 ecore_timer_del(it->long_timer);
1182 it->long_timer = NULL;
1184 if (!it->wd->wasselected)
1189 evas_object_smart_callback_call(it->base.widget,
1190 "drag,start,up", it);
1195 evas_object_smart_callback_call(it->base.widget,
1196 "drag,start,left", it);
1197 _item_slide(it, EINA_FALSE);
1201 evas_object_smart_callback_call(it->base.widget,
1202 "drag,start,right", it);
1203 _item_slide(it, EINA_TRUE);
1210 evas_object_smart_callback_call(it->base.widget,
1211 "drag,start,down", it);
1216 evas_object_smart_callback_call(it->base.widget,
1217 "drag,start,left", it);
1218 _item_slide(it, EINA_FALSE);
1222 evas_object_smart_callback_call(it->base.widget,
1223 "drag,start,right", it);
1224 _item_slide(it, EINA_TRUE);
1232 _long_press(void *data)
1234 Elm_Genlist_Item *it = data;
1235 Elm_Genlist_Item *it_tmp;
1236 static Eina_Bool done = EINA_FALSE;
1237 //static Eina_Bool contracted = EINA_FALSE;
1241 it->long_timer = NULL;
1242 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1243 return ECORE_CALLBACK_CANCEL;
1244 it->wd->longpressed = EINA_TRUE;
1245 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1246 if ((it->wd->reorder_mode) && (it != it->wd->head_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1248 it->wd->reorder_it = it;
1249 it->wd->reorder_start_y = 0;
1250 evas_object_raise(it->edit_obj);
1251 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1252 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1254 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1259 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1261 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1263 _item_unselect(it_tmp);
1275 EINA_LIST_FOREACH(it->items, l, it_tmp)
1277 if (elm_genlist_item_expanded_get(it_tmp))
1279 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1280 return ECORE_CALLBACK_RENEW;
1284 if (elm_genlist_item_expanded_get(it)) {
1285 elm_genlist_item_expanded_set(it, EINA_FALSE);
1286 return ECORE_CALLBACK_RENEW;
1290 return ECORE_CALLBACK_CANCEL;
1294 _swipe(Elm_Genlist_Item *it)
1299 it->wd->swipe = EINA_FALSE;
1300 for (i = 0; i < it->wd->movements; i++)
1302 sum += it->wd->history[i].x;
1303 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1306 sum /= it->wd->movements;
1307 if (abs(sum - it->wd->history[0].x) <= 10) return;
1308 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1312 _swipe_cancel(void *data)
1314 Elm_Genlist_Item *it = data;
1316 if (!it) return ECORE_CALLBACK_CANCEL;
1317 it->wd->swipe = EINA_FALSE;
1318 it->wd->movements = 0;
1319 return ECORE_CALLBACK_RENEW;
1323 _multi_cancel(void *data)
1325 Widget_Data *wd = data;
1327 if (!wd) return ECORE_CALLBACK_CANCEL;
1328 wd->multi_timeout = EINA_TRUE;
1329 return ECORE_CALLBACK_RENEW;
1333 _multi_touch_gesture_eval(void *data)
1335 Elm_Genlist_Item *it = data;
1337 it->wd->multitouched = EINA_FALSE;
1338 if (it->wd->multi_timer)
1340 ecore_timer_del(it->wd->multi_timer);
1341 it->wd->multi_timer = NULL;
1343 if (it->wd->multi_timeout)
1345 it->wd->multi_timeout = EINA_FALSE;
1349 Evas_Coord minw = 0, minh = 0;
1350 Evas_Coord off_x, off_y, off_mx, off_my;
1352 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1353 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1354 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1355 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1356 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1358 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1360 if ((off_x + off_mx) > (off_y + off_my))
1362 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1363 evas_object_smart_callback_call(it->base.widget,
1364 "multi,swipe,right", it);
1365 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1366 evas_object_smart_callback_call(it->base.widget,
1367 "multi,swipe,left", it);
1368 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1369 evas_object_smart_callback_call(it->base.widget,
1370 "multi,pinch,out", it);
1372 evas_object_smart_callback_call(it->base.widget,
1373 "multi,pinch,in", it);
1377 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1378 evas_object_smart_callback_call(it->base.widget,
1379 "multi,swipe,down", it);
1380 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1381 evas_object_smart_callback_call(it->base.widget,
1382 "multi,swipe,up", it);
1383 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1384 evas_object_smart_callback_call(it->base.widget,
1385 "multi,pinch,out", it);
1387 evas_object_smart_callback_call(it->base.widget,
1388 "multi,pinch,in", it);
1391 it->wd->multi_timeout = EINA_FALSE;
1395 _multi_down(void *data,
1396 Evas *evas __UNUSED__,
1397 Evas_Object *obj __UNUSED__,
1400 Elm_Genlist_Item *it = data;
1401 Evas_Event_Multi_Down *ev = event_info;
1403 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1404 it->wd->multi_device = ev->device;
1405 it->wd->multi_down = EINA_TRUE;
1406 it->wd->multitouched = EINA_TRUE;
1407 it->wd->prev_mx = ev->canvas.x;
1408 it->wd->prev_my = ev->canvas.y;
1409 if (!it->wd->wasselected) _item_unselect(it);
1410 it->wd->wasselected = EINA_FALSE;
1411 it->wd->longpressed = EINA_FALSE;
1414 ecore_timer_del(it->long_timer);
1415 it->long_timer = NULL;
1419 it->dragging = EINA_FALSE;
1420 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1422 if (it->swipe_timer)
1424 ecore_timer_del(it->swipe_timer);
1425 it->swipe_timer = NULL;
1427 if (it->wd->on_hold)
1429 it->wd->swipe = EINA_FALSE;
1430 it->wd->movements = 0;
1431 it->wd->on_hold = EINA_FALSE;
1436 _multi_up(void *data,
1437 Evas *evas __UNUSED__,
1438 Evas_Object *obj __UNUSED__,
1441 Elm_Genlist_Item *it = data;
1442 Evas_Event_Multi_Up *ev = event_info;
1444 if (it->wd->multi_device != ev->device) return;
1445 it->wd->multi_device = 0;
1446 it->wd->multi_down = EINA_FALSE;
1447 if (it->wd->mouse_down) return;
1448 _multi_touch_gesture_eval(data);
1452 _multi_move(void *data,
1453 Evas *evas __UNUSED__,
1454 Evas_Object *obj __UNUSED__,
1457 Elm_Genlist_Item *it = data;
1458 Evas_Event_Multi_Move *ev = event_info;
1460 if (it->wd->multi_device != ev->device) return;
1461 it->wd->cur_mx = ev->cur.canvas.x;
1462 it->wd->cur_my = ev->cur.canvas.y;
1466 _mouse_down(void *data,
1467 Evas *evas __UNUSED__,
1471 Elm_Genlist_Item *it = data;
1472 Evas_Event_Mouse_Down *ev = event_info;
1475 if (it->renamed) return;
1476 if (ev->button != 1) return;
1477 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1479 it->wd->on_hold = EINA_TRUE;
1481 if (it->wd->rename_it) elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1482 it->down = EINA_TRUE;
1483 it->dragging = EINA_FALSE;
1484 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1485 it->dx = ev->canvas.x - x;
1486 it->dy = ev->canvas.y - y;
1487 it->wd->mouse_down = EINA_TRUE;
1488 if (!it->wd->multitouched)
1490 it->wd->prev_x = ev->canvas.x;
1491 it->wd->prev_y = ev->canvas.y;
1492 it->wd->multi_timeout = EINA_FALSE;
1493 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1494 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1496 it->wd->longpressed = EINA_FALSE;
1497 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1498 else it->wd->on_hold = EINA_FALSE;
1499 if (it->wd->on_hold) return;
1500 it->wd->wasselected = it->selected;
1502 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1503 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1504 if (it->long_timer) ecore_timer_del(it->long_timer);
1505 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1506 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1508 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1511 it->long_timer = NULL;
1512 it->wd->swipe = EINA_FALSE;
1513 it->wd->movements = 0;
1517 _mouse_up(void *data,
1518 Evas *evas __UNUSED__,
1519 Evas_Object *obj __UNUSED__,
1522 Elm_Genlist_Item *it = data;
1523 Evas_Event_Mouse_Up *ev = event_info;
1524 Eina_Bool dragged = EINA_FALSE;
1526 if (it->renamed) return;
1527 if (ev->button != 1) return;
1528 it->down = EINA_FALSE;
1529 it->wd->mouse_down = EINA_FALSE;
1530 if (it->wd->multitouched)
1532 if (it->wd->multi_down) return;
1533 _multi_touch_gesture_eval(data);
1536 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1537 else it->wd->on_hold = EINA_FALSE;
1540 ecore_timer_del(it->long_timer);
1541 it->long_timer = NULL;
1545 it->dragging = EINA_FALSE;
1546 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1549 if (it->swipe_timer)
1551 ecore_timer_del(it->swipe_timer);
1552 it->swipe_timer = NULL;
1554 if (it->wd->multi_timer)
1556 ecore_timer_del(it->wd->multi_timer);
1557 it->wd->multi_timer = NULL;
1558 it->wd->multi_timeout = EINA_FALSE;
1560 if (it->wd->on_hold)
1562 if (it->wd->swipe) _swipe(data);
1563 it->wd->longpressed = EINA_FALSE;
1564 it->wd->on_hold = EINA_FALSE;
1567 if (it->wd->reorder_mode)
1569 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1570 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1573 Evas_Coord ox,oy,oh,ow;
1574 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1575 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1576 if (it->wd->head_item) sel_all_h = it->wd->head_item->h;
1577 if (it->wd->reorder_rel)
1579 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1581 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1582 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1584 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1587 it->wd->reorder_deleted = EINA_FALSE;
1588 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1589 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1590 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1593 if (it->wd->longpressed)
1595 it->wd->longpressed = EINA_FALSE;
1596 if (!it->wd->wasselected)
1598 it->wd->wasselected = EINA_FALSE;
1603 if (it->want_unrealize)
1605 _item_unrealize(it);
1606 if (it->block->want_unrealize)
1607 _item_block_unrealize(it->block);
1610 if ((it->disabled) || (dragged) || (it->display_only)) return;
1611 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1614 if ((!it->selected) && (!it->sweeped))
1619 else _item_unselect(it);
1625 Widget_Data *wd = it->wd;
1628 while (wd->selected) _item_unselect(wd->selected->data);
1633 const Eina_List *l, *l_next;
1634 Elm_Genlist_Item *it2;
1636 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1637 if (it2 != it) _item_unselect(it2);
1638 //_item_hilight(it);
1650 _signal_expand_toggle(void *data,
1651 Evas_Object *obj __UNUSED__,
1652 const char *emission __UNUSED__,
1653 const char *source __UNUSED__)
1655 Elm_Genlist_Item *it = data;
1658 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1660 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1664 _signal_expand(void *data,
1665 Evas_Object *obj __UNUSED__,
1666 const char *emission __UNUSED__,
1667 const char *source __UNUSED__)
1669 Elm_Genlist_Item *it = data;
1672 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1676 _signal_contract(void *data,
1677 Evas_Object *obj __UNUSED__,
1678 const char *emission __UNUSED__,
1679 const char *source __UNUSED__)
1681 Elm_Genlist_Item *it = data;
1684 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1688 _item_cache_clean(Widget_Data *wd)
1690 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1694 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1695 wd->item_cache = eina_inlist_remove(wd->item_cache,
1696 wd->item_cache->last);
1697 wd->item_cache_count--;
1698 if (itc->spacer) evas_object_del(itc->spacer);
1699 if (itc->base_view) evas_object_del(itc->base_view);
1700 if (itc->item_style) eina_stringshare_del(itc->item_style);
1706 _item_cache_zero(Widget_Data *wd)
1708 int pmax = wd->item_cache_max;
1709 wd->item_cache_max = 0;
1710 _item_cache_clean(wd);
1711 wd->item_cache_max = pmax;
1715 _item_cache_add(Elm_Genlist_Item *it)
1719 if (it->wd->item_cache_max <= 0)
1721 evas_object_del(it->base.view);
1722 it->base.view = NULL;
1723 evas_object_del(it->spacer);
1728 it->wd->item_cache_count++;
1729 itc = calloc(1, sizeof(Item_Cache));
1731 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1732 EINA_INLIST_GET(itc));
1733 itc->spacer = it->spacer;
1735 itc->base_view = it->base.view;
1736 it->base.view = NULL;
1737 evas_object_hide(itc->base_view);
1738 evas_object_move(itc->base_view, -9999, -9999);
1739 itc->item_style = eina_stringshare_add(it->itc->item_style);
1740 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1741 itc->compress = (it->wd->compress);
1742 itc->odd = (it->order_num_in & 0x1);
1743 itc->selected = it->selected;
1744 itc->disabled = it->disabled;
1745 itc->expanded = it->expanded;
1748 ecore_timer_del(it->long_timer);
1749 it->long_timer = NULL;
1751 if (it->swipe_timer)
1753 ecore_timer_del(it->swipe_timer);
1754 it->swipe_timer = NULL;
1756 // FIXME: other callbacks?
1757 edje_object_signal_callback_del_full(itc->base_view,
1758 "elm,action,expand,toggle",
1759 "elm", _signal_expand_toggle, it);
1760 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1762 _signal_expand, it);
1763 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1764 "elm", _signal_contract, it);
1765 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1767 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1769 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1771 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1773 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1775 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1777 _item_cache_clean(it->wd);
1781 _item_cache_find(Elm_Genlist_Item *it)
1784 Eina_Bool tree = 0, odd;
1786 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1787 odd = (it->order_num_in & 0x1);
1788 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1790 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1792 if ((itc->tree == tree) &&
1793 (itc->odd == odd) &&
1794 (itc->compress == it->wd->compress) &&
1795 (!strcmp(it->itc->item_style, itc->item_style)))
1797 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1798 EINA_INLIST_GET(itc));
1799 it->wd->item_cache_count--;
1807 _item_cache_free(Item_Cache *itc)
1809 if (itc->spacer) evas_object_del(itc->spacer);
1810 if (itc->base_view) evas_object_del(itc->base_view);
1811 if (itc->item_style) eina_stringshare_del(itc->item_style);
1816 _item_realize(Elm_Genlist_Item *it,
1820 Elm_Genlist_Item *it2;
1821 const char *stacking;
1822 const char *treesize;
1824 int depth, tsize = 20;
1825 Item_Cache *itc = NULL;
1827 if ((it->realized) || (it->delete_me)) return;
1828 it->order_num_in = in;
1829 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1831 it->nocache = EINA_FALSE;
1833 itc = _item_cache_find(it);
1834 if ((!it->wd->effect_mode) && (itc))
1836 it->base.view = itc->base_view;
1837 itc->base_view = NULL;
1838 it->spacer = itc->spacer;
1843 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1844 edje_object_scale_set(it->base.view,
1845 elm_widget_scale_get(it->base.widget) *
1846 _elm_config->scale);
1847 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1848 elm_widget_sub_object_add(it->base.widget, it->base.view);
1850 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1851 strncpy(buf, "tree", sizeof(buf));
1852 else strncpy(buf, "item", sizeof(buf));
1853 if (it->wd->compress)
1854 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1856 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1857 strncat(buf, "/", sizeof(buf) - strlen(buf));
1858 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1860 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1861 elm_widget_style_get(it->base.widget));
1863 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1864 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1865 elm_widget_sub_object_add(it->base.widget, it->spacer);
1867 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1869 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1871 it->expanded_depth = depth;
1872 treesize = edje_object_data_get(it->base.view, "treesize");
1873 if (treesize) tsize = atoi(treesize);
1874 evas_object_size_hint_min_set(it->spacer,
1875 (depth * tsize) * _elm_config->scale, 1);
1876 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1879 edje_object_signal_callback_add(it->base.view,
1880 "elm,action,expand,toggle",
1881 "elm", _signal_expand_toggle, it);
1882 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1883 "elm", _signal_expand, it);
1884 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1885 "elm", _signal_contract, it);
1886 stacking = edje_object_data_get(it->base.view, "stacking");
1889 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1890 else if (!strcmp(stacking, "above"))
1891 evas_object_raise(it->base.view);
1893 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1895 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1897 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1899 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1901 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1903 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1907 if (it->selected != itc->selected)
1909 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1910 edje_object_signal_emit(it->base.view,
1911 "elm,state,selected", "elm");
1913 if (it->disabled != itc->disabled)
1916 edje_object_signal_emit(it->base.view,
1917 "elm,state,disabled", "elm");
1919 if (it->expanded != itc->expanded)
1922 edje_object_signal_emit(it->base.view,
1923 "elm,state,expanded", "elm");
1928 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1929 edje_object_signal_emit(it->base.view,
1930 "elm,state,selected", "elm");
1932 edje_object_signal_emit(it->base.view,
1933 "elm,state,disabled", "elm");
1935 edje_object_signal_emit(it->base.view,
1936 "elm,state,expanded", "elm");
1940 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1942 /* homogenous genlist shortcut */
1943 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1945 it->w = it->minw = it->wd->group_item_width;
1946 it->h = it->minh = it->wd->group_item_height;
1947 it->mincalcd = EINA_TRUE;
1949 else if (!it->mincalcd)
1951 it->w = it->minw = it->wd->item_width;
1952 it->h = it->minh = it->wd->item_height;
1953 it->mincalcd = EINA_TRUE;
1958 if (it->itc->func.label_get)
1964 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1966 EINA_LIST_FOREACH(it->labels, l, key)
1968 char *s = it->itc->func.label_get
1969 ((void *)it->base.data, it->base.widget, l->data);
1973 edje_object_part_text_set(it->base.view, l->data, s);
1977 edje_object_part_text_set(it->base.view, l->data, "");
1980 if (it->itc->func.icon_get)
1986 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1988 EINA_LIST_FOREACH(it->icons, l, key)
1990 Evas_Object *ic = it->itc->func.icon_get
1991 ((void *)it->base.data, it->base.widget, l->data);
1995 it->icon_objs = eina_list_append(it->icon_objs, ic);
1996 edje_object_part_swallow(it->base.view, key, ic);
1997 evas_object_show(ic);
1998 elm_widget_sub_object_add(it->base.widget, ic);
1999 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2002 if (it->wd->rename_it && it->renamed)
2005 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2006 EINA_LIST_FOREACH(it->icons, l, key)
2008 Evas_Object *ic = it->itc->func.icon_get
2009 ((void *)it->base.data, it->base.widget, l->data);
2012 it->icon_objs = eina_list_append(it->icon_objs, ic);
2013 edje_object_part_swallow(it->base.view, key, ic);
2014 evas_object_show(ic);
2015 elm_widget_sub_object_add(it->base.widget, ic);
2020 if (it->itc->func.state_get)
2026 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2028 EINA_LIST_FOREACH(it->states, l, key)
2030 Eina_Bool on = it->itc->func.state_get
2031 ((void *)it->base.data, it->base.widget, l->data);
2035 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2036 edje_object_signal_emit(it->base.view, buf, "elm");
2040 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2041 edje_object_signal_emit(it->base.view, buf, "elm");
2046 _create_sweep_objs(it);
2049 Evas_Coord mw = -1, mh = -1;
2051 if (it->wd->height_for_width) mw = it->wd->w;
2053 if (!it->display_only)
2054 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2055 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2056 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2058 if (!it->display_only)
2059 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2060 it->w = it->minw = mw;
2061 it->h = it->minh = mh;
2062 it->mincalcd = EINA_TRUE;
2064 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2066 it->wd->group_item_width = mw;
2067 it->wd->group_item_height = mh;
2069 else if ((it->wd->homogeneous))
2070 // if ((!in) && (it->wd->homogeneous))
2072 it->wd->item_width = mw;
2073 it->wd->item_height = mh;
2075 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2077 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2079 it->wd->group_item_width = mw;
2080 it->wd->group_item_height = mh;
2084 if (!calc) evas_object_show(it->base.view);
2087 if (it->tooltip.content_cb)
2089 elm_widget_item_tooltip_content_cb_set(it,
2090 it->tooltip.content_cb,
2091 it->tooltip.data, NULL);
2092 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2095 if (it->mouse_cursor)
2096 elm_widget_item_cursor_set(it, it->mouse_cursor);
2098 it->realized = EINA_TRUE;
2099 it->want_unrealize = EINA_FALSE;
2101 if (itc) _item_cache_free(itc);
2102 evas_object_smart_callback_call(it->base.widget, "realized", it);
2103 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->flags != ELM_GENLIST_ITEM_HEAD))
2105 if (it->itc->edit_item_style )
2107 _effect_item_realize(it, EINA_FALSE);
2108 edje_object_message_signal_process(it->edit_obj);
2114 _item_unrealize(Elm_Genlist_Item *it)
2118 if (!it->realized) return;
2119 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2120 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2123 ecore_timer_del(it->long_timer);
2124 it->long_timer = NULL;
2126 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2128 it->sweeped = EINA_FALSE;
2129 it->wassweeped = EINA_FALSE;
2130 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2131 _delete_sweep_objs(it);
2132 evas_object_del(it->base.view);
2133 it->base.view = NULL;
2134 evas_object_del(it->spacer);
2138 _item_cache_add(it);
2139 elm_widget_stringlist_free(it->labels);
2141 elm_widget_stringlist_free(it->icons);
2143 elm_widget_stringlist_free(it->states);
2145 EINA_LIST_FREE(it->icon_objs, icon)
2146 evas_object_del(icon);
2149 it->realized = EINA_FALSE;
2150 it->want_unrealize = EINA_FALSE;
2151 if (it->wd->edit_mode) _effect_item_unrealize(it);
2155 _item_block_recalc(Item_Block *itb,
2161 Elm_Genlist_Item *it;
2162 Evas_Coord minw = 0, minh = 0;
2163 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2167 EINA_LIST_FOREACH(itb->items, l, it)
2169 if (it->delete_me) continue;
2170 showme |= it->showme;
2175 if (!it->mincalcd) changed = EINA_TRUE;
2178 _item_realize(it, in, 1);
2179 _item_unrealize(it);
2184 _item_realize(it, in, 1);
2185 if (!it->wd->contracting) _item_unrealize(it);
2189 _item_realize(it, in, 0);
2191 if (minw < it->minw) minw = it->minw;
2199 itb->changed = EINA_FALSE;
2200 /* force an evas norender to garbage collect deleted objects */
2201 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2206 _item_block_realize(Item_Block *itb,
2211 Elm_Genlist_Item *it;
2213 if (itb->realized) return;
2214 EINA_LIST_FOREACH(itb->items, l, it)
2216 if (it->delete_me) continue;
2217 if (full) _item_realize(it, in, 0);
2220 itb->realized = EINA_TRUE;
2221 itb->want_unrealize = EINA_FALSE;
2225 _item_block_unrealize(Item_Block *itb)
2228 Elm_Genlist_Item *it;
2229 Eina_Bool dragging = EINA_FALSE;
2231 if (!itb->realized) return;
2232 EINA_LIST_FOREACH(itb->items, l, it)
2234 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2238 dragging = EINA_TRUE;
2239 it->want_unrealize = EINA_TRUE;
2242 if (!it->wd->contracting) _item_unrealize(it);
2247 itb->realized = EINA_FALSE;
2248 itb->want_unrealize = EINA_TRUE;
2251 itb->want_unrealize = EINA_FALSE;
2255 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2257 Evas_Coord rox, roy, row, roh;
2258 Eina_Bool top = EINA_FALSE;
2259 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2260 if (!reorder_it) return 0;
2262 Evas_Coord ox,oy,oh,ow;
2263 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2264 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2266 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2268 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2269 if (it->block->count == 1)
2270 it->wd->reorder_rel = it;
2272 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2274 it->block->reorder_offset = it->wd->reorder_it->h;
2277 it->block->reorder_offset = 0;
2279 it->scrl_y += it->block->reorder_offset;
2281 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2282 rox, roy+roh/2, row, 1));
2285 it->wd->reorder_rel = it;
2286 it->scrl_y+=it->wd->reorder_it->h;
2287 return it->wd->reorder_it->h;
2294 _reorder_item_moving_effect_timer_cb(void *data)
2296 Elm_Genlist_Item *it = data;
2297 Eina_Bool down = EINA_FALSE;
2298 double time = 0.4, t;
2300 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2303 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2307 if (it->old_scrl_y < it->scrl_y)
2309 it->old_scrl_y += y;
2312 else if (it->old_scrl_y > it->scrl_y)
2314 it->old_scrl_y -= y;
2318 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2320 _group_items_recalc(it->wd);
2321 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2323 it->old_scrl_y = it->scrl_y;
2324 it->move_effect_me = EINA_FALSE;
2325 it->wd->item_moving_effect_timer = NULL;
2326 return ECORE_CALLBACK_CANCEL;
2328 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2330 it->old_scrl_y = it->scrl_y;
2331 it->move_effect_me = EINA_FALSE;
2332 it->wd->item_moving_effect_timer = NULL;
2333 return ECORE_CALLBACK_CANCEL;
2335 return ECORE_CALLBACK_RENEW;
2339 _item_block_position(Item_Block *itb,
2343 Elm_Genlist_Item *it;
2344 Elm_Genlist_Item *git;
2345 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2348 Elm_Genlist_Item *head_item = itb->wd->head_item;
2350 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2351 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2356 if (!head_item->realized)
2358 _item_realize(head_item, 0, 0);
2359 itb->wd->minh += itb->wd->head_item->h;
2361 evas_object_resize(head_item->base.view, itb->w, head_item->h);
2362 evas_object_move(head_item->base.view, ox, oy);
2363 evas_object_raise(head_item->base.view);
2366 sel_all_h = head_item->h;
2368 EINA_LIST_FOREACH(itb->items, l, it)
2370 if (it->delete_me) continue;
2371 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2376 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2377 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2379 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2380 cvx, cvy, cvw, cvh));
2381 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2383 if ((itb->realized) && (!it->realized))
2387 _item_realize(it, in, 0);
2390 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2391 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2399 if(it->wd->reorder_mode)
2400 y += _get_space_for_reorder_item(it);
2401 git = it->group_item;
2404 git->scrl_x = it->scrl_x;
2405 if (git->scrl_y < oy + sel_all_h)
2406 git->scrl_y = oy + sel_all_h;
2407 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2408 git->scrl_y = (it->scrl_y + it->h) - git->h;
2409 git->want_realize = EINA_TRUE;
2411 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2413 if (!it->move_effect_me)
2415 it->move_effect_me = EINA_TRUE;
2416 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2420 if (!it->move_effect_me )
2421 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))
2423 if (it->wd->edit_mode && it->itc->edit_item_style)
2425 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2429 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2430 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2431 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)))
2432 evas_object_show(it->base.view);
2434 evas_object_hide(it->base.view);
2436 it->old_scrl_x = it->scrl_x;
2437 it->old_scrl_y = it->scrl_y;
2442 if (!it->dragging) _item_unrealize(it);
2449 if (vis) it->want_realize = EINA_TRUE;
2456 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2458 Elm_Genlist_Item *it = data;
2460 it->mincalcd = EINA_FALSE;
2461 it->block->updateme = EINA_TRUE;
2462 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2463 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2467 _group_items_recalc(void *data)
2469 Widget_Data *wd = data;
2471 Elm_Genlist_Item *git;
2473 EINA_LIST_FOREACH(wd->group_items, l, git)
2475 if (git->want_realize)
2478 _item_realize(git, 0, 0);
2479 evas_object_resize(git->base.view, wd->minw, git->h);
2480 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2481 evas_object_show(git->base.view);
2482 evas_object_raise(git->base.view);
2484 else if (!git->want_realize && git->realized)
2487 _item_unrealize(git);
2493 _must_recalc_idler(void *data)
2495 Widget_Data *wd = data;
2496 if (wd->calc_job) ecore_job_del(wd->calc_job);
2497 wd->calc_job = ecore_job_add(_calc_job, wd);
2498 wd->must_recalc_idler = NULL;
2499 return ECORE_CALLBACK_CANCEL;
2503 _calc_job(void *data)
2505 Widget_Data *wd = data;
2507 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2508 Item_Block *chb = NULL;
2509 int in = 0, minw_change = 0;
2510 Eina_Bool changed = EINA_FALSE;
2512 Eina_Bool did_must_recalc = EINA_FALSE;
2515 t0 = ecore_time_get();
2516 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2520 // if (wd->height_for_width) changed = EINA_TRUE;
2523 EINA_INLIST_FOREACH(wd->blocks, itb)
2525 Eina_Bool showme = EINA_FALSE;
2528 showme = itb->showme;
2529 itb->showme = EINA_FALSE;
2532 if (itb->realized) _item_block_unrealize(itb);
2534 if ((itb->changed) || (changed) ||
2535 ((itb->must_recalc) && (!did_must_recalc)))
2537 if ((changed) || (itb->must_recalc))
2540 Elm_Genlist_Item *it;
2541 EINA_LIST_FOREACH(itb->items, l, it)
2542 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2543 itb->changed = EINA_TRUE;
2544 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2545 itb->must_recalc = EINA_FALSE;
2547 if (itb->realized) _item_block_unrealize(itb);
2548 showme = _item_block_recalc(itb, in, 0, 1);
2554 if (minw == -1) minw = itb->minw;
2555 else if ((!itb->must_recalc) && (minw < itb->minw))
2564 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2566 wd->show_item->showme = EINA_FALSE;
2568 elm_smart_scroller_region_bring_in(wd->scr,
2570 wd->show_item->block->x,
2572 wd->show_item->block->y,
2573 wd->show_item->block->w,
2576 elm_smart_scroller_child_region_show(wd->scr,
2578 wd->show_item->block->x,
2580 wd->show_item->block->y,
2581 wd->show_item->block->w,
2583 wd->show_item = NULL;
2588 EINA_INLIST_FOREACH(wd->blocks, itb)
2594 if ((chb) && (EINA_INLIST_GET(chb)->next))
2596 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2598 if (itb->realized) _item_block_unrealize(itb);
2601 wd->realminw = minw;
2602 if (minw < wd->w) minw = wd->w;
2603 if ((minw != wd->minw) || (minh != wd->minh) || (wd->head_item))
2607 if (wd->head_item) wd->minh += wd->head_item->h;
2608 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2609 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2610 _sizing_eval(wd->obj);
2612 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2614 Elm_Genlist_Item *it;
2617 it = wd->anchor_item;
2618 it_y = wd->anchor_y;
2619 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2620 it->block->y + it->y + it_y);
2621 wd->anchor_item = it;
2622 wd->anchor_y = it_y;
2626 t = ecore_time_get();
2627 if (did_must_recalc)
2629 if (!wd->must_recalc_idler)
2630 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2632 wd->calc_job = NULL;
2633 evas_object_smart_changed(wd->pan_smart);
2637 _update_job(void *data)
2639 Widget_Data *wd = data;
2642 int num, num0, position = 0, recalc = 0;
2644 wd->update_job = NULL;
2648 _item_unrealize(wd->head_item);
2649 _item_realize(wd->head_item, 0, 0);
2650 position = EINA_TRUE;
2652 EINA_INLIST_FOREACH(wd->blocks, itb)
2654 Evas_Coord itminw, itminh;
2655 Elm_Genlist_Item *it;
2661 _item_block_position(itb, num);
2666 EINA_LIST_FOREACH(itb->items, l2, it)
2673 it->updateme = EINA_FALSE;
2676 _item_unrealize(it);
2677 _item_realize(it, num, 0);
2682 _item_realize(it, num, 1);
2683 _item_unrealize(it);
2685 if ((it->minw != itminw) || (it->minh != itminh))
2690 itb->updateme = EINA_FALSE;
2694 itb->changed = EINA_TRUE;
2695 _item_block_recalc(itb, num0, 0, 1);
2696 _item_block_position(itb, num0);
2701 if (wd->calc_job) ecore_job_del(wd->calc_job);
2702 wd->calc_job = ecore_job_add(_calc_job, wd);
2707 _changed_job(void *data)
2709 Widget_Data *wd = data; Eina_List *l2;
2711 int num, num0, position = 0, recalc = 0;
2713 wd->changed_job = NULL;
2715 EINA_INLIST_FOREACH(wd->blocks, itb)
2717 Evas_Coord itminw, itminh;
2718 Elm_Genlist_Item *it;
2724 _item_block_position(itb, num);
2729 EINA_LIST_FOREACH(itb->items, l2, it)
2733 Evas_Coord mw = -1, mh = -1;
2737 if (it->wd->height_for_width) mw = it->wd->w;
2738 if (!it->display_only)
2739 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2740 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2741 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2742 if (!it->display_only)
2743 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2744 it->w = it->minw = mw;
2745 it->h = it->minh = mh;
2746 it->mincalcd = EINA_TRUE;
2748 //if ((it->minw != itminw) || (it->minh != itminh))
2749 if ((it->minh != itminh))
2754 itb->updateme = EINA_FALSE;
2758 itb->changed = EINA_TRUE;
2759 _item_block_recalc(itb, num0, 0, 1);
2760 _item_block_position(itb, num0);
2765 if (wd->calc_job) ecore_job_del(wd->calc_job);
2766 wd->calc_job = ecore_job_add(_calc_job, wd);
2771 _pan_set(Evas_Object *obj,
2775 Pan *sd = evas_object_smart_data_get(obj);
2778 // Evas_Coord ow, oh;
2779 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2780 // ow = sd->wd->minw - ow;
2781 // if (ow < 0) ow = 0;
2782 // oh = sd->wd->minh - oh;
2783 // if (oh < 0) oh = 0;
2784 // if (x < 0) x = 0;
2785 // if (y < 0) y = 0;
2786 // if (x > ow) x = ow;
2787 // if (y > oh) y = oh;
2788 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2793 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2795 if ((itb->y + itb->h) > y)
2797 Elm_Genlist_Item *it;
2800 EINA_LIST_FOREACH(itb->items, l2, it)
2802 if ((itb->y + it->y) >= y)
2804 sd->wd->anchor_item = it;
2805 sd->wd->anchor_y = -(itb->y + it->y - y);
2813 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2817 _pan_get(Evas_Object *obj,
2821 Pan *sd = evas_object_smart_data_get(obj);
2823 if (x) *x = sd->wd->pan_x;
2824 if (y) *y = sd->wd->pan_y;
2828 _pan_max_get(Evas_Object *obj,
2832 Pan *sd = evas_object_smart_data_get(obj);
2835 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2836 ow = sd->wd->minw - ow;
2838 oh = sd->wd->minh - oh;
2845 _pan_min_get(Evas_Object *obj __UNUSED__,
2854 _pan_child_size_get(Evas_Object *obj,
2858 Pan *sd = evas_object_smart_data_get(obj);
2860 if (w) *w = sd->wd->minw;
2861 if (h) *h = sd->wd->minh;
2865 _pan_add(Evas_Object *obj)
2868 Evas_Object_Smart_Clipped_Data *cd;
2871 cd = evas_object_smart_data_get(obj);
2874 sd->__clipped_data = *cd;
2876 evas_object_smart_data_set(obj, sd);
2880 _pan_del(Evas_Object *obj)
2882 Pan *sd = evas_object_smart_data_get(obj);
2887 ecore_job_del(sd->resize_job);
2888 sd->resize_job = NULL;
2894 _pan_resize_job(void *data)
2897 _sizing_eval(sd->wd->obj);
2898 sd->resize_job = NULL;
2902 _pan_resize(Evas_Object *obj,
2906 Pan *sd = evas_object_smart_data_get(obj);
2909 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2910 if ((ow == w) && (oh == h)) return;
2911 if ((sd->wd->height_for_width) && (ow != w))
2913 if (sd->resize_job) ecore_job_del(sd->resize_job);
2914 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2916 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2917 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2921 _pan_calculate(Evas_Object *obj)
2923 Pan *sd = evas_object_smart_data_get(obj);
2925 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2926 static Evas_Coord old_pan_y = 0;
2928 Elm_Genlist_Item *git;
2931 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2932 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2933 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2935 git->want_realize = EINA_FALSE;
2937 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2939 itb->w = sd->wd->minw;
2940 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2941 itb->y - sd->wd->pan_y + oy,
2943 cvx, cvy, cvw, cvh))
2945 if ((!itb->realized) || (itb->changed))
2946 _item_block_realize(itb, in, 0);
2947 _item_block_position(itb, in);
2951 if (itb->realized) _item_block_unrealize(itb);
2955 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2956 _group_items_recalc(sd->wd);
2958 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2960 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2961 else sd->wd->reorder_pan_move = EINA_FALSE;
2962 evas_object_raise(sd->wd->reorder_it->edit_obj);
2963 old_pan_y = sd->wd->pan_y;
2966 if (sd->wd->effect_mode &&
2967 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2968 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2969 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2971 if (!sd->wd->item_moving_effect_timer)
2973 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2974 _item_flip_effect_show(sd->wd->expand_item);
2976 evas_object_raise(sd->wd->alpha_bg);
2977 evas_object_show(sd->wd->alpha_bg);
2978 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2979 sd->wd->start_time = current_time_get();
2980 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2983 else _item_auto_scroll(sd->wd);
2984 if (sd->wd->head_item) evas_object_raise(sd->wd->head_item->base.view);
2985 sd->wd->contracting = EINA_FALSE;
2989 _pan_move(Evas_Object *obj,
2990 Evas_Coord x __UNUSED__,
2991 Evas_Coord y __UNUSED__)
2993 Pan *sd = evas_object_smart_data_get(obj);
2995 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2996 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3000 _hold_on(void *data __UNUSED__,
3002 void *event_info __UNUSED__)
3004 Widget_Data *wd = elm_widget_data_get(obj);
3006 elm_smart_scroller_hold_set(wd->scr, 1);
3010 _hold_off(void *data __UNUSED__,
3012 void *event_info __UNUSED__)
3014 Widget_Data *wd = elm_widget_data_get(obj);
3016 elm_smart_scroller_hold_set(wd->scr, 0);
3020 _freeze_on(void *data __UNUSED__,
3022 void *event_info __UNUSED__)
3024 Widget_Data *wd = elm_widget_data_get(obj);
3026 elm_smart_scroller_freeze_set(wd->scr, 1);
3030 _freeze_off(void *data __UNUSED__,
3032 void *event_info __UNUSED__)
3034 Widget_Data *wd = elm_widget_data_get(obj);
3036 elm_smart_scroller_freeze_set(wd->scr, 0);
3040 _scroll_edge_left(void *data,
3041 Evas_Object *scr __UNUSED__,
3042 void *event_info __UNUSED__)
3044 Evas_Object *obj = data;
3045 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3049 _scroll_edge_right(void *data,
3050 Evas_Object *scr __UNUSED__,
3051 void *event_info __UNUSED__)
3053 Evas_Object *obj = data;
3054 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3058 _scroll_edge_top(void *data,
3059 Evas_Object *scr __UNUSED__,
3060 void *event_info __UNUSED__)
3062 Evas_Object *obj = data;
3063 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3067 _scroll_edge_bottom(void *data,
3068 Evas_Object *scr __UNUSED__,
3069 void *event_info __UNUSED__)
3071 Evas_Object *obj = data;
3072 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3076 * Add a new Genlist object
3078 * @param parent The parent object
3079 * @return The new object or NULL if it cannot be created
3084 elm_genlist_add(Evas_Object *parent)
3089 Evas_Coord minw, minh;
3090 static Evas_Smart *smart = NULL;
3092 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3096 static Evas_Smart_Class sc;
3098 evas_object_smart_clipped_smart_set(&_pan_sc);
3100 sc.name = "elm_genlist_pan";
3101 sc.version = EVAS_SMART_CLASS_VERSION;
3104 sc.resize = _pan_resize;
3105 sc.move = _pan_move;
3106 sc.calculate = _pan_calculate;
3107 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3109 wd = ELM_NEW(Widget_Data);
3110 e = evas_object_evas_get(parent);
3111 if (!e) return NULL;
3112 obj = elm_widget_add(e);
3113 ELM_SET_WIDTYPE(widtype, "genlist");
3114 elm_widget_type_set(obj, "genlist");
3115 elm_widget_sub_object_add(parent, obj);
3116 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3117 elm_widget_data_set(obj, wd);
3118 elm_widget_del_hook_set(obj, _del_hook);
3119 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3120 elm_widget_theme_hook_set(obj, _theme_hook);
3121 elm_widget_can_focus_set(obj, EINA_TRUE);
3122 elm_widget_event_hook_set(obj, _event_hook);
3123 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3125 wd->scr = elm_smart_scroller_add(e);
3126 elm_smart_scroller_widget_set(wd->scr, obj);
3127 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3128 elm_widget_style_get(obj));
3129 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3130 _elm_config->thumbscroll_bounce_enable);
3131 elm_widget_resize_object_set(obj, wd->scr);
3133 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3134 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3136 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3137 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3141 wd->mode = ELM_LIST_SCROLL;
3142 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3143 wd->item_cache_max = wd->max_items_per_block * 2;
3144 wd->longpress_timeout = _elm_config->longpress_timeout;
3145 //wd->effect_mode = _elm_config->effect_enable;
3146 // wd->effect_mode = EINA_TRUE;
3148 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3149 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3150 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3151 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3153 wd->pan_smart = evas_object_smart_add(e, smart);
3154 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3157 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3158 _pan_set, _pan_get, _pan_max_get,
3159 _pan_min_get, _pan_child_size_get);
3161 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3163 evas_object_size_hint_min_set(obj, minw, minh);
3169 static Elm_Genlist_Item *
3170 _item_new(Widget_Data *wd,
3171 const Elm_Genlist_Item_Class *itc,
3173 Elm_Genlist_Item *parent,
3174 Elm_Genlist_Item_Flags flags,
3176 const void *func_data)
3178 Elm_Genlist_Item *it;
3180 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3181 if (!it) return NULL;
3184 it->base.data = data;
3185 it->parent = parent;
3187 it->func.func = func;
3188 it->func.data = func_data;
3189 it->mouse_cursor = NULL;
3190 it->expanded_depth = 0;
3191 it->num = ++wd->total_num; // todo : remov
3196 _item_block_add(Widget_Data *wd,
3197 Elm_Genlist_Item *it)
3199 Item_Block *itb = NULL;
3206 itb = calloc(1, sizeof(Item_Block));
3209 if (!it->rel->block)
3212 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3213 itb->items = eina_list_append(itb->items, it);
3219 wd->blocks = eina_inlist_prepend_relative
3220 (wd->blocks, EINA_INLIST_GET(itb),
3221 EINA_INLIST_GET(it->rel->block));
3223 eina_list_prepend_relative(itb->items, it, it->rel);
3227 wd->blocks = eina_inlist_append_relative
3228 (wd->blocks, EINA_INLIST_GET(itb),
3229 EINA_INLIST_GET(it->rel->block));
3231 eina_list_append_relative(itb->items, it, it->rel);
3241 itb = (Item_Block *)(wd->blocks);
3242 if (itb->count >= wd->max_items_per_block)
3244 itb = calloc(1, sizeof(Item_Block));
3248 eina_inlist_prepend(wd->blocks,
3249 EINA_INLIST_GET(itb));
3254 itb = calloc(1, sizeof(Item_Block));
3258 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3260 itb->items = eina_list_prepend(itb->items, it);
3266 itb = (Item_Block *)(wd->blocks->last);
3267 if (itb->count >= wd->max_items_per_block)
3269 itb = calloc(1, sizeof(Item_Block));
3273 eina_inlist_append(wd->blocks,
3274 EINA_INLIST_GET(itb));
3279 itb = calloc(1, sizeof(Item_Block));
3283 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3285 itb->items = eina_list_append(itb->items, it);
3291 itb = it->rel->block;
3292 if (!itb) goto newblock;
3294 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3296 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3299 itb->changed = EINA_TRUE;
3301 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3302 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3305 it->rel->relcount--;
3306 if ((it->rel->delete_me) && (!it->rel->relcount))
3310 if (itb->count > itb->wd->max_items_per_block)
3314 Elm_Genlist_Item *it2;
3316 newc = itb->count / 2;
3317 itb2 = calloc(1, sizeof(Item_Block));
3321 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3322 EINA_INLIST_GET(itb));
3323 itb2->changed = EINA_TRUE;
3324 while ((itb->count > newc) && (itb->items))
3328 l = eina_list_last(itb->items);
3330 itb->items = eina_list_remove_list(itb->items, l);
3333 itb2->items = eina_list_prepend(itb2->items, it2);
3341 _queue_proecess(Widget_Data *wd,
3345 Eina_Bool showme = EINA_FALSE;
3348 t0 = ecore_time_get();
3349 for (n = 0; (wd->queue) && (n < 128); n++)
3351 Elm_Genlist_Item *it;
3353 it = wd->queue->data;
3354 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3355 it->queued = EINA_FALSE;
3356 _item_block_add(wd, it);
3357 t = ecore_time_get();
3358 if (it->block->changed)
3360 showme = _item_block_recalc(it->block, it->block->num, 1,
3362 it->block->changed = 0;
3364 if (showme) it->block->showme = EINA_TRUE;
3365 if (eina_inlist_count(wd->blocks) > 1)
3367 if ((t - t0) > (ecore_animator_frametime_get())) break;
3374 _item_idler(void *data)
3376 Widget_Data *wd = data;
3379 //static double q_start = 0.0;
3380 //if (q_start == 0.0) q_start = ecore_time_get();
3383 if (_queue_proecess(wd, 1) > 0)
3385 if (wd->calc_job) ecore_job_del(wd->calc_job);
3386 wd->calc_job = ecore_job_add(_calc_job, wd);
3391 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3393 wd->queue_idler = NULL;
3394 return ECORE_CALLBACK_CANCEL;
3396 return ECORE_CALLBACK_RENEW;
3400 _item_queue(Widget_Data *wd,
3401 Elm_Genlist_Item *it)
3403 if (it->queued) return;
3404 it->queued = EINA_TRUE;
3405 wd->queue = eina_list_append(wd->queue, it);
3406 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3408 if (wd->queue_idler)
3410 ecore_idler_del(wd->queue_idler);
3411 wd->queue_idler = NULL;
3413 _queue_proecess(wd, 0);
3415 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3419 * Append item to the end of the genlist
3421 * This appends the given item to the end of the list or the end of
3422 * the children if the parent is given.
3424 * @param obj The genlist object
3425 * @param itc The item class for the item
3426 * @param data The item data
3427 * @param parent The parent item, or NULL if none
3428 * @param flags Item flags
3429 * @param func Convenience function called when item selected
3430 * @param func_data Data passed to @p func above.
3431 * @return A handle to the item added or NULL if not possible
3435 EAPI Elm_Genlist_Item *
3436 elm_genlist_item_append(Evas_Object *obj,
3437 const Elm_Genlist_Item_Class *itc,
3439 Elm_Genlist_Item *parent,
3440 Elm_Genlist_Item_Flags flags,
3442 const void *func_data)
3444 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3445 Widget_Data *wd = elm_widget_data_get(obj);
3446 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3448 if (!wd) return NULL;
3449 if (!it) return NULL;
3452 if (flags & ELM_GENLIST_ITEM_HEAD) wd->head_item = it;
3455 if (flags & ELM_GENLIST_ITEM_GROUP)
3456 wd->group_items = eina_list_append(wd->group_items, it);
3457 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3463 Elm_Genlist_Item *it2 = NULL;
3464 Eina_List *ll = eina_list_last(it->parent->items);
3465 if (ll) it2 = ll->data;
3466 it->parent->items = eina_list_append(it->parent->items, it);
3467 if (!it2) it2 = it->parent;
3469 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3470 EINA_INLIST_GET(it2));
3472 it->rel->relcount++;
3474 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3475 it->group_item = parent;
3476 else if (it->parent->group_item)
3477 it->group_item = it->parent->group_item;
3479 it->before = EINA_FALSE;
3480 if (flags != ELM_GENLIST_ITEM_HEAD) _item_queue(wd, it);
3486 * Prepend item at start of the genlist
3488 * This adds an item to the beginning of the list or beginning of the
3489 * children of the parent if given.
3491 * @param obj The genlist object
3492 * @param itc The item class for the item
3493 * @param data The item data
3494 * @param parent The parent item, or NULL if none
3495 * @param flags Item flags
3496 * @param func Convenience function called when item selected
3497 * @param func_data Data passed to @p func above.
3498 * @return A handle to the item added or NULL if not possible
3502 EAPI Elm_Genlist_Item *
3503 elm_genlist_item_prepend(Evas_Object *obj,
3504 const Elm_Genlist_Item_Class *itc,
3506 Elm_Genlist_Item *parent,
3507 Elm_Genlist_Item_Flags flags,
3509 const void *func_data)
3511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3512 Widget_Data *wd = elm_widget_data_get(obj);
3513 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3515 if (!wd) return NULL;
3516 if (!it) return NULL;
3519 if (flags & ELM_GENLIST_ITEM_GROUP)
3520 wd->group_items = eina_list_prepend(wd->group_items, it);
3521 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3526 Elm_Genlist_Item *it2 = NULL;
3527 Eina_List *ll = it->parent->items;
3528 if (ll) it2 = ll->data;
3529 it->parent->items = eina_list_prepend(it->parent->items, it);
3530 if (!it2) it2 = it->parent;
3532 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3533 EINA_INLIST_GET(it2));
3535 it->rel->relcount++;
3537 it->before = EINA_TRUE;
3538 _item_queue(wd, it);
3543 * Insert item before another in the genlist
3545 * This inserts an item before another in the list. It will be in the
3546 * same tree level or group as the item it is inseted before.
3548 * @param obj The genlist object
3549 * @param itc The item class for the item
3550 * @param data The item data
3551 * @param before The item to insert before
3552 * @param flags Item flags
3553 * @param func Convenience function called when item selected
3554 * @param func_data Data passed to @p func above.
3555 * @return A handle to the item added or NULL if not possible
3559 EAPI Elm_Genlist_Item *
3560 elm_genlist_item_insert_before(Evas_Object *obj,
3561 const Elm_Genlist_Item_Class *itc,
3563 Elm_Genlist_Item *parent,
3564 Elm_Genlist_Item *before,
3565 Elm_Genlist_Item_Flags flags,
3567 const void *func_data)
3569 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3570 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3571 Widget_Data *wd = elm_widget_data_get(obj);
3572 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3574 if (!wd) return NULL;
3575 if (!it) return NULL;
3578 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3581 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3582 EINA_INLIST_GET(before));
3584 it->rel->relcount++;
3585 it->before = EINA_TRUE;
3586 _item_queue(wd, it);
3591 * Insert an item after another in the genlst
3593 * This inserts an item after another in the list. It will be in the
3594 * same tree level or group as the item it is inseted after.
3596 * @param obj The genlist object
3597 * @param itc The item class for the item
3598 * @param data The item data
3599 * @param after The item to insert after
3600 * @param flags Item flags
3601 * @param func Convenience function called when item selected
3602 * @param func_data Data passed to @p func above.
3603 * @return A handle to the item added or NULL if not possible
3607 EAPI Elm_Genlist_Item *
3608 elm_genlist_item_insert_after(Evas_Object *obj,
3609 const Elm_Genlist_Item_Class *itc,
3611 Elm_Genlist_Item *parent,
3612 Elm_Genlist_Item *after,
3613 Elm_Genlist_Item_Flags flags,
3615 const void *func_data)
3617 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3618 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3619 Widget_Data *wd = elm_widget_data_get(obj);
3620 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3622 if (!wd) return NULL;
3623 if (!it) return NULL;
3624 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3625 EINA_INLIST_GET(after));
3628 it->parent->items = eina_list_append_relative(it->parent->items, it,
3632 it->rel->relcount++;
3633 it->before = EINA_FALSE;
3634 _item_queue(wd, it);
3641 * This clears all items in the list, leaving it empty.
3643 * @param obj The genlist object
3648 elm_genlist_clear(Evas_Object *obj)
3650 ELM_CHECK_WIDTYPE(obj, widtype);
3651 Widget_Data *wd = elm_widget_data_get(obj);
3653 if (wd->walking > 0)
3655 Elm_Genlist_Item *it;
3657 wd->clear_me = EINA_TRUE;
3658 EINA_INLIST_FOREACH(wd->items, it)
3660 it->delete_me = EINA_TRUE;
3664 wd->clear_me = EINA_FALSE;
3667 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3668 it->nocache = EINA_TRUE;
3669 it->hilighted = EINA_FALSE;
3671 if (wd->anchor_item == it)
3673 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3674 if (!wd->anchor_item)
3676 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3679 wd->items = eina_inlist_remove(wd->items, wd->items);
3680 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3681 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3682 if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL;
3683 elm_widget_item_pre_notify_del(it);
3684 if (it->effect_item_realized) _effect_item_unrealize(it);
3685 if (it->realized) _item_unrealize(it);
3686 if (it->itc->func.del)
3687 it->itc->func.del((void *)it->base.data, it->base.widget);
3688 if (it->long_timer) ecore_timer_del(it->long_timer);
3689 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3690 elm_widget_item_del(it);
3692 wd->anchor_item = NULL;
3695 Item_Block *itb = (Item_Block *)(wd->blocks);
3697 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3698 if (itb->items) eina_list_free(itb->items);
3703 ecore_job_del(wd->calc_job);
3704 wd->calc_job = NULL;
3706 if (wd->queue_idler)
3708 ecore_idler_del(wd->queue_idler);
3709 wd->queue_idler = NULL;
3711 if (wd->must_recalc_idler)
3713 ecore_idler_del(wd->must_recalc_idler);
3714 wd->must_recalc_idler = NULL;
3718 eina_list_free(wd->queue);
3723 eina_list_free(wd->selected);
3724 wd->selected = NULL;
3726 if (wd->item_moving_effect_timer)
3728 ecore_animator_del(wd->item_moving_effect_timer);
3729 wd->item_moving_effect_timer = NULL;
3731 wd->show_item = NULL;
3738 evas_object_del(wd->alpha_bg);
3739 wd->alpha_bg = NULL;
3743 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3744 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3750 * Enable or disable multi-select in the genlist
3752 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3753 * the list. This allows more than 1 item to be selected.
3755 * @param obj The genlist object
3756 * @param multi Multi-select enable/disable
3761 elm_genlist_multi_select_set(Evas_Object *obj,
3764 ELM_CHECK_WIDTYPE(obj, widtype);
3765 Widget_Data *wd = elm_widget_data_get(obj);
3771 * Gets if multi-select in genlist is enable or disable
3773 * @param obj The genlist object
3774 * @return Multi-select enable/disable
3775 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3780 elm_genlist_multi_select_get(const Evas_Object *obj)
3782 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3783 Widget_Data *wd = elm_widget_data_get(obj);
3784 if (!wd) return EINA_FALSE;
3789 * Get the selectd item in the genlist
3791 * This gets the selected item in the list (if multi-select is enabled
3792 * only the first item in the list is selected - which is not very
3793 * useful, so see elm_genlist_selected_items_get() for when
3794 * multi-select is used).
3796 * If no item is selected, NULL is returned.
3798 * @param obj The genlist object
3799 * @return The selected item, or NULL if none.
3803 EAPI Elm_Genlist_Item *
3804 elm_genlist_selected_item_get(const Evas_Object *obj)
3806 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3807 Widget_Data *wd = elm_widget_data_get(obj);
3808 if (!wd) return NULL;
3809 if (wd->selected) return wd->selected->data;
3814 * Get a list of selected items in the genlist
3816 * This returns a list of the selected items. This list pointer is
3817 * only valid so long as no items are selected or unselected (or
3818 * unselected implicitly by deletion). The list contains
3819 * Elm_Genlist_Item pointers.
3821 * @param obj The genlist object
3822 * @return The list of selected items, nor NULL if none are selected.
3826 EAPI const Eina_List *
3827 elm_genlist_selected_items_get(const Evas_Object *obj)
3829 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3830 Widget_Data *wd = elm_widget_data_get(obj);
3831 if (!wd) return NULL;
3832 return wd->selected;
3836 * Get a list of realized items in genlist
3838 * This returns a list of the realized items in the genlist. The list
3839 * contains Elm_Genlist_Item pointers. The list must be freed by the
3840 * caller when done with eina_list_free(). The item pointers in the
3841 * list are only valid so long as those items are not deleted or the
3842 * genlist is not deleted.
3844 * @param obj The genlist object
3845 * @return The list of realized items, nor NULL if none are realized.
3850 elm_genlist_realized_items_get(const Evas_Object *obj)
3852 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3853 Widget_Data *wd = elm_widget_data_get(obj);
3854 Eina_List *list = NULL;
3856 Eina_Bool done = EINA_FALSE;
3857 if (!wd) return NULL;
3858 EINA_INLIST_FOREACH(wd->blocks, itb)
3863 Elm_Genlist_Item *it;
3866 EINA_LIST_FOREACH(itb->items, l, it)
3868 if (it->realized) list = eina_list_append(list, it);
3880 * Get the item that is at the x, y canvas coords
3882 * This returns the item at the given coordinates (which are canvas
3883 * relative not object-relative). If an item is at that coordinate,
3884 * that item handle is returned, and if @p posret is not NULL, the
3885 * integer pointed to is set to a value of -1, 0 or 1, depending if
3886 * the coordinate is on the upper portion of that item (-1), on the
3887 * middle section (0) or on the lower part (1). If NULL is returned as
3888 * an item (no item found there), then posret may indicate -1 or 1
3889 * based if the coordinate is above or below all items respectively in
3892 * @param it The item
3893 * @param x The input x coordinate
3894 * @param y The input y coordinate
3895 * @param posret The position relative to the item returned here
3896 * @return The item at the coordinates or NULL if none
3900 EAPI Elm_Genlist_Item *
3901 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3906 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3907 Widget_Data *wd = elm_widget_data_get(obj);
3908 Evas_Coord ox, oy, ow, oh;
3909 Evas_Coord head_y = 0;
3912 if (!wd) return NULL;
3913 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3916 if (wd->head_item) head_y = wd->head_item->h;
3917 EINA_INLIST_FOREACH(wd->blocks, itb)
3920 Elm_Genlist_Item *it;
3922 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3923 oy + itb->y + head_y - itb->wd->pan_y ,
3924 itb->w, itb->h, x, y, 1, 1))
3926 EINA_LIST_FOREACH(itb->items, l, it)
3928 Evas_Coord itx, ity;
3930 itx = ox + itb->x + it->x - itb->wd->pan_x;
3931 ity = oy + itb->y + it->y - itb->wd->pan_y;
3932 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3936 if (y <= (ity + (it->h / 4))) *posret = -1;
3937 else if (y >= (ity + it->h - (it->h / 4)))
3943 lasty = ity + it->h;
3948 if (y > lasty) *posret = 1;
3955 * Get the first item in the genlist
3957 * This returns the first item in the list.
3959 * @param obj The genlist object
3960 * @return The first item, or NULL if none
3964 EAPI Elm_Genlist_Item *
3965 elm_genlist_first_item_get(const Evas_Object *obj)
3967 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3968 Widget_Data *wd = elm_widget_data_get(obj);
3969 if (!wd) return NULL;
3970 if (!wd->items) return NULL;
3971 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3972 while ((it) && (it->delete_me))
3973 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3978 * Get the last item in the genlist
3980 * This returns the last item in the list.
3982 * @return The last item, or NULL if none
3986 EAPI Elm_Genlist_Item *
3987 elm_genlist_last_item_get(const Evas_Object *obj)
3989 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3990 Widget_Data *wd = elm_widget_data_get(obj);
3991 if (!wd) return NULL;
3992 if (!wd->items) return NULL;
3993 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3994 while ((it) && (it->delete_me))
3995 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4000 * Get the next item in the genlist
4002 * This returns the item after the item @p it.
4004 * @param it The item
4005 * @return The item after @p it, or NULL if none
4009 EAPI Elm_Genlist_Item *
4010 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4012 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4015 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4016 if ((it) && (!it->delete_me)) break;
4018 return (Elm_Genlist_Item *)it;
4022 * Get the previous item in the genlist
4024 * This returns the item before the item @p it.
4026 * @param it The item
4027 * @return The item before @p it, or NULL if none
4031 EAPI Elm_Genlist_Item *
4032 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4034 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4037 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4038 if ((it) && (!it->delete_me)) break;
4040 return (Elm_Genlist_Item *)it;
4044 * Get the genlist object from an item
4046 * This returns the genlist object itself that an item belongs to.
4048 * @param it The item
4049 * @return The genlist object
4054 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4056 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4057 return it->base.widget;
4061 * Get the parent item of the given item
4063 * This returns the parent item of the item @p it given.
4065 * @param it The item
4066 * @return The parent of the item or NULL if none
4070 EAPI Elm_Genlist_Item *
4071 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4073 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4078 * Clear all sub-items (children) of the given item
4080 * This clears all items that are children (or their descendants) of the
4083 * @param it The item
4088 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4090 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4091 Elm_Genlist_Item *it2;
4094 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4095 _item_subitems_clear(it);
4098 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4099 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4101 it->wd->expand_item = it;
4102 _item_flip_effect_show(it);
4103 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4104 it->wd->expand_item_end = y + h;
4108 it2 = elm_genlist_item_next_get(it2);
4110 } while (it2->expanded_depth > it->expanded_depth);
4112 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4114 it->wd->expand_item_gap = 0;
4116 evas_object_raise(it->wd->alpha_bg);
4117 evas_object_show(it->wd->alpha_bg);
4119 it->wd->start_time = current_time_get();
4120 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4123 _item_subitems_clear(it);
4128 * Set the selected state of an item
4130 * This sets the selected state (1 selected, 0 not selected) of the given
4133 * @param it The item
4134 * @param selected The selected state
4139 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4142 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4143 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4145 if (it->delete_me) return;
4146 selected = !!selected;
4147 if (it->selected == selected) return;
4153 while (wd->selected)
4154 _item_unselect(wd->selected->data);
4164 * Get the selected state of an item
4166 * This gets the selected state of an item (1 selected, 0 not selected).
4168 * @param it The item
4169 * @return The selected state
4174 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4176 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4177 return it->selected;
4181 * Sets the expanded state of an item (if it's a parent)
4183 * This expands or contracts a parent item (thus showing or hiding the
4186 * @param it The item
4187 * @param expanded The expanded state (1 expanded, 0 not expanded).
4192 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4195 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4196 if (it->expanded == expanded) return;
4197 it->expanded = expanded;
4198 it->wd->expand_item = it;
4200 if(it->wd->effect_mode && !it->wd->alpha_bg)
4201 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4205 it->wd->auto_scrolled = EINA_FALSE;
4206 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4208 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4209 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4213 it->wd->contracting = EINA_TRUE;
4214 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4216 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4217 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4222 * Get the expanded state of an item
4224 * This gets the expanded state of an item
4226 * @param it The item
4227 * @return Thre expanded state
4232 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4234 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4235 return it->expanded;
4239 * Get the depth of expanded item
4241 * @param it The genlist item object
4242 * @return The depth of expanded item
4247 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4249 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4250 return it->expanded_depth;
4254 * Sets the disabled state of an item.
4256 * A disabled item cannot be selected or unselected. It will also
4257 * change appearance to appear disabled. This sets the disabled state
4258 * (1 disabled, 0 not disabled).
4260 * @param it The item
4261 * @param disabled The disabled state
4266 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4269 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4270 if (it->disabled == disabled) return;
4271 if (it->delete_me) return;
4272 it->disabled = disabled;
4276 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4278 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4283 * Get the disabled state of an item
4285 * This gets the disabled state of the given item.
4287 * @param it The item
4288 * @return The disabled state
4293 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4295 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4296 if (it->delete_me) return EINA_FALSE;
4297 return it->disabled;
4301 * Sets the display only state of an item.
4303 * A display only item cannot be selected or unselected. It is for
4304 * display only and not selecting or otherwise clicking, dragging
4305 * etc. by the user, thus finger size rules will not be applied to
4308 * @param it The item
4309 * @param display_only The display only state
4314 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4315 Eina_Bool display_only)
4317 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4318 if (it->display_only == display_only) return;
4319 if (it->delete_me) return;
4320 it->display_only = display_only;
4321 it->mincalcd = EINA_FALSE;
4322 it->updateme = EINA_TRUE;
4323 if (it->block) it->block->updateme = EINA_TRUE;
4324 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4325 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4329 * Get the display only state of an item
4331 * This gets the display only state of the given item.
4333 * @param it The item
4334 * @return The display only state
4339 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4341 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4342 if (it->delete_me) return EINA_FALSE;
4343 return it->display_only;
4347 * Show the given item
4349 * This causes genlist to jump to the given item @p it and show it (by
4350 * scrolling), if it is not fully visible.
4352 * @param it The item
4357 elm_genlist_item_show(Elm_Genlist_Item *it)
4359 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4360 Evas_Coord gith = 0;
4361 if (it->delete_me) return;
4362 if ((it->queued) || (!it->mincalcd))
4364 it->wd->show_item = it;
4365 it->wd->bring_in = EINA_TRUE;
4366 it->showme = EINA_TRUE;
4369 if (it->wd->show_item)
4371 it->wd->show_item->showme = EINA_FALSE;
4372 it->wd->show_item = NULL;
4374 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4375 gith = it->group_item->h;
4376 elm_smart_scroller_child_region_show(it->wd->scr,
4377 it->x + it->block->x,
4378 it->y + it->block->y - gith,
4379 it->block->w, it->h);
4383 * Bring in the given item
4385 * This causes genlist to jump to the given item @p it and show it (by
4386 * scrolling), if it is not fully visible. This may use animation to
4387 * do so and take a period of time
4389 * @param it The item
4394 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4396 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4397 Evas_Coord gith = 0;
4398 if (it->delete_me) return;
4399 if ((it->queued) || (!it->mincalcd))
4401 it->wd->show_item = it;
4402 it->wd->bring_in = EINA_TRUE;
4403 it->showme = EINA_TRUE;
4406 if (it->wd->show_item)
4408 it->wd->show_item->showme = EINA_FALSE;
4409 it->wd->show_item = NULL;
4411 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4412 gith = it->group_item->h;
4413 elm_smart_scroller_region_bring_in(it->wd->scr,
4414 it->x + it->block->x,
4415 it->y + it->block->y - gith,
4416 it->block->w, it->h);
4420 * Show the given item at the top
4422 * This causes genlist to jump to the given item @p it and show it (by
4423 * scrolling), if it is not fully visible.
4425 * @param it The item
4430 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4432 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4434 Evas_Coord gith = 0;
4436 if (it->delete_me) return;
4437 if ((it->queued) || (!it->mincalcd))
4439 it->wd->show_item = it;
4440 it->wd->bring_in = EINA_TRUE;
4441 it->showme = EINA_TRUE;
4444 if (it->wd->show_item)
4446 it->wd->show_item->showme = EINA_FALSE;
4447 it->wd->show_item = NULL;
4449 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4450 if (it->group_item) gith = it->group_item->h;
4451 elm_smart_scroller_child_region_show(it->wd->scr,
4452 it->x + it->block->x,
4453 it->y + it->block->y - gith,
4458 * Bring in the given item at the top
4460 * This causes genlist to jump to the given item @p it and show it (by
4461 * scrolling), if it is not fully visible. This may use animation to
4462 * do so and take a period of time
4464 * @param it The item
4469 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4471 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4473 Evas_Coord gith = 0;
4475 if (it->delete_me) return;
4476 if ((it->queued) || (!it->mincalcd))
4478 it->wd->show_item = it;
4479 it->wd->bring_in = EINA_TRUE;
4480 it->showme = EINA_TRUE;
4483 if (it->wd->show_item)
4485 it->wd->show_item->showme = EINA_FALSE;
4486 it->wd->show_item = NULL;
4488 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4489 if (it->group_item) gith = it->group_item->h;
4490 elm_smart_scroller_region_bring_in(it->wd->scr,
4491 it->x + it->block->x,
4492 it->y + it->block->y - gith,
4497 * Show the given item at the middle
4499 * This causes genlist to jump to the given item @p it and show it (by
4500 * scrolling), if it is not fully visible.
4502 * @param it The item
4507 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4509 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4512 if (it->delete_me) return;
4513 if ((it->queued) || (!it->mincalcd))
4515 it->wd->show_item = it;
4516 it->wd->bring_in = EINA_TRUE;
4517 it->showme = EINA_TRUE;
4520 if (it->wd->show_item)
4522 it->wd->show_item->showme = EINA_FALSE;
4523 it->wd->show_item = NULL;
4525 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4526 elm_smart_scroller_child_region_show(it->wd->scr,
4527 it->x + it->block->x,
4528 it->y + it->block->y - oh / 2 +
4529 it->h / 2, it->block->w, oh);
4533 * Bring in the given item at the middle
4535 * This causes genlist to jump to the given item @p it and show it (by
4536 * scrolling), if it is not fully visible. This may use animation to
4537 * do so and take a period of time
4539 * @param it The item
4544 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4546 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4549 if (it->delete_me) return;
4550 if ((it->queued) || (!it->mincalcd))
4552 it->wd->show_item = it;
4553 it->wd->bring_in = EINA_TRUE;
4554 it->showme = EINA_TRUE;
4557 if (it->wd->show_item)
4559 it->wd->show_item->showme = EINA_FALSE;
4560 it->wd->show_item = NULL;
4562 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4563 elm_smart_scroller_region_bring_in(it->wd->scr,
4564 it->x + it->block->x,
4565 it->y + it->block->y - oh / 2 + it->h / 2,
4570 * Delete a given item
4572 * This deletes the item from genlist and calls the genlist item del
4573 * class callback defined in the item class, if it is set. This clears all
4574 * subitems if it is a tree.
4576 * @param it The item
4581 elm_genlist_item_del(Elm_Genlist_Item *it)
4583 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4584 if ((it->relcount > 0) || (it->walking > 0))
4586 elm_widget_item_pre_notify_del(it);
4587 elm_genlist_item_subitems_clear(it);
4588 it->delete_me = EINA_TRUE;
4589 if (it->wd->show_item == it) it->wd->show_item = NULL;
4591 it->wd->selected = eina_list_remove(it->wd->selected,
4595 if (it->realized) _item_unrealize(it);
4596 if (it->effect_item_realized) _effect_item_unrealize(it);
4597 it->block->changed = EINA_TRUE;
4598 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4599 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4601 // if (it->itc->func.del)
4602 // it->itc->func.del((void *)it->base.data, it->base.widget);
4609 * Set the data item from the genlist item
4611 * This set the data value passed on the elm_genlist_item_append() and
4612 * related item addition calls. This function will also call
4613 * elm_genlist_item_update() so the item will be updated to reflect the
4616 * @param it The item
4617 * @param data The new data pointer to set
4622 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4625 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4626 elm_widget_item_data_set(it, data);
4627 elm_genlist_item_update(it);
4631 * Get the data item from the genlist item
4633 * This returns the data value passed on the elm_genlist_item_append()
4634 * and related item addition calls and elm_genlist_item_data_set().
4636 * @param it The item
4637 * @return The data pointer provided when created
4642 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4644 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4645 return elm_widget_item_data_get(it);
4649 * Tells genlist to "orphan" icons fetchs by the item class
4651 * This instructs genlist to release references to icons in the item,
4652 * meaning that they will no longer be managed by genlist and are
4653 * floating "orphans" that can be re-used elsewhere if the user wants
4656 * @param it The item
4661 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4664 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4665 EINA_LIST_FREE(it->icon_objs, icon)
4667 elm_widget_sub_object_del(it->base.widget, icon);
4668 evas_object_smart_member_del(icon);
4669 evas_object_hide(icon);
4674 * Get the real evas object of the genlist item
4676 * This returns the actual evas object used for the specified genlist
4677 * item. This may be NULL as it may not be created, and may be deleted
4678 * at any time by genlist. Do not modify this object (move, resize,
4679 * show, hide etc.) as genlist is controlling it. This function is for
4680 * querying, emitting custom signals or hooking lower level callbacks
4681 * for events. Do not delete this object under any circumstances.
4683 * @param it The item
4684 * @return The object pointer
4688 EAPI const Evas_Object *
4689 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4691 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4692 return it->base.view;
4696 * Update the contents of an item
4698 * This updates an item by calling all the item class functions again
4699 * to get the icons, labels and states. Use this when the original
4700 * item data has changed and the changes are desired to be reflected.
4702 * @param it The item
4707 elm_genlist_item_update(Elm_Genlist_Item *it)
4709 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4710 if (it->flags != ELM_GENLIST_ITEM_HEAD)
4712 if (!it->block) return;
4713 if (it->delete_me) return;
4714 it->mincalcd = EINA_FALSE;
4715 it->updateme = EINA_TRUE;
4716 it->block->updateme = EINA_TRUE;
4718 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4719 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4723 * Update the item class of an item
4725 * @param it The item
4726 * @parem itc The item class for the item
4731 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4732 const Elm_Genlist_Item_Class *itc)
4734 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4735 if (!it->block) return;
4736 EINA_SAFETY_ON_NULL_RETURN(itc);
4737 if (it->delete_me) return;
4739 it->nocache = EINA_TRUE;
4740 elm_genlist_item_update(it);
4743 static Evas_Object *
4744 _elm_genlist_item_label_create(void *data,
4746 void *item __UNUSED__)
4748 Evas_Object *label = elm_label_add(obj);
4751 elm_object_style_set(label, "tooltip");
4752 elm_label_label_set(label, data);
4757 _elm_genlist_item_label_del_cb(void *data,
4758 Evas_Object *obj __UNUSED__,
4759 void *event_info __UNUSED__)
4761 eina_stringshare_del(data);
4765 * Set the text to be shown in the genlist item.
4767 * @param item Target item
4768 * @param text The text to set in the content
4770 * Setup the text as tooltip to object. The item can have only one
4771 * tooltip, so any previous tooltip data is removed.
4776 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4779 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4780 text = eina_stringshare_add(text);
4781 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4783 _elm_genlist_item_label_del_cb);
4787 * Set the content to be shown in the tooltip item
4789 * Setup the tooltip to item. The item can have only one tooltip, so
4790 * any previous tooltip data is removed. @p func(with @p data) will be
4791 * called every time that need to show the tooltip and it should return a
4792 * valid Evas_Object. This object is then managed fully by tooltip
4793 * system and is deleted when the tooltip is gone.
4795 * @param item the genlist item being attached by a tooltip.
4796 * @param func the function used to create the tooltip contents.
4797 * @param data what to provide to @a func as callback data/context.
4798 * @param del_cb called when data is not needed anymore, either when
4799 * another callback replaces @func, the tooltip is unset with
4800 * elm_genlist_item_tooltip_unset() or the owner @a item
4801 * dies. This callback receives as the first parameter the
4802 * given @a data, and @c event_info is the item.
4807 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4808 Elm_Tooltip_Item_Content_Cb func,
4810 Evas_Smart_Cb del_cb)
4812 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4814 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4817 if (item->tooltip.del_cb)
4818 item->tooltip.del_cb((void *)item->tooltip.data,
4819 item->base.widget, item);
4821 item->tooltip.content_cb = func;
4822 item->tooltip.data = data;
4823 item->tooltip.del_cb = del_cb;
4825 if (item->base.view)
4827 elm_widget_item_tooltip_content_cb_set(item,
4828 item->tooltip.content_cb,
4829 item->tooltip.data, NULL);
4830 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4836 if (del_cb) del_cb((void *)data, NULL, NULL);
4840 * Unset tooltip from item
4842 * @param item genlist item to remove previously set tooltip.
4844 * Remove tooltip from item. The callback provided as del_cb to
4845 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4846 * it is not used anymore.
4848 * @see elm_genlist_item_tooltip_content_cb_set()
4853 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4855 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4856 if ((item->base.view) && (item->tooltip.content_cb))
4857 elm_widget_item_tooltip_unset(item);
4859 if (item->tooltip.del_cb)
4860 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4861 item->tooltip.del_cb = NULL;
4862 item->tooltip.content_cb = NULL;
4863 item->tooltip.data = NULL;
4864 if (item->tooltip.style)
4865 elm_genlist_item_tooltip_style_set(item, NULL);
4869 * Sets a different style for this item tooltip.
4871 * @note before you set a style you should define a tooltip with
4872 * elm_genlist_item_tooltip_content_cb_set() or
4873 * elm_genlist_item_tooltip_text_set()
4875 * @param item genlist item with tooltip already set.
4876 * @param style the theme style to use (default, transparent, ...)
4881 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4884 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4885 eina_stringshare_replace(&item->tooltip.style, style);
4886 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4890 * Get the style for this item tooltip.
4892 * @param item genlist item with tooltip already set.
4893 * @return style the theme style in use, defaults to "default". If the
4894 * object does not have a tooltip set, then NULL is returned.
4899 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4901 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4902 return item->tooltip.style;
4906 * Set the cursor to be shown when mouse is over the genlist item
4908 * @param item Target item
4909 * @param cursor the cursor name to be used.
4911 * @see elm_object_cursor_set()
4915 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4918 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4919 eina_stringshare_replace(&item->mouse_cursor, cursor);
4920 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4924 * Get the cursor to be shown when mouse is over the genlist item
4926 * @param item genlist item with cursor already set.
4927 * @return the cursor name.
4932 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4934 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4935 return elm_widget_item_cursor_get(item);
4939 * Unset the cursor to be shown when mouse is over the genlist item
4941 * @param item Target item
4943 * @see elm_object_cursor_unset()
4947 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4949 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4950 if (!item->mouse_cursor)
4953 if (item->base.view)
4954 elm_widget_item_cursor_unset(item);
4956 eina_stringshare_del(item->mouse_cursor);
4957 item->mouse_cursor = NULL;
4961 * Sets a different style for this item cursor.
4963 * @note before you set a style you should define a cursor with
4964 * elm_genlist_item_cursor_set()
4966 * @param item genlist item with cursor already set.
4967 * @param style the theme style to use (default, transparent, ...)
4972 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4975 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4976 elm_widget_item_cursor_style_set(item, style);
4980 * Get the style for this item cursor.
4982 * @param item genlist item with cursor already set.
4983 * @return style the theme style in use, defaults to "default". If the
4984 * object does not have a cursor set, then NULL is returned.
4989 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4991 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4992 return elm_widget_item_cursor_style_get(item);
4996 * Set if the cursor set should be searched on the theme or should use
4997 * the provided by the engine, only.
4999 * @note before you set if should look on theme you should define a
5000 * cursor with elm_object_cursor_set(). By default it will only look
5001 * for cursors provided by the engine.
5003 * @param item widget item with cursor already set.
5004 * @param engine_only boolean to define it cursors should be looked
5005 * only between the provided by the engine or searched on widget's
5011 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5012 Eina_Bool engine_only)
5014 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5015 elm_widget_item_cursor_engine_only_set(item, engine_only);
5019 * Get the cursor engine only usage for this item cursor.
5021 * @param item widget item with cursor already set.
5022 * @return engine_only boolean to define it cursors should be looked
5023 * only between the provided by the engine or searched on widget's
5024 * theme as well. If the object does not have a cursor set, then
5025 * EINA_FALSE is returned.
5030 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5032 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5033 return elm_widget_item_cursor_engine_only_get(item);
5037 * This sets the horizontal stretching mode
5039 * This sets the mode used for sizing items horizontally. Valid modes
5040 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5041 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5042 * the scroller will scroll horizontally. Otherwise items are expanded
5043 * to fill the width of the viewport of the scroller. If it is
5044 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5045 * limited to that size.
5047 * @param obj The genlist object
5048 * @param mode The mode to use
5053 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5056 ELM_CHECK_WIDTYPE(obj, widtype);
5057 Widget_Data *wd = elm_widget_data_get(obj);
5059 if (wd->mode == mode) return;
5065 * Gets the horizontal stretching mode
5067 * @param obj The genlist object
5068 * @return The mode to use
5069 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5074 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5076 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5077 Widget_Data *wd = elm_widget_data_get(obj);
5078 if (!wd) return ELM_LIST_LAST;
5083 * Set the always select mode.
5085 * Items will only call their selection func and callback when first
5086 * becoming selected. Any further clicks will do nothing, unless you
5087 * enable always select with elm_genlist_always_select_mode_set().
5088 * This means even if selected, every click will make the selected
5089 * callbacks be called.
5091 * @param obj The genlist object
5092 * @param always_select The always select mode
5093 * (EINA_TRUE = on, EINA_FALSE = off)
5098 elm_genlist_always_select_mode_set(Evas_Object *obj,
5099 Eina_Bool always_select)
5101 ELM_CHECK_WIDTYPE(obj, widtype);
5102 Widget_Data *wd = elm_widget_data_get(obj);
5104 wd->always_select = always_select;
5108 * Get the always select mode.
5110 * @param obj The genlist object
5111 * @return The always select mode
5112 * (EINA_TRUE = on, EINA_FALSE = off)
5117 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5119 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5120 Widget_Data *wd = elm_widget_data_get(obj);
5121 if (!wd) return EINA_FALSE;
5122 return wd->always_select;
5126 * Set no select mode
5128 * This will turn off the ability to select items entirely and they
5129 * will neither appear selected nor call selected callback functions.
5131 * @param obj The genlist object
5132 * @param no_select The no select mode
5133 * (EINA_TRUE = on, EINA_FALSE = off)
5138 elm_genlist_no_select_mode_set(Evas_Object *obj,
5139 Eina_Bool no_select)
5141 ELM_CHECK_WIDTYPE(obj, widtype);
5142 Widget_Data *wd = elm_widget_data_get(obj);
5144 wd->no_select = no_select;
5148 * Gets no select mode
5150 * @param obj The genlist object
5151 * @return The no select mode
5152 * (EINA_TRUE = on, EINA_FALSE = off)
5157 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5159 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5160 Widget_Data *wd = elm_widget_data_get(obj);
5161 if (!wd) return EINA_FALSE;
5162 return wd->no_select;
5168 * This will enable the compress mode where items are "compressed"
5169 * horizontally to fit the genlist scrollable viewport width. This is
5170 * special for genlist. Do not rely on
5171 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5172 * work as genlist needs to handle it specially.
5174 * @param obj The genlist object
5175 * @param compress The compress mode
5176 * (EINA_TRUE = on, EINA_FALSE = off)
5181 elm_genlist_compress_mode_set(Evas_Object *obj,
5184 ELM_CHECK_WIDTYPE(obj, widtype);
5185 Widget_Data *wd = elm_widget_data_get(obj);
5187 wd->compress = compress;
5191 * Get the compress mode
5193 * @param obj The genlist object
5194 * @return The compress mode
5195 * (EINA_TRUE = on, EINA_FALSE = off)
5200 elm_genlist_compress_mode_get(const Evas_Object *obj)
5202 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5203 Widget_Data *wd = elm_widget_data_get(obj);
5204 if (!wd) return EINA_FALSE;
5205 return wd->compress;
5209 * Set height-for-width mode
5211 * With height-for-width mode the item width will be fixed (restricted
5212 * to a minimum of) to the list width when calculating its size in
5213 * order to allow the height to be calculated based on it. This allows,
5214 * for instance, text block to wrap lines if the Edje part is
5215 * configured with "text.min: 0 1".
5217 * @note This mode will make list resize slower as it will have to
5218 * recalculate every item height again whenever the list width
5221 * @note When height-for-width mode is enabled, it also enables
5222 * compress mode (see elm_genlist_compress_mode_set()) and
5223 * disables homogeneous (see elm_genlist_homogeneous_set()).
5225 * @param obj The genlist object
5226 * @param setting The height-for-width mode (EINA_TRUE = on,
5232 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5233 Eina_Bool height_for_width)
5235 ELM_CHECK_WIDTYPE(obj, widtype);
5236 Widget_Data *wd = elm_widget_data_get(obj);
5238 wd->height_for_width = !!height_for_width;
5239 if (wd->height_for_width)
5241 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5242 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5247 * Get the height-for-width mode
5249 * @param obj The genlist object
5250 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5256 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5258 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5259 Widget_Data *wd = elm_widget_data_get(obj);
5260 if (!wd) return EINA_FALSE;
5261 return wd->height_for_width;
5267 * This will enable or disable the scroller bounce mode for the
5268 * genlist. See elm_scroller_bounce_set() for details
5270 * @param obj The genlist object
5271 * @param h_bounce Allow bounce horizontally
5272 * @param v_bounce Allow bounce vertically
5277 elm_genlist_bounce_set(Evas_Object *obj,
5281 ELM_CHECK_WIDTYPE(obj, widtype);
5282 Widget_Data *wd = elm_widget_data_get(obj);
5284 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5288 * Get the bounce mode
5290 * @param obj The genlist object
5291 * @param h_bounce Allow bounce horizontally
5292 * @param v_bounce Allow bounce vertically
5297 elm_genlist_bounce_get(const Evas_Object *obj,
5298 Eina_Bool *h_bounce,
5299 Eina_Bool *v_bounce)
5301 ELM_CHECK_WIDTYPE(obj, widtype);
5302 Widget_Data *wd = elm_widget_data_get(obj);
5304 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5308 * Set homogenous mode
5310 * This will enable the homogeneous mode where items are of the same
5311 * height and width so that genlist may do the lazy-loading at its
5312 * maximum. This implies 'compressed' mode.
5314 * @param obj The genlist object
5315 * @param homogeneous Assume the items within the genlist are of the
5316 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5321 elm_genlist_homogeneous_set(Evas_Object *obj,
5322 Eina_Bool homogeneous)
5324 ELM_CHECK_WIDTYPE(obj, widtype);
5325 Widget_Data *wd = elm_widget_data_get(obj);
5327 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5328 wd->homogeneous = homogeneous;
5332 * Get the homogenous mode
5334 * @param obj The genlist object
5335 * @return Assume the items within the genlist are of the same height
5336 * and width (EINA_TRUE = on, EINA_FALSE = off)
5341 elm_genlist_homogeneous_get(const Evas_Object *obj)
5343 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5344 Widget_Data *wd = elm_widget_data_get(obj);
5345 if (!wd) return EINA_FALSE;
5346 return wd->homogeneous;
5350 * Set the maximum number of items within an item block
5352 * This will configure the block count to tune to the target with
5353 * particular performance matrix.
5355 * @param obj The genlist object
5356 * @param n Maximum number of items within an item block
5361 elm_genlist_block_count_set(Evas_Object *obj,
5364 ELM_CHECK_WIDTYPE(obj, widtype);
5365 Widget_Data *wd = elm_widget_data_get(obj);
5367 wd->max_items_per_block = n;
5368 wd->item_cache_max = wd->max_items_per_block * 2;
5369 _item_cache_clean(wd);
5373 * Get the maximum number of items within an item block
5375 * @param obj The genlist object
5376 * @return Maximum number of items within an item block
5381 elm_genlist_block_count_get(const Evas_Object *obj)
5383 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5384 Widget_Data *wd = elm_widget_data_get(obj);
5386 return wd->max_items_per_block;
5390 * Set the timeout in seconds for the longpress event
5392 * @param obj The genlist object
5393 * @param timeout timeout in seconds
5398 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5401 ELM_CHECK_WIDTYPE(obj, widtype);
5402 Widget_Data *wd = elm_widget_data_get(obj);
5404 wd->longpress_timeout = timeout;
5408 * Get the timeout in seconds for the longpress event
5410 * @param obj The genlist object
5411 * @return timeout in seconds
5416 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5418 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5419 Widget_Data *wd = elm_widget_data_get(obj);
5421 return wd->longpress_timeout;
5425 * Set the scrollbar policy
5427 * This sets the scrollbar visibility policy for the given genlist
5428 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5429 * made visible if it is needed, and otherwise kept hidden.
5430 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5431 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5432 * respectively for the horizontal and vertical scrollbars.
5434 * @param obj The genlist object
5435 * @param policy_h Horizontal scrollbar policy
5436 * @param policy_v Vertical scrollbar policy
5441 elm_genlist_scroller_policy_set(Evas_Object *obj,
5442 Elm_Scroller_Policy policy_h,
5443 Elm_Scroller_Policy policy_v)
5445 ELM_CHECK_WIDTYPE(obj, widtype);
5446 Widget_Data *wd = elm_widget_data_get(obj);
5448 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5449 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5452 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5456 * Get the scrollbar policy
5458 * @param obj The genlist object
5459 * @param policy_h Horizontal scrollbar policy
5460 * @param policy_v Vertical scrollbar policy
5465 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5466 Elm_Scroller_Policy *policy_h,
5467 Elm_Scroller_Policy *policy_v)
5469 ELM_CHECK_WIDTYPE(obj, widtype);
5470 Widget_Data *wd = elm_widget_data_get(obj);
5471 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5472 if ((!wd) || (!wd->scr)) return;
5473 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5474 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5475 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5478 /****************************************************************************/
5483 * @param obj The genlist object
5484 * @param reorder_mode The reorder mode
5485 * (EINA_TRUE = on, EINA_FALSE = off)
5490 elm_genlist_reorder_mode_set(Evas_Object *obj,
5491 Eina_Bool reorder_mode)
5493 ELM_CHECK_WIDTYPE(obj, widtype);
5494 Widget_Data *wd = elm_widget_data_get(obj);
5496 wd->reorder_mode = reorder_mode;
5500 * Get the reorder mode
5502 * @param obj The genlist object
5503 * @return The reorder mode
5504 * (EINA_TRUE = on, EINA_FALSE = off)
5509 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5511 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5512 Widget_Data *wd = elm_widget_data_get(obj);
5513 if (!wd) return EINA_FALSE;
5514 return wd->reorder_mode;
5518 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5524 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5530 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5535 // printf("MOVE AFTER : it = %d after = %d \n", it->num, after->num);
5536 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5537 it->wd->reorder_deleted = EINA_TRUE;
5538 _item_block_del(it);
5540 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5542 it->rel->relcount++;
5543 it->before = EINA_FALSE;
5544 _item_queue(it->wd, it);
5546 if (it->itc->func.moved)
5547 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
5551 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5554 if (!before) return;
5556 // printf("MOVE BEFORE : it = %d before = %d \n", it->num, before->num);
5557 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5558 it->wd->reorder_deleted = EINA_TRUE;
5559 _item_block_del(it);
5560 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5562 it->rel->relcount++;
5563 it->before = EINA_TRUE;
5564 _item_queue(it->wd, it);
5566 if (it->itc->func.moved)
5567 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
5571 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5573 ELM_CHECK_WIDTYPE(obj, widtype);
5574 Widget_Data *wd = elm_widget_data_get(obj);
5576 wd->effect_mode = emode;
5577 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5578 // evas_object_resize(wd->point_rect, 10, 25);
5579 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5580 // evas_object_show(wd->point_rect);
5581 // evas_object_hide(wd->point_rect);
5585 _create_tray_alpha_bg(const Evas_Object *obj)
5587 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5588 Widget_Data *wd = elm_widget_data_get(obj);
5589 if (!wd) return NULL;
5591 Evas_Object *bg = NULL;
5592 Evas_Coord ox, oy, ow, oh;
5594 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5595 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5596 evas_object_color_set(bg,0,0,0,0);
5597 evas_object_resize(bg , ow, oh);
5598 evas_object_move(bg , ox, oy);
5599 evas_object_show(bg);
5600 evas_object_hide(bg);
5607 struct timeval timev;
5609 gettimeofday(&timev, NULL);
5610 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5613 // added for item moving animation.
5615 _item_moving_effect_timer_cb(void *data)
5617 Widget_Data *wd = data;
5618 if (!wd) return EINA_FALSE;
5620 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5621 Elm_Genlist_Item *it, *it2;
5623 double time = 0.4, t;
5625 Eina_Bool check, end = EINA_FALSE;
5626 // static Eina_Bool first = EINA_TRUE;
5629 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5631 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5632 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5633 if (t > time) end = EINA_TRUE;
5634 EINA_INLIST_FOREACH(wd->blocks, itb)
5637 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5638 itb->y - wd->pan_y + oy,
5640 cvx, cvy, cvw, cvh))
5642 EINA_LIST_FOREACH(itb->items, l, it)
5644 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5649 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5655 //printf(" s: %d %d ", oy, oh);
5656 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5657 dy = it->scrl_y - it->old_scrl_y;
5658 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5660 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5661 if(wd->expand_item_end < it->old_scrl_y)
5662 dy = wd->expand_item_gap;
5664 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5666 if (wd->expand_item_end < it->old_scrl_y)
5667 dy = wd->expand_item_gap;
5670 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5677 if (!it->old_scrl_y)
5678 it->old_scrl_y = it->scrl_y;
5681 if (it->old_scrl_y + y < oy + oh)
5683 if (!it->realized) _item_realize(it, in, 0);
5685 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5686 it->old_scrl_y = it->scrl_y - y;
5689 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5690 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5692 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5695 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5696 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5697 evas_object_show(it->base.view);
5698 evas_object_raise(it->base.view);
5701 if(wd->head_item) evas_object_raise(wd->head_item->base.view);
5702 if (it->group_item) evas_object_raise(it->group_item->base.view);
5705 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5707 it2 = elm_genlist_item_prev_get(it);
5710 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5712 if(!it2->effect_done)
5714 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5715 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5716 evas_object_show(it2->base.view);
5717 it2->effect_done = EINA_TRUE;
5721 it2 = elm_genlist_item_prev_get(it2);
5724 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5726 it2 = elm_genlist_item_prev_get(it);
5729 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5731 if(!it2->effect_done)
5733 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5734 it2->effect_done = EINA_TRUE;
5739 it2 = elm_genlist_item_prev_get(it2);
5745 // first = EINA_FALSE;
5749 if (wd->item_moving_effect_timer)
5751 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5752 _item_subitems_clear(wd->expand_item);
5753 EINA_INLIST_FOREACH(wd->blocks, itb)
5755 EINA_LIST_FOREACH(itb->items, l, it)
5757 it->effect_done = EINA_TRUE;
5758 it->old_scrl_y = it->scrl_y;
5762 //evas_render(evas_object_evas_get(wd->obj));
5763 wd->item_moving_effect_timer = NULL;
5764 // first = EINA_TRUE;
5766 _item_auto_scroll(wd);
5767 evas_object_lower(wd->alpha_bg);
5768 evas_object_hide(wd->alpha_bg);
5769 if (wd->calc_job) ecore_job_del(wd->calc_job);
5770 wd->calc_job = ecore_job_add(_calc_job, wd);
5771 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5772 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5774 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5775 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5776 return ECORE_CALLBACK_CANCEL;
5778 return ECORE_CALLBACK_RENEW;
5782 _emit_contract(Elm_Genlist_Item *it)
5784 Elm_Genlist_Item *it2;
5787 // printf("%p is emited contract\n", it);
5788 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5789 it->effect_done = EINA_FALSE;
5791 EINA_LIST_FOREACH(it->items, l, it2)
5793 _emit_contract(it2);
5796 // added for item moving animation.
5798 _item_flip_effect_show(Elm_Genlist_Item *it)
5800 Elm_Genlist_Item *it2;
5802 Widget_Data *wd = it->wd;
5803 Eina_Bool check = EINA_FALSE;
5805 it2 = elm_genlist_item_next_get(it);
5808 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5809 it2 = elm_genlist_item_next_get(it2);
5811 EINA_LIST_FOREACH(it->items, l, it2)
5813 if (it2->parent && it == it2->parent)
5815 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5817 edje_object_signal_emit(it2->base.view, "flip_item", "");
5819 evas_object_move(it2->base.view, -9999, -9999);
5821 evas_object_show(it2->base.view);
5823 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5824 _emit_contract(it2);
5828 return ECORE_CALLBACK_CANCEL;
5833 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5835 printf("!!! NOW FIXING \n");
5840 * Set pinch zoom mode
5842 * @param obj The genlist object
5844 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5849 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5851 printf("!!! NOW FIXING \n");
5855 * Get pinch zoom mode
5857 * @param obj The genlist object
5858 * @return The pinch mode
5859 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5864 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5866 printf("!!! NOW FIXING \n");
5871 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5873 printf("!!! NOW FIXING \n");
5877 ////////////////////////////////////////////////////////////////////////
5879 ////////////////////////////////////////////////////////////////////////
5882 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5884 if (!it->wd->edit_mode) return;
5885 evas_object_resize(it->edit_obj,it->w, it->h);
5886 evas_object_move(it->edit_obj, itx, ity);
5890 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5892 if ((it->effect_item_realized) || (it->delete_me)) return;
5894 it->pad_left = it->pad_right = 0;
5896 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5897 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5898 _elm_config->scale);
5899 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5900 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5902 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5903 else strncpy(buf, "item", sizeof(buf));
5904 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5906 strncat(buf, "/", sizeof(buf) - strlen(buf));
5908 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5910 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5911 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5915 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5918 if (it->wd->reorder_mode)
5920 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm");
5921 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm");
5924 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5925 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5927 if ((it->wd->edit_mode))
5929 if (it->itc->func.icon_get)
5934 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5935 EINA_LIST_FOREACH(it->icons, l, key)
5937 Evas_Object *ic = it->itc->func.icon_get
5938 (it->base.data, it->base.widget, l->data);
5942 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5943 edje_object_part_swallow(it->edit_obj, key, ic);
5944 evas_object_show(ic);
5945 elm_widget_sub_object_add(it->base.widget, ic);
5950 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5951 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5952 evas_object_show(it->edit_obj);
5954 it->effect_item_realized = EINA_TRUE;
5955 it->want_unrealize = EINA_FALSE;
5959 _effect_item_unrealize(Elm_Genlist_Item *it)
5963 if (!it->effect_item_realized) return;
5964 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5966 it->pad_left = it->pad_right = 0;
5967 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5968 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5969 edje_object_message_signal_process(it->edit_obj);
5970 edje_object_part_unswallow(it->edit_obj, it->base.view);
5971 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5972 elm_widget_sub_object_add(it->base.widget, it->base.view);
5973 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5974 // _item_cache_add(it);
5975 evas_object_del(it->edit_obj);
5976 it->edit_obj = NULL;
5977 EINA_LIST_FREE(it->edit_icon_objs, icon)
5978 evas_object_del(icon);
5980 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5981 it->effect_item_realized = EINA_FALSE;
5985 * Get Genlist edit mode
5987 * @param obj The genlist object
5988 * @return The edit mode status
5989 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5994 elm_genlist_edit_mode_get(const Evas_Object *obj)
5996 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5997 Widget_Data *wd = elm_widget_data_get(obj);
5998 if (!wd) return EINA_FALSE;
6000 if (wd->edit_mode) return EINA_TRUE;
6001 else return EINA_FALSE;
6005 * Set Genlist edit mode
6007 * This sets Genlist edit mode.
6009 * @param obj The Genlist object
6010 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6011 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6016 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
6018 ELM_CHECK_WIDTYPE(obj, widtype);
6022 Elm_Genlist_Item *it;
6024 Widget_Data *wd = elm_widget_data_get(obj);
6026 if (wd->edit_mode == edit_mode) return;
6028 wd->edit_mode = edit_mode;
6031 EINA_INLIST_FOREACH(wd->blocks, itb)
6035 EINA_LIST_FOREACH(itb->items, l, it)
6037 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6039 it->pad_left = it->pad_right = 0;
6040 _effect_item_unrealize(it);
6045 _item_cache_zero(wd);
6050 EINA_INLIST_FOREACH(wd->blocks, itb)
6054 EINA_LIST_FOREACH(itb->items, l, it)
6056 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6058 if(it->selected) _item_unselect(it);
6059 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
6066 if (wd->calc_job) ecore_job_del(wd->calc_job);
6067 wd->calc_job = ecore_job_add(_calc_job, wd);
6071 * Delete selected items in genlist edit mode.
6073 * @param obj The genlist object
6078 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6080 fprintf(stderr, "=================> Caution!!! <========================\n");
6081 fprintf(stderr, "==> elm_genlist_edit_selected_items_del() is deprecated. <=======\n");
6082 fprintf(stderr, "=======================================================\n");
6086 elm_genlist_selected_items_del(Evas_Object *obj)
6088 fprintf(stderr, "=================> Caution!!! <========================\n");
6089 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6090 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6091 fprintf(stderr, "=======================================================\n");
6095 * Get a list of selected items in genlist
6097 * This returns a list of the selected items in the genlist. The list
6098 * contains Elm_Genlist_Item pointers. The list must be freed by the
6099 * caller when done with eina_list_free(). The item pointers in the list
6100 * are only vallid so long as those items are not deleted or the genlist is
6103 * @param obj The genlist object
6104 * @return The list of selected items, nor NULL if none are selected.
6109 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6111 fprintf(stderr, "========================> Caution!!! <==========================\n");
6112 fprintf(stderr, "==> elm_genlist_edit_selected_items_get() is deprecated. <=======\n");
6113 fprintf(stderr, "================================================================\n");
6117 // TODO : add comment
6119 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6122 fprintf(stderr, "========================> Caution!!! <==========================\n");
6123 fprintf(stderr, "==> elm_genlist_edit_item_selected_set() is deprecated. <=======\n");
6124 fprintf(stderr, "================================================================\n");
6127 // TODO : add comment
6129 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6131 fprintf(stderr, "========================> Caution!!! <==========================\n");
6132 fprintf(stderr, "==> elm_genlist_edit_item_selected_get() is deprecated. <=======\n");
6133 fprintf(stderr, "================================================================\n");
6138 * Set a given item's rename mode
6140 * This renames the item's label from genlist
6142 * @param it The item
6143 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6148 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
6154 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6159 Elm_Genlist_Item *it;
6161 EINA_LIST_FOREACH(itb->items, l, it)
6165 it->renamed = EINA_FALSE;
6166 it->nocache = EINA_TRUE;
6167 it->wd->rename_it = NULL;
6168 elm_genlist_item_update(it);
6176 it->renamed = EINA_TRUE;
6177 it->wd->rename_it = it;
6178 it->nocache = EINA_TRUE;
6179 if (it->selected) _item_unselect(it);
6181 _item_unrealize(it);
6182 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
6183 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
6188 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
6190 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6191 return item->renamed;
6194 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6196 Elm_Genlist_Item *it = data;
6198 _delete_sweep_objs(it);
6202 _scr_hold_timer_cb(void *data)
6204 Elm_Genlist_Item *it = data;
6205 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6206 it->wd->scr_hold_timer = NULL;
6207 return ECORE_CALLBACK_CANCEL;
6211 _delete_sweep_objs(Elm_Genlist_Item *it)
6215 elm_widget_stringlist_free(it->sweep_labels);
6216 it->sweep_labels = NULL;
6217 elm_widget_stringlist_free(it->sweep_icons);
6218 it->sweep_icons = NULL;
6219 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6220 evas_object_del(ic);
6224 _create_sweep_objs(Elm_Genlist_Item *it)
6230 if (it->itc->func.label_get)
6233 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6235 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6237 char *s = it->itc->func.label_get
6238 ((void *)it->base.data, it->base.widget, l->data);
6242 edje_object_part_text_set(it->base.view, l->data, s);
6247 if (it->itc->func.icon_get)
6250 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6252 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6254 ic = it->itc->func.icon_get
6255 ((void *)it->base.data, it->base.widget, l->data);
6259 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6260 edje_object_part_swallow(it->base.view, key, ic);
6261 evas_object_show(ic);
6262 elm_widget_sub_object_add(it->base.widget, ic);
6269 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6272 Elm_Genlist_Item *it2;
6273 const char *allow_slide;
6275 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6276 if ((!allow_slide) || (atoi(allow_slide) != 1))
6281 if (it->sweeped) return;
6282 if (it->wd->scr_hold_timer)
6284 ecore_timer_del(it->wd->scr_hold_timer);
6285 it->wd->scr_hold_timer = NULL;
6287 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6288 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6290 _delete_sweep_objs(it);
6291 _create_sweep_objs(it);
6292 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6293 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6294 it->wassweeped = EINA_TRUE;
6295 it->sweeped = EINA_TRUE;
6297 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6301 it2->sweeped = EINA_FALSE;
6302 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6303 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6304 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6310 if (!it->sweeped) return;
6311 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6312 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6313 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6314 it->sweeped = EINA_FALSE;
6319 _item_auto_scroll(void *data)
6321 Widget_Data *wd = data;
6324 if ((wd->expand_item) && (!wd->auto_scrolled))
6326 Elm_Genlist_Item *it;
6328 Evas_Coord ox, oy, ow, oh;
6329 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6331 wd->auto_scrolled = EINA_TRUE;
6332 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6334 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6336 elm_genlist_item_bring_in(it);
6343 elm_genlist_item_flags_get(const Elm_Genlist_Item *item)
6345 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6350 elm_genlist_realized_items_update(const Evas_Object *obj)
6352 ELM_CHECK_WIDTYPE(obj, widtype);
6354 Eina_List *list, *l;
6355 Elm_Genlist_Item *it;
6357 list = elm_genlist_realized_items_get(obj);
6358 EINA_LIST_FOREACH(list, l, it)
6359 elm_genlist_item_update(it);