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 - "default", "double_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 * "realized" (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 "default".
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 "elm,state,XXX,active" "elm" 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
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
289 typedef struct _Edit_Data Edit_Data;
291 typedef enum _Elm_Genlist_Item_Move_effect_Mode
293 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
294 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
297 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 3),
298 } Elm_Genlist_Item_Move_effect_Mode;
302 Evas_Object *obj, *scr, *pan_smart;
303 Eina_Inlist *items, *blocks;
304 Eina_List *group_items;
306 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
307 Ecore_Job *calc_job, *update_job;
308 Ecore_Idler *queue_idler;
309 Ecore_Idler *must_recalc_idler;
310 Eina_List *queue, *selected;
311 Elm_Genlist_Item *show_item;
312 Elm_Genlist_Item *last_selected_item;
313 Eina_Inlist *item_cache;
314 Elm_Genlist_Item *anchor_item;
317 Ecore_Timer *multi_timer;
318 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
319 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
320 Eina_Bool mouse_down : 1;
321 Eina_Bool multi_down : 1;
322 Eina_Bool multi_timeout : 1;
323 Eina_Bool multitouched : 1;
324 Eina_Bool on_hold : 1;
326 Eina_Bool always_select : 1;
327 Eina_Bool longpressed : 1;
328 Eina_Bool wasselected : 1;
329 Eina_Bool no_select : 1;
330 Eina_Bool bring_in : 1;
331 Eina_Bool compress : 1;
332 Eina_Bool height_for_width : 1;
333 Eina_Bool homogeneous : 1;
334 Eina_Bool clear_me : 1;
339 } history[SWIPE_MOVES];
341 int item_cache_count;
347 int group_item_width;
348 int group_item_height;
349 int max_items_per_block;
350 double longpress_timeout;
352 // TODO : refactoring
353 Eina_Bool reorder_mode : 1;
354 Eina_Bool reorder_pan_move : 1;
355 Eina_Bool reorder_deleted : 1;
356 Eina_Bool effect_mode : 1;
357 Eina_Bool auto_scrolled : 1;
358 Eina_Bool contracting : 1;
360 Eina_List *sweeped_items;
361 Ecore_Timer *scr_hold_timer;
363 Elm_Genlist_Item *reorder_it, *reorder_rel;
364 Evas_Coord reorder_start_y;
365 Ecore_Animator *item_moving_effect_timer;
366 Evas_Object *alpha_bg;
367 Elm_Genlist_Item *expand_item;
368 Evas_Coord expand_item_end;
369 Evas_Coord expand_item_gap;
370 int move_effect_mode;
371 unsigned int start_time;
372 Ecore_Job *changed_job;
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 highlighted : 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;
473 Evas_Object *base_view, *spacer;
475 const char *item_style; // it->itc->item_style
476 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
477 Eina_Bool compress : 1; // it->wd->compress
478 Eina_Bool odd : 1; // in & 0x1
480 Eina_Bool selected : 1; // it->selected
481 Eina_Bool disabled : 1; // it->disabled
482 Eina_Bool expanded : 1; // it->expanded
485 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
486 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
490 Evas_Object_Smart_Clipped_Data __clipped_data;
492 Ecore_Job *resize_job;
495 static const char *widtype = NULL;
496 static void _item_cache_zero(Widget_Data *wd);
497 static void _del_hook(Evas_Object *obj);
498 static void _mirrored_set(Evas_Object *obj,
500 static void _theme_hook(Evas_Object *obj);
501 static void _show_region_hook(void *data,
503 static void _sizing_eval(Evas_Object *obj);
504 static void _item_unrealize(Elm_Genlist_Item *it);
505 static void _item_block_unrealize(Item_Block *itb);
506 static void _calc_job(void *data);
507 static void _on_focus_hook(void *data,
509 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
510 static void _changed_job(void *data);
511 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
512 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
513 static Eina_Bool _item_single_select_up(Widget_Data *wd);
514 static Eina_Bool _item_single_select_down(Widget_Data *wd);
515 static Eina_Bool _event_hook(Evas_Object *obj,
517 Evas_Callback_Type type,
519 static Eina_Bool _deselect_all_items(Widget_Data *wd);
520 static void _pan_calculate(Evas_Object *obj);
521 // TODO : refactoring
522 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
523 static unsigned int current_time_get();
524 static Eina_Bool _item_moving_effect_timer_cb(void *data);
525 static int _item_flip_effect_show(Elm_Genlist_Item *it);
526 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
527 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
528 static void _effect_item_unrealize(Elm_Genlist_Item *it);
529 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
530 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
531 static void _create_sweep_objs(Elm_Genlist_Item *it);
532 static void _delete_sweep_objs(Elm_Genlist_Item *it);
533 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
534 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
535 static void _group_items_recalc(void *data);
536 static void _item_auto_scroll(void *data);
538 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
541 _event_hook(Evas_Object *obj,
542 Evas_Object *src __UNUSED__,
543 Evas_Callback_Type type,
546 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
547 Evas_Event_Key_Down *ev = event_info;
548 Widget_Data *wd = elm_widget_data_get(obj);
549 if (!wd) return EINA_FALSE;
550 if (!wd->items) return EINA_FALSE;
551 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
552 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
554 Elm_Genlist_Item *it = NULL;
557 Evas_Coord step_x = 0;
558 Evas_Coord step_y = 0;
561 Evas_Coord page_x = 0;
562 Evas_Coord page_y = 0;
564 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
565 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
566 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
567 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
569 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
573 else if ((!strcmp(ev->keyname, "Right")) ||
574 (!strcmp(ev->keyname, "KP_Right")))
578 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
580 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
581 (_item_multi_select_up(wd)))
582 || (_item_single_select_up(wd)))
584 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
590 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
592 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
593 (_item_multi_select_down(wd)))
594 || (_item_single_select_down(wd)))
596 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
602 else if ((!strcmp(ev->keyname, "Home")) ||
603 (!strcmp(ev->keyname, "KP_Home")))
605 it = elm_genlist_first_item_get(obj);
606 elm_genlist_item_bring_in(it);
607 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
610 else if ((!strcmp(ev->keyname, "End")) ||
611 (!strcmp(ev->keyname, "KP_End")))
613 it = elm_genlist_last_item_get(obj);
614 elm_genlist_item_bring_in(it);
615 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
618 else if ((!strcmp(ev->keyname, "Prior")) ||
619 (!strcmp(ev->keyname, "KP_Prior")))
622 y -= -(page_y * v_h) / 100;
626 else if ((!strcmp(ev->keyname, "Next")) ||
627 (!strcmp(ev->keyname, "KP_Next")))
630 y += -(page_y * v_h) / 100;
634 else if(((!strcmp(ev->keyname, "Return")) ||
635 (!strcmp(ev->keyname, "KP_Enter")) ||
636 (!strcmp(ev->keyname, "space")))
637 && (!wd->multi) && (wd->selected))
639 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
640 elm_genlist_item_expanded_set(it,
641 !elm_genlist_item_expanded_get(it));
643 else if (!strcmp(ev->keyname, "Escape"))
645 if (!_deselect_all_items(wd)) return EINA_FALSE;
646 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
649 else return EINA_FALSE;
651 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
652 elm_smart_scroller_child_pos_set(wd->scr, x, y);
657 _deselect_all_items(Widget_Data *wd)
659 if (!wd->selected) return EINA_FALSE;
661 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
667 _item_multi_select_up(Widget_Data *wd)
669 if (!wd->selected) return EINA_FALSE;
670 if (!wd->multi) return EINA_FALSE;
672 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
673 if (!prev) return EINA_TRUE;
675 if (elm_genlist_item_selected_get(prev))
677 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
678 wd->last_selected_item = prev;
679 elm_genlist_item_show(wd->last_selected_item);
683 elm_genlist_item_selected_set(prev, EINA_TRUE);
684 elm_genlist_item_show(prev);
690 _item_multi_select_down(Widget_Data *wd)
692 if (!wd->selected) return EINA_FALSE;
693 if (!wd->multi) return EINA_FALSE;
695 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
696 if (!next) return EINA_TRUE;
698 if (elm_genlist_item_selected_get(next))
700 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
701 wd->last_selected_item = next;
702 elm_genlist_item_show(wd->last_selected_item);
706 elm_genlist_item_selected_set(next, EINA_TRUE);
707 elm_genlist_item_show(next);
713 _item_single_select_up(Widget_Data *wd)
715 Elm_Genlist_Item *prev;
718 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
719 while ((prev) && (prev->delete_me))
720 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
722 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
724 if (!prev) return EINA_FALSE;
726 _deselect_all_items(wd);
728 elm_genlist_item_selected_set(prev, EINA_TRUE);
729 elm_genlist_item_show(prev);
734 _item_single_select_down(Widget_Data *wd)
736 Elm_Genlist_Item *next;
739 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
740 while ((next) && (next->delete_me))
741 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
743 else next = elm_genlist_item_next_get(wd->last_selected_item);
745 if (!next) return EINA_FALSE;
747 _deselect_all_items(wd);
749 elm_genlist_item_selected_set(next, EINA_TRUE);
750 elm_genlist_item_show(next);
755 _on_focus_hook(void *data __UNUSED__,
758 Widget_Data *wd = elm_widget_data_get(obj);
760 if (elm_widget_focus_get(obj))
762 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
763 evas_object_focus_set(wd->obj, EINA_TRUE);
764 if ((wd->selected) && (!wd->last_selected_item))
765 wd->last_selected_item = eina_list_data_get(wd->selected);
769 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
770 evas_object_focus_set(wd->obj, EINA_FALSE);
775 _del_hook(Evas_Object *obj)
777 Widget_Data *wd = elm_widget_data_get(obj);
779 _item_cache_zero(wd);
780 if (wd->calc_job) ecore_job_del(wd->calc_job);
781 if (wd->update_job) ecore_job_del(wd->update_job);
782 if (wd->changed_job) ecore_job_del(wd->changed_job);
783 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
784 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
785 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
790 _del_pre_hook(Evas_Object *obj)
792 Widget_Data *wd = elm_widget_data_get(obj);
794 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
795 evas_object_del(wd->pan_smart);
796 wd->pan_smart = NULL;
797 elm_genlist_clear(obj);
801 _mirrored_set(Evas_Object *obj,
804 Widget_Data *wd = elm_widget_data_get(obj);
806 _item_cache_zero(wd);
807 // TODO: uncomment this after upstream merge
808 //elm_smart_scroller_mirrored_set(wd->scr, rtl);
812 _theme_hook(Evas_Object *obj)
814 Widget_Data *wd = elm_widget_data_get(obj);
817 _item_cache_zero(wd);
818 // TODO: uncomment this after upstream merge
819 //_elm_widget_mirrored_reload(obj);
820 //_mirrored_set(obj, elm_widget_mirrored_get(obj));
821 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
822 elm_widget_style_get(obj));
823 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
824 wd->item_width = wd->item_height = 0;
825 wd->group_item_width = wd->group_item_height = 0;
826 wd->minw = wd->minh = wd->realminw = 0;
827 EINA_INLIST_FOREACH(wd->blocks, itb)
830 Elm_Genlist_Item *it;
832 if (itb->realized) _item_block_unrealize(itb);
833 EINA_LIST_FOREACH(itb->items, l, it)
834 it->mincalcd = EINA_FALSE;
836 itb->changed = EINA_TRUE;
838 if (wd->calc_job) ecore_job_del(wd->calc_job);
839 wd->calc_job = ecore_job_add(_calc_job, wd);
844 _show_region_hook(void *data,
847 Widget_Data *wd = elm_widget_data_get(data);
848 Evas_Coord x, y, w, h;
850 elm_widget_show_region_get(obj, &x, &y, &w, &h);
851 //x & y are screen coordinates, Add with pan coordinates
854 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
858 _sizing_eval(Evas_Object *obj)
860 Widget_Data *wd = elm_widget_data_get(obj);
861 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
863 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
864 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
866 if (wd->height_for_width)
870 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
871 if ((vw != 0) && (vw != wd->prev_viewport_w))
875 wd->prev_viewport_w = vw;
876 EINA_INLIST_FOREACH(wd->blocks, itb)
878 itb->must_recalc = EINA_TRUE;
880 if (wd->calc_job) ecore_job_del(wd->calc_job);
881 wd->calc_job = ecore_job_add(_calc_job, wd);
884 if (wd->mode == ELM_LIST_LIMIT)
886 Evas_Coord vmw, vmh, vw, vh;
890 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
891 if ((minw > 0) && (vw < minw)) vw = minw;
892 else if ((maxw > 0) && (vw > maxw))
894 edje_object_size_min_calc
895 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
902 edje_object_size_min_calc
903 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
907 evas_object_size_hint_min_set(obj, minw, minh);
908 evas_object_size_hint_max_set(obj, maxw, maxh);
912 _item_highlight(Elm_Genlist_Item *it)
914 const char *selectraise;
915 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
916 if ((!it->sweeped) && (!it->wd->edit_mode))
917 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
918 selectraise = edje_object_data_get(it->base.view, "selectraise");
919 if ((selectraise) && (!strcmp(selectraise, "on")))
921 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
922 if ((it->group_item) && (it->group_item->realized))
923 evas_object_raise(it->group_item->base.view);
925 it->highlighted = EINA_TRUE;
929 _item_block_del(Elm_Genlist_Item *it)
932 Item_Block *itb = it->block;
934 itb->items = eina_list_remove(itb->items, it);
936 itb->changed = EINA_TRUE;
937 if (!it->wd->reorder_deleted)
939 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
940 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
944 il = EINA_INLIST_GET(itb);
945 Item_Block *itbn = (Item_Block *)(il->next);
947 it->parent->items = eina_list_remove(it->parent->items, it);
949 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
951 if (itbn) itbn->changed = EINA_TRUE;
955 if (itb->count < itb->wd->max_items_per_block/2)
957 il = EINA_INLIST_GET(itb);
958 Item_Block *itbp = (Item_Block *)(il->prev);
959 Item_Block *itbn = (Item_Block *)(il->next);
960 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
962 Elm_Genlist_Item *it2;
964 EINA_LIST_FREE(itb->items, it2)
967 itbp->items = eina_list_append(itbp->items, it2);
969 itbp->changed = EINA_TRUE;
971 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
972 EINA_INLIST_GET(itb));
975 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
979 Eina_List *last = eina_list_last(itb->items);
980 Elm_Genlist_Item *it2 = last->data;
983 itb->items = eina_list_remove_list(itb->items, last);
984 itbn->items = eina_list_prepend(itbn->items, it2);
986 itbn->changed = EINA_TRUE;
989 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
997 _item_subitems_clear(Elm_Genlist_Item *it)
1000 Eina_List *tl = NULL, *l;
1001 Elm_Genlist_Item *it2;
1003 EINA_LIST_FOREACH(it->items, l, it2)
1004 tl = eina_list_append(tl, it2);
1006 EINA_LIST_FREE(tl, it2)
1007 elm_genlist_item_del(it2);
1011 _item_del(Elm_Genlist_Item *it)
1013 elm_widget_item_pre_notify_del(it);
1014 elm_genlist_item_subitems_clear(it);
1015 it->wd->walking -= it->walking;
1016 if (it->wd->show_item == it) it->wd->show_item = NULL;
1017 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1018 if (it->realized) _item_unrealize(it);
1019 if (it->effect_item_realized) _effect_item_unrealize(it);
1020 if (it->block) _item_block_del(it);
1021 if ((!it->delete_me) && (it->itc->func.del))
1022 it->itc->func.del((void *)it->base.data, it->base.widget);
1023 it->delete_me = EINA_TRUE;
1025 it->wd->queue = eina_list_remove(it->wd->queue, it);
1027 if (it->wd->anchor_item == it)
1029 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1030 if (!it->wd->anchor_item)
1031 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1034 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1036 it->parent->items = eina_list_remove(it->parent->items, it);
1037 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1038 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1039 if (it->long_timer) ecore_timer_del(it->long_timer);
1040 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1042 if (it->tooltip.del_cb)
1043 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1045 elm_widget_item_del(it);
1046 it->wd->total_num--; // todo : remove
1050 _item_select(Elm_Genlist_Item *it)
1052 if ((it->wd->no_select) || (it->delete_me)) return;
1055 if (it->wd->always_select) goto call;
1058 it->selected = EINA_TRUE;
1059 it->wd->selected = eina_list_append(it->wd->selected, it);
1063 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1065 evas_object_smart_callback_call(it->base.widget, "selected", it);
1068 if ((it->wd->clear_me) && (!it->wd->walking))
1070 elm_genlist_clear(it->base.widget);
1075 if ((!it->walking) && (it->delete_me))
1077 if (!it->relcount) _item_del(it);
1080 if (it && it->wd) it->wd->last_selected_item = it;
1084 _item_unselect(Elm_Genlist_Item *it)
1086 const char *stacking, *selectraise;
1088 if ((it->delete_me) || (!it->highlighted)) return;
1090 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1091 stacking = edje_object_data_get(it->base.view, "stacking");
1092 selectraise = edje_object_data_get(it->base.view, "selectraise");
1093 if ((selectraise) && (!strcmp(selectraise, "on")))
1095 if ((stacking) && (!strcmp(stacking, "below")))
1096 evas_object_lower(it->base.view);
1098 it->highlighted = EINA_FALSE;
1101 it->selected = EINA_FALSE;
1102 it->wd->selected = eina_list_remove(it->wd->selected, it);
1103 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1108 _mouse_move(void *data,
1109 Evas *evas __UNUSED__,
1113 Elm_Genlist_Item *it = data;
1114 Evas_Event_Mouse_Move *ev = event_info;
1115 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1117 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1119 if (!it->wd->on_hold)
1121 it->wd->on_hold = EINA_TRUE;
1122 if (!it->wd->wasselected)
1126 if (it->wd->multitouched)
1128 it->wd->cur_x = ev->cur.canvas.x;
1129 it->wd->cur_y = ev->cur.canvas.y;
1132 if ((it->dragging) && (it->down))
1134 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1137 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1138 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1139 if (abs((it->wd->history[it->wd->movements].x -
1140 it->wd->history[0].x)) > 40)
1141 it->wd->swipe = EINA_TRUE;
1143 it->wd->movements++;
1147 ecore_timer_del(it->long_timer);
1148 it->long_timer = NULL;
1150 evas_object_smart_callback_call(it->base.widget, "drag", it);
1153 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1157 ecore_timer_del(it->long_timer);
1158 it->long_timer = NULL;
1160 if (it->wd->reorder_mode && it->wd->reorder_it)
1162 Evas_Coord ox,oy,oh,ow;
1163 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1164 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1165 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1167 evas_object_resize(it->base.view, it->w, it->h);
1168 if (it_y < oy) _effect_item_controls(it, it->scrl_x, oy);
1169 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);
1170 else _effect_item_controls(it, it->scrl_x, it_y);
1172 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1173 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1177 if (!it->display_only)
1178 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1179 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1180 x = ev->cur.canvas.x - x;
1181 y = ev->cur.canvas.y - y;
1184 if (adx < 0) adx = -dx;
1187 if (ady < 0) ady = -dy;
1190 if ((adx > minw) || (ady > minh))
1192 it->dragging = EINA_TRUE;
1195 ecore_timer_del(it->long_timer);
1196 it->long_timer = NULL;
1198 if (!it->wd->wasselected)
1203 evas_object_smart_callback_call(it->base.widget,
1204 "drag,start,up", it);
1209 evas_object_smart_callback_call(it->base.widget,
1210 "drag,start,left", it);
1211 _item_slide(it, EINA_FALSE);
1215 evas_object_smart_callback_call(it->base.widget,
1216 "drag,start,right", it);
1217 _item_slide(it, EINA_TRUE);
1224 evas_object_smart_callback_call(it->base.widget,
1225 "drag,start,down", it);
1230 evas_object_smart_callback_call(it->base.widget,
1231 "drag,start,left", it);
1232 _item_slide(it, EINA_FALSE);
1236 evas_object_smart_callback_call(it->base.widget,
1237 "drag,start,right", it);
1238 _item_slide(it, EINA_TRUE);
1246 _long_press(void *data)
1248 Elm_Genlist_Item *it = data;
1249 Elm_Genlist_Item *it_tmp;
1250 static Eina_Bool done = EINA_FALSE;
1251 //static Eina_Bool contracted = EINA_FALSE;
1255 it->long_timer = NULL;
1256 if ((it->disabled) || (it->dragging) || (it->display_only))
1257 return ECORE_CALLBACK_CANCEL;
1258 it->wd->longpressed = EINA_TRUE;
1259 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1260 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1262 it->wd->reorder_it = it;
1263 it->wd->reorder_start_y = 0;
1264 evas_object_raise(it->edit_obj);
1265 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1266 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1268 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1273 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1275 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1277 _item_unselect(it_tmp);
1289 EINA_LIST_FOREACH(it->items, l, it_tmp)
1291 if (elm_genlist_item_expanded_get(it_tmp))
1293 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1294 return ECORE_CALLBACK_RENEW;
1298 if (elm_genlist_item_expanded_get(it)) {
1299 elm_genlist_item_expanded_set(it, EINA_FALSE);
1300 return ECORE_CALLBACK_RENEW;
1302 if (it->wd->edit_field && it->renamed)
1303 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1306 return ECORE_CALLBACK_CANCEL;
1310 _swipe(Elm_Genlist_Item *it)
1315 if ((it->display_only) || (it->disabled)) return;
1316 it->wd->swipe = EINA_FALSE;
1317 for (i = 0; i < it->wd->movements; i++)
1319 sum += it->wd->history[i].x;
1320 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1323 sum /= it->wd->movements;
1324 if (abs(sum - it->wd->history[0].x) <= 10) return;
1325 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1329 _swipe_cancel(void *data)
1331 Elm_Genlist_Item *it = data;
1333 if (!it) return ECORE_CALLBACK_CANCEL;
1334 it->wd->swipe = EINA_FALSE;
1335 it->wd->movements = 0;
1336 return ECORE_CALLBACK_RENEW;
1340 _multi_cancel(void *data)
1342 Widget_Data *wd = data;
1344 if (!wd) return ECORE_CALLBACK_CANCEL;
1345 wd->multi_timeout = EINA_TRUE;
1346 return ECORE_CALLBACK_RENEW;
1350 _multi_touch_gesture_eval(void *data)
1352 Elm_Genlist_Item *it = data;
1354 it->wd->multitouched = EINA_FALSE;
1355 if (it->wd->multi_timer)
1357 ecore_timer_del(it->wd->multi_timer);
1358 it->wd->multi_timer = NULL;
1360 if (it->wd->multi_timeout)
1362 it->wd->multi_timeout = EINA_FALSE;
1366 Evas_Coord minw = 0, minh = 0;
1367 Evas_Coord off_x, off_y, off_mx, off_my;
1369 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1370 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1371 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1372 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1373 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1375 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1377 if ((off_x + off_mx) > (off_y + off_my))
1379 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1380 evas_object_smart_callback_call(it->base.widget,
1381 "multi,swipe,right", it);
1382 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1383 evas_object_smart_callback_call(it->base.widget,
1384 "multi,swipe,left", it);
1385 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1386 evas_object_smart_callback_call(it->base.widget,
1387 "multi,pinch,out", it);
1389 evas_object_smart_callback_call(it->base.widget,
1390 "multi,pinch,in", it);
1394 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1395 evas_object_smart_callback_call(it->base.widget,
1396 "multi,swipe,down", it);
1397 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1398 evas_object_smart_callback_call(it->base.widget,
1399 "multi,swipe,up", it);
1400 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1401 evas_object_smart_callback_call(it->base.widget,
1402 "multi,pinch,out", it);
1404 evas_object_smart_callback_call(it->base.widget,
1405 "multi,pinch,in", it);
1408 it->wd->multi_timeout = EINA_FALSE;
1412 _multi_down(void *data,
1413 Evas *evas __UNUSED__,
1414 Evas_Object *obj __UNUSED__,
1417 Elm_Genlist_Item *it = data;
1418 Evas_Event_Multi_Down *ev = event_info;
1420 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1421 it->wd->multi_device = ev->device;
1422 it->wd->multi_down = EINA_TRUE;
1423 it->wd->multitouched = EINA_TRUE;
1424 it->wd->prev_mx = ev->canvas.x;
1425 it->wd->prev_my = ev->canvas.y;
1426 if (!it->wd->wasselected) _item_unselect(it);
1427 it->wd->wasselected = EINA_FALSE;
1428 it->wd->longpressed = EINA_FALSE;
1431 ecore_timer_del(it->long_timer);
1432 it->long_timer = NULL;
1436 it->dragging = EINA_FALSE;
1437 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1439 if (it->swipe_timer)
1441 ecore_timer_del(it->swipe_timer);
1442 it->swipe_timer = NULL;
1444 if (it->wd->on_hold)
1446 it->wd->swipe = EINA_FALSE;
1447 it->wd->movements = 0;
1448 it->wd->on_hold = EINA_FALSE;
1453 _multi_up(void *data,
1454 Evas *evas __UNUSED__,
1455 Evas_Object *obj __UNUSED__,
1458 Elm_Genlist_Item *it = data;
1459 Evas_Event_Multi_Up *ev = event_info;
1461 if (it->wd->multi_device != ev->device) return;
1462 it->wd->multi_device = 0;
1463 it->wd->multi_down = EINA_FALSE;
1464 if (it->wd->mouse_down) return;
1465 _multi_touch_gesture_eval(data);
1469 _multi_move(void *data,
1470 Evas *evas __UNUSED__,
1471 Evas_Object *obj __UNUSED__,
1474 Elm_Genlist_Item *it = data;
1475 Evas_Event_Multi_Move *ev = event_info;
1477 if (it->wd->multi_device != ev->device) return;
1478 it->wd->cur_mx = ev->cur.canvas.x;
1479 it->wd->cur_my = ev->cur.canvas.y;
1483 _mouse_down(void *data,
1484 Evas *evas __UNUSED__,
1488 Elm_Genlist_Item *it = data;
1489 Evas_Event_Mouse_Down *ev = event_info;
1492 if (ev->button != 1) return;
1493 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1495 it->wd->on_hold = EINA_TRUE;
1498 if (it->wd->edit_field && !it->renamed)
1499 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1500 it->down = EINA_TRUE;
1501 it->dragging = EINA_FALSE;
1502 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1503 it->dx = ev->canvas.x - x;
1504 it->dy = ev->canvas.y - y;
1505 it->wd->mouse_down = EINA_TRUE;
1506 if (!it->wd->multitouched)
1508 it->wd->prev_x = ev->canvas.x;
1509 it->wd->prev_y = ev->canvas.y;
1510 it->wd->multi_timeout = EINA_FALSE;
1511 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1512 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1514 it->wd->longpressed = EINA_FALSE;
1515 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1516 else it->wd->on_hold = EINA_FALSE;
1517 if (it->wd->on_hold) return;
1518 it->wd->wasselected = it->selected;
1519 _item_highlight(it);
1520 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1521 if ((!it->disabled) && (!it->display_only))
1522 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1523 if (it->long_timer) ecore_timer_del(it->long_timer);
1524 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1525 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1527 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1530 it->long_timer = NULL;
1531 it->wd->swipe = EINA_FALSE;
1532 it->wd->movements = 0;
1536 _mouse_up(void *data,
1537 Evas *evas __UNUSED__,
1538 Evas_Object *obj __UNUSED__,
1541 Elm_Genlist_Item *it = data;
1542 Evas_Event_Mouse_Up *ev = event_info;
1543 Eina_Bool dragged = EINA_FALSE;
1545 if (ev->button != 1) return;
1546 it->down = EINA_FALSE;
1547 it->wd->mouse_down = EINA_FALSE;
1548 if (it->wd->multitouched)
1550 if (it->wd->multi_down) return;
1551 _multi_touch_gesture_eval(data);
1554 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1555 else it->wd->on_hold = EINA_FALSE;
1558 ecore_timer_del(it->long_timer);
1559 it->long_timer = NULL;
1563 it->dragging = EINA_FALSE;
1564 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1567 if (it->swipe_timer)
1569 ecore_timer_del(it->swipe_timer);
1570 it->swipe_timer = NULL;
1572 if (it->wd->multi_timer)
1574 ecore_timer_del(it->wd->multi_timer);
1575 it->wd->multi_timer = NULL;
1576 it->wd->multi_timeout = EINA_FALSE;
1578 if (it->wd->on_hold)
1580 if (it->wd->swipe) _swipe(data);
1581 it->wd->longpressed = EINA_FALSE;
1582 it->wd->on_hold = EINA_FALSE;
1585 if (it->wd->reorder_mode)
1587 Evas_Coord rox, roy, row, roh;
1588 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1591 Evas_Coord ox,oy,oh,ow;
1592 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1593 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1594 if (it->wd->reorder_rel)
1596 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1598 if (roy + oy <= it->wd->reorder_rel->scrl_y)
1599 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1601 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1604 it->wd->reorder_deleted = EINA_FALSE;
1605 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1606 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1607 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1610 if (it->wd->longpressed)
1612 it->wd->longpressed = EINA_FALSE;
1613 if (!it->wd->wasselected)
1615 it->wd->wasselected = EINA_FALSE;
1620 if (it->want_unrealize)
1622 _item_unrealize(it);
1623 if (it->block->want_unrealize)
1624 _item_block_unrealize(it->block);
1627 if ((it->disabled) || (dragged) || (it->display_only)) return;
1628 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1631 if ((!it->selected) && (!it->sweeped))
1633 _item_highlight(it);
1636 else _item_unselect(it);
1642 Widget_Data *wd = it->wd;
1645 while (wd->selected) _item_unselect(wd->selected->data);
1650 const Eina_List *l, *l_next;
1651 Elm_Genlist_Item *it2;
1653 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1654 if (it2 != it) _item_unselect(it2);
1655 //_item_highlight(it);
1660 _item_highlight(it);
1667 _signal_expand_toggle(void *data,
1668 Evas_Object *obj __UNUSED__,
1669 const char *emission __UNUSED__,
1670 const char *source __UNUSED__)
1672 Elm_Genlist_Item *it = data;
1675 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1677 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1681 _signal_expand(void *data,
1682 Evas_Object *obj __UNUSED__,
1683 const char *emission __UNUSED__,
1684 const char *source __UNUSED__)
1686 Elm_Genlist_Item *it = data;
1689 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1693 _signal_contract(void *data,
1694 Evas_Object *obj __UNUSED__,
1695 const char *emission __UNUSED__,
1696 const char *source __UNUSED__)
1698 Elm_Genlist_Item *it = data;
1701 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1705 _item_cache_clean(Widget_Data *wd)
1707 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1711 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1712 wd->item_cache = eina_inlist_remove(wd->item_cache,
1713 wd->item_cache->last);
1714 wd->item_cache_count--;
1715 if (itc->spacer) evas_object_del(itc->spacer);
1716 if (itc->base_view) evas_object_del(itc->base_view);
1717 if (itc->item_style) eina_stringshare_del(itc->item_style);
1723 _item_cache_zero(Widget_Data *wd)
1725 int pmax = wd->item_cache_max;
1726 wd->item_cache_max = 0;
1727 _item_cache_clean(wd);
1728 wd->item_cache_max = pmax;
1732 _item_cache_add(Elm_Genlist_Item *it)
1736 if (it->wd->item_cache_max <= 0)
1738 evas_object_del(it->base.view);
1739 it->base.view = NULL;
1740 evas_object_del(it->spacer);
1745 it->wd->item_cache_count++;
1746 itc = calloc(1, sizeof(Item_Cache));
1748 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1749 EINA_INLIST_GET(itc));
1750 itc->spacer = it->spacer;
1752 itc->base_view = it->base.view;
1753 it->base.view = NULL;
1754 evas_object_hide(itc->base_view);
1755 evas_object_move(itc->base_view, -9999, -9999);
1756 itc->item_style = eina_stringshare_add(it->itc->item_style);
1757 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1758 itc->compress = (it->wd->compress);
1759 itc->odd = (it->order_num_in & 0x1);
1760 itc->selected = it->selected;
1761 itc->disabled = it->disabled;
1762 itc->expanded = it->expanded;
1765 ecore_timer_del(it->long_timer);
1766 it->long_timer = NULL;
1768 if (it->swipe_timer)
1770 ecore_timer_del(it->swipe_timer);
1771 it->swipe_timer = NULL;
1773 // FIXME: other callbacks?
1774 edje_object_signal_callback_del_full(itc->base_view,
1775 "elm,action,expand,toggle",
1776 "elm", _signal_expand_toggle, it);
1777 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1779 _signal_expand, it);
1780 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1781 "elm", _signal_contract, it);
1782 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1784 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1786 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1788 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1790 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1792 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1794 _item_cache_clean(it->wd);
1798 _item_cache_find(Elm_Genlist_Item *it)
1801 Eina_Bool tree = 0, odd;
1803 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1804 odd = (it->order_num_in & 0x1);
1805 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1807 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1809 if ((itc->tree == tree) &&
1810 (itc->odd == odd) &&
1811 (itc->compress == it->wd->compress) &&
1812 (!strcmp(it->itc->item_style, itc->item_style)))
1814 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1815 EINA_INLIST_GET(itc));
1816 it->wd->item_cache_count--;
1824 _item_cache_free(Item_Cache *itc)
1826 if (itc->spacer) evas_object_del(itc->spacer);
1827 if (itc->base_view) evas_object_del(itc->base_view);
1828 if (itc->item_style) eina_stringshare_del(itc->item_style);
1833 _item_realize(Elm_Genlist_Item *it,
1837 Elm_Genlist_Item *it2;
1838 const char *stacking;
1839 const char *treesize;
1841 int depth, tsize = 20;
1842 Item_Cache *itc = NULL;
1844 if ((it->realized) || (it->delete_me)) return;
1845 it->order_num_in = in;
1846 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1848 it->nocache = EINA_FALSE;
1850 itc = _item_cache_find(it);
1851 if ((!it->wd->effect_mode) && (itc))
1853 it->base.view = itc->base_view;
1854 itc->base_view = NULL;
1855 it->spacer = itc->spacer;
1860 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1861 edje_object_scale_set(it->base.view,
1862 elm_widget_scale_get(it->base.widget) *
1863 _elm_config->scale);
1864 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1865 elm_widget_sub_object_add(it->base.widget, it->base.view);
1867 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1868 strncpy(buf, "tree", sizeof(buf));
1869 else strncpy(buf, "item", sizeof(buf));
1870 if (it->wd->compress)
1871 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1873 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1874 strncat(buf, "/", sizeof(buf) - strlen(buf));
1875 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1877 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1878 elm_widget_style_get(it->base.widget));
1879 // TODO: uncomment this after upstream merge
1880 //edje_object_mirrored_set(it->base.view,
1881 // elm_widget_mirrored_get(it->base.widget));
1883 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1884 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1885 elm_widget_sub_object_add(it->base.widget, it->spacer);
1887 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1889 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1891 it->expanded_depth = depth;
1892 treesize = edje_object_data_get(it->base.view, "treesize");
1893 if (treesize) tsize = atoi(treesize);
1894 evas_object_size_hint_min_set(it->spacer,
1895 (depth * tsize) * _elm_config->scale, 1);
1896 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1899 edje_object_signal_callback_add(it->base.view,
1900 "elm,action,expand,toggle",
1901 "elm", _signal_expand_toggle, it);
1902 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1903 "elm", _signal_expand, it);
1904 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1905 "elm", _signal_contract, it);
1906 stacking = edje_object_data_get(it->base.view, "stacking");
1909 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1910 else if (!strcmp(stacking, "above"))
1911 evas_object_raise(it->base.view);
1913 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1915 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1917 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1919 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1921 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1923 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1927 if (it->selected != itc->selected)
1929 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1930 edje_object_signal_emit(it->base.view,
1931 "elm,state,selected", "elm");
1933 if (it->disabled != itc->disabled)
1936 edje_object_signal_emit(it->base.view,
1937 "elm,state,disabled", "elm");
1939 if (it->expanded != itc->expanded)
1942 edje_object_signal_emit(it->base.view,
1943 "elm,state,expanded", "elm");
1948 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1949 edje_object_signal_emit(it->base.view,
1950 "elm,state,selected", "elm");
1952 edje_object_signal_emit(it->base.view,
1953 "elm,state,disabled", "elm");
1955 edje_object_signal_emit(it->base.view,
1956 "elm,state,expanded", "elm");
1960 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1962 /* homogenous genlist shortcut */
1965 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1967 it->w = it->minw = it->wd->group_item_width;
1968 it->h = it->minh = it->wd->group_item_height;
1972 it->w = it->minw = it->wd->item_width;
1973 it->h = it->minh = it->wd->item_height;
1975 it->mincalcd = EINA_TRUE;
1980 if (it->itc->func.label_get)
1986 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1988 EINA_LIST_FOREACH(it->labels, l, key)
1990 char *s = it->itc->func.label_get
1991 ((void *)it->base.data, it->base.widget, l->data);
1995 edje_object_part_text_set(it->base.view, l->data, s);
1999 edje_object_part_text_set(it->base.view, l->data, "");
2002 if (it->itc->func.icon_get)
2008 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2010 EINA_LIST_FOREACH(it->icons, l, key)
2012 Evas_Object *ic = it->itc->func.icon_get
2013 ((void *)it->base.data, it->base.widget, l->data);
2017 it->icon_objs = eina_list_append(it->icon_objs, ic);
2018 edje_object_part_swallow(it->base.view, key, ic);
2019 evas_object_show(ic);
2020 elm_widget_sub_object_add(it->base.widget, ic);
2021 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2025 if (it->itc->func.state_get)
2031 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2033 EINA_LIST_FOREACH(it->states, l, key)
2035 Eina_Bool on = it->itc->func.state_get
2036 ((void *)it->base.data, it->base.widget, l->data);
2040 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2041 edje_object_signal_emit(it->base.view, buf, "elm");
2045 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2046 edje_object_signal_emit(it->base.view, buf, "elm");
2051 _create_sweep_objs(it);
2054 Evas_Coord mw = -1, mh = -1;
2056 if (it->wd->height_for_width) mw = it->wd->w;
2058 if (!it->display_only)
2059 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2060 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2061 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2063 if (!it->display_only)
2064 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2065 it->w = it->minw = mw;
2066 it->h = it->minh = mh;
2067 it->mincalcd = EINA_TRUE;
2069 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2071 it->wd->group_item_width = mw;
2072 it->wd->group_item_height = mh;
2074 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2076 it->wd->item_width = mw;
2077 it->wd->item_height = mh;
2080 if (!calc) evas_object_show(it->base.view);
2083 if (it->tooltip.content_cb)
2085 elm_widget_item_tooltip_content_cb_set(it,
2086 it->tooltip.content_cb,
2087 it->tooltip.data, NULL);
2088 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2091 if (it->mouse_cursor)
2092 elm_widget_item_cursor_set(it, it->mouse_cursor);
2094 it->realized = EINA_TRUE;
2095 it->want_unrealize = EINA_FALSE;
2097 if (itc) _item_cache_free(itc);
2098 evas_object_smart_callback_call(it->base.widget, "realized", it);
2099 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2101 if (it->itc->edit_item_style )
2103 _effect_item_realize(it, EINA_FALSE);
2104 edje_object_message_signal_process(it->edit_obj);
2110 _item_unrealize(Elm_Genlist_Item *it)
2114 if (!it->realized) return;
2115 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2116 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2119 ecore_timer_del(it->long_timer);
2120 it->long_timer = NULL;
2122 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2124 it->sweeped = EINA_FALSE;
2125 it->wassweeped = EINA_FALSE;
2126 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2127 _delete_sweep_objs(it);
2128 evas_object_del(it->base.view);
2129 it->base.view = NULL;
2130 evas_object_del(it->spacer);
2135 // TODO: uncomment this after upstream merge
2136 //edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2137 _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, EINA_TRUE);
2179 _item_unrealize(it);
2184 _item_realize(it, in, EINA_TRUE);
2185 if (!it->wd->contracting) _item_unrealize(it);
2189 _item_realize(it, in, EINA_FALSE);
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, EINA_FALSE);
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 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2349 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2352 EINA_LIST_FOREACH(itb->items, l, it)
2354 if (it->delete_me) continue;
2355 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2360 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2361 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2363 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2364 cvx, cvy, cvw, cvh));
2365 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2367 if ((itb->realized) && (!it->realized))
2371 _item_realize(it, in, 0);
2374 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2375 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2383 if(it->wd->reorder_mode)
2384 y += _get_space_for_reorder_item(it);
2385 git = it->group_item;
2388 git->scrl_x = it->scrl_x;
2389 if (git->scrl_y < oy)
2391 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2392 git->scrl_y = (it->scrl_y + it->h) - git->h;
2393 git->want_realize = EINA_TRUE;
2395 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2397 if (!it->move_effect_me)
2399 it->move_effect_me = EINA_TRUE;
2400 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2404 if (!it->move_effect_me )
2405 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))
2407 if (it->wd->edit_mode && it->itc->edit_item_style)
2409 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2413 evas_object_resize(it->base.view, it->w, it->h);
2414 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2415 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)))
2416 evas_object_show(it->base.view);
2418 evas_object_hide(it->base.view);
2420 it->old_scrl_x = it->scrl_x;
2421 it->old_scrl_y = it->scrl_y;
2426 if (!it->dragging) _item_unrealize(it);
2433 if (vis) it->want_realize = EINA_TRUE;
2440 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2442 Elm_Genlist_Item *it = data;
2444 it->mincalcd = EINA_FALSE;
2445 it->block->updateme = EINA_TRUE;
2446 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2447 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2451 _group_items_recalc(void *data)
2453 Widget_Data *wd = data;
2455 Elm_Genlist_Item *git;
2457 EINA_LIST_FOREACH(wd->group_items, l, git)
2459 if (git->want_realize)
2462 _item_realize(git, 0, EINA_FALSE);
2463 evas_object_resize(git->base.view, wd->minw, git->h);
2464 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2465 evas_object_show(git->base.view);
2466 evas_object_raise(git->base.view);
2468 else if (!git->want_realize && git->realized)
2471 _item_unrealize(git);
2477 _must_recalc_idler(void *data)
2479 Widget_Data *wd = data;
2480 if (wd->calc_job) ecore_job_del(wd->calc_job);
2481 wd->calc_job = ecore_job_add(_calc_job, wd);
2482 wd->must_recalc_idler = NULL;
2483 return ECORE_CALLBACK_CANCEL;
2487 _calc_job(void *data)
2489 Widget_Data *wd = data;
2491 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2492 Item_Block *chb = NULL;
2493 int in = 0, minw_change = 0;
2494 Eina_Bool changed = EINA_FALSE;
2496 Eina_Bool did_must_recalc = EINA_FALSE;
2499 t0 = ecore_time_get();
2500 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2504 // if (wd->height_for_width) changed = EINA_TRUE;
2507 EINA_INLIST_FOREACH(wd->blocks, itb)
2509 Eina_Bool showme = EINA_FALSE;
2512 showme = itb->showme;
2513 itb->showme = EINA_FALSE;
2516 if (itb->realized) _item_block_unrealize(itb);
2518 if ((itb->changed) || (changed) ||
2519 ((itb->must_recalc) && (!did_must_recalc)))
2521 if ((changed) || (itb->must_recalc))
2524 Elm_Genlist_Item *it;
2525 EINA_LIST_FOREACH(itb->items, l, it)
2526 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2527 itb->changed = EINA_TRUE;
2528 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2529 itb->must_recalc = EINA_FALSE;
2531 if (itb->realized) _item_block_unrealize(itb);
2532 showme = _item_block_recalc(itb, in, 0, 1);
2538 if (minw == -1) minw = itb->minw;
2539 else if ((!itb->must_recalc) && (minw < itb->minw))
2548 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2550 wd->show_item->showme = EINA_FALSE;
2552 elm_smart_scroller_region_bring_in(wd->scr,
2554 wd->show_item->block->x,
2556 wd->show_item->block->y,
2557 wd->show_item->block->w,
2560 elm_smart_scroller_child_region_show(wd->scr,
2562 wd->show_item->block->x,
2564 wd->show_item->block->y,
2565 wd->show_item->block->w,
2567 wd->show_item = NULL;
2572 EINA_INLIST_FOREACH(wd->blocks, itb)
2578 if ((chb) && (EINA_INLIST_GET(chb)->next))
2580 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2582 if (itb->realized) _item_block_unrealize(itb);
2585 wd->realminw = minw;
2586 if (minw < wd->w) minw = wd->w;
2587 if ((minw != wd->minw) || (minh != wd->minh))
2591 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2592 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2593 _sizing_eval(wd->obj);
2595 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2597 Elm_Genlist_Item *it;
2600 it = wd->anchor_item;
2601 it_y = wd->anchor_y;
2602 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2603 it->block->y + it->y + it_y);
2604 wd->anchor_item = it;
2605 wd->anchor_y = it_y;
2609 t = ecore_time_get();
2610 if (did_must_recalc)
2612 if (!wd->must_recalc_idler)
2613 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2615 wd->calc_job = NULL;
2616 evas_object_smart_changed(wd->pan_smart);
2620 _update_job(void *data)
2622 Widget_Data *wd = data;
2625 int num, num0, position = 0, recalc = 0;
2627 wd->update_job = NULL;
2629 EINA_INLIST_FOREACH(wd->blocks, itb)
2631 Evas_Coord itminw, itminh;
2632 Elm_Genlist_Item *it;
2638 _item_block_position(itb, num);
2643 EINA_LIST_FOREACH(itb->items, l2, it)
2650 it->updateme = EINA_FALSE;
2653 _item_unrealize(it);
2654 _item_realize(it, num, 0);
2659 _item_realize(it, num, 1);
2660 _item_unrealize(it);
2662 if ((it->minw != itminw) || (it->minh != itminh))
2667 itb->updateme = EINA_FALSE;
2671 itb->changed = EINA_TRUE;
2672 _item_block_recalc(itb, num0, 0, 1);
2673 _item_block_position(itb, num0);
2678 if (wd->calc_job) ecore_job_del(wd->calc_job);
2679 wd->calc_job = ecore_job_add(_calc_job, wd);
2684 _changed_job(void *data)
2686 Widget_Data *wd = data; Eina_List *l2;
2688 int num, num0, position = 0, recalc = 0;
2690 wd->changed_job = NULL;
2692 EINA_INLIST_FOREACH(wd->blocks, itb)
2694 Evas_Coord itminw, itminh;
2695 Elm_Genlist_Item *it;
2701 _item_block_position(itb, num);
2706 EINA_LIST_FOREACH(itb->items, l2, it)
2710 Evas_Coord mw = -1, mh = -1;
2714 if (it->wd->height_for_width) mw = it->wd->w;
2715 if (!it->display_only)
2716 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2717 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2718 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2719 if (!it->display_only)
2720 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2721 it->w = it->minw = mw;
2722 it->h = it->minh = mh;
2723 it->mincalcd = EINA_TRUE;
2725 //if ((it->minw != itminw) || (it->minh != itminh))
2726 if ((it->minh != itminh))
2731 itb->updateme = EINA_FALSE;
2735 itb->changed = EINA_TRUE;
2736 _item_block_recalc(itb, num0, 0, 1);
2737 _item_block_position(itb, num0);
2742 if (wd->calc_job) ecore_job_del(wd->calc_job);
2743 wd->calc_job = ecore_job_add(_calc_job, wd);
2748 _pan_set(Evas_Object *obj,
2752 Pan *sd = evas_object_smart_data_get(obj);
2755 // Evas_Coord ow, oh;
2756 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2757 // ow = sd->wd->minw - ow;
2758 // if (ow < 0) ow = 0;
2759 // oh = sd->wd->minh - oh;
2760 // if (oh < 0) oh = 0;
2761 // if (x < 0) x = 0;
2762 // if (y < 0) y = 0;
2763 // if (x > ow) x = ow;
2764 // if (y > oh) y = oh;
2765 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2770 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2772 if ((itb->y + itb->h) > y)
2774 Elm_Genlist_Item *it;
2777 EINA_LIST_FOREACH(itb->items, l2, it)
2779 if ((itb->y + it->y) >= y)
2781 sd->wd->anchor_item = it;
2782 sd->wd->anchor_y = -(itb->y + it->y - y);
2790 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2794 _pan_get(Evas_Object *obj,
2798 Pan *sd = evas_object_smart_data_get(obj);
2800 if (x) *x = sd->wd->pan_x;
2801 if (y) *y = sd->wd->pan_y;
2805 _pan_max_get(Evas_Object *obj,
2809 Pan *sd = evas_object_smart_data_get(obj);
2812 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2813 ow = sd->wd->minw - ow;
2815 oh = sd->wd->minh - oh;
2822 _pan_min_get(Evas_Object *obj __UNUSED__,
2831 _pan_child_size_get(Evas_Object *obj,
2835 Pan *sd = evas_object_smart_data_get(obj);
2837 if (w) *w = sd->wd->minw;
2838 if (h) *h = sd->wd->minh;
2842 _pan_add(Evas_Object *obj)
2845 Evas_Object_Smart_Clipped_Data *cd;
2848 cd = evas_object_smart_data_get(obj);
2851 sd->__clipped_data = *cd;
2853 evas_object_smart_data_set(obj, sd);
2857 _pan_del(Evas_Object *obj)
2859 Pan *sd = evas_object_smart_data_get(obj);
2864 ecore_job_del(sd->resize_job);
2865 sd->resize_job = NULL;
2871 _pan_resize_job(void *data)
2874 _sizing_eval(sd->wd->obj);
2875 sd->resize_job = NULL;
2879 _pan_resize(Evas_Object *obj,
2883 Pan *sd = evas_object_smart_data_get(obj);
2886 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2887 if ((ow == w) && (oh == h)) return;
2888 if ((sd->wd->height_for_width) && (ow != w))
2890 if (sd->resize_job) ecore_job_del(sd->resize_job);
2891 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2893 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2894 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2898 _pan_calculate(Evas_Object *obj)
2900 Pan *sd = evas_object_smart_data_get(obj);
2902 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2903 static Evas_Coord old_pan_y = 0;
2905 Elm_Genlist_Item *git;
2908 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2909 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2910 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2912 git->want_realize = EINA_FALSE;
2914 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2916 itb->w = sd->wd->minw;
2917 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2918 itb->y - sd->wd->pan_y + oy,
2920 cvx, cvy, cvw, cvh))
2922 if ((!itb->realized) || (itb->changed))
2923 _item_block_realize(itb, in, 0);
2924 _item_block_position(itb, in);
2928 if (itb->realized) _item_block_unrealize(itb);
2932 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2933 _group_items_recalc(sd->wd);
2935 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2937 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2938 else sd->wd->reorder_pan_move = EINA_FALSE;
2939 evas_object_raise(sd->wd->reorder_it->edit_obj);
2940 old_pan_y = sd->wd->pan_y;
2943 if (sd->wd->effect_mode &&
2944 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2945 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2946 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2948 if (!sd->wd->item_moving_effect_timer)
2950 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2951 _item_flip_effect_show(sd->wd->expand_item);
2953 evas_object_raise(sd->wd->alpha_bg);
2954 evas_object_show(sd->wd->alpha_bg);
2955 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
2956 sd->wd->start_time = current_time_get();
2957 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2960 else _item_auto_scroll(sd->wd);
2961 sd->wd->contracting = EINA_FALSE;
2965 _pan_move(Evas_Object *obj,
2966 Evas_Coord x __UNUSED__,
2967 Evas_Coord y __UNUSED__)
2969 Pan *sd = evas_object_smart_data_get(obj);
2971 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2972 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2976 _hold_on(void *data __UNUSED__,
2978 void *event_info __UNUSED__)
2980 Widget_Data *wd = elm_widget_data_get(obj);
2982 elm_smart_scroller_hold_set(wd->scr, 1);
2986 _hold_off(void *data __UNUSED__,
2988 void *event_info __UNUSED__)
2990 Widget_Data *wd = elm_widget_data_get(obj);
2992 elm_smart_scroller_hold_set(wd->scr, 0);
2996 _freeze_on(void *data __UNUSED__,
2998 void *event_info __UNUSED__)
3000 Widget_Data *wd = elm_widget_data_get(obj);
3002 elm_smart_scroller_freeze_set(wd->scr, 1);
3006 _freeze_off(void *data __UNUSED__,
3008 void *event_info __UNUSED__)
3010 Widget_Data *wd = elm_widget_data_get(obj);
3012 elm_smart_scroller_freeze_set(wd->scr, 0);
3016 _scroll_edge_left(void *data,
3017 Evas_Object *scr __UNUSED__,
3018 void *event_info __UNUSED__)
3020 Evas_Object *obj = data;
3021 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3025 _scroll_edge_right(void *data,
3026 Evas_Object *scr __UNUSED__,
3027 void *event_info __UNUSED__)
3029 Evas_Object *obj = data;
3030 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3034 _scroll_edge_top(void *data,
3035 Evas_Object *scr __UNUSED__,
3036 void *event_info __UNUSED__)
3038 Evas_Object *obj = data;
3039 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3043 _scroll_edge_bottom(void *data,
3044 Evas_Object *scr __UNUSED__,
3045 void *event_info __UNUSED__)
3047 Evas_Object *obj = data;
3048 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3052 * Add a new Genlist object
3054 * @param parent The parent object
3055 * @return The new object or NULL if it cannot be created
3060 elm_genlist_add(Evas_Object *parent)
3065 Evas_Coord minw, minh;
3066 static Evas_Smart *smart = NULL;
3068 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3072 static Evas_Smart_Class sc;
3074 evas_object_smart_clipped_smart_set(&_pan_sc);
3076 sc.name = "elm_genlist_pan";
3077 sc.version = EVAS_SMART_CLASS_VERSION;
3080 sc.resize = _pan_resize;
3081 sc.move = _pan_move;
3082 sc.calculate = _pan_calculate;
3083 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3085 wd = ELM_NEW(Widget_Data);
3086 e = evas_object_evas_get(parent);
3087 if (!e) return NULL;
3088 obj = elm_widget_add(e);
3089 ELM_SET_WIDTYPE(widtype, "genlist");
3090 elm_widget_type_set(obj, "genlist");
3091 elm_widget_sub_object_add(parent, obj);
3092 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3093 elm_widget_data_set(obj, wd);
3094 elm_widget_del_hook_set(obj, _del_hook);
3095 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3096 elm_widget_theme_hook_set(obj, _theme_hook);
3097 elm_widget_can_focus_set(obj, EINA_TRUE);
3098 elm_widget_event_hook_set(obj, _event_hook);
3099 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3101 wd->scr = elm_smart_scroller_add(e);
3102 elm_smart_scroller_widget_set(wd->scr, obj);
3103 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3104 elm_widget_style_get(obj));
3105 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3106 _elm_config->thumbscroll_bounce_enable);
3107 elm_widget_resize_object_set(obj, wd->scr);
3109 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3110 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3112 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3113 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3117 wd->mode = ELM_LIST_SCROLL;
3118 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3119 wd->item_cache_max = wd->max_items_per_block * 2;
3120 wd->longpress_timeout = _elm_config->longpress_timeout;
3121 //wd->effect_mode = _elm_config->effect_enable;
3122 // wd->effect_mode = EINA_TRUE;
3124 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3125 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3126 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3127 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3129 wd->pan_smart = evas_object_smart_add(e, smart);
3130 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3133 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3134 _pan_set, _pan_get, _pan_max_get,
3135 _pan_min_get, _pan_child_size_get);
3137 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3139 evas_object_size_hint_min_set(obj, minw, minh);
3141 // TODO: uncomment this after upstream merge
3142 //_mirrored_set(obj, elm_widget_mirrored_get(obj));
3147 static Elm_Genlist_Item *
3148 _item_new(Widget_Data *wd,
3149 const Elm_Genlist_Item_Class *itc,
3151 Elm_Genlist_Item *parent,
3152 Elm_Genlist_Item_Flags flags,
3154 const void *func_data)
3156 Elm_Genlist_Item *it;
3158 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3159 if (!it) return NULL;
3162 it->base.data = data;
3163 it->parent = parent;
3165 it->func.func = func;
3166 it->func.data = func_data;
3167 it->mouse_cursor = NULL;
3168 it->expanded_depth = 0;
3169 it->num = ++wd->total_num; // todo : remov
3174 _item_block_add(Widget_Data *wd,
3175 Elm_Genlist_Item *it)
3177 Item_Block *itb = NULL;
3184 itb = calloc(1, sizeof(Item_Block));
3187 if (!it->rel->block)
3190 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3191 itb->items = eina_list_append(itb->items, it);
3197 wd->blocks = eina_inlist_prepend_relative
3198 (wd->blocks, EINA_INLIST_GET(itb),
3199 EINA_INLIST_GET(it->rel->block));
3201 eina_list_prepend_relative(itb->items, it, it->rel);
3205 wd->blocks = eina_inlist_append_relative
3206 (wd->blocks, EINA_INLIST_GET(itb),
3207 EINA_INLIST_GET(it->rel->block));
3209 eina_list_append_relative(itb->items, it, it->rel);
3219 itb = (Item_Block *)(wd->blocks);
3220 if (itb->count >= wd->max_items_per_block)
3222 itb = calloc(1, sizeof(Item_Block));
3226 eina_inlist_prepend(wd->blocks,
3227 EINA_INLIST_GET(itb));
3232 itb = calloc(1, sizeof(Item_Block));
3236 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3238 itb->items = eina_list_prepend(itb->items, it);
3244 itb = (Item_Block *)(wd->blocks->last);
3245 if (itb->count >= wd->max_items_per_block)
3247 itb = calloc(1, sizeof(Item_Block));
3251 eina_inlist_append(wd->blocks,
3252 EINA_INLIST_GET(itb));
3257 itb = calloc(1, sizeof(Item_Block));
3261 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3263 itb->items = eina_list_append(itb->items, it);
3269 itb = it->rel->block;
3270 if (!itb) goto newblock;
3272 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3274 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3277 itb->changed = EINA_TRUE;
3279 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3280 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3283 it->rel->relcount--;
3284 if ((it->rel->delete_me) && (!it->rel->relcount))
3288 if (itb->count > itb->wd->max_items_per_block)
3292 Elm_Genlist_Item *it2;
3294 newc = itb->count / 2;
3295 itb2 = calloc(1, sizeof(Item_Block));
3299 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3300 EINA_INLIST_GET(itb));
3301 itb2->changed = EINA_TRUE;
3302 while ((itb->count > newc) && (itb->items))
3306 l = eina_list_last(itb->items);
3308 itb->items = eina_list_remove_list(itb->items, l);
3311 itb2->items = eina_list_prepend(itb2->items, it2);
3319 _queue_process(Widget_Data *wd,
3323 Eina_Bool showme = EINA_FALSE;
3326 t0 = ecore_time_get();
3327 for (n = 0; (wd->queue) && (n < 128); n++)
3329 Elm_Genlist_Item *it;
3331 it = wd->queue->data;
3332 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3333 it->queued = EINA_FALSE;
3334 _item_block_add(wd, it);
3335 t = ecore_time_get();
3336 if (it->block->changed)
3338 showme = _item_block_recalc(it->block, it->block->num, 1,
3340 it->block->changed = 0;
3342 if (showme) it->block->showme = EINA_TRUE;
3343 if (eina_inlist_count(wd->blocks) > 1)
3345 if ((t - t0) > (ecore_animator_frametime_get())) break;
3352 _item_idler(void *data)
3354 Widget_Data *wd = data;
3357 //static double q_start = 0.0;
3358 //if (q_start == 0.0) q_start = ecore_time_get();
3361 if (_queue_process(wd, 1) > 0)
3363 if (wd->calc_job) ecore_job_del(wd->calc_job);
3364 wd->calc_job = ecore_job_add(_calc_job, wd);
3369 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3371 wd->queue_idler = NULL;
3372 return ECORE_CALLBACK_CANCEL;
3374 return ECORE_CALLBACK_RENEW;
3378 _item_queue(Widget_Data *wd,
3379 Elm_Genlist_Item *it)
3381 if (it->queued) return;
3382 it->queued = EINA_TRUE;
3383 wd->queue = eina_list_append(wd->queue, it);
3384 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3386 if (wd->queue_idler)
3388 ecore_idler_del(wd->queue_idler);
3389 wd->queue_idler = NULL;
3391 _queue_process(wd, 0);
3393 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3397 * Append item to the end of the genlist
3399 * This appends the given item to the end of the list or the end of
3400 * the children if the parent is given.
3402 * @param obj The genlist object
3403 * @param itc The item class for the item
3404 * @param data The item data
3405 * @param parent The parent item, or NULL if none
3406 * @param flags Item flags
3407 * @param func Convenience function called when item selected
3408 * @param func_data Data passed to @p func above.
3409 * @return A handle to the item added or NULL if not possible
3413 EAPI Elm_Genlist_Item *
3414 elm_genlist_item_append(Evas_Object *obj,
3415 const Elm_Genlist_Item_Class *itc,
3417 Elm_Genlist_Item *parent,
3418 Elm_Genlist_Item_Flags flags,
3420 const void *func_data)
3422 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3423 Widget_Data *wd = elm_widget_data_get(obj);
3424 if (!wd) return NULL;
3425 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3427 if (!it) return NULL;
3430 if (flags & ELM_GENLIST_ITEM_GROUP)
3431 wd->group_items = eina_list_append(wd->group_items, it);
3432 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3437 Elm_Genlist_Item *it2 = NULL;
3438 Eina_List *ll = eina_list_last(it->parent->items);
3439 if (ll) it2 = ll->data;
3440 it->parent->items = eina_list_append(it->parent->items, it);
3441 if (!it2) it2 = it->parent;
3443 it2 = elm_genlist_item_prev_get(it2);
3445 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3446 EINA_INLIST_GET(it2));
3448 it->rel->relcount++;
3450 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3451 it->group_item = parent;
3452 else if (it->parent->group_item)
3453 it->group_item = it->parent->group_item;
3455 it->before = EINA_FALSE;
3456 _item_queue(wd, it);
3461 * Prepend item at start of the genlist
3463 * This adds an item to the beginning of the list or beginning of the
3464 * children of the parent if given.
3466 * @param obj The genlist object
3467 * @param itc The item class for the item
3468 * @param data The item data
3469 * @param parent The parent item, or NULL if none
3470 * @param flags Item flags
3471 * @param func Convenience function called when item selected
3472 * @param func_data Data passed to @p func above.
3473 * @return A handle to the item added or NULL if not possible
3477 EAPI Elm_Genlist_Item *
3478 elm_genlist_item_prepend(Evas_Object *obj,
3479 const Elm_Genlist_Item_Class *itc,
3481 Elm_Genlist_Item *parent,
3482 Elm_Genlist_Item_Flags flags,
3484 const void *func_data)
3486 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3487 Widget_Data *wd = elm_widget_data_get(obj);
3488 if (!wd) return NULL;
3489 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3491 if (!it) return NULL;
3494 if (flags & ELM_GENLIST_ITEM_GROUP)
3495 wd->group_items = eina_list_prepend(wd->group_items, it);
3496 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3501 Elm_Genlist_Item *it2 = NULL;
3502 Eina_List *ll = it->parent->items;
3503 if (ll) it2 = ll->data;
3504 it->parent->items = eina_list_prepend(it->parent->items, it);
3505 if (!it2) it2 = it->parent;
3507 it2 = elm_genlist_item_next_get(it2);
3509 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3510 EINA_INLIST_GET(it2));
3512 it->rel->relcount++;
3514 it->before = EINA_TRUE;
3515 _item_queue(wd, it);
3520 * Insert item before another in the genlist
3522 * This inserts an item before another in the list. It will be in the
3523 * same tree level or group as the item it is inseted before.
3525 * @param obj The genlist object
3526 * @param itc The item class for the item
3527 * @param data The item data
3528 * @param before The item to insert before
3529 * @param flags Item flags
3530 * @param func Convenience function called when item selected
3531 * @param func_data Data passed to @p func above.
3532 * @return A handle to the item added or NULL if not possible
3536 EAPI Elm_Genlist_Item *
3537 elm_genlist_item_insert_before(Evas_Object *obj,
3538 const Elm_Genlist_Item_Class *itc,
3540 Elm_Genlist_Item *parent,
3541 Elm_Genlist_Item *before,
3542 Elm_Genlist_Item_Flags flags,
3544 const void *func_data)
3546 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3547 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3548 Widget_Data *wd = elm_widget_data_get(obj);
3549 if (!wd) return NULL;
3550 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3552 if (!it) return NULL;
3555 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3558 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3559 EINA_INLIST_GET(before));
3561 it->rel->relcount++;
3562 it->before = EINA_TRUE;
3563 _item_queue(wd, it);
3568 * Insert an item after another in the genlst
3570 * This inserts an item after another in the list. It will be in the
3571 * same tree level or group as the item it is inseted after.
3573 * @param obj The genlist object
3574 * @param itc The item class for the item
3575 * @param data The item data
3576 * @param after The item to insert after
3577 * @param flags Item flags
3578 * @param func Convenience function called when item selected
3579 * @param func_data Data passed to @p func above.
3580 * @return A handle to the item added or NULL if not possible
3584 EAPI Elm_Genlist_Item *
3585 elm_genlist_item_insert_after(Evas_Object *obj,
3586 const Elm_Genlist_Item_Class *itc,
3588 Elm_Genlist_Item *parent,
3589 Elm_Genlist_Item *after,
3590 Elm_Genlist_Item_Flags flags,
3592 const void *func_data)
3594 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3595 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3596 Widget_Data *wd = elm_widget_data_get(obj);
3597 if (!wd) return NULL;
3598 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3600 if (!it) return NULL;
3601 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3602 EINA_INLIST_GET(after));
3605 it->parent->items = eina_list_append_relative(it->parent->items, it,
3609 it->rel->relcount++;
3610 it->before = EINA_FALSE;
3611 _item_queue(wd, it);
3618 * This clears all items in the list, leaving it empty.
3620 * @param obj The genlist object
3625 elm_genlist_clear(Evas_Object *obj)
3627 ELM_CHECK_WIDTYPE(obj, widtype);
3628 Widget_Data *wd = elm_widget_data_get(obj);
3630 if (wd->walking > 0)
3632 Elm_Genlist_Item *it;
3634 wd->clear_me = EINA_TRUE;
3635 EINA_INLIST_FOREACH(wd->items, it)
3637 it->delete_me = EINA_TRUE;
3643 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3644 it->nocache = EINA_TRUE;
3645 it->highlighted = EINA_FALSE;
3647 if (wd->anchor_item == it)
3649 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3650 if (!wd->anchor_item)
3652 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3655 wd->items = eina_inlist_remove(wd->items, wd->items);
3656 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3657 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3658 elm_widget_item_pre_notify_del(it);
3659 if (it->effect_item_realized) _effect_item_unrealize(it);
3660 if (it->realized) _item_unrealize(it);
3661 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3662 it->itc->func.del((void *)it->base.data, it->base.widget);
3663 if (it->long_timer) ecore_timer_del(it->long_timer);
3664 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3665 elm_widget_item_del(it);
3667 wd->clear_me = EINA_FALSE;
3668 wd->anchor_item = NULL;
3671 Item_Block *itb = (Item_Block *)(wd->blocks);
3673 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3674 if (itb->items) eina_list_free(itb->items);
3679 ecore_job_del(wd->calc_job);
3680 wd->calc_job = NULL;
3682 if (wd->queue_idler)
3684 ecore_idler_del(wd->queue_idler);
3685 wd->queue_idler = NULL;
3687 if (wd->must_recalc_idler)
3689 ecore_idler_del(wd->must_recalc_idler);
3690 wd->must_recalc_idler = NULL;
3694 eina_list_free(wd->queue);
3699 eina_list_free(wd->selected);
3700 wd->selected = NULL;
3702 if (wd->item_moving_effect_timer)
3704 ecore_animator_del(wd->item_moving_effect_timer);
3705 wd->item_moving_effect_timer = NULL;
3707 wd->show_item = NULL;
3714 evas_object_del(wd->alpha_bg);
3715 wd->alpha_bg = NULL;
3719 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3720 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3726 * Enable or disable multi-select in the genlist
3728 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3729 * the list. This allows more than 1 item to be selected.
3731 * @param obj The genlist object
3732 * @param multi Multi-select enable/disable
3737 elm_genlist_multi_select_set(Evas_Object *obj,
3740 ELM_CHECK_WIDTYPE(obj, widtype);
3741 Widget_Data *wd = elm_widget_data_get(obj);
3747 * Gets if multi-select in genlist is enable or disable
3749 * @param obj The genlist object
3750 * @return Multi-select enable/disable
3751 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3756 elm_genlist_multi_select_get(const Evas_Object *obj)
3758 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3759 Widget_Data *wd = elm_widget_data_get(obj);
3760 if (!wd) return EINA_FALSE;
3765 * Get the selectd item in the genlist
3767 * This gets the selected item in the list (if multi-select is enabled
3768 * only the first item in the list is selected - which is not very
3769 * useful, so see elm_genlist_selected_items_get() for when
3770 * multi-select is used).
3772 * If no item is selected, NULL is returned.
3774 * @param obj The genlist object
3775 * @return The selected item, or NULL if none.
3779 EAPI Elm_Genlist_Item *
3780 elm_genlist_selected_item_get(const Evas_Object *obj)
3782 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3783 Widget_Data *wd = elm_widget_data_get(obj);
3784 if (!wd) return NULL;
3785 if (wd->selected) return wd->selected->data;
3790 * Get a list of selected items in the genlist
3792 * This returns a list of the selected items. This list pointer is
3793 * only valid so long as no items are selected or unselected (or
3794 * unselected implicitly by deletion). The list contains
3795 * Elm_Genlist_Item pointers.
3797 * @param obj The genlist object
3798 * @return The list of selected items, nor NULL if none are selected.
3802 EAPI const Eina_List *
3803 elm_genlist_selected_items_get(const Evas_Object *obj)
3805 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3806 Widget_Data *wd = elm_widget_data_get(obj);
3807 if (!wd) return NULL;
3808 return wd->selected;
3812 * Get a list of realized items in genlist
3814 * This returns a list of the realized items in the genlist. The list
3815 * contains Elm_Genlist_Item pointers. The list must be freed by the
3816 * caller when done with eina_list_free(). The item pointers in the
3817 * list are only valid so long as those items are not deleted or the
3818 * genlist is not deleted.
3820 * @param obj The genlist object
3821 * @return The list of realized items, nor NULL if none are realized.
3826 elm_genlist_realized_items_get(const Evas_Object *obj)
3828 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3829 Widget_Data *wd = elm_widget_data_get(obj);
3830 Eina_List *list = NULL;
3832 Eina_Bool done = EINA_FALSE;
3833 if (!wd) return NULL;
3834 EINA_INLIST_FOREACH(wd->blocks, itb)
3839 Elm_Genlist_Item *it;
3842 EINA_LIST_FOREACH(itb->items, l, it)
3844 if (it->realized) list = eina_list_append(list, it);
3856 * Get the item that is at the x, y canvas coords
3858 * This returns the item at the given coordinates (which are canvas
3859 * relative not object-relative). If an item is at that coordinate,
3860 * that item handle is returned, and if @p posret is not NULL, the
3861 * integer pointed to is set to a value of -1, 0 or 1, depending if
3862 * the coordinate is on the upper portion of that item (-1), on the
3863 * middle section (0) or on the lower part (1). If NULL is returned as
3864 * an item (no item found there), then posret may indicate -1 or 1
3865 * based if the coordinate is above or below all items respectively in
3868 * @param it The item
3869 * @param x The input x coordinate
3870 * @param y The input y coordinate
3871 * @param posret The position relative to the item returned here
3872 * @return The item at the coordinates or NULL if none
3876 EAPI Elm_Genlist_Item *
3877 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3882 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3883 Widget_Data *wd = elm_widget_data_get(obj);
3884 Evas_Coord ox, oy, ow, oh;
3887 if (!wd) return NULL;
3888 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3890 EINA_INLIST_FOREACH(wd->blocks, itb)
3893 Elm_Genlist_Item *it;
3895 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3896 oy + itb->y - itb->wd->pan_y,
3897 itb->w, itb->h, x, y, 1, 1))
3899 EINA_LIST_FOREACH(itb->items, l, it)
3901 Evas_Coord itx, ity;
3903 itx = ox + itb->x + it->x - itb->wd->pan_x;
3904 ity = oy + itb->y + it->y - itb->wd->pan_y;
3905 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3909 if (y <= (ity + (it->h / 4))) *posret = -1;
3910 else if (y >= (ity + it->h - (it->h / 4)))
3916 lasty = ity + it->h;
3921 if (y > lasty) *posret = 1;
3928 * Get the first item in the genlist
3930 * This returns the first item in the list.
3932 * @param obj The genlist object
3933 * @return The first item, or NULL if none
3937 EAPI Elm_Genlist_Item *
3938 elm_genlist_first_item_get(const Evas_Object *obj)
3940 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3941 Widget_Data *wd = elm_widget_data_get(obj);
3942 if (!wd) return NULL;
3943 if (!wd->items) return NULL;
3944 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3945 while ((it) && (it->delete_me))
3946 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3951 * Get the last item in the genlist
3953 * This returns the last item in the list.
3955 * @return The last item, or NULL if none
3959 EAPI Elm_Genlist_Item *
3960 elm_genlist_last_item_get(const Evas_Object *obj)
3962 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3963 Widget_Data *wd = elm_widget_data_get(obj);
3964 if (!wd) return NULL;
3965 if (!wd->items) return NULL;
3966 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3967 while ((it) && (it->delete_me))
3968 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3973 * Get the next item in the genlist
3975 * This returns the item after the item @p it.
3977 * @param it The item
3978 * @return The item after @p it, or NULL if none
3982 EAPI Elm_Genlist_Item *
3983 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3985 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3988 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3989 if ((it) && (!it->delete_me)) break;
3991 return (Elm_Genlist_Item *)it;
3995 * Get the previous item in the genlist
3997 * This returns the item before the item @p it.
3999 * @param it The item
4000 * @return The item before @p it, or NULL if none
4004 EAPI Elm_Genlist_Item *
4005 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4007 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4010 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4011 if ((it) && (!it->delete_me)) break;
4013 return (Elm_Genlist_Item *)it;
4017 * Get the genlist object from an item
4019 * This returns the genlist object itself that an item belongs to.
4021 * @param it The item
4022 * @return The genlist object
4027 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4029 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4030 return it->base.widget;
4034 * Get the parent item of the given item
4036 * This returns the parent item of the item @p it given.
4038 * @param it The item
4039 * @return The parent of the item or NULL if none
4043 EAPI Elm_Genlist_Item *
4044 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4046 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4051 * Clear all sub-items (children) of the given item
4053 * This clears all items that are children (or their descendants) of the
4056 * @param it The item
4061 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4063 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4064 Elm_Genlist_Item *it2;
4067 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4068 _item_subitems_clear(it);
4071 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4072 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4074 it->wd->expand_item = it;
4075 _item_flip_effect_show(it);
4076 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4077 it->wd->expand_item_end = y + h;
4081 it2 = elm_genlist_item_next_get(it2);
4083 } while (it2->expanded_depth > it->expanded_depth);
4085 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4087 it->wd->expand_item_gap = 0;
4089 evas_object_raise(it->wd->alpha_bg);
4090 evas_object_show(it->wd->alpha_bg);
4092 it->wd->start_time = current_time_get();
4093 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4096 _item_subitems_clear(it);
4101 * Set the selected state of an item
4103 * This sets the selected state (1 selected, 0 not selected) of the given
4106 * @param it The item
4107 * @param selected The selected state
4112 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4115 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4116 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4118 if (it->delete_me) return;
4119 selected = !!selected;
4120 if (it->selected == selected) return;
4126 while (wd->selected)
4127 _item_unselect(wd->selected->data);
4129 _item_highlight(it);
4137 * Get the selected state of an item
4139 * This gets the selected state of an item (1 selected, 0 not selected).
4141 * @param it The item
4142 * @return The selected state
4147 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4149 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4150 return it->selected;
4154 * Sets the expanded state of an item (if it's a parent)
4156 * This expands or contracts a parent item (thus showing or hiding the
4159 * @param it The item
4160 * @param expanded The expanded state (1 expanded, 0 not expanded).
4165 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4168 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4169 if (it->expanded == expanded) return;
4170 it->expanded = expanded;
4171 it->wd->expand_item = it;
4173 if(it->wd->effect_mode && !it->wd->alpha_bg)
4174 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4178 it->wd->auto_scrolled = EINA_FALSE;
4179 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4181 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4182 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4186 it->wd->contracting = EINA_TRUE;
4187 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4189 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4190 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4195 * Get the expanded state of an item
4197 * This gets the expanded state of an item
4199 * @param it The item
4200 * @return Thre expanded state
4205 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4207 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4208 return it->expanded;
4212 * Get the depth of expanded item
4214 * @param it The genlist item object
4215 * @return The depth of expanded item
4220 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4222 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4223 return it->expanded_depth;
4227 * Sets the disabled state of an item.
4229 * A disabled item cannot be selected or unselected. It will also
4230 * change appearance to appear disabled. This sets the disabled state
4231 * (1 disabled, 0 not disabled).
4233 * @param it The item
4234 * @param disabled The disabled state
4239 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4242 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4243 if (it->disabled == disabled) return;
4244 if (it->delete_me) return;
4245 it->disabled = disabled;
4249 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4251 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4256 * Get the disabled state of an item
4258 * This gets the disabled state of the given item.
4260 * @param it The item
4261 * @return The disabled state
4266 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4268 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4269 if (it->delete_me) return EINA_FALSE;
4270 return it->disabled;
4274 * Sets the display only state of an item.
4276 * A display only item cannot be selected or unselected. It is for
4277 * display only and not selecting or otherwise clicking, dragging
4278 * etc. by the user, thus finger size rules will not be applied to
4281 * @param it The item
4282 * @param display_only The display only state
4287 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4288 Eina_Bool display_only)
4290 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4291 if (it->display_only == display_only) return;
4292 if (it->delete_me) return;
4293 it->display_only = display_only;
4294 it->mincalcd = EINA_FALSE;
4295 it->updateme = EINA_TRUE;
4296 if (it->block) it->block->updateme = EINA_TRUE;
4297 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4298 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4302 * Get the display only state of an item
4304 * This gets the display only state of the given item.
4306 * @param it The item
4307 * @return The display only state
4312 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4314 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4315 if (it->delete_me) return EINA_FALSE;
4316 return it->display_only;
4320 * Show the given item
4322 * This causes genlist to jump to the given item @p it and show it (by
4323 * scrolling), if it is not fully visible.
4325 * @param it The item
4330 elm_genlist_item_show(Elm_Genlist_Item *it)
4332 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4333 Evas_Coord gith = 0;
4334 if (it->delete_me) return;
4335 if ((it->queued) || (!it->mincalcd))
4337 it->wd->show_item = it;
4338 it->wd->bring_in = EINA_TRUE;
4339 it->showme = EINA_TRUE;
4342 if (it->wd->show_item)
4344 it->wd->show_item->showme = EINA_FALSE;
4345 it->wd->show_item = NULL;
4347 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4348 gith = it->group_item->h;
4349 elm_smart_scroller_child_region_show(it->wd->scr,
4350 it->x + it->block->x,
4351 it->y + it->block->y - gith,
4352 it->block->w, it->h);
4356 * Bring in the given item
4358 * This causes genlist to jump to the given item @p it and show it (by
4359 * scrolling), if it is not fully visible. This may use animation to
4360 * do so and take a period of time
4362 * @param it The item
4367 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4369 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4370 Evas_Coord gith = 0;
4371 if (it->delete_me) return;
4372 if ((it->queued) || (!it->mincalcd))
4374 it->wd->show_item = it;
4375 it->wd->bring_in = EINA_TRUE;
4376 it->showme = EINA_TRUE;
4379 if (it->wd->show_item)
4381 it->wd->show_item->showme = EINA_FALSE;
4382 it->wd->show_item = NULL;
4384 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4385 gith = it->group_item->h;
4386 elm_smart_scroller_region_bring_in(it->wd->scr,
4387 it->x + it->block->x,
4388 it->y + it->block->y - gith,
4389 it->block->w, it->h);
4393 * Show the given item at the top
4395 * This causes genlist to jump to the given item @p it and show it (by
4396 * scrolling), if it is not fully visible.
4398 * @param it The item
4403 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4405 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4407 Evas_Coord gith = 0;
4409 if (it->delete_me) return;
4410 if ((it->queued) || (!it->mincalcd))
4412 it->wd->show_item = it;
4413 it->wd->bring_in = EINA_TRUE;
4414 it->showme = EINA_TRUE;
4417 if (it->wd->show_item)
4419 it->wd->show_item->showme = EINA_FALSE;
4420 it->wd->show_item = NULL;
4422 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4423 if (it->group_item) gith = it->group_item->h;
4424 elm_smart_scroller_child_region_show(it->wd->scr,
4425 it->x + it->block->x,
4426 it->y + it->block->y - gith,
4431 * Bring in the given item at the top
4433 * This causes genlist to jump to the given item @p it and show it (by
4434 * scrolling), if it is not fully visible. This may use animation to
4435 * do so and take a period of time
4437 * @param it The item
4442 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4444 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4446 Evas_Coord gith = 0;
4448 if (it->delete_me) return;
4449 if ((it->queued) || (!it->mincalcd))
4451 it->wd->show_item = it;
4452 it->wd->bring_in = EINA_TRUE;
4453 it->showme = EINA_TRUE;
4456 if (it->wd->show_item)
4458 it->wd->show_item->showme = EINA_FALSE;
4459 it->wd->show_item = NULL;
4461 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4462 if (it->group_item) gith = it->group_item->h;
4463 elm_smart_scroller_region_bring_in(it->wd->scr,
4464 it->x + it->block->x,
4465 it->y + it->block->y - gith,
4470 * Show the given item at the middle
4472 * This causes genlist to jump to the given item @p it and show it (by
4473 * scrolling), if it is not fully visible.
4475 * @param it The item
4480 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4482 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4485 if (it->delete_me) return;
4486 if ((it->queued) || (!it->mincalcd))
4488 it->wd->show_item = it;
4489 it->wd->bring_in = EINA_TRUE;
4490 it->showme = EINA_TRUE;
4493 if (it->wd->show_item)
4495 it->wd->show_item->showme = EINA_FALSE;
4496 it->wd->show_item = NULL;
4498 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4499 elm_smart_scroller_child_region_show(it->wd->scr,
4500 it->x + it->block->x,
4501 it->y + it->block->y - oh / 2 +
4502 it->h / 2, it->block->w, oh);
4506 * Bring in the given item at the middle
4508 * This causes genlist to jump to the given item @p it and show it (by
4509 * scrolling), if it is not fully visible. This may use animation to
4510 * do so and take a period of time
4512 * @param it The item
4517 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4519 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4522 if (it->delete_me) return;
4523 if ((it->queued) || (!it->mincalcd))
4525 it->wd->show_item = it;
4526 it->wd->bring_in = EINA_TRUE;
4527 it->showme = EINA_TRUE;
4530 if (it->wd->show_item)
4532 it->wd->show_item->showme = EINA_FALSE;
4533 it->wd->show_item = NULL;
4535 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4536 elm_smart_scroller_region_bring_in(it->wd->scr,
4537 it->x + it->block->x,
4538 it->y + it->block->y - oh / 2 + it->h / 2,
4543 * Delete a given item
4545 * This deletes the item from genlist and calls the genlist item del
4546 * class callback defined in the item class, if it is set. This clears all
4547 * subitems if it is a tree.
4549 * @param it The item
4554 elm_genlist_item_del(Elm_Genlist_Item *it)
4556 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4557 if ((it->relcount > 0) || (it->walking > 0))
4559 elm_widget_item_pre_notify_del(it);
4560 elm_genlist_item_subitems_clear(it);
4561 it->delete_me = EINA_TRUE;
4562 if (it->wd->show_item == it) it->wd->show_item = NULL;
4564 it->wd->selected = eina_list_remove(it->wd->selected,
4568 if (it->realized) _item_unrealize(it);
4569 if (it->effect_item_realized) _effect_item_unrealize(it);
4570 it->block->changed = EINA_TRUE;
4571 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4572 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4574 if (it->itc->func.del)
4575 it->itc->func.del((void *)it->base.data, it->base.widget);
4582 * Set the data item from the genlist item
4584 * This set the data value passed on the elm_genlist_item_append() and
4585 * related item addition calls. This function will also call
4586 * elm_genlist_item_update() so the item will be updated to reflect the
4589 * @param it The item
4590 * @param data The new data pointer to set
4595 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4598 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4599 elm_widget_item_data_set(it, data);
4600 elm_genlist_item_update(it);
4604 * Get the data item from the genlist item
4606 * This returns the data value passed on the elm_genlist_item_append()
4607 * and related item addition calls and elm_genlist_item_data_set().
4609 * @param it The item
4610 * @return The data pointer provided when created
4615 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4617 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4618 return elm_widget_item_data_get(it);
4622 * Tells genlist to "orphan" icons fetchs by the item class
4624 * This instructs genlist to release references to icons in the item,
4625 * meaning that they will no longer be managed by genlist and are
4626 * floating "orphans" that can be re-used elsewhere if the user wants
4629 * @param it The item
4634 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4637 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4638 EINA_LIST_FREE(it->icon_objs, icon)
4640 elm_widget_sub_object_del(it->base.widget, icon);
4641 evas_object_smart_member_del(icon);
4642 evas_object_hide(icon);
4647 * Get the real evas object of the genlist item
4649 * This returns the actual evas object used for the specified genlist
4650 * item. This may be NULL as it may not be created, and may be deleted
4651 * at any time by genlist. Do not modify this object (move, resize,
4652 * show, hide etc.) as genlist is controlling it. This function is for
4653 * querying, emitting custom signals or hooking lower level callbacks
4654 * for events. Do not delete this object under any circumstances.
4656 * @param it The item
4657 * @return The object pointer
4661 EAPI const Evas_Object *
4662 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4664 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4665 return it->base.view;
4669 * Update the contents of an item
4671 * This updates an item by calling all the item class functions again
4672 * to get the icons, labels and states. Use this when the original
4673 * item data has changed and the changes are desired to be reflected.
4675 * @param it The item
4680 elm_genlist_item_update(Elm_Genlist_Item *it)
4682 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4683 if (!it->block) return;
4684 if (it->delete_me) return;
4685 it->mincalcd = EINA_FALSE;
4686 it->updateme = EINA_TRUE;
4687 it->block->updateme = EINA_TRUE;
4688 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4689 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4693 * Update the item class of an item
4695 * @param it The item
4696 * @parem itc The item class for the item
4701 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4702 const Elm_Genlist_Item_Class *itc)
4704 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4705 if (!it->block) return;
4706 EINA_SAFETY_ON_NULL_RETURN(itc);
4707 if (it->delete_me) return;
4709 it->nocache = EINA_TRUE;
4710 elm_genlist_item_update(it);
4713 static Evas_Object *
4714 _elm_genlist_item_label_create(void *data,
4716 void *item __UNUSED__)
4718 Evas_Object *label = elm_label_add(obj);
4721 elm_object_style_set(label, "tooltip");
4722 elm_label_label_set(label, data);
4727 _elm_genlist_item_label_del_cb(void *data,
4728 Evas_Object *obj __UNUSED__,
4729 void *event_info __UNUSED__)
4731 eina_stringshare_del(data);
4735 * Set the text to be shown in the genlist item.
4737 * @param item Target item
4738 * @param text The text to set in the content
4740 * Setup the text as tooltip to object. The item can have only one
4741 * tooltip, so any previous tooltip data is removed.
4746 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4749 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4750 text = eina_stringshare_add(text);
4751 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4753 _elm_genlist_item_label_del_cb);
4757 * Set the content to be shown in the tooltip item
4759 * Setup the tooltip to item. The item can have only one tooltip, so
4760 * any previous tooltip data is removed. @p func(with @p data) will be
4761 * called every time that need to show the tooltip and it should return a
4762 * valid Evas_Object. This object is then managed fully by tooltip
4763 * system and is deleted when the tooltip is gone.
4765 * @param item the genlist item being attached by a tooltip.
4766 * @param func the function used to create the tooltip contents.
4767 * @param data what to provide to @a func as callback data/context.
4768 * @param del_cb called when data is not needed anymore, either when
4769 * another callback replaces @func, the tooltip is unset with
4770 * elm_genlist_item_tooltip_unset() or the owner @a item
4771 * dies. This callback receives as the first parameter the
4772 * given @a data, and @c event_info is the item.
4777 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4778 Elm_Tooltip_Item_Content_Cb func,
4780 Evas_Smart_Cb del_cb)
4782 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4784 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4787 if (item->tooltip.del_cb)
4788 item->tooltip.del_cb((void *)item->tooltip.data,
4789 item->base.widget, item);
4791 item->tooltip.content_cb = func;
4792 item->tooltip.data = data;
4793 item->tooltip.del_cb = del_cb;
4795 if (item->base.view)
4797 elm_widget_item_tooltip_content_cb_set(item,
4798 item->tooltip.content_cb,
4799 item->tooltip.data, NULL);
4800 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4806 if (del_cb) del_cb((void *)data, NULL, NULL);
4810 * Unset tooltip from item
4812 * @param item genlist item to remove previously set tooltip.
4814 * Remove tooltip from item. The callback provided as del_cb to
4815 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4816 * it is not used anymore.
4818 * @see elm_genlist_item_tooltip_content_cb_set()
4823 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4825 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4826 if ((item->base.view) && (item->tooltip.content_cb))
4827 elm_widget_item_tooltip_unset(item);
4829 if (item->tooltip.del_cb)
4830 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4831 item->tooltip.del_cb = NULL;
4832 item->tooltip.content_cb = NULL;
4833 item->tooltip.data = NULL;
4834 if (item->tooltip.style)
4835 elm_genlist_item_tooltip_style_set(item, NULL);
4839 * Sets a different style for this item tooltip.
4841 * @note before you set a style you should define a tooltip with
4842 * elm_genlist_item_tooltip_content_cb_set() or
4843 * elm_genlist_item_tooltip_text_set()
4845 * @param item genlist item with tooltip already set.
4846 * @param style the theme style to use (default, transparent, ...)
4851 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4854 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4855 eina_stringshare_replace(&item->tooltip.style, style);
4856 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4860 * Get the style for this item tooltip.
4862 * @param item genlist item with tooltip already set.
4863 * @return style the theme style in use, defaults to "default". If the
4864 * object does not have a tooltip set, then NULL is returned.
4869 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4871 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4872 return item->tooltip.style;
4876 * Set the cursor to be shown when mouse is over the genlist item
4878 * @param item Target item
4879 * @param cursor the cursor name to be used.
4881 * @see elm_object_cursor_set()
4885 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4888 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4889 eina_stringshare_replace(&item->mouse_cursor, cursor);
4890 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4894 * Get the cursor to be shown when mouse is over the genlist item
4896 * @param item genlist item with cursor already set.
4897 * @return the cursor name.
4902 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4904 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4905 return elm_widget_item_cursor_get(item);
4909 * Unset the cursor to be shown when mouse is over the genlist item
4911 * @param item Target item
4913 * @see elm_object_cursor_unset()
4917 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4919 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4920 if (!item->mouse_cursor)
4923 if (item->base.view)
4924 elm_widget_item_cursor_unset(item);
4926 eina_stringshare_del(item->mouse_cursor);
4927 item->mouse_cursor = NULL;
4931 * Sets a different style for this item cursor.
4933 * @note before you set a style you should define a cursor with
4934 * elm_genlist_item_cursor_set()
4936 * @param item genlist item with cursor already set.
4937 * @param style the theme style to use (default, transparent, ...)
4942 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4945 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4946 elm_widget_item_cursor_style_set(item, style);
4950 * Get the style for this item cursor.
4952 * @param item genlist item with cursor already set.
4953 * @return style the theme style in use, defaults to "default". If the
4954 * object does not have a cursor set, then NULL is returned.
4959 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4961 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4962 return elm_widget_item_cursor_style_get(item);
4966 * Set if the cursor set should be searched on the theme or should use
4967 * the provided by the engine, only.
4969 * @note before you set if should look on theme you should define a
4970 * cursor with elm_object_cursor_set(). By default it will only look
4971 * for cursors provided by the engine.
4973 * @param item widget item with cursor already set.
4974 * @param engine_only boolean to define it cursors should be looked
4975 * only between the provided by the engine or searched on widget's
4981 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4982 Eina_Bool engine_only)
4984 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4985 elm_widget_item_cursor_engine_only_set(item, engine_only);
4989 * Get the cursor engine only usage for this item cursor.
4991 * @param item widget item with cursor already set.
4992 * @return engine_only boolean to define it cursors should be looked
4993 * only between the provided by the engine or searched on widget's
4994 * theme as well. If the object does not have a cursor set, then
4995 * EINA_FALSE is returned.
5000 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5002 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5003 return elm_widget_item_cursor_engine_only_get(item);
5007 * This sets the horizontal stretching mode
5009 * This sets the mode used for sizing items horizontally. Valid modes
5010 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5011 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5012 * the scroller will scroll horizontally. Otherwise items are expanded
5013 * to fill the width of the viewport of the scroller. If it is
5014 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5015 * limited to that size.
5017 * @param obj The genlist object
5018 * @param mode The mode to use
5023 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5026 ELM_CHECK_WIDTYPE(obj, widtype);
5027 Widget_Data *wd = elm_widget_data_get(obj);
5029 if (wd->mode == mode) return;
5035 * Gets the horizontal stretching mode
5037 * @param obj The genlist object
5038 * @return The mode to use
5039 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5044 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5046 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5047 Widget_Data *wd = elm_widget_data_get(obj);
5048 if (!wd) return ELM_LIST_LAST;
5053 * Set the always select mode.
5055 * Items will only call their selection func and callback when first
5056 * becoming selected. Any further clicks will do nothing, unless you
5057 * enable always select with elm_genlist_always_select_mode_set().
5058 * This means even if selected, every click will make the selected
5059 * callbacks be called.
5061 * @param obj The genlist object
5062 * @param always_select The always select mode
5063 * (EINA_TRUE = on, EINA_FALSE = off)
5068 elm_genlist_always_select_mode_set(Evas_Object *obj,
5069 Eina_Bool always_select)
5071 ELM_CHECK_WIDTYPE(obj, widtype);
5072 Widget_Data *wd = elm_widget_data_get(obj);
5074 wd->always_select = always_select;
5078 * Get the always select mode.
5080 * @param obj The genlist object
5081 * @return The always select mode
5082 * (EINA_TRUE = on, EINA_FALSE = off)
5087 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5089 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5090 Widget_Data *wd = elm_widget_data_get(obj);
5091 if (!wd) return EINA_FALSE;
5092 return wd->always_select;
5096 * Set no select mode
5098 * This will turn off the ability to select items entirely and they
5099 * will neither appear selected nor call selected callback functions.
5101 * @param obj The genlist object
5102 * @param no_select The no select mode
5103 * (EINA_TRUE = on, EINA_FALSE = off)
5108 elm_genlist_no_select_mode_set(Evas_Object *obj,
5109 Eina_Bool no_select)
5111 ELM_CHECK_WIDTYPE(obj, widtype);
5112 Widget_Data *wd = elm_widget_data_get(obj);
5114 wd->no_select = no_select;
5118 * Gets no select mode
5120 * @param obj The genlist object
5121 * @return The no select mode
5122 * (EINA_TRUE = on, EINA_FALSE = off)
5127 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5129 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5130 Widget_Data *wd = elm_widget_data_get(obj);
5131 if (!wd) return EINA_FALSE;
5132 return wd->no_select;
5138 * This will enable the compress mode where items are "compressed"
5139 * horizontally to fit the genlist scrollable viewport width. This is
5140 * special for genlist. Do not rely on
5141 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5142 * work as genlist needs to handle it specially.
5144 * @param obj The genlist object
5145 * @param compress The compress mode
5146 * (EINA_TRUE = on, EINA_FALSE = off)
5151 elm_genlist_compress_mode_set(Evas_Object *obj,
5154 ELM_CHECK_WIDTYPE(obj, widtype);
5155 Widget_Data *wd = elm_widget_data_get(obj);
5157 wd->compress = compress;
5161 * Get the compress mode
5163 * @param obj The genlist object
5164 * @return The compress mode
5165 * (EINA_TRUE = on, EINA_FALSE = off)
5170 elm_genlist_compress_mode_get(const Evas_Object *obj)
5172 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5173 Widget_Data *wd = elm_widget_data_get(obj);
5174 if (!wd) return EINA_FALSE;
5175 return wd->compress;
5179 * Set height-for-width mode
5181 * With height-for-width mode the item width will be fixed (restricted
5182 * to a minimum of) to the list width when calculating its size in
5183 * order to allow the height to be calculated based on it. This allows,
5184 * for instance, text block to wrap lines if the Edje part is
5185 * configured with "text.min: 0 1".
5187 * @note This mode will make list resize slower as it will have to
5188 * recalculate every item height again whenever the list width
5191 * @note When height-for-width mode is enabled, it also enables
5192 * compress mode (see elm_genlist_compress_mode_set()) and
5193 * disables homogeneous (see elm_genlist_homogeneous_set()).
5195 * @param obj The genlist object
5196 * @param setting The height-for-width mode (EINA_TRUE = on,
5202 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5203 Eina_Bool height_for_width)
5205 ELM_CHECK_WIDTYPE(obj, widtype);
5206 Widget_Data *wd = elm_widget_data_get(obj);
5208 wd->height_for_width = !!height_for_width;
5209 if (wd->height_for_width)
5211 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5212 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5217 * Get the height-for-width mode
5219 * @param obj The genlist object
5220 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5226 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5228 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5229 Widget_Data *wd = elm_widget_data_get(obj);
5230 if (!wd) return EINA_FALSE;
5231 return wd->height_for_width;
5237 * This will enable or disable the scroller bounce mode for the
5238 * genlist. See elm_scroller_bounce_set() for details
5240 * @param obj The genlist object
5241 * @param h_bounce Allow bounce horizontally
5242 * @param v_bounce Allow bounce vertically
5247 elm_genlist_bounce_set(Evas_Object *obj,
5251 ELM_CHECK_WIDTYPE(obj, widtype);
5252 Widget_Data *wd = elm_widget_data_get(obj);
5254 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5258 * Get the bounce mode
5260 * @param obj The genlist object
5261 * @param h_bounce Allow bounce horizontally
5262 * @param v_bounce Allow bounce vertically
5267 elm_genlist_bounce_get(const Evas_Object *obj,
5268 Eina_Bool *h_bounce,
5269 Eina_Bool *v_bounce)
5271 ELM_CHECK_WIDTYPE(obj, widtype);
5272 Widget_Data *wd = elm_widget_data_get(obj);
5274 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5278 * Set homogenous mode
5280 * This will enable the homogeneous mode where items are of the same
5281 * height and width so that genlist may do the lazy-loading at its
5282 * maximum. This implies 'compressed' mode.
5284 * @param obj The genlist object
5285 * @param homogeneous Assume the items within the genlist are of the
5286 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5291 elm_genlist_homogeneous_set(Evas_Object *obj,
5292 Eina_Bool homogeneous)
5294 ELM_CHECK_WIDTYPE(obj, widtype);
5295 Widget_Data *wd = elm_widget_data_get(obj);
5297 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5298 wd->homogeneous = homogeneous;
5302 * Get the homogenous mode
5304 * @param obj The genlist object
5305 * @return Assume the items within the genlist are of the same height
5306 * and width (EINA_TRUE = on, EINA_FALSE = off)
5311 elm_genlist_homogeneous_get(const Evas_Object *obj)
5313 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5314 Widget_Data *wd = elm_widget_data_get(obj);
5315 if (!wd) return EINA_FALSE;
5316 return wd->homogeneous;
5320 * Set the maximum number of items within an item block
5322 * This will configure the block count to tune to the target with
5323 * particular performance matrix.
5325 * @param obj The genlist object
5326 * @param n Maximum number of items within an item block
5331 elm_genlist_block_count_set(Evas_Object *obj,
5334 ELM_CHECK_WIDTYPE(obj, widtype);
5335 Widget_Data *wd = elm_widget_data_get(obj);
5337 wd->max_items_per_block = n;
5338 wd->item_cache_max = wd->max_items_per_block * 2;
5339 _item_cache_clean(wd);
5343 * Get the maximum number of items within an item block
5345 * @param obj The genlist object
5346 * @return Maximum number of items within an item block
5351 elm_genlist_block_count_get(const Evas_Object *obj)
5353 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5354 Widget_Data *wd = elm_widget_data_get(obj);
5356 return wd->max_items_per_block;
5360 * Set the timeout in seconds for the longpress event
5362 * @param obj The genlist object
5363 * @param timeout timeout in seconds
5368 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5371 ELM_CHECK_WIDTYPE(obj, widtype);
5372 Widget_Data *wd = elm_widget_data_get(obj);
5374 wd->longpress_timeout = timeout;
5378 * Get the timeout in seconds for the longpress event
5380 * @param obj The genlist object
5381 * @return timeout in seconds
5386 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5388 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5389 Widget_Data *wd = elm_widget_data_get(obj);
5391 return wd->longpress_timeout;
5395 * Set the scrollbar policy
5397 * This sets the scrollbar visibility policy for the given genlist
5398 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5399 * made visible if it is needed, and otherwise kept hidden.
5400 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5401 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5402 * respectively for the horizontal and vertical scrollbars.
5404 * @param obj The genlist object
5405 * @param policy_h Horizontal scrollbar policy
5406 * @param policy_v Vertical scrollbar policy
5411 elm_genlist_scroller_policy_set(Evas_Object *obj,
5412 Elm_Scroller_Policy policy_h,
5413 Elm_Scroller_Policy policy_v)
5415 ELM_CHECK_WIDTYPE(obj, widtype);
5416 Widget_Data *wd = elm_widget_data_get(obj);
5418 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5419 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5422 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5426 * Get the scrollbar policy
5428 * @param obj The genlist object
5429 * @param policy_h Horizontal scrollbar policy
5430 * @param policy_v Vertical scrollbar policy
5435 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5436 Elm_Scroller_Policy *policy_h,
5437 Elm_Scroller_Policy *policy_v)
5439 ELM_CHECK_WIDTYPE(obj, widtype);
5440 Widget_Data *wd = elm_widget_data_get(obj);
5441 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5442 if ((!wd) || (!wd->scr)) return;
5443 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5444 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5445 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5448 /****************************************************************************/
5453 * @param obj The genlist object
5454 * @param reorder_mode The reorder mode
5455 * (EINA_TRUE = on, EINA_FALSE = off)
5460 elm_genlist_reorder_mode_set(Evas_Object *obj,
5461 Eina_Bool reorder_mode)
5463 ELM_CHECK_WIDTYPE(obj, widtype);
5464 Widget_Data *wd = elm_widget_data_get(obj);
5466 wd->reorder_mode = reorder_mode;
5470 * Get the reorder mode
5472 * @param obj The genlist object
5473 * @return The reorder mode
5474 * (EINA_TRUE = on, EINA_FALSE = off)
5479 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5481 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5482 Widget_Data *wd = elm_widget_data_get(obj);
5483 if (!wd) return EINA_FALSE;
5484 return wd->reorder_mode;
5488 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5494 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5500 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5505 if (it->wd->ed->ec->move)
5506 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5508 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5509 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5510 it->wd->reorder_deleted = EINA_TRUE;
5511 _item_block_del(it);
5513 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5515 it->rel->relcount++;
5516 it->before = EINA_FALSE;
5517 _item_queue(it->wd, it);
5521 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5524 if (!before) return;
5526 if (it->wd->ed->ec->move)
5527 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5529 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5530 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5531 it->wd->reorder_deleted = EINA_TRUE;
5532 _item_block_del(it);
5533 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5535 it->rel->relcount++;
5536 it->before = EINA_TRUE;
5537 _item_queue(it->wd, it);
5541 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5543 ELM_CHECK_WIDTYPE(obj, widtype);
5544 Widget_Data *wd = elm_widget_data_get(obj);
5546 wd->effect_mode = emode;
5547 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5548 // evas_object_resize(wd->point_rect, 10, 25);
5549 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5550 // evas_object_show(wd->point_rect);
5551 // evas_object_hide(wd->point_rect);
5555 _create_tray_alpha_bg(const Evas_Object *obj)
5557 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5558 Widget_Data *wd = elm_widget_data_get(obj);
5559 if (!wd) return NULL;
5561 Evas_Object *bg = NULL;
5562 Evas_Coord ox, oy, ow, oh;
5564 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5565 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5566 evas_object_color_set(bg,0,0,0,0);
5567 evas_object_resize(bg , ow, oh);
5568 evas_object_move(bg , ox, oy);
5569 evas_object_show(bg);
5570 evas_object_hide(bg);
5577 struct timeval timev;
5579 gettimeofday(&timev, NULL);
5580 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5583 // added for item moving animation.
5585 _item_moving_effect_timer_cb(void *data)
5587 Widget_Data *wd = data;
5588 if (!wd) return EINA_FALSE;
5590 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5591 Elm_Genlist_Item *it, *it2;
5593 double time = 0.4, t;
5595 Eina_Bool check, end = EINA_FALSE;
5596 // static Eina_Bool first = EINA_TRUE;
5599 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5601 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5602 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5603 if (t > time) end = EINA_TRUE;
5604 EINA_INLIST_FOREACH(wd->blocks, itb)
5607 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5608 itb->y - wd->pan_y + oy,
5610 cvx, cvy, cvw, cvh))
5612 EINA_LIST_FOREACH(itb->items, l, it)
5614 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5619 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5625 //printf(" s: %d %d ", oy, oh);
5626 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5627 dy = it->scrl_y - it->old_scrl_y;
5628 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5630 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5631 if(wd->expand_item_end < it->old_scrl_y)
5632 dy = wd->expand_item_gap;
5634 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5636 if (wd->expand_item_end < it->old_scrl_y)
5637 dy = wd->expand_item_gap;
5640 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5647 if (!it->old_scrl_y)
5648 it->old_scrl_y = it->scrl_y;
5651 if (it->old_scrl_y + y < oy + oh)
5653 if (!it->realized) _item_realize(it, in, 0);
5655 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5656 it->old_scrl_y = it->scrl_y - y;
5659 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5660 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5662 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5665 evas_object_resize(it->base.view, it->w, it->h);
5666 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5667 evas_object_show(it->base.view);
5668 evas_object_raise(it->base.view);
5671 if (it->group_item) evas_object_raise(it->group_item->base.view);
5674 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5676 it2 = elm_genlist_item_prev_get(it);
5679 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5681 if(!it2->effect_done)
5683 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5684 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5685 evas_object_show(it2->base.view);
5686 it2->effect_done = EINA_TRUE;
5690 it2 = elm_genlist_item_prev_get(it2);
5693 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5695 it2 = elm_genlist_item_prev_get(it);
5698 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5700 if(!it2->effect_done)
5702 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5703 it2->effect_done = EINA_TRUE;
5708 it2 = elm_genlist_item_prev_get(it2);
5714 // first = EINA_FALSE;
5718 if (wd->item_moving_effect_timer)
5720 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5721 _item_subitems_clear(wd->expand_item);
5722 EINA_INLIST_FOREACH(wd->blocks, itb)
5724 EINA_LIST_FOREACH(itb->items, l, it)
5726 it->effect_done = EINA_TRUE;
5727 it->old_scrl_y = it->scrl_y;
5731 //evas_render(evas_object_evas_get(wd->obj));
5732 wd->item_moving_effect_timer = NULL;
5733 // first = EINA_TRUE;
5735 _item_auto_scroll(wd);
5736 evas_object_lower(wd->alpha_bg);
5737 evas_object_hide(wd->alpha_bg);
5738 if (wd->calc_job) ecore_job_del(wd->calc_job);
5739 wd->calc_job = ecore_job_add(_calc_job, wd);
5740 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5741 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5743 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5744 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5745 return ECORE_CALLBACK_CANCEL;
5747 return ECORE_CALLBACK_RENEW;
5751 _emit_contract(Elm_Genlist_Item *it)
5753 Elm_Genlist_Item *it2;
5756 // printf("%p is emited contract\n", it);
5757 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5758 it->effect_done = EINA_FALSE;
5760 EINA_LIST_FOREACH(it->items, l, it2)
5762 _emit_contract(it2);
5765 // added for item moving animation.
5767 _item_flip_effect_show(Elm_Genlist_Item *it)
5769 Elm_Genlist_Item *it2;
5771 Widget_Data *wd = it->wd;
5772 Eina_Bool check = EINA_FALSE;
5774 it2 = elm_genlist_item_next_get(it);
5777 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5778 it2 = elm_genlist_item_next_get(it2);
5780 EINA_LIST_FOREACH(it->items, l, it2)
5782 if (it2->parent && it == it2->parent)
5784 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5786 edje_object_signal_emit(it2->base.view, "flip_item", "");
5788 evas_object_move(it2->base.view, -9999, -9999);
5790 evas_object_show(it2->base.view);
5792 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5793 _emit_contract(it2);
5797 return ECORE_CALLBACK_CANCEL;
5802 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5804 printf("!!! NOW FIXING \n");
5809 * Set pinch zoom mode
5811 * @param obj The genlist object
5813 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5818 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5820 printf("!!! NOW FIXING \n");
5824 * Get pinch zoom mode
5826 * @param obj The genlist object
5827 * @return The pinch mode
5828 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5833 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5835 printf("!!! NOW FIXING \n");
5840 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5842 printf("!!! NOW FIXING \n");
5846 ////////////////////////////////////////////////////////////////////////
5848 ////////////////////////////////////////////////////////////////////////
5851 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5853 if (!it->wd->edit_mode) return;
5854 evas_object_resize(it->edit_obj,it->w, it->h);
5855 evas_object_move(it->edit_obj, itx, ity);
5859 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
5861 if ((it->effect_item_realized) || (it->delete_me)) return;
5864 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5865 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5866 _elm_config->scale);
5867 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5868 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5870 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5871 else strncpy(buf, "item", sizeof(buf));
5872 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5874 strncat(buf, "/", sizeof(buf) - strlen(buf));
5876 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
5878 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
5879 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5883 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
5886 if (it->wd->reorder_mode)
5888 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
5889 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
5891 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
5892 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
5894 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
5895 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
5898 if ((it->wd->edit_mode))
5900 if (it->itc->func.icon_get)
5905 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
5906 EINA_LIST_FOREACH(it->icons, l, key)
5908 Evas_Object *ic = it->itc->func.icon_get
5909 (it->base.data, it->base.widget, l->data);
5913 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5914 edje_object_part_swallow(it->edit_obj, key, ic);
5915 evas_object_show(ic);
5916 elm_widget_sub_object_add(it->base.widget, ic);
5921 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
5922 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5923 evas_object_show(it->edit_obj);
5925 it->effect_item_realized = EINA_TRUE;
5926 it->want_unrealize = EINA_FALSE;
5930 _effect_item_unrealize(Elm_Genlist_Item *it)
5934 if (!it->effect_item_realized) return;
5935 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5937 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
5938 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
5939 edje_object_message_signal_process(it->edit_obj);
5940 edje_object_part_unswallow(it->edit_obj, it->base.view);
5941 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
5942 elm_widget_sub_object_add(it->base.widget, it->base.view);
5943 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5944 // _item_cache_add(it);
5945 evas_object_del(it->edit_obj);
5946 it->edit_obj = NULL;
5947 EINA_LIST_FREE(it->edit_icon_objs, icon)
5948 evas_object_del(icon);
5950 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5951 it->effect_item_realized = EINA_FALSE;
5955 * Get Genlist edit mode
5957 * @param obj The genlist object
5958 * @return The edit mode status
5959 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
5964 elm_genlist_edit_mode_get(const Evas_Object *obj)
5966 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5967 Widget_Data *wd = elm_widget_data_get(obj);
5968 if (!wd) return EINA_FALSE;
5970 if (wd->edit_mode) return EINA_TRUE;
5971 else return EINA_FALSE;
5975 * Set Genlist edit mode
5977 * This sets Genlist edit mode.
5979 * @param obj The Genlist object
5980 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5981 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5986 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
5988 ELM_CHECK_WIDTYPE(obj, widtype);
5992 Elm_Genlist_Item *it;
5994 Widget_Data *wd = elm_widget_data_get(obj);
5996 if (wd->edit_mode == edit_mode) return;
5998 wd->edit_mode = edit_mode;
6001 EINA_INLIST_FOREACH(wd->blocks, itb)
6005 EINA_LIST_FOREACH(itb->items, l, it)
6007 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6009 _effect_item_unrealize(it);
6014 _item_cache_zero(wd);
6019 EINA_INLIST_FOREACH(wd->blocks, itb)
6023 EINA_LIST_FOREACH(itb->items, l, it)
6025 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6027 if(it->selected) _item_unselect(it);
6028 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
6035 if (wd->calc_job) ecore_job_del(wd->calc_job);
6036 wd->calc_job = ecore_job_add(_calc_job, wd);
6040 * Delete selected items in genlist edit mode.
6042 * @param obj The genlist object
6047 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6049 fprintf(stderr, "=================> Caution!!! <========================\n");
6050 fprintf(stderr, "==> elm_genlist_edit_selected_items_del() is deprecated. <=======\n");
6051 fprintf(stderr, "=======================================================\n");
6055 elm_genlist_selected_items_del(Evas_Object *obj)
6057 fprintf(stderr, "=================> Caution!!! <========================\n");
6058 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6059 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6060 fprintf(stderr, "=======================================================\n");
6064 * Get a list of selected items in genlist
6066 * This returns a list of the selected items in the genlist. The list
6067 * contains Elm_Genlist_Item pointers. The list must be freed by the
6068 * caller when done with eina_list_free(). The item pointers in the list
6069 * are only vallid so long as those items are not deleted or the genlist is
6072 * @param obj The genlist object
6073 * @return The list of selected items, nor NULL if none are selected.
6078 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6080 fprintf(stderr, "========================> Caution!!! <==========================\n");
6081 fprintf(stderr, "==> elm_genlist_edit_selected_items_get() is deprecated. <=======\n");
6082 fprintf(stderr, "================================================================\n");
6086 // TODO : add comment
6088 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6091 fprintf(stderr, "========================> Caution!!! <==========================\n");
6092 fprintf(stderr, "==> elm_genlist_edit_item_selected_set() is deprecated. <=======\n");
6093 fprintf(stderr, "================================================================\n");
6096 // TODO : add comment
6098 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6100 fprintf(stderr, "========================> Caution!!! <==========================\n");
6101 fprintf(stderr, "==> elm_genlist_edit_item_selected_get() is deprecated. <=======\n");
6102 fprintf(stderr, "================================================================\n");
6107 * Set a given item's rename mode
6109 * This renames the item's label from genlist
6111 * @param it The item
6112 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6117 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6119 if (!it) return NULL;
6120 if (it->wd->queue_idler) return NULL;
6122 const Eina_List *l, *list, *l2;
6123 const char *label, *rename_swallow_part;
6125 Eina_Bool done = EINA_FALSE;
6126 int label_cnt = 0 , swallow_part_cnt = 0;
6129 Evas_Object *editfield;
6130 Evas_Object *entry = NULL;
6131 int edit_field_cnt = 0;
6133 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6138 Elm_Genlist_Item *it;
6140 EINA_LIST_FOREACH(itb->items, l, it)
6144 it->renamed = EINA_FALSE;
6145 if (it->selected) _item_unselect(it);
6146 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6148 entry = elm_editfield_entry_get(editfield);
6149 const char *text = elm_entry_entry_get(entry);
6150 if (it->itc->func.label_changed)
6151 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6153 EINA_LIST_FREE(it->wd->edit_field, editfield)
6154 evas_object_del(editfield);
6155 it->wd->edit_field = NULL;
6157 if (it->wd->edit_mode)
6159 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6160 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6161 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6162 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6165 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6178 it->renamed = EINA_TRUE;
6179 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6181 it->wd->edit_mode = 0xF0;
6182 _effect_item_realize(it, EINA_TRUE);
6183 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6186 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6187 EINA_LIST_FOREACH(it->labels, list, label)
6189 if (it->itc->func.label_get)
6191 swallow_part_cnt = 0;
6193 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6194 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6196 if (label_cnt == swallow_part_cnt)
6198 editfield = elm_editfield_add(it->base.widget);
6199 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6201 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6202 elm_editfield_eraser_set(editfield, EINA_TRUE);
6203 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6204 elm_widget_sub_object_add(it->edit_obj, editfield);
6206 evas_object_show(editfield);
6208 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6211 entry = elm_editfield_entry_get(editfield);
6212 elm_entry_entry_set(entry,s);
6213 elm_entry_cursor_end_set(entry);
6217 elm_editfield_guide_text_set(editfield, "Text Input");
6224 elm_widget_focused_object_clear(elm_widget_focused_object_get(it->wd->obj));
6225 elm_widget_focus_set(editfield, EINA_TRUE);
6231 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6233 Elm_Genlist_Item *it = data;
6235 _delete_sweep_objs(it);
6239 _scr_hold_timer_cb(void *data)
6241 Elm_Genlist_Item *it = data;
6242 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6243 it->wd->scr_hold_timer = NULL;
6244 return ECORE_CALLBACK_CANCEL;
6248 _delete_sweep_objs(Elm_Genlist_Item *it)
6252 elm_widget_stringlist_free(it->sweep_labels);
6253 it->sweep_labels = NULL;
6254 elm_widget_stringlist_free(it->sweep_icons);
6255 it->sweep_icons = NULL;
6256 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6257 evas_object_del(ic);
6261 _create_sweep_objs(Elm_Genlist_Item *it)
6267 if (it->itc->func.label_get)
6270 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6272 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6274 char *s = it->itc->func.label_get
6275 ((void *)it->base.data, it->base.widget, l->data);
6279 edje_object_part_text_set(it->base.view, l->data, s);
6284 if (it->itc->func.icon_get)
6287 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6289 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6291 ic = it->itc->func.icon_get
6292 ((void *)it->base.data, it->base.widget, l->data);
6296 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6297 edje_object_part_swallow(it->base.view, key, ic);
6298 evas_object_show(ic);
6299 elm_widget_sub_object_add(it->base.widget, ic);
6306 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6309 Elm_Genlist_Item *it2;
6310 const char *allow_slide;
6312 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6313 if ((!allow_slide) || (atoi(allow_slide) != 1))
6318 if (it->sweeped) return;
6319 if (it->wd->scr_hold_timer)
6321 ecore_timer_del(it->wd->scr_hold_timer);
6322 it->wd->scr_hold_timer = NULL;
6324 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6325 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6327 _delete_sweep_objs(it);
6328 _create_sweep_objs(it);
6329 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6330 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6331 it->wassweeped = EINA_TRUE;
6332 it->sweeped = EINA_TRUE;
6334 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6338 it2->sweeped = EINA_FALSE;
6339 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6340 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6341 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6347 if (!it->sweeped) return;
6348 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6349 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6350 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6351 it->sweeped = EINA_FALSE;
6356 _item_auto_scroll(void *data)
6358 Widget_Data *wd = data;
6361 if ((wd->expand_item) && (!wd->auto_scrolled))
6363 Elm_Genlist_Item *it;
6365 Evas_Coord ox, oy, ow, oh;
6366 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6368 wd->auto_scrolled = EINA_TRUE;
6369 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6371 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6373 elm_genlist_item_bring_in(it);