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 * Genlist has a fairly large API, mostly because it's relatively complex,
19 * trying to be both expansive, powerful and efficient. First we will begin
20 * an overview on the theory behind genlist.
22 * Evas tracks every object you create. Every time it processes an event
23 * (mouse move, down, up etc.) it needs to walk through objects and find out
24 * what event that affects. Even worse every time it renders display updates,
25 * in order to just calculate what to re-draw, it needs to walk through many
26 * many many objects. Thus, the more objects you keep active, the more
27 * overhead Evas has in just doing its work. It is advisable to keep your
28 * active objects to the minimum working set you need. Also remember that
29 * object creation and deletion carries an overhead, so there is a
30 * middle-ground, which is not easily determined. But don't keep massive lists
31 * of objects you can't see or use. Genlist does this with list objects. It
32 * creates and destroys them dynamically as you scroll around. It groups them
33 * into blocks so it can determine the visibility etc. of a whole block at
34 * once as opposed to having to walk the whole list. This 2-level list allows
35 * for very large numbers of items to be in the list (tests have used up to
36 * 2,000,000 items). Also genlist employs a queue for adding items. As items
37 * may be different sizes, every item added needs to be calculated as to its
38 * size and thus this presents a lot of overhead on populating the list, this
39 * genlist employs a queue. Any item added is queued and spooled off over
40 * time, actually appearing some time later, so if your list has many members
41 * you may find it takes a while for them to all appear, with your process
42 * consuming a lot of CPU while it is busy spooling.
44 * Genlist also implements a tree structure, but it does so with callbacks to
45 * the application, with the application filling in tree structures when
46 * requested (allowing for efficient building of a very deep tree that could
47 * even be used for file-management). See the above smart signal callbacks for
50 * An item in the genlist world can have 0 or more text labels (they can be
51 * regular text or textblock - that's up to the style to determine), 0 or
52 * more icons (which are simply objects swallowed into the genlist item) and
53 * 0 or more boolean states that can be used for check, radio or other
54 * indicators by the edje theme style. An item may be one of several styles
55 * (Elementary provides 4 by default - "default", "double_label", "group_index"
56 * and "icon_top_text_bottom", but this can be extended by system or
57 * application custom themes/overlays/extensions).
59 * In order to implement the ability to add and delete items on the fly,
60 * Genlist implements a class/callback system where the application provides
61 * a structure with information about that type of item (genlist may contain
62 * multiple different items with different classes, states and styles).
63 * Genlist will call the functions in this struct (methods) when an item is
64 * "realized" (that is created dynamically while scrolling). All objects will
65 * simply be deleted when no longer needed with evas_object_del(). The
66 * Elm_Genlist_Item_Class structure contains the following members:
68 * item_style - This is a constant string and simply defines the name of the
69 * item style. It must be specified and the default should be "default".
71 * func.label_get - This function is called when an actual item object is
72 * created. The data parameter is the data parameter passed to
73 * elm_genlist_item_append() and related item creation functions. The obj
74 * parameter is the genlist object and the part parameter is the string name
75 * of the text part in the edje design that is listed as one of the possible
76 * labels that can be set. This function must return a strudup()'ed string as
77 * the caller will free() it when done.
79 * func.icon_get - This function is called when an actual item object is
80 * created. The data parameter is the data parameter passed to
81 * elm_genlist_item_append() and related item creation functions. The obj
82 * parameter is the genlist object and the part parameter is the string name
83 * of the icon part in the edje design that is listed as one of the possible
84 * icons that can be set. This must return NULL for no object or a valid
85 * object. The object will be deleted by genlist on shutdown or when the item
88 * func.state_get - This function is called when an actual item object is
89 * created. The data parameter is the data parameter passed to
90 * elm_genlist_item_append() and related item creation functions. The obj
91 * parameter is the genlist object and the part parameter is the string name
92 * of the state part in the edje design that is listed as one of the possible
93 * states that can be set. Return 0 for false or 1 for true. Genlist will
94 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
95 * true (the default is false), where XXX is the name of the part.
97 * func.del - This is called when elm_genlist_item_del() is called on an
98 * item, elm_genlist_clear() is called on the genlist, or
99 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
100 * intended for use when actual genlist items are deleted, so any backing
101 * data attached to the item (e.g. its data parameter on creation) can be
104 * Items can be added by several calls. All of them return a Elm_Genlist_Item
105 * handle that is an internal member inside the genlist. They all take a data
106 * parameter that is meant to be used for a handle to the applications
107 * internal data (eg the struct with the original item data). The parent
108 * parameter is the parent genlist item this belongs to if it is a tree or
109 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
110 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
111 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
112 * is displayed as an item that is able to expand and have child items.
113 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
114 * displayed at the top until the next group comes. The func parameter is a
115 * convenience callback that is called when the item is selected and the data
116 * parameter will be the func_data parameter, obj be the genlist object and
117 * event_info will be the genlist item.
119 * elm_genlist_item_append() appends an item to the end of the list, or if
120 * there is a parent, to the end of all the child items of the parent.
121 * elm_genlist_item_prepend() is the same but prepends to the beginning of
122 * the list or children list. elm_genlist_item_insert_before() inserts at
123 * item before another item and elm_genlist_item_insert_after() inserts after
124 * the indicated item.
126 * The application can clear the list with elm_genlist_clear() which deletes
127 * all the items in the list and elm_genlist_item_del() will delete a specific
128 * item. elm_genlist_item_subitems_clear() will clear all items that are
129 * children of the indicated parent item.
131 * If the application wants multiple items to be able to be selected,
132 * elm_genlist_multi_select_set() can enable this. If the list is
133 * single-selection only (the default), then elm_genlist_selected_item_get()
134 * will return the selected item, if any, or NULL I none is selected. If the
135 * list is multi-select then elm_genlist_selected_items_get() will return a
136 * list (that is only valid as long as no items are modified (added, deleted,
137 * selected or unselected)).
139 * To help inspect list items you can jump to the item at the top of the list
140 * with elm_genlist_first_item_get() which will return the item pointer, and
141 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
142 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
143 * and previous items respectively relative to the indicated item. Using
144 * these calls you can walk the entire item list/tree. Note that as a tree
145 * the items are flattened in the list, so elm_genlist_item_parent_get() will
146 * let you know which item is the parent (and thus know how to skip them if
149 * There are also convenience functions. elm_genlist_item_genlist_get() will
150 * return the genlist object the item belongs to. elm_genlist_item_show()
151 * will make the scroller scroll to show that specific item so its visible.
152 * elm_genlist_item_data_get() returns the data pointer set by the item
153 * creation functions.
155 * If an item changes (state of boolean changes, label or icons change),
156 * then use elm_genlist_item_update() to have genlist update the item with
157 * the new state. Genlist will re-realize the item thus call the functions
158 * in the _Elm_Genlist_Item_Class for that item.
160 * To programmatically (un)select an item use elm_genlist_item_selected_set().
161 * To get its selected state use elm_genlist_item_selected_get(). Similarly
162 * to expand/contract an item and get its expanded state, use
163 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
164 * again to make an item disabled (unable to be selected and appear
165 * differently) use elm_genlist_item_disabled_set() to set this and
166 * elm_genlist_item_disabled_get() to get the disabled state.
168 * In general to indicate how the genlist should expand items horizontally to
169 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
170 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
171 * mode means that if items are too wide to fit, the scroller will scroll
172 * horizontally. Otherwise items are expanded to fill the width of the
173 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
174 * to the viewport width and limited to that size. This can be combined with
175 * a different style that uses edjes' ellipsis feature (cutting text off like
178 * Items will only call their selection func and callback when first becoming
179 * selected. Any further clicks will do nothing, unless you enable always
180 * select with elm_genlist_always_select_mode_set(). This means even if
181 * selected, every click will make the selected callbacks be called.
182 * elm_genlist_no_select_mode_set() will turn off the ability to select
183 * items entirely and they will neither appear selected nor call selected
184 * callback functions.
186 * Remember that you can create new styles and add your own theme augmentation
187 * per application with elm_theme_extension_add(). If you absolutely must
188 * have a specific style that overrides any theme the user or system sets up
189 * you can use elm_theme_overlay_add() to add such a file.
191 * Signals that you can add callbacks for are:
193 * "clicked,double" - This is called when a user has double-clicked an item. The
194 * event_info parameter is the genlist item that was double-c
196 * "selected" - This is called when a user has made an item selected. The
197 * event_info parameter is the genlist item that was selected.
198 * "unselected" - This is called when a user has made an item unselected. The
199 * event_info parameter is the genlist item that was unselected.
200 * "expanded" - This is called when elm_genlist_item_expanded_set() is called
201 * and the item is now meant to be expanded. The event_info
202 * parameter is the genlist item that was indicated to expand. It
203 * is the job of this callback to then fill in the child items.
204 * "contracted" - This is called when elm_genlist_item_expanded_set() is called
205 * and the item is now meant to be contracted. The event_info
206 * parameter is the genlist item that was indicated to contract.
207 * It is the job of this callback to then delete the child items.
208 * "expand,request" - This is called when a user has indicated they want to
209 * expand a tree branch item. The callback should decide if
210 * the item can expand (has any children) and then call
211 * elm_genlist_item_expanded_set() appropriately to set the
212 * state. The event_info parameter is the genlist item that
213 * was indicated to expand.
214 * "contract,request" - This is called when a user has indicated they want to
215 * contract a tree branch item. The callback should decide
216 * if the item can contract (has any children) and then
217 * call elm_genlist_item_expanded_set() appropriately to
218 * set the state. The event_info parameter is the genlist
219 * item that was indicated to contract.
220 * "realized" - This is called when the item in the list is created as a real
221 * evas object. event_info parameter is the genlist item that was
222 * created. The object may be deleted at any time, so it is up to
223 * the caller to not use the object pointer from
224 * elm_genlist_item_object_get() in a way where it may point to
226 * "unrealized" - This is called just before an item is unrealized. After this
227 * call icon objects provided will be deleted and the item object
228 * itself delete or be put into a floating cache.
229 * "drag,start,up" - This is called when the item in the list has been dragged
231 * "drag,start,down" - This is called when the item in the list has been dragged
232 * (not scrolled) down.
233 * "drag,start,left" - This is called when the item in the list has been dragged
234 * (not scrolled) left.
235 * "drag,start,right" - This is called when the item in the list has been
236 * dragged (not scrolled) right.
237 * "drag,stop" - This is called when the item in the list has stopped being
239 * "drag" - This is called when the item in the list is being dragged.
240 * "longpressed" - This is called when the item is pressed for a certain amount
241 * of time. By default it's 1 second.
242 * "scroll,edge,top" - This is called when the genlist is scrolled until the
244 * "scroll,edge,bottom" - This is called when the genlist is scrolled until the
246 * "scroll,edge,left" - This is called when the genlist is scrolled until the
248 * "scroll,edge,right" - This is called when the genlist is scrolled until the
250 * "multi,swipe,left" - This is called when the genlist is multi-touch swiped
252 * "multi,swipe,right" - This is called when the genlist is multi-touch swiped
254 * "multi,swipe,up" - This is called when the genlist is multi-touch swiped up.
255 * "multi,swipe,down" - This is called when the genlist is multi-touch swiped
257 * "multi,pinch,out" - This is called when the genlist is multi-touch pinched
259 * "multi,pinch,in" - This is called when the genlist is multi-touch pinched in.
262 typedef struct _Widget_Data Widget_Data;
263 typedef struct _Item_Block Item_Block;
264 typedef struct _Pan Pan;
265 typedef struct _Item_Cache Item_Cache;
266 typedef enum _Elm_Genlist_Item_Move_effect_Mode
268 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
269 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
270 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
271 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 2),
272 } Elm_Genlist_Item_Move_effect_Mode;
276 Evas_Object *obj, *scr, *pan_smart;
277 Eina_Inlist *items, *blocks;
278 Eina_List *group_items;
280 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
281 Ecore_Job *calc_job, *update_job;
282 Ecore_Idle_Enterer *queue_idle_enterer;
283 Ecore_Idler *must_recalc_idler;
284 Eina_List *queue, *selected;
285 Elm_Genlist_Item *show_item;
286 Elm_Genlist_Item *last_selected_item;
287 Eina_Inlist *item_cache;
288 Elm_Genlist_Item *anchor_item;
291 Ecore_Timer *multi_timer;
292 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
293 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
294 Eina_Bool mouse_down : 1;
295 Eina_Bool multi_down : 1;
296 Eina_Bool multi_timeout : 1;
297 Eina_Bool multitouched : 1;
298 Eina_Bool on_hold : 1;
300 Eina_Bool always_select : 1;
301 Eina_Bool longpressed : 1;
302 Eina_Bool wasselected : 1;
303 Eina_Bool no_select : 1;
304 Eina_Bool bring_in : 1;
305 Eina_Bool compress : 1;
306 Eina_Bool height_for_width : 1;
307 Eina_Bool homogeneous : 1;
308 Eina_Bool clear_me : 1;
313 } history[SWIPE_MOVES];
315 int item_cache_count;
321 int group_item_width;
322 int group_item_height;
323 int max_items_per_block;
324 double longpress_timeout;
326 // TODO : refactoring
327 Eina_Bool reorder_mode : 1;
328 Eina_Bool reorder_pan_move : 1;
329 Eina_Bool reorder_deleted : 1;
330 Eina_Bool effect_mode : 1;
331 Eina_Bool auto_scrolled : 1;
334 Elm_Genlist_Item *reorder_it, *reorder_rel;
335 Evas_Coord reorder_start_y;
336 Ecore_Animator *item_moving_effect_timer;
337 Evas_Object *alpha_bg;
338 Elm_Genlist_Item *expand_item;
339 Evas_Coord expand_item_end;
340 Evas_Coord expand_item_gap;
341 int move_effect_mode;
342 unsigned int start_time;
343 Ecore_Job *changed_job;
344 Elm_Genlist_Item *rename_it;
345 const char *mode_type;
346 Elm_Genlist_Item *mode_item;
347 Ecore_Timer *scr_hold_timer;
357 Evas_Coord x, y, w, h, minw, minh;
358 Eina_Bool want_unrealize : 1;
359 Eina_Bool realized : 1;
360 Eina_Bool changed : 1;
361 Eina_Bool updateme : 1;
362 Eina_Bool showme : 1;
363 Eina_Bool must_recalc : 1;
367 struct _Elm_Genlist_Item
369 Elm_Widget_Item base;
374 Evas_Coord x, y, w, h, minw, minh;
375 const Elm_Genlist_Item_Class *itc;
376 Elm_Genlist_Item *parent;
377 Elm_Genlist_Item *group_item;
378 Elm_Genlist_Item_Flags flags;
386 Eina_List *labels, *icons, *states, *icon_objs;
387 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
388 Ecore_Timer *long_timer;
389 Ecore_Timer *swipe_timer;
391 Evas_Coord scrl_x, scrl_y;
393 Elm_Genlist_Item *rel;
394 Evas_Object *mode_view;
399 Elm_Tooltip_Item_Content_Cb content_cb;
400 Evas_Smart_Cb del_cb;
404 const char *mouse_cursor;
411 Eina_Bool before : 1;
413 Eina_Bool want_unrealize : 1;
414 Eina_Bool want_realize : 1;
415 Eina_Bool realized : 1;
416 Eina_Bool selected : 1;
417 Eina_Bool highlighted : 1;
418 Eina_Bool expanded : 1;
419 Eina_Bool disabled : 1;
420 Eina_Bool display_only : 1;
421 Eina_Bool mincalcd : 1;
422 Eina_Bool queued : 1;
423 Eina_Bool showme : 1;
424 Eina_Bool delete_me : 1;
426 Eina_Bool dragging : 1;
427 Eina_Bool updateme : 1;
428 Eina_Bool nocache : 1;
431 Eina_Bool move_effect_me : 1;
432 Eina_Bool effect_done : 1;
433 Eina_Bool reordering : 1;
434 Eina_Bool renamed : 1;
435 Eina_Bool effect_item_realized : 1;
436 Eina_List *edit_icon_objs;
437 Evas_Object *edit_obj;
439 Ecore_Animator *item_moving_effect_timer;
440 Evas_Coord old_scrl_y;
447 Evas_Object *base_view, *spacer;
449 const char *item_style; // it->itc->item_style
450 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
451 Eina_Bool compress : 1; // it->wd->compress
452 Eina_Bool odd : 1; // in & 0x1
454 Eina_Bool selected : 1; // it->selected
455 Eina_Bool disabled : 1; // it->disabled
456 Eina_Bool expanded : 1; // it->expanded
459 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
460 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
464 Evas_Object_Smart_Clipped_Data __clipped_data;
466 Ecore_Job *resize_job;
469 static const char *widtype = NULL;
470 static void _item_cache_zero(Widget_Data *wd);
471 static void _del_hook(Evas_Object *obj);
472 static void _mirrored_set(Evas_Object *obj,
474 static void _theme_hook(Evas_Object *obj);
475 static void _show_region_hook(void *data,
477 static void _sizing_eval(Evas_Object *obj);
478 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
479 static void _item_block_unrealize(Item_Block *itb);
480 static void _calc_job(void *data);
481 static void _on_focus_hook(void *data,
483 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
484 static void _changed_job(void *data);
485 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
486 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
487 static Eina_Bool _item_single_select_up(Widget_Data *wd);
488 static Eina_Bool _item_single_select_down(Widget_Data *wd);
489 static Eina_Bool _event_hook(Evas_Object *obj,
491 Evas_Callback_Type type,
493 static void _signal_emit_hook(Evas_Object *obj,
494 const char *emission,
496 static Eina_Bool _deselect_all_items(Widget_Data *wd);
497 static void _pan_calculate(Evas_Object *obj);
498 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
499 static void _mode_item_realize(Elm_Genlist_Item *it);
500 static void _mode_item_unrealize(Elm_Genlist_Item *it);
501 static void _item_mode_set(Elm_Genlist_Item *it);
502 static void _item_mode_unset(Widget_Data *wd);
504 // TODO : refactoring
505 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
506 static unsigned int current_time_get();
507 static Eina_Bool _item_moving_effect_timer_cb(void *data);
508 static int _item_flip_effect_show(Elm_Genlist_Item *it);
509 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
510 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
511 static void _effect_item_unrealize(Elm_Genlist_Item *it);
512 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
513 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
514 static void _group_items_recalc(void *data);
515 static void _item_auto_scroll(void *data);
517 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
520 _event_hook(Evas_Object *obj,
521 Evas_Object *src __UNUSED__,
522 Evas_Callback_Type type,
525 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
526 Evas_Event_Key_Down *ev = event_info;
527 Widget_Data *wd = elm_widget_data_get(obj);
528 if (!wd) return EINA_FALSE;
529 if (!wd->items) return EINA_FALSE;
530 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
531 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
533 Elm_Genlist_Item *it = NULL;
536 Evas_Coord step_x = 0;
537 Evas_Coord step_y = 0;
540 Evas_Coord page_x = 0;
541 Evas_Coord page_y = 0;
543 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
544 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
545 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
546 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
548 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
552 else if ((!strcmp(ev->keyname, "Right")) ||
553 (!strcmp(ev->keyname, "KP_Right")))
557 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
559 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
560 (_item_multi_select_up(wd)))
561 || (_item_single_select_up(wd)))
563 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
569 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
571 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
572 (_item_multi_select_down(wd)))
573 || (_item_single_select_down(wd)))
575 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
581 else if ((!strcmp(ev->keyname, "Home")) ||
582 (!strcmp(ev->keyname, "KP_Home")))
584 it = elm_genlist_first_item_get(obj);
585 elm_genlist_item_bring_in(it);
586 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
589 else if ((!strcmp(ev->keyname, "End")) ||
590 (!strcmp(ev->keyname, "KP_End")))
592 it = elm_genlist_last_item_get(obj);
593 elm_genlist_item_bring_in(it);
594 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
597 else if ((!strcmp(ev->keyname, "Prior")) ||
598 (!strcmp(ev->keyname, "KP_Prior")))
601 y -= -(page_y * v_h) / 100;
605 else if ((!strcmp(ev->keyname, "Next")) ||
606 (!strcmp(ev->keyname, "KP_Next")))
609 y += -(page_y * v_h) / 100;
613 else if(((!strcmp(ev->keyname, "Return")) ||
614 (!strcmp(ev->keyname, "KP_Enter")) ||
615 (!strcmp(ev->keyname, "space")))
616 && (!wd->multi) && (wd->selected))
618 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
619 elm_genlist_item_expanded_set(it,
620 !elm_genlist_item_expanded_get(it));
622 else if (!strcmp(ev->keyname, "Escape"))
624 if (!_deselect_all_items(wd)) return EINA_FALSE;
625 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
628 else return EINA_FALSE;
630 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
631 elm_smart_scroller_child_pos_set(wd->scr, x, y);
636 _deselect_all_items(Widget_Data *wd)
638 if (!wd->selected) return EINA_FALSE;
640 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
646 _item_multi_select_up(Widget_Data *wd)
648 if (!wd->selected) return EINA_FALSE;
649 if (!wd->multi) return EINA_FALSE;
651 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
652 if (!prev) return EINA_TRUE;
654 if (elm_genlist_item_selected_get(prev))
656 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
657 wd->last_selected_item = prev;
658 elm_genlist_item_show(wd->last_selected_item);
662 elm_genlist_item_selected_set(prev, EINA_TRUE);
663 elm_genlist_item_show(prev);
669 _item_multi_select_down(Widget_Data *wd)
671 if (!wd->selected) return EINA_FALSE;
672 if (!wd->multi) return EINA_FALSE;
674 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
675 if (!next) return EINA_TRUE;
677 if (elm_genlist_item_selected_get(next))
679 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
680 wd->last_selected_item = next;
681 elm_genlist_item_show(wd->last_selected_item);
685 elm_genlist_item_selected_set(next, EINA_TRUE);
686 elm_genlist_item_show(next);
692 _item_single_select_up(Widget_Data *wd)
694 Elm_Genlist_Item *prev;
697 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
698 while ((prev) && (prev->delete_me))
699 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
701 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
703 if (!prev) return EINA_FALSE;
705 _deselect_all_items(wd);
707 elm_genlist_item_selected_set(prev, EINA_TRUE);
708 elm_genlist_item_show(prev);
713 _item_single_select_down(Widget_Data *wd)
715 Elm_Genlist_Item *next;
718 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
719 while ((next) && (next->delete_me))
720 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
722 else next = elm_genlist_item_next_get(wd->last_selected_item);
724 if (!next) return EINA_FALSE;
726 _deselect_all_items(wd);
728 elm_genlist_item_selected_set(next, EINA_TRUE);
729 elm_genlist_item_show(next);
734 _on_focus_hook(void *data __UNUSED__,
737 Widget_Data *wd = elm_widget_data_get(obj);
739 if (elm_widget_focus_get(obj))
741 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
742 evas_object_focus_set(wd->obj, EINA_TRUE);
743 if ((wd->selected) && (!wd->last_selected_item))
744 wd->last_selected_item = eina_list_data_get(wd->selected);
748 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
749 evas_object_focus_set(wd->obj, EINA_FALSE);
754 _del_hook(Evas_Object *obj)
756 Widget_Data *wd = elm_widget_data_get(obj);
758 _item_cache_zero(wd);
759 if (wd->calc_job) ecore_job_del(wd->calc_job);
760 if (wd->update_job) ecore_job_del(wd->update_job);
761 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
762 if (wd->changed_job) ecore_job_del(wd->changed_job);
763 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
764 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
765 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
766 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
767 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
772 _del_pre_hook(Evas_Object *obj)
774 Widget_Data *wd = elm_widget_data_get(obj);
776 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
777 evas_object_del(wd->pan_smart);
778 wd->pan_smart = NULL;
779 elm_genlist_clear(obj);
783 _mirrored_set(Evas_Object *obj,
786 Widget_Data *wd = elm_widget_data_get(obj);
788 _item_cache_zero(wd);
789 elm_smart_scroller_mirrored_set(wd->scr, rtl);
793 _theme_hook(Evas_Object *obj)
795 Widget_Data *wd = elm_widget_data_get(obj);
798 evas_event_freeze(evas_object_evas_get(wd->obj));
799 _item_cache_zero(wd);
800 _elm_widget_mirrored_reload(obj);
801 _mirrored_set(obj, elm_widget_mirrored_get(obj));
802 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
803 elm_widget_style_get(obj));
804 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
805 wd->item_width = wd->item_height = 0;
806 wd->group_item_width = wd->group_item_height = 0;
807 wd->minw = wd->minh = wd->realminw = 0;
808 EINA_INLIST_FOREACH(wd->blocks, itb)
811 Elm_Genlist_Item *it;
813 if (itb->realized) _item_block_unrealize(itb);
814 EINA_LIST_FOREACH(itb->items, l, it)
815 it->mincalcd = EINA_FALSE;
817 itb->changed = EINA_TRUE;
819 if (wd->calc_job) ecore_job_del(wd->calc_job);
820 wd->calc_job = ecore_job_add(_calc_job, wd);
822 evas_event_thaw(evas_object_evas_get(wd->obj));
823 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
827 _show_region_hook(void *data,
830 Widget_Data *wd = elm_widget_data_get(data);
831 Evas_Coord x, y, w, h;
833 elm_widget_show_region_get(obj, &x, &y, &w, &h);
834 //x & y are screen coordinates, Add with pan coordinates
837 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
841 _sizing_eval(Evas_Object *obj)
843 Widget_Data *wd = elm_widget_data_get(obj);
844 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
846 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
847 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
849 if (wd->height_for_width)
853 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
854 if ((vw != 0) && (vw != wd->prev_viewport_w))
858 wd->prev_viewport_w = vw;
859 EINA_INLIST_FOREACH(wd->blocks, itb)
861 itb->must_recalc = EINA_TRUE;
863 if (wd->calc_job) ecore_job_del(wd->calc_job);
864 wd->calc_job = ecore_job_add(_calc_job, wd);
867 if (wd->mode == ELM_LIST_LIMIT)
869 Evas_Coord vmw, vmh, vw, vh;
873 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
874 if ((minw > 0) && (vw < minw)) vw = minw;
875 else if ((maxw > 0) && (vw > maxw))
877 edje_object_size_min_calc
878 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
885 edje_object_size_min_calc
886 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
890 evas_object_size_hint_min_set(obj, minw, minh);
891 evas_object_size_hint_max_set(obj, maxw, maxh);
895 _signal_emit_hook(Evas_Object *obj,
896 const char *emission,
899 Widget_Data *wd = elm_widget_data_get(obj);
900 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
905 _item_highlight(Elm_Genlist_Item *it)
907 const char *selectraise;
908 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
909 (it->disabled) || (it->display_only) || (it->mode_view))
911 if (!it->wd->edit_mode)
912 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
913 selectraise = edje_object_data_get(it->base.view, "selectraise");
914 if ((selectraise) && (!strcmp(selectraise, "on")))
916 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
917 if ((it->group_item) && (it->group_item->realized))
918 evas_object_raise(it->group_item->base.view);
920 it->highlighted = EINA_TRUE;
924 _item_block_del(Elm_Genlist_Item *it)
927 Item_Block *itb = it->block;
929 itb->items = eina_list_remove(itb->items, it);
931 itb->changed = EINA_TRUE;
932 if (!it->wd->reorder_deleted)
934 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
935 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
939 il = EINA_INLIST_GET(itb);
940 Item_Block *itbn = (Item_Block *)(il->next);
942 it->parent->items = eina_list_remove(it->parent->items, it);
944 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
946 if (itbn) itbn->changed = EINA_TRUE;
950 if (itb->count < itb->wd->max_items_per_block/2)
952 il = EINA_INLIST_GET(itb);
953 Item_Block *itbp = (Item_Block *)(il->prev);
954 Item_Block *itbn = (Item_Block *)(il->next);
955 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
957 Elm_Genlist_Item *it2;
959 EINA_LIST_FREE(itb->items, it2)
962 itbp->items = eina_list_append(itbp->items, it2);
964 itbp->changed = EINA_TRUE;
966 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
967 EINA_INLIST_GET(itb));
970 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
974 Eina_List *last = eina_list_last(itb->items);
975 Elm_Genlist_Item *it2 = last->data;
978 itb->items = eina_list_remove_list(itb->items, last);
979 itbn->items = eina_list_prepend(itbn->items, it2);
981 itbn->changed = EINA_TRUE;
984 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
992 _item_subitems_clear(Elm_Genlist_Item *it)
995 Eina_List *tl = NULL, *l;
996 Elm_Genlist_Item *it2;
998 EINA_LIST_FOREACH(it->items, l, it2)
999 tl = eina_list_append(tl, it2);
1001 EINA_LIST_FREE(tl, it2)
1002 elm_genlist_item_del(it2);
1006 _item_del(Elm_Genlist_Item *it)
1008 Evas_Object *tob = it->wd->obj;
1010 evas_event_freeze(evas_object_evas_get(tob));
1011 elm_widget_item_pre_notify_del(it);
1012 elm_genlist_item_subitems_clear(it);
1013 it->wd->walking -= it->walking;
1014 if (it->wd->show_item == it) it->wd->show_item = NULL;
1015 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1016 if (it->realized) _item_unrealize(it, EINA_FALSE);
1017 if (it->effect_item_realized) _effect_item_unrealize(it);
1018 if (it->block) _item_block_del(it);
1019 if ((!it->delete_me) && (it->itc->func.del))
1020 it->itc->func.del((void *)it->base.data, it->base.widget);
1021 it->delete_me = EINA_TRUE;
1023 it->wd->queue = eina_list_remove(it->wd->queue, it);
1025 if (it->wd->anchor_item == it)
1027 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1028 if (!it->wd->anchor_item)
1029 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1032 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1034 it->parent->items = eina_list_remove(it->parent->items, it);
1035 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1036 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1037 if (it->long_timer) ecore_timer_del(it->long_timer);
1038 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1040 if (it->tooltip.del_cb)
1041 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1043 evas_event_thaw(evas_object_evas_get(tob));
1044 evas_event_thaw_eval(evas_object_evas_get(tob));
1046 elm_widget_item_del(it);
1047 it->wd->total_num--; // todo : remove
1051 _item_select(Elm_Genlist_Item *it)
1053 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
1056 if (it->wd->always_select) goto call;
1059 it->selected = EINA_TRUE;
1060 it->wd->selected = eina_list_append(it->wd->selected, it);
1064 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1066 evas_object_smart_callback_call(it->base.widget, "selected", it);
1069 if ((it->wd->clear_me) && (!it->wd->walking))
1071 elm_genlist_clear(it->base.widget);
1076 if ((!it->walking) && (it->delete_me))
1078 if (!it->relcount) _item_del(it);
1081 if (it && it->wd) it->wd->last_selected_item = it;
1085 _item_unselect(Elm_Genlist_Item *it)
1087 const char *stacking, *selectraise;
1089 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 if (it_y < oy) _effect_item_controls(it, it->scrl_x, oy);
1168 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);
1169 else _effect_item_controls(it, it->scrl_x, it_y);
1171 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1172 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1176 if (!it->display_only)
1177 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1178 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1179 x = ev->cur.canvas.x - x;
1180 y = ev->cur.canvas.y - y;
1183 if (adx < 0) adx = -dx;
1186 if (ady < 0) ady = -dy;
1189 if ((adx > minw) || (ady > minh))
1191 it->dragging = EINA_TRUE;
1194 ecore_timer_del(it->long_timer);
1195 it->long_timer = NULL;
1197 if (!it->wd->wasselected)
1202 evas_object_smart_callback_call(it->base.widget,
1203 "drag,start,up", it);
1207 evas_object_smart_callback_call(it->base.widget,
1208 "drag,start,left", it);
1210 evas_object_smart_callback_call(it->base.widget,
1211 "drag,start,right", it);
1217 evas_object_smart_callback_call(it->base.widget,
1218 "drag,start,down", it);
1222 evas_object_smart_callback_call(it->base.widget,
1223 "drag,start,left", it);
1225 evas_object_smart_callback_call(it->base.widget,
1226 "drag,start,right", it);
1233 _long_press(void *data)
1235 Elm_Genlist_Item *it = data;
1236 Elm_Genlist_Item *it_tmp;
1237 static Eina_Bool done = EINA_FALSE;
1238 //static Eina_Bool contracted = EINA_FALSE;
1242 it->long_timer = NULL;
1243 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1244 return ECORE_CALLBACK_CANCEL;
1245 it->wd->longpressed = EINA_TRUE;
1246 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1247 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1249 it->wd->reorder_it = it;
1250 it->wd->reorder_start_y = 0;
1251 evas_object_raise(it->edit_obj);
1252 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1253 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1255 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1260 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1262 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1264 _item_unselect(it_tmp);
1276 EINA_LIST_FOREACH(it->items, l, it_tmp)
1278 if (elm_genlist_item_expanded_get(it_tmp))
1280 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1281 return ECORE_CALLBACK_RENEW;
1285 if (elm_genlist_item_expanded_get(it)) {
1286 elm_genlist_item_expanded_set(it, EINA_FALSE);
1287 return ECORE_CALLBACK_RENEW;
1291 return ECORE_CALLBACK_CANCEL;
1295 _swipe(Elm_Genlist_Item *it)
1300 if ((it->display_only) || (it->disabled)) return;
1301 it->wd->swipe = EINA_FALSE;
1302 for (i = 0; i < it->wd->movements; i++)
1304 sum += it->wd->history[i].x;
1305 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1308 sum /= it->wd->movements;
1309 if (abs(sum - it->wd->history[0].x) <= 10) return;
1310 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1314 _swipe_cancel(void *data)
1316 Elm_Genlist_Item *it = data;
1318 if (!it) return ECORE_CALLBACK_CANCEL;
1319 it->wd->swipe = EINA_FALSE;
1320 it->wd->movements = 0;
1321 return ECORE_CALLBACK_RENEW;
1325 _multi_cancel(void *data)
1327 Widget_Data *wd = data;
1329 if (!wd) return ECORE_CALLBACK_CANCEL;
1330 wd->multi_timeout = EINA_TRUE;
1331 return ECORE_CALLBACK_RENEW;
1335 _multi_touch_gesture_eval(void *data)
1337 Elm_Genlist_Item *it = data;
1339 it->wd->multitouched = EINA_FALSE;
1340 if (it->wd->multi_timer)
1342 ecore_timer_del(it->wd->multi_timer);
1343 it->wd->multi_timer = NULL;
1345 if (it->wd->multi_timeout)
1347 it->wd->multi_timeout = EINA_FALSE;
1351 Evas_Coord minw = 0, minh = 0;
1352 Evas_Coord off_x, off_y, off_mx, off_my;
1354 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1355 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1356 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1357 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1358 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1360 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1362 if ((off_x + off_mx) > (off_y + off_my))
1364 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1365 evas_object_smart_callback_call(it->base.widget,
1366 "multi,swipe,right", it);
1367 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1368 evas_object_smart_callback_call(it->base.widget,
1369 "multi,swipe,left", it);
1370 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1371 evas_object_smart_callback_call(it->base.widget,
1372 "multi,pinch,out", it);
1374 evas_object_smart_callback_call(it->base.widget,
1375 "multi,pinch,in", it);
1379 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1380 evas_object_smart_callback_call(it->base.widget,
1381 "multi,swipe,down", it);
1382 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1383 evas_object_smart_callback_call(it->base.widget,
1384 "multi,swipe,up", it);
1385 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
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);
1393 it->wd->multi_timeout = EINA_FALSE;
1397 _multi_down(void *data,
1398 Evas *evas __UNUSED__,
1399 Evas_Object *obj __UNUSED__,
1402 Elm_Genlist_Item *it = data;
1403 Evas_Event_Multi_Down *ev = event_info;
1405 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1406 it->wd->multi_device = ev->device;
1407 it->wd->multi_down = EINA_TRUE;
1408 it->wd->multitouched = EINA_TRUE;
1409 it->wd->prev_mx = ev->canvas.x;
1410 it->wd->prev_my = ev->canvas.y;
1411 if (!it->wd->wasselected) _item_unselect(it);
1412 it->wd->wasselected = EINA_FALSE;
1413 it->wd->longpressed = EINA_FALSE;
1416 ecore_timer_del(it->long_timer);
1417 it->long_timer = NULL;
1421 it->dragging = EINA_FALSE;
1422 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1424 if (it->swipe_timer)
1426 ecore_timer_del(it->swipe_timer);
1427 it->swipe_timer = NULL;
1429 if (it->wd->on_hold)
1431 it->wd->swipe = EINA_FALSE;
1432 it->wd->movements = 0;
1433 it->wd->on_hold = EINA_FALSE;
1438 _multi_up(void *data,
1439 Evas *evas __UNUSED__,
1440 Evas_Object *obj __UNUSED__,
1443 Elm_Genlist_Item *it = data;
1444 Evas_Event_Multi_Up *ev = event_info;
1446 if (it->wd->multi_device != ev->device) return;
1447 it->wd->multi_device = 0;
1448 it->wd->multi_down = EINA_FALSE;
1449 if (it->wd->mouse_down) return;
1450 _multi_touch_gesture_eval(data);
1454 _multi_move(void *data,
1455 Evas *evas __UNUSED__,
1456 Evas_Object *obj __UNUSED__,
1459 Elm_Genlist_Item *it = data;
1460 Evas_Event_Multi_Move *ev = event_info;
1462 if (it->wd->multi_device != ev->device) return;
1463 it->wd->cur_mx = ev->cur.canvas.x;
1464 it->wd->cur_my = ev->cur.canvas.y;
1468 _mouse_down(void *data,
1469 Evas *evas __UNUSED__,
1473 Elm_Genlist_Item *it = data;
1474 Evas_Event_Mouse_Down *ev = event_info;
1477 if (ev->button != 1) return;
1478 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1480 it->wd->on_hold = EINA_TRUE;
1482 it->down = EINA_TRUE;
1483 it->dragging = EINA_FALSE;
1484 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1485 it->dx = ev->canvas.x - x;
1486 it->dy = ev->canvas.y - y;
1487 it->wd->mouse_down = EINA_TRUE;
1488 if (!it->wd->multitouched)
1490 it->wd->prev_x = ev->canvas.x;
1491 it->wd->prev_y = ev->canvas.y;
1492 it->wd->multi_timeout = EINA_FALSE;
1493 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1494 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1496 it->wd->longpressed = EINA_FALSE;
1497 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1498 else it->wd->on_hold = EINA_FALSE;
1499 if (it->wd->on_hold) return;
1500 it->wd->wasselected = it->selected;
1501 _item_highlight(it);
1502 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1503 if ((!it->disabled) && (!it->display_only))
1504 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1505 if (it->long_timer) ecore_timer_del(it->long_timer);
1506 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1507 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1509 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1512 it->long_timer = NULL;
1513 it->wd->swipe = EINA_FALSE;
1514 it->wd->movements = 0;
1518 _mouse_up(void *data,
1519 Evas *evas __UNUSED__,
1520 Evas_Object *obj __UNUSED__,
1523 Elm_Genlist_Item *it = data;
1524 Evas_Event_Mouse_Up *ev = event_info;
1525 Eina_Bool dragged = EINA_FALSE;
1527 if (ev->button != 1) return;
1528 it->down = EINA_FALSE;
1529 it->wd->mouse_down = EINA_FALSE;
1530 if (it->wd->multitouched)
1532 // in single selection modes, some multi touching can make multi highlighted items.
1533 // if a item not selected and highlighted, it should be unhighlighted.
1534 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1535 if (it->wd->multi_down) return;
1536 _multi_touch_gesture_eval(data);
1539 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1540 else it->wd->on_hold = EINA_FALSE;
1543 ecore_timer_del(it->long_timer);
1544 it->long_timer = NULL;
1548 it->dragging = EINA_FALSE;
1549 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1552 if (it->swipe_timer)
1554 ecore_timer_del(it->swipe_timer);
1555 it->swipe_timer = NULL;
1557 if (it->wd->multi_timer)
1559 ecore_timer_del(it->wd->multi_timer);
1560 it->wd->multi_timer = NULL;
1561 it->wd->multi_timeout = EINA_FALSE;
1563 if (it->wd->on_hold)
1565 if (it->wd->swipe) _swipe(data);
1566 it->wd->longpressed = EINA_FALSE;
1567 it->wd->on_hold = EINA_FALSE;
1570 if (it->wd->reorder_mode)
1572 Evas_Coord rox, roy, row, roh;
1573 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1576 Evas_Coord ox,oy,oh,ow;
1577 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1578 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1579 if (it->wd->reorder_rel)
1581 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1583 if (roy + oy <= it->wd->reorder_rel->scrl_y)
1584 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1586 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1589 it->wd->reorder_deleted = EINA_FALSE;
1590 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1591 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1592 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1595 if (it->wd->longpressed)
1597 it->wd->longpressed = EINA_FALSE;
1598 if (!it->wd->wasselected)
1600 it->wd->wasselected = EINA_FALSE;
1605 if (it->want_unrealize)
1607 _item_unrealize(it, EINA_FALSE);
1608 if (it->block->want_unrealize)
1609 _item_block_unrealize(it->block);
1612 if ((it->disabled) || (dragged) || (it->display_only)) return;
1613 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1618 _item_highlight(it);
1621 else _item_unselect(it);
1627 Widget_Data *wd = it->wd;
1630 while (wd->selected) _item_unselect(wd->selected->data);
1635 const Eina_List *l, *l_next;
1636 Elm_Genlist_Item *it2;
1638 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1639 if (it2 != it) _item_unselect(it2);
1640 //_item_highlight(it);
1643 _item_highlight(it);
1649 _signal_expand_toggle(void *data,
1650 Evas_Object *obj __UNUSED__,
1651 const char *emission __UNUSED__,
1652 const char *source __UNUSED__)
1654 Elm_Genlist_Item *it = data;
1657 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1659 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1663 _signal_expand(void *data,
1664 Evas_Object *obj __UNUSED__,
1665 const char *emission __UNUSED__,
1666 const char *source __UNUSED__)
1668 Elm_Genlist_Item *it = data;
1671 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1675 _signal_contract(void *data,
1676 Evas_Object *obj __UNUSED__,
1677 const char *emission __UNUSED__,
1678 const char *source __UNUSED__)
1680 Elm_Genlist_Item *it = data;
1683 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1687 _scr_hold_timer_cb(void *data)
1689 if (!data) return ECORE_CALLBACK_CANCEL;
1690 Widget_Data *wd = data;
1691 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1692 wd->scr_hold_timer = NULL;
1693 return ECORE_CALLBACK_CANCEL;
1697 _mode_finished_signal_cb(void *data,
1699 const char *emission __UNUSED__,
1700 const char *source __UNUSED__)
1704 Elm_Genlist_Item *it = data;
1705 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1707 Evas *te = evas_object_evas_get(obj);
1709 evas_event_freeze(te);
1710 it->nocache = EINA_FALSE;
1711 _mode_item_unrealize(it);
1712 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1713 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1714 evas_event_thaw(te);
1715 evas_event_thaw_eval(te);
1719 _item_cache_clean(Widget_Data *wd)
1721 evas_event_freeze(evas_object_evas_get(wd->obj));
1722 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1726 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1727 wd->item_cache = eina_inlist_remove(wd->item_cache,
1728 wd->item_cache->last);
1729 wd->item_cache_count--;
1730 if (itc->spacer) evas_object_del(itc->spacer);
1731 if (itc->base_view) evas_object_del(itc->base_view);
1732 if (itc->item_style) eina_stringshare_del(itc->item_style);
1735 evas_event_thaw(evas_object_evas_get(wd->obj));
1736 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1740 _item_cache_zero(Widget_Data *wd)
1742 int pmax = wd->item_cache_max;
1743 wd->item_cache_max = 0;
1744 _item_cache_clean(wd);
1745 wd->item_cache_max = pmax;
1749 _item_cache_add(Elm_Genlist_Item *it)
1753 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1754 if (it->wd->item_cache_max <= 0)
1756 evas_object_del(it->base.view);
1757 it->base.view = NULL;
1758 evas_object_del(it->spacer);
1760 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1761 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1765 it->wd->item_cache_count++;
1766 itc = calloc(1, sizeof(Item_Cache));
1769 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1770 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1773 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1774 EINA_INLIST_GET(itc));
1775 itc->spacer = it->spacer;
1777 itc->base_view = it->base.view;
1778 it->base.view = NULL;
1779 evas_object_hide(itc->base_view);
1780 evas_object_move(itc->base_view, -9999, -9999);
1781 itc->item_style = eina_stringshare_add(it->itc->item_style);
1782 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1783 itc->compress = (it->wd->compress);
1784 itc->odd = (it->order_num_in & 0x1);
1785 itc->selected = it->selected;
1786 itc->disabled = it->disabled;
1787 itc->expanded = it->expanded;
1790 ecore_timer_del(it->long_timer);
1791 it->long_timer = NULL;
1793 if (it->swipe_timer)
1795 ecore_timer_del(it->swipe_timer);
1796 it->swipe_timer = NULL;
1798 // FIXME: other callbacks?
1799 edje_object_signal_callback_del_full(itc->base_view,
1800 "elm,action,expand,toggle",
1801 "elm", _signal_expand_toggle, it);
1802 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1804 _signal_expand, it);
1805 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1806 "elm", _signal_contract, it);
1807 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1809 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1811 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1813 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1815 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1817 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1819 _item_cache_clean(it->wd);
1820 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1821 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1825 _item_cache_find(Elm_Genlist_Item *it)
1828 Eina_Bool tree = 0, odd;
1830 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1831 odd = (it->order_num_in & 0x1);
1832 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1834 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1836 if ((itc->tree == tree) &&
1837 (itc->odd == odd) &&
1838 (itc->compress == it->wd->compress) &&
1839 (!strcmp(it->itc->item_style, itc->item_style)))
1841 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1842 EINA_INLIST_GET(itc));
1843 it->wd->item_cache_count--;
1851 _item_cache_free(Item_Cache *itc)
1853 if (itc->spacer) evas_object_del(itc->spacer);
1854 if (itc->base_view) evas_object_del(itc->base_view);
1855 if (itc->item_style) eina_stringshare_del(itc->item_style);
1860 _item_realize(Elm_Genlist_Item *it,
1864 Elm_Genlist_Item *it2;
1865 const char *stacking;
1866 const char *treesize;
1868 int depth, tsize = 20;
1869 Item_Cache *itc = NULL;
1871 if ((it->realized) || (it->delete_me)) return;
1872 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1873 it->order_num_in = in;
1874 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1875 if ((it->nocache) && (!it->renamed))
1876 it->nocache = EINA_FALSE;
1878 itc = _item_cache_find(it);
1879 if (itc && (!it->wd->effect_mode))
1881 it->base.view = itc->base_view;
1882 itc->base_view = NULL;
1883 it->spacer = itc->spacer;
1888 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1889 edje_object_scale_set(it->base.view,
1890 elm_widget_scale_get(it->base.widget) *
1891 _elm_config->scale);
1892 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1893 elm_widget_sub_object_add(it->base.widget, it->base.view);
1895 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1896 strncpy(buf, "tree", sizeof(buf));
1897 else strncpy(buf, "item", sizeof(buf));
1898 if (it->wd->compress)
1899 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1901 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1902 strncat(buf, "/", sizeof(buf) - strlen(buf));
1903 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1905 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1906 elm_widget_style_get(it->base.widget));
1907 edje_object_mirrored_set(it->base.view,
1908 elm_widget_mirrored_get(it->base.widget));
1910 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1911 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1912 elm_widget_sub_object_add(it->base.widget, it->spacer);
1914 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1916 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1918 it->expanded_depth = depth;
1919 treesize = edje_object_data_get(it->base.view, "treesize");
1920 if (treesize) tsize = atoi(treesize);
1921 evas_object_size_hint_min_set(it->spacer,
1922 (depth * tsize) * _elm_config->scale, 1);
1923 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1926 edje_object_signal_callback_add(it->base.view,
1927 "elm,action,expand,toggle",
1928 "elm", _signal_expand_toggle, it);
1929 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1930 "elm", _signal_expand, it);
1931 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1932 "elm", _signal_contract, it);
1933 stacking = edje_object_data_get(it->base.view, "stacking");
1936 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1937 else if (!strcmp(stacking, "above"))
1938 evas_object_raise(it->base.view);
1940 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1942 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1944 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1946 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1948 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1950 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1954 if (it->selected != itc->selected)
1956 if ((it->selected) && (!it->wd->edit_mode))
1957 edje_object_signal_emit(it->base.view,
1958 "elm,state,selected", "elm");
1960 if (it->disabled != itc->disabled)
1963 edje_object_signal_emit(it->base.view,
1964 "elm,state,disabled", "elm");
1966 if (it->expanded != itc->expanded)
1969 edje_object_signal_emit(it->base.view,
1970 "elm,state,expanded", "elm");
1975 if ((it->selected) && (!it->wd->edit_mode))
1976 edje_object_signal_emit(it->base.view,
1977 "elm,state,selected", "elm");
1979 edje_object_signal_emit(it->base.view,
1980 "elm,state,disabled", "elm");
1982 edje_object_signal_emit(it->base.view,
1983 "elm,state,expanded", "elm");
1987 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1989 /* homogenous genlist shortcut */
1992 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1994 it->w = it->minw = it->wd->group_item_width;
1995 it->h = it->minh = it->wd->group_item_height;
1999 it->w = it->minw = it->wd->item_width;
2000 it->h = it->minh = it->wd->item_height;
2002 it->mincalcd = EINA_TRUE;
2007 if (it->itc->func.label_get)
2013 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2015 EINA_LIST_FOREACH(it->labels, l, key)
2017 char *s = it->itc->func.label_get
2018 ((void *)it->base.data, it->base.widget, l->data);
2022 edje_object_part_text_set(it->base.view, l->data, s);
2026 edje_object_part_text_set(it->base.view, l->data, "");
2029 if (it->itc->func.icon_get)
2035 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2037 EINA_LIST_FOREACH(it->icons, l, key)
2039 Evas_Object *ic = it->itc->func.icon_get
2040 ((void *)it->base.data, it->base.widget, l->data);
2044 it->icon_objs = eina_list_append(it->icon_objs, ic);
2045 edje_object_part_swallow(it->base.view, key, ic);
2046 evas_object_show(ic);
2047 elm_widget_sub_object_add(it->base.widget, ic);
2048 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2050 elm_widget_disabled_set(ic, EINA_TRUE);
2056 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2057 EINA_LIST_FOREACH(it->icons, l, key)
2059 Evas_Object *ic = it->itc->func.icon_get
2060 ((void *)it->base.data, it->base.widget, l->data);
2063 it->icon_objs = eina_list_append(it->icon_objs, ic);
2064 edje_object_part_swallow(it->base.view, key, ic);
2065 evas_object_show(ic);
2066 elm_widget_sub_object_add(it->base.widget, ic);
2071 if (it->itc->func.state_get)
2077 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2079 EINA_LIST_FOREACH(it->states, l, key)
2081 Eina_Bool on = it->itc->func.state_get
2082 ((void *)it->base.data, it->base.widget, l->data);
2086 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2087 edje_object_signal_emit(it->base.view, buf, "elm");
2091 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2092 edje_object_signal_emit(it->base.view, buf, "elm");
2098 Evas_Coord mw = -1, mh = -1;
2100 if (it->wd->height_for_width) mw = it->wd->w;
2102 if (!it->display_only)
2103 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2104 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2105 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2107 if (!it->display_only)
2108 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2109 it->w = it->minw = mw;
2110 it->h = it->minh = mh;
2111 it->mincalcd = EINA_TRUE;
2113 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2115 it->wd->group_item_width = mw;
2116 it->wd->group_item_height = mh;
2118 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2120 it->wd->item_width = mw;
2121 it->wd->item_height = mh;
2124 if (!calc) evas_object_show(it->base.view);
2127 if (it->tooltip.content_cb)
2129 elm_widget_item_tooltip_content_cb_set(it,
2130 it->tooltip.content_cb,
2131 it->tooltip.data, NULL);
2132 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2135 if (it->mouse_cursor)
2136 elm_widget_item_cursor_set(it, it->mouse_cursor);
2138 it->realized = EINA_TRUE;
2139 it->want_unrealize = EINA_FALSE;
2141 if (itc) _item_cache_free(itc);
2142 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2143 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2145 evas_object_smart_callback_call(it->base.widget, "realized", it);
2146 if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
2148 if (it->itc->edit_item_style )
2150 _effect_item_realize(it, EINA_FALSE);
2151 edje_object_message_signal_process(it->edit_obj);
2154 edje_object_message_signal_process(it->base.view);
2158 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2162 if (!it->realized) return;
2163 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2164 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2165 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2168 ecore_timer_del(it->long_timer);
2169 it->long_timer = NULL;
2173 evas_object_del(it->base.view);
2174 it->base.view = NULL;
2175 evas_object_del(it->spacer);
2180 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2181 _item_cache_add(it);
2183 elm_widget_stringlist_free(it->labels);
2185 elm_widget_stringlist_free(it->icons);
2187 elm_widget_stringlist_free(it->states);
2189 EINA_LIST_FREE(it->icon_objs, icon)
2190 evas_object_del(icon);
2192 _mode_item_unrealize(it);
2194 it->realized = EINA_FALSE;
2195 it->want_unrealize = EINA_FALSE;
2196 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2197 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2198 if (it->wd->edit_mode) _effect_item_unrealize(it);
2202 _item_block_recalc(Item_Block *itb,
2208 Elm_Genlist_Item *it;
2209 Evas_Coord minw = 0, minh = 0;
2210 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2213 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2215 EINA_LIST_FOREACH(itb->items, l, it)
2217 if (it->delete_me) continue;
2218 showme |= it->showme;
2223 if (!it->mincalcd) changed = EINA_TRUE;
2226 _item_realize(it, in, EINA_TRUE);
2227 _item_unrealize(it, EINA_TRUE);
2232 _item_realize(it, in, EINA_TRUE);
2233 _item_unrealize(it, EINA_TRUE);
2237 _item_realize(it, in, EINA_FALSE);
2239 if (minw < it->minw) minw = it->minw;
2247 itb->changed = EINA_FALSE;
2248 /* force an evas norender to garbage collect deleted objects */
2249 //if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2250 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2251 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2256 _item_block_realize(Item_Block *itb,
2261 Elm_Genlist_Item *it;
2263 if (itb->realized) return;
2264 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2265 EINA_LIST_FOREACH(itb->items, l, it)
2267 if (it->delete_me) continue;
2268 if (full) _item_realize(it, in, EINA_FALSE);
2271 itb->realized = EINA_TRUE;
2272 itb->want_unrealize = EINA_FALSE;
2273 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2274 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2278 _item_block_unrealize(Item_Block *itb)
2281 Elm_Genlist_Item *it;
2282 Eina_Bool dragging = EINA_FALSE;
2284 if (!itb->realized) return;
2285 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2286 EINA_LIST_FOREACH(itb->items, l, it)
2288 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2292 dragging = EINA_TRUE;
2293 it->want_unrealize = EINA_TRUE;
2296 _item_unrealize(it, EINA_FALSE);
2301 itb->realized = EINA_FALSE;
2302 itb->want_unrealize = EINA_TRUE;
2305 itb->want_unrealize = EINA_FALSE;
2306 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2307 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2311 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2313 Evas_Coord rox, roy, row, roh;
2314 Eina_Bool top = EINA_FALSE;
2315 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2316 if (!reorder_it) return 0;
2318 Evas_Coord ox,oy,oh,ow;
2319 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2320 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2322 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2324 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2325 if (it->block->count == 1)
2326 it->wd->reorder_rel = it;
2328 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2330 it->block->reorder_offset = it->wd->reorder_it->h;
2333 it->block->reorder_offset = 0;
2335 it->scrl_y += it->block->reorder_offset;
2337 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2338 rox, roy+roh/2, row, 1));
2341 it->wd->reorder_rel = it;
2342 it->scrl_y+=it->wd->reorder_it->h;
2343 return it->wd->reorder_it->h;
2350 _reorder_item_moving_effect_timer_cb(void *data)
2352 Elm_Genlist_Item *it = data;
2353 Eina_Bool down = EINA_FALSE;
2354 double time = 0.4, t;
2356 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2359 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2363 if (it->old_scrl_y < it->scrl_y)
2365 it->old_scrl_y += y;
2368 else if (it->old_scrl_y > it->scrl_y)
2370 it->old_scrl_y -= y;
2374 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2376 _group_items_recalc(it->wd);
2377 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2379 it->old_scrl_y = it->scrl_y;
2380 it->move_effect_me = EINA_FALSE;
2381 it->wd->item_moving_effect_timer = NULL;
2382 return ECORE_CALLBACK_CANCEL;
2384 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2386 it->old_scrl_y = it->scrl_y;
2387 it->move_effect_me = EINA_FALSE;
2388 it->wd->item_moving_effect_timer = NULL;
2389 return ECORE_CALLBACK_CANCEL;
2391 return ECORE_CALLBACK_RENEW;
2395 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2400 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2401 evas_object_resize(view, it->w, it->h);
2402 evas_object_move(view, it->scrl_x, it->scrl_y);
2403 evas_object_show(view);
2404 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2405 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2409 _item_block_position(Item_Block *itb,
2413 Elm_Genlist_Item *it;
2414 Elm_Genlist_Item *git;
2415 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2418 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2419 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2420 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2422 EINA_LIST_FOREACH(itb->items, l, it)
2424 if (it->delete_me) continue;
2425 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2430 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2431 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2433 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2434 cvx, cvy, cvw, cvh));
2435 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2437 if ((itb->realized))
2441 if (!it->realized) _item_realize(it, in, EINA_FALSE);
2444 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2445 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2453 if(it->wd->reorder_mode)
2454 y += _get_space_for_reorder_item(it);
2455 git = it->group_item;
2458 git->scrl_x = it->scrl_x;
2459 if (git->scrl_y < oy)
2461 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2462 git->scrl_y = (it->scrl_y + it->h) - git->h;
2463 git->want_realize = EINA_TRUE;
2465 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2467 if (!it->move_effect_me)
2469 it->move_effect_me = EINA_TRUE;
2470 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2474 if (!it->move_effect_me )
2475 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))
2477 if (it->wd->edit_mode && it->itc->edit_item_style)
2479 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2483 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)))
2486 _item_position(it, it->mode_view);
2488 _item_position(it, it->base.view);
2492 evas_object_resize(it->base.view, it->w, it->h);
2493 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2494 evas_object_hide(it->base.view);
2501 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2508 if (vis) it->want_realize = EINA_TRUE;
2510 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))
2512 it->old_scrl_y = it->scrl_y;
2516 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2517 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2521 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2523 Elm_Genlist_Item *it = data;
2525 it->mincalcd = EINA_FALSE;
2526 it->block->updateme = EINA_TRUE;
2527 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2528 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2532 _group_items_recalc(void *data)
2534 Widget_Data *wd = data;
2536 Elm_Genlist_Item *git;
2538 evas_event_freeze(evas_object_evas_get(wd->obj));
2539 EINA_LIST_FOREACH(wd->group_items, l, git)
2541 if (git->want_realize)
2544 _item_realize(git, 0, EINA_FALSE);
2545 evas_object_resize(git->base.view, wd->minw, git->h);
2546 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2547 evas_object_show(git->base.view);
2548 evas_object_raise(git->base.view);
2550 else if (!git->want_realize && git->realized)
2553 _item_unrealize(git, EINA_FALSE);
2556 evas_event_thaw(evas_object_evas_get(wd->obj));
2557 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2561 _must_recalc_idler(void *data)
2563 Widget_Data *wd = data;
2564 if (wd->calc_job) ecore_job_del(wd->calc_job);
2565 wd->calc_job = ecore_job_add(_calc_job, wd);
2566 wd->must_recalc_idler = NULL;
2567 return ECORE_CALLBACK_CANCEL;
2571 _calc_job(void *data)
2573 Widget_Data *wd = data;
2575 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2576 Item_Block *chb = NULL;
2577 int in = 0, minw_change = 0;
2578 Eina_Bool changed = EINA_FALSE;
2580 Eina_Bool did_must_recalc = EINA_FALSE;
2583 t0 = ecore_time_get();
2584 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2588 // if (wd->height_for_width) changed = EINA_TRUE;
2591 evas_event_freeze(evas_object_evas_get(wd->obj));
2592 EINA_INLIST_FOREACH(wd->blocks, itb)
2594 Eina_Bool showme = EINA_FALSE;
2597 showme = itb->showme;
2598 itb->showme = EINA_FALSE;
2601 if (itb->realized) _item_block_unrealize(itb);
2603 if ((itb->changed) || (changed) ||
2604 ((itb->must_recalc) && (!did_must_recalc)))
2606 if ((changed) || (itb->must_recalc))
2609 Elm_Genlist_Item *it;
2610 EINA_LIST_FOREACH(itb->items, l, it)
2611 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2612 itb->changed = EINA_TRUE;
2613 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2614 itb->must_recalc = EINA_FALSE;
2616 if (itb->realized) _item_block_unrealize(itb);
2617 showme = _item_block_recalc(itb, in, 0, 1);
2623 if (minw == -1) minw = itb->minw;
2624 else if ((!itb->must_recalc) && (minw < itb->minw))
2633 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2635 wd->show_item->showme = EINA_FALSE;
2637 elm_smart_scroller_region_bring_in(wd->scr,
2639 wd->show_item->block->x,
2641 wd->show_item->block->y,
2642 wd->show_item->block->w,
2645 elm_smart_scroller_child_region_show(wd->scr,
2647 wd->show_item->block->x,
2649 wd->show_item->block->y,
2650 wd->show_item->block->w,
2652 wd->show_item = NULL;
2657 EINA_INLIST_FOREACH(wd->blocks, itb)
2663 if ((chb) && (EINA_INLIST_GET(chb)->next))
2665 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2667 if (itb->realized) _item_block_unrealize(itb);
2670 wd->realminw = minw;
2671 if (minw < wd->w) minw = wd->w;
2672 if ((minw != wd->minw) || (minh != wd->minh))
2676 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2677 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2678 _sizing_eval(wd->obj);
2680 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2682 Elm_Genlist_Item *it;
2685 it = wd->anchor_item;
2686 it_y = wd->anchor_y;
2687 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2688 it->block->y + it->y + it_y);
2689 wd->anchor_item = it;
2690 wd->anchor_y = it_y;
2694 t = ecore_time_get();
2695 if (did_must_recalc)
2697 if (!wd->must_recalc_idler)
2698 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2700 wd->calc_job = NULL;
2701 evas_object_smart_changed(wd->pan_smart);
2702 evas_event_thaw(evas_object_evas_get(wd->obj));
2703 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2707 _update_job(void *data)
2709 Widget_Data *wd = data;
2712 int num, num0, position = 0, recalc = 0;
2714 wd->update_job = NULL;
2717 evas_event_freeze(evas_object_evas_get(wd->obj));
2718 EINA_INLIST_FOREACH(wd->blocks, itb)
2720 Evas_Coord itminw, itminh;
2721 Elm_Genlist_Item *it;
2727 _item_block_position(itb, num);
2732 EINA_LIST_FOREACH(itb->items, l2, it)
2739 it->updateme = EINA_FALSE;
2742 _item_unrealize(it, EINA_FALSE);
2743 _item_realize(it, num, EINA_FALSE);
2748 _item_realize(it, num, EINA_TRUE);
2749 _item_unrealize(it, EINA_TRUE);
2751 if ((it->minw != itminw) || (it->minh != itminh))
2756 itb->updateme = EINA_FALSE;
2760 itb->changed = EINA_TRUE;
2761 _item_block_recalc(itb, num0, 0, 1);
2762 _item_block_position(itb, num0);
2767 if (wd->calc_job) ecore_job_del(wd->calc_job);
2768 wd->calc_job = ecore_job_add(_calc_job, wd);
2770 evas_event_thaw(evas_object_evas_get(wd->obj));
2771 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2775 _changed_job(void *data)
2777 Widget_Data *wd = data; Eina_List *l2;
2779 int num, num0, position = 0;
2780 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2782 wd->changed_job = NULL;
2784 EINA_INLIST_FOREACH(wd->blocks, itb)
2786 Evas_Coord itminw, itminh;
2787 Elm_Genlist_Item *it;
2793 _item_block_position(itb, num);
2797 width_changed = height_changed = EINA_FALSE;
2798 EINA_LIST_FOREACH(itb->items, l2, it)
2800 if ((!it->mincalcd) && (it->realized))
2802 Evas_Coord mw = -1, mh = -1;
2806 if (it->wd->height_for_width) mw = it->wd->w;
2807 if (!it->display_only)
2808 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2809 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2810 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2811 if (!it->display_only)
2812 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2813 it->w = it->minw = mw;
2814 it->h = it->minh = mh;
2815 it->mincalcd = EINA_TRUE;
2817 //if ((it->minw != itminw) || (it->minh != itminh))
2818 //if ((it->minh != itminh))
2820 if ((it->minw != itminw))
2821 width_changed = EINA_TRUE;
2822 if ((it->minh != itminh))
2823 height_changed = EINA_TRUE;
2825 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2827 it->wd->group_item_width = mw;
2828 it->wd->group_item_height = mh;
2830 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2832 it->wd->item_width = mw;
2833 it->wd->item_height = mh;
2838 itb->updateme = EINA_FALSE;
2839 // TODO: why this is separated.
2843 itb->changed = EINA_TRUE;
2844 _item_block_recalc(itb, num0, 0, 1);
2845 _item_block_position(itb, num0);
2847 else if (width_changed)
2849 _item_block_position(itb, num0);
2854 if (wd->calc_job) ecore_job_del(wd->calc_job);
2855 wd->calc_job = ecore_job_add(_calc_job, wd);
2860 _pan_set(Evas_Object *obj,
2864 Pan *sd = evas_object_smart_data_get(obj);
2869 // Evas_Coord ow, oh;
2870 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2871 // ow = sd->wd->minw - ow;
2872 // if (ow < 0) ow = 0;
2873 // oh = sd->wd->minh - oh;
2874 // if (oh < 0) oh = 0;
2875 // if (x < 0) x = 0;
2876 // if (y < 0) y = 0;
2877 // if (x > ow) x = ow;
2878 // if (y > oh) y = oh;
2879 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2884 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2886 if ((itb->y + itb->h) > y)
2888 Elm_Genlist_Item *it;
2891 EINA_LIST_FOREACH(itb->items, l2, it)
2893 if ((itb->y + it->y) >= y)
2895 sd->wd->anchor_item = it;
2896 sd->wd->anchor_y = -(itb->y + it->y - y);
2904 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2908 _pan_get(Evas_Object *obj,
2912 Pan *sd = evas_object_smart_data_get(obj);
2914 if (x) *x = sd->wd->pan_x;
2915 if (y) *y = sd->wd->pan_y;
2919 _pan_max_get(Evas_Object *obj,
2923 Pan *sd = evas_object_smart_data_get(obj);
2926 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2927 ow = sd->wd->minw - ow;
2929 oh = sd->wd->minh - oh;
2936 _pan_min_get(Evas_Object *obj __UNUSED__,
2945 _pan_child_size_get(Evas_Object *obj,
2949 Pan *sd = evas_object_smart_data_get(obj);
2951 if (w) *w = sd->wd->minw;
2952 if (h) *h = sd->wd->minh;
2956 _pan_add(Evas_Object *obj)
2959 Evas_Object_Smart_Clipped_Data *cd;
2962 cd = evas_object_smart_data_get(obj);
2965 sd->__clipped_data = *cd;
2967 evas_object_smart_data_set(obj, sd);
2971 _pan_del(Evas_Object *obj)
2973 Pan *sd = evas_object_smart_data_get(obj);
2978 ecore_job_del(sd->resize_job);
2979 sd->resize_job = NULL;
2985 _pan_resize_job(void *data)
2988 _sizing_eval(sd->wd->obj);
2989 sd->resize_job = NULL;
2993 _pan_resize(Evas_Object *obj,
2997 Pan *sd = evas_object_smart_data_get(obj);
3000 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
3001 if ((ow == w) && (oh == h)) return;
3002 if ((sd->wd->height_for_width) && (ow != w))
3004 if (sd->resize_job) ecore_job_del(sd->resize_job);
3005 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
3007 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3008 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3012 _pan_calculate(Evas_Object *obj)
3014 Pan *sd = evas_object_smart_data_get(obj);
3016 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
3017 static Evas_Coord old_pan_y = 0;
3019 Elm_Genlist_Item *git;
3022 evas_event_freeze(evas_object_evas_get(obj));
3023 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3024 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3025 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3027 git->want_realize = EINA_FALSE;
3029 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3031 itb->w = sd->wd->minw;
3032 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3033 itb->y - sd->wd->pan_y + oy,
3035 cvx, cvy, cvw, cvh))
3037 if ((!itb->realized) || (itb->changed))
3038 _item_block_realize(itb, in, 0);
3039 _item_block_position(itb, in);
3043 if (itb->realized) _item_block_unrealize(itb);
3047 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
3048 _group_items_recalc(sd->wd);
3050 if (sd->wd->reorder_mode && sd->wd->reorder_it)
3052 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
3053 else sd->wd->reorder_pan_move = EINA_FALSE;
3054 evas_object_raise(sd->wd->reorder_it->edit_obj);
3055 old_pan_y = sd->wd->pan_y;
3058 if (sd->wd->effect_mode &&
3059 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3060 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3061 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3063 if (!sd->wd->item_moving_effect_timer)
3065 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3066 _item_flip_effect_show(sd->wd->expand_item);
3068 evas_object_raise(sd->wd->alpha_bg);
3069 evas_object_show(sd->wd->alpha_bg);
3070 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3071 sd->wd->start_time = current_time_get();
3072 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3075 else _item_auto_scroll(sd->wd);
3076 evas_event_thaw(evas_object_evas_get(obj));
3077 evas_event_thaw_eval(evas_object_evas_get(obj));
3081 _pan_move(Evas_Object *obj,
3082 Evas_Coord x __UNUSED__,
3083 Evas_Coord y __UNUSED__)
3085 Pan *sd = evas_object_smart_data_get(obj);
3087 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3088 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3092 _hold_on(void *data __UNUSED__,
3094 void *event_info __UNUSED__)
3096 Widget_Data *wd = elm_widget_data_get(obj);
3098 elm_smart_scroller_hold_set(wd->scr, 1);
3102 _hold_off(void *data __UNUSED__,
3104 void *event_info __UNUSED__)
3106 Widget_Data *wd = elm_widget_data_get(obj);
3108 elm_smart_scroller_hold_set(wd->scr, 0);
3112 _freeze_on(void *data __UNUSED__,
3114 void *event_info __UNUSED__)
3116 Widget_Data *wd = elm_widget_data_get(obj);
3118 elm_smart_scroller_freeze_set(wd->scr, 1);
3122 _freeze_off(void *data __UNUSED__,
3124 void *event_info __UNUSED__)
3126 Widget_Data *wd = elm_widget_data_get(obj);
3128 elm_smart_scroller_freeze_set(wd->scr, 0);
3132 _scroll_edge_left(void *data,
3133 Evas_Object *scr __UNUSED__,
3134 void *event_info __UNUSED__)
3136 Evas_Object *obj = data;
3137 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3141 _scroll_edge_right(void *data,
3142 Evas_Object *scr __UNUSED__,
3143 void *event_info __UNUSED__)
3145 Evas_Object *obj = data;
3146 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3150 _scroll_edge_top(void *data,
3151 Evas_Object *scr __UNUSED__,
3152 void *event_info __UNUSED__)
3154 Evas_Object *obj = data;
3155 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3159 _scroll_edge_bottom(void *data,
3160 Evas_Object *scr __UNUSED__,
3161 void *event_info __UNUSED__)
3163 Evas_Object *obj = data;
3164 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3168 _mode_item_realize(Elm_Genlist_Item *it)
3172 if ((it->mode_view) || (it->delete_me)) return;
3174 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3175 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3176 edje_object_scale_set(it->mode_view,
3177 elm_widget_scale_get(it->base.widget) *
3178 _elm_config->scale);
3179 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3180 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3182 strncpy(buf, "item", sizeof(buf));
3183 if (it->wd->compress)
3184 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3186 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3187 strncat(buf, "/", sizeof(buf) - strlen(buf));
3188 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3190 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3191 elm_widget_style_get(it->base.widget));
3192 //edje_object_mirrored_set(it->mode_view,
3193 // elm_widget_mirrored_get(it->base.widget));
3195 /* signal callback add */
3196 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3198 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3200 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3203 /* label_get, icon_get, state_get */
3204 if (it->itc->func.label_get)
3210 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3212 EINA_LIST_FOREACH(it->mode_labels, l, key)
3214 char *s = it->itc->func.label_get
3215 ((void *)it->base.data, it->base.widget, l->data);
3219 edje_object_part_text_set(it->mode_view, l->data, s);
3224 if (it->itc->func.icon_get)
3230 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3232 EINA_LIST_FOREACH(it->mode_icons, l, key)
3234 Evas_Object *ic = it->itc->func.icon_get
3235 ((void *)it->base.data, it->base.widget, l->data);
3239 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3240 edje_object_part_swallow(it->mode_view, key, ic);
3241 evas_object_show(ic);
3242 elm_widget_sub_object_add(it->base.widget, ic);
3244 elm_widget_disabled_set(ic, EINA_TRUE);
3248 if (it->itc->func.state_get)
3254 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3256 EINA_LIST_FOREACH(it->mode_states, l, key)
3258 Eina_Bool on = it->itc->func.state_get
3259 ((void *)it->base.data, it->base.widget, l->data);
3263 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3264 edje_object_signal_emit(it->mode_view, buf, "elm");
3269 edje_object_part_swallow(it->mode_view,
3270 edje_object_data_get(it->mode_view, "mode_part"),
3273 it->want_unrealize = EINA_FALSE;
3274 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3275 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3279 _mode_item_unrealize(Elm_Genlist_Item *it)
3281 Widget_Data *wd = it->wd;
3283 if (!it->mode_view) return;
3285 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3286 elm_widget_stringlist_free(it->mode_labels);
3287 it->mode_labels = NULL;
3288 elm_widget_stringlist_free(it->mode_icons);
3289 it->mode_icons = NULL;
3290 elm_widget_stringlist_free(it->mode_states);
3292 EINA_LIST_FREE(it->mode_icon_objs, icon)
3293 evas_object_del(icon);
3295 edje_object_part_unswallow(it->mode_view, it->base.view);
3296 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3297 evas_object_del(it->mode_view);
3298 it->mode_view = NULL;
3300 if (wd->mode_item == it)
3301 wd->mode_item = NULL;
3302 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3303 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3307 _item_mode_set(Elm_Genlist_Item *it)
3310 Widget_Data *wd = it->wd;
3315 it->nocache = EINA_TRUE;
3317 if (wd->scr_hold_timer)
3319 ecore_timer_del(wd->scr_hold_timer);
3320 wd->scr_hold_timer = NULL;
3322 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3323 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3325 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3326 _mode_item_realize(it);
3327 _item_position(it, it->mode_view);
3328 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3329 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3331 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3332 edje_object_signal_emit(it->mode_view, buf, "elm");
3336 _item_mode_unset(Widget_Data *wd)
3339 if (!wd->mode_item) return;
3340 char buf[1024], buf2[1024];
3341 Elm_Genlist_Item *it;
3344 it->nocache = EINA_TRUE;
3346 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3347 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3349 edje_object_signal_emit(it->mode_view, buf, "elm");
3350 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3352 wd->mode_item = NULL;
3356 * Add a new Genlist object
3358 * @param parent The parent object
3359 * @return The new object or NULL if it cannot be created
3364 elm_genlist_add(Evas_Object *parent)
3369 Evas_Coord minw, minh;
3370 static Evas_Smart *smart = NULL;
3374 static Evas_Smart_Class sc;
3376 evas_object_smart_clipped_smart_set(&_pan_sc);
3378 sc.name = "elm_genlist_pan";
3379 sc.version = EVAS_SMART_CLASS_VERSION;
3382 sc.resize = _pan_resize;
3383 sc.move = _pan_move;
3384 sc.calculate = _pan_calculate;
3385 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3388 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3390 ELM_SET_WIDTYPE(widtype, "genlist");
3391 elm_widget_type_set(obj, "genlist");
3392 elm_widget_sub_object_add(parent, obj);
3393 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3394 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3395 elm_widget_data_set(obj, wd);
3396 elm_widget_del_hook_set(obj, _del_hook);
3397 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3398 elm_widget_theme_hook_set(obj, _theme_hook);
3399 elm_widget_can_focus_set(obj, EINA_TRUE);
3400 elm_widget_event_hook_set(obj, _event_hook);
3401 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3403 wd->scr = elm_smart_scroller_add(e);
3404 elm_smart_scroller_widget_set(wd->scr, obj);
3405 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3406 elm_widget_style_get(obj));
3407 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3408 _elm_config->thumbscroll_bounce_enable);
3409 elm_widget_resize_object_set(obj, wd->scr);
3411 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3412 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3414 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3415 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3419 wd->mode = ELM_LIST_SCROLL;
3420 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3421 wd->item_cache_max = wd->max_items_per_block * 2;
3422 wd->longpress_timeout = _elm_config->longpress_timeout;
3423 wd->effect_mode = _elm_config->effect_enable;
3425 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3426 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3427 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3428 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3430 wd->pan_smart = evas_object_smart_add(e, smart);
3431 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3434 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3435 _pan_set, _pan_get, _pan_max_get,
3436 _pan_min_get, _pan_child_size_get);
3438 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3440 evas_object_size_hint_min_set(obj, minw, minh);
3442 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3447 static Elm_Genlist_Item *
3448 _item_new(Widget_Data *wd,
3449 const Elm_Genlist_Item_Class *itc,
3451 Elm_Genlist_Item *parent,
3452 Elm_Genlist_Item_Flags flags,
3454 const void *func_data)
3456 Elm_Genlist_Item *it;
3458 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3459 if (!it) return NULL;
3462 it->base.data = data;
3463 it->parent = parent;
3465 it->func.func = func;
3466 it->func.data = func_data;
3467 it->mouse_cursor = NULL;
3468 it->expanded_depth = 0;
3469 it->num = ++wd->total_num; // todo : remove
3474 _item_block_add(Widget_Data *wd,
3475 Elm_Genlist_Item *it)
3477 Item_Block *itb = NULL;
3484 itb = calloc(1, sizeof(Item_Block));
3487 if (!it->rel->block)
3490 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3491 itb->items = eina_list_append(itb->items, it);
3497 wd->blocks = eina_inlist_prepend_relative
3498 (wd->blocks, EINA_INLIST_GET(itb),
3499 EINA_INLIST_GET(it->rel->block));
3501 eina_list_prepend_relative(itb->items, it, it->rel);
3505 wd->blocks = eina_inlist_append_relative
3506 (wd->blocks, EINA_INLIST_GET(itb),
3507 EINA_INLIST_GET(it->rel->block));
3509 eina_list_append_relative(itb->items, it, it->rel);
3519 itb = (Item_Block *)(wd->blocks);
3520 if (itb->count >= wd->max_items_per_block)
3522 itb = calloc(1, sizeof(Item_Block));
3526 eina_inlist_prepend(wd->blocks,
3527 EINA_INLIST_GET(itb));
3532 itb = calloc(1, sizeof(Item_Block));
3536 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3538 itb->items = eina_list_prepend(itb->items, it);
3544 itb = (Item_Block *)(wd->blocks->last);
3545 if (itb->count >= wd->max_items_per_block)
3547 itb = calloc(1, sizeof(Item_Block));
3551 eina_inlist_append(wd->blocks,
3552 EINA_INLIST_GET(itb));
3557 itb = calloc(1, sizeof(Item_Block));
3561 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3563 itb->items = eina_list_append(itb->items, it);
3569 itb = it->rel->block;
3570 if (!itb) goto newblock;
3572 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3574 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3577 itb->changed = EINA_TRUE;
3579 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3580 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3583 it->rel->relcount--;
3584 if ((it->rel->delete_me) && (!it->rel->relcount))
3588 if (itb->count > itb->wd->max_items_per_block)
3592 Elm_Genlist_Item *it2;
3594 newc = itb->count / 2;
3595 itb2 = calloc(1, sizeof(Item_Block));
3599 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3600 EINA_INLIST_GET(itb));
3601 itb2->changed = EINA_TRUE;
3602 while ((itb->count > newc) && (itb->items))
3606 l = eina_list_last(itb->items);
3608 itb->items = eina_list_remove_list(itb->items, l);
3611 itb2->items = eina_list_prepend(itb2->items, it2);
3619 _queue_process(Widget_Data *wd,
3623 Eina_Bool showme = EINA_FALSE;
3626 t0 = ecore_time_get();
3627 evas_event_freeze(evas_object_evas_get(wd->obj));
3628 for (n = 0; (wd->queue) && (n < 128); n++)
3630 Elm_Genlist_Item *it;
3632 it = wd->queue->data;
3633 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3634 it->queued = EINA_FALSE;
3635 _item_block_add(wd, it);
3636 t = ecore_time_get();
3637 if (it->block->changed)
3639 showme = _item_block_recalc(it->block, it->block->num, 1,
3641 it->block->changed = 0;
3643 if (showme) it->block->showme = EINA_TRUE;
3644 if (eina_inlist_count(wd->blocks) > 1)
3646 if ((t - t0) > (ecore_animator_frametime_get())) break;
3649 evas_event_thaw(evas_object_evas_get(wd->obj));
3650 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3655 _idle_process(void *data, Eina_Bool *wakeup)
3657 Widget_Data *wd = data;
3660 //static double q_start = 0.0;
3661 //if (q_start == 0.0) q_start = ecore_time_get();
3663 if (_queue_process(wd, 1) > 0) *wakeup = EINA_TRUE;
3667 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3669 return ECORE_CALLBACK_CANCEL;
3671 return ECORE_CALLBACK_RENEW;
3675 _item_idle_enterer(void *data)
3677 Widget_Data *wd = data;
3678 Eina_Bool wakeup = EINA_FALSE;
3679 Eina_Bool ok = _idle_process(data, &wakeup);
3684 if (wd->calc_job) ecore_job_del(wd->calc_job);
3685 wd->calc_job = ecore_job_add(_calc_job, wd);
3687 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3692 _item_queue(Widget_Data *wd,
3693 Elm_Genlist_Item *it)
3695 if (it->queued) return;
3696 it->queued = EINA_TRUE;
3697 wd->queue = eina_list_append(wd->queue, it);
3698 // FIXME: why does a freeze then thaw here cause some genlist
3699 // elm_genlist_item_append() to be much much slower?
3700 // evas_event_freeze(evas_object_evas_get(wd->obj));
3701 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3703 if (wd->queue_idle_enterer)
3705 ecore_idle_enterer_del(wd->queue_idle_enterer);
3706 wd->queue_idle_enterer = NULL;
3708 _queue_process(wd, 0);
3710 // evas_event_thaw(evas_object_evas_get(wd->obj));
3711 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3712 if (!wd->queue_idle_enterer)
3713 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3717 * Append item to the end of the genlist
3719 * This appends the given item to the end of the list or the end of
3720 * the children if the parent is given.
3722 * @param obj The genlist object
3723 * @param itc The item class for the item
3724 * @param data The item data
3725 * @param parent The parent item, or NULL if none
3726 * @param flags Item flags
3727 * @param func Convenience function called when item selected
3728 * @param func_data Data passed to @p func above.
3729 * @return A handle to the item added or NULL if not possible
3733 EAPI Elm_Genlist_Item *
3734 elm_genlist_item_append(Evas_Object *obj,
3735 const Elm_Genlist_Item_Class *itc,
3737 Elm_Genlist_Item *parent,
3738 Elm_Genlist_Item_Flags flags,
3740 const void *func_data)
3742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3743 Widget_Data *wd = elm_widget_data_get(obj);
3744 if (!wd) return NULL;
3745 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3747 if (!it) return NULL;
3750 if (flags & ELM_GENLIST_ITEM_GROUP)
3751 wd->group_items = eina_list_append(wd->group_items, it);
3752 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3757 Elm_Genlist_Item *it2 = NULL;
3758 Eina_List *ll = eina_list_last(it->parent->items);
3759 if (ll) it2 = ll->data;
3760 it->parent->items = eina_list_append(it->parent->items, it);
3761 if (!it2) it2 = it->parent;
3763 it2 = elm_genlist_item_prev_get(it2);
3765 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3766 EINA_INLIST_GET(it2));
3768 it->rel->relcount++;
3770 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3771 it->group_item = parent;
3772 else if (it->parent->group_item)
3773 it->group_item = it->parent->group_item;
3775 it->before = EINA_FALSE;
3776 _item_queue(wd, it);
3781 * Prepend item at start of the genlist
3783 * This adds an item to the beginning of the list or beginning of the
3784 * children of the parent if given.
3786 * @param obj The genlist object
3787 * @param itc The item class for the item
3788 * @param data The item data
3789 * @param parent The parent item, or NULL if none
3790 * @param flags Item flags
3791 * @param func Convenience function called when item selected
3792 * @param func_data Data passed to @p func above.
3793 * @return A handle to the item added or NULL if not possible
3797 EAPI Elm_Genlist_Item *
3798 elm_genlist_item_prepend(Evas_Object *obj,
3799 const Elm_Genlist_Item_Class *itc,
3801 Elm_Genlist_Item *parent,
3802 Elm_Genlist_Item_Flags flags,
3804 const void *func_data)
3806 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3807 Widget_Data *wd = elm_widget_data_get(obj);
3808 if (!wd) return NULL;
3809 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3811 if (!it) return NULL;
3814 if (flags & ELM_GENLIST_ITEM_GROUP)
3815 wd->group_items = eina_list_prepend(wd->group_items, it);
3816 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3821 Elm_Genlist_Item *it2 = NULL;
3822 Eina_List *ll = it->parent->items;
3823 if (ll) it2 = ll->data;
3824 it->parent->items = eina_list_prepend(it->parent->items, it);
3825 if (!it2) it2 = it->parent;
3827 it2 = elm_genlist_item_next_get(it2);
3829 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3830 EINA_INLIST_GET(it2));
3832 it->rel->relcount++;
3834 it->before = EINA_TRUE;
3835 _item_queue(wd, it);
3840 * Insert item before another in the genlist
3842 * This inserts an item before another in the list. It will be in the
3843 * same tree level or group as the item it is inseted before.
3845 * @param obj The genlist object
3846 * @param itc The item class for the item
3847 * @param data The item data
3848 * @param before The item to insert before
3849 * @param flags Item flags
3850 * @param func Convenience function called when item selected
3851 * @param func_data Data passed to @p func above.
3852 * @return A handle to the item added or NULL if not possible
3856 EAPI Elm_Genlist_Item *
3857 elm_genlist_item_insert_before(Evas_Object *obj,
3858 const Elm_Genlist_Item_Class *itc,
3860 Elm_Genlist_Item *parent,
3861 Elm_Genlist_Item *before,
3862 Elm_Genlist_Item_Flags flags,
3864 const void *func_data)
3866 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3867 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3868 Widget_Data *wd = elm_widget_data_get(obj);
3869 if (!wd) return NULL;
3870 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3872 if (!it) return NULL;
3875 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3878 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3879 EINA_INLIST_GET(before));
3881 it->rel->relcount++;
3882 it->before = EINA_TRUE;
3883 _item_queue(wd, it);
3888 * Insert an item after another in the genlst
3890 * This inserts an item after another in the list. It will be in the
3891 * same tree level or group as the item it is inseted after.
3893 * @param obj The genlist object
3894 * @param itc The item class for the item
3895 * @param data The item data
3896 * @param after The item to insert after
3897 * @param flags Item flags
3898 * @param func Convenience function called when item selected
3899 * @param func_data Data passed to @p func above.
3900 * @return A handle to the item added or NULL if not possible
3904 EAPI Elm_Genlist_Item *
3905 elm_genlist_item_insert_after(Evas_Object *obj,
3906 const Elm_Genlist_Item_Class *itc,
3908 Elm_Genlist_Item *parent,
3909 Elm_Genlist_Item *after,
3910 Elm_Genlist_Item_Flags flags,
3912 const void *func_data)
3914 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3915 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3916 Widget_Data *wd = elm_widget_data_get(obj);
3917 if (!wd) return NULL;
3918 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3920 if (!it) return NULL;
3921 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3922 EINA_INLIST_GET(after));
3925 it->parent->items = eina_list_append_relative(it->parent->items, it,
3929 it->rel->relcount++;
3930 it->before = EINA_FALSE;
3931 _item_queue(wd, it);
3938 * This clears all items in the list, leaving it empty.
3940 * @param obj The genlist object
3945 elm_genlist_clear(Evas_Object *obj)
3947 ELM_CHECK_WIDTYPE(obj, widtype);
3948 Widget_Data *wd = elm_widget_data_get(obj);
3950 if (wd->walking > 0)
3952 Elm_Genlist_Item *it;
3954 wd->clear_me = EINA_TRUE;
3955 EINA_INLIST_FOREACH(wd->items, it)
3957 it->delete_me = EINA_TRUE;
3961 evas_event_freeze(evas_object_evas_get(wd->obj));
3964 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3965 it->nocache = EINA_TRUE;
3966 it->highlighted = EINA_FALSE;
3968 if (wd->anchor_item == it)
3970 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3971 if (!wd->anchor_item)
3973 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3976 wd->items = eina_inlist_remove(wd->items, wd->items);
3977 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3978 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3979 elm_widget_item_pre_notify_del(it);
3980 if (it->realized) _item_unrealize(it, EINA_FALSE);
3981 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3982 it->itc->func.del((void *)it->base.data, it->base.widget);
3983 if (it->long_timer) ecore_timer_del(it->long_timer);
3984 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3985 elm_widget_item_del(it);
3987 wd->clear_me = EINA_FALSE;
3988 wd->anchor_item = NULL;
3991 Item_Block *itb = (Item_Block *)(wd->blocks);
3993 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3994 if (itb->items) eina_list_free(itb->items);
3999 ecore_job_del(wd->calc_job);
4000 wd->calc_job = NULL;
4002 if (wd->queue_idle_enterer)
4004 ecore_idle_enterer_del(wd->queue_idle_enterer);
4005 wd->queue_idle_enterer = NULL;
4007 if (wd->must_recalc_idler)
4009 ecore_idler_del(wd->must_recalc_idler);
4010 wd->must_recalc_idler = NULL;
4014 eina_list_free(wd->queue);
4019 eina_list_free(wd->selected);
4020 wd->selected = NULL;
4022 if (wd->item_moving_effect_timer)
4024 ecore_animator_del(wd->item_moving_effect_timer);
4025 wd->item_moving_effect_timer = NULL;
4027 wd->show_item = NULL;
4034 evas_object_del(wd->alpha_bg);
4035 wd->alpha_bg = NULL;
4039 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4040 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4043 evas_event_thaw(evas_object_evas_get(wd->obj));
4044 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4048 * Enable or disable multi-select in the genlist
4050 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
4051 * the list. This allows more than 1 item to be selected.
4053 * @param obj The genlist object
4054 * @param multi Multi-select enable/disable
4059 elm_genlist_multi_select_set(Evas_Object *obj,
4062 ELM_CHECK_WIDTYPE(obj, widtype);
4063 Widget_Data *wd = elm_widget_data_get(obj);
4069 * Gets if multi-select in genlist is enable or disable
4071 * @param obj The genlist object
4072 * @return Multi-select enable/disable
4073 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
4078 elm_genlist_multi_select_get(const Evas_Object *obj)
4080 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4081 Widget_Data *wd = elm_widget_data_get(obj);
4082 if (!wd) return EINA_FALSE;
4087 * Get the selectd item in the genlist
4089 * This gets the selected item in the list (if multi-select is enabled
4090 * only the first item in the list is selected - which is not very
4091 * useful, so see elm_genlist_selected_items_get() for when
4092 * multi-select is used).
4094 * If no item is selected, NULL is returned.
4096 * @param obj The genlist object
4097 * @return The selected item, or NULL if none.
4101 EAPI Elm_Genlist_Item *
4102 elm_genlist_selected_item_get(const Evas_Object *obj)
4104 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4105 Widget_Data *wd = elm_widget_data_get(obj);
4106 if (!wd) return NULL;
4107 if (wd->selected) return wd->selected->data;
4112 * Get a list of selected items in the genlist
4114 * This returns a list of the selected items. This list pointer is
4115 * only valid so long as no items are selected or unselected (or
4116 * unselected implicitly by deletion). The list contains
4117 * Elm_Genlist_Item pointers.
4119 * @param obj The genlist object
4120 * @return The list of selected items, nor NULL if none are selected.
4124 EAPI const Eina_List *
4125 elm_genlist_selected_items_get(const Evas_Object *obj)
4127 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4128 Widget_Data *wd = elm_widget_data_get(obj);
4129 if (!wd) return NULL;
4130 return wd->selected;
4134 * Get a list of realized items in genlist
4136 * This returns a list of the realized items in the genlist. The list
4137 * contains Elm_Genlist_Item pointers. The list must be freed by the
4138 * caller when done with eina_list_free(). The item pointers in the
4139 * list are only valid so long as those items are not deleted or the
4140 * genlist is not deleted.
4142 * @param obj The genlist object
4143 * @return The list of realized items, nor NULL if none are realized.
4148 elm_genlist_realized_items_get(const Evas_Object *obj)
4150 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4151 Widget_Data *wd = elm_widget_data_get(obj);
4152 Eina_List *list = NULL;
4154 Eina_Bool done = EINA_FALSE;
4155 if (!wd) return NULL;
4156 EINA_INLIST_FOREACH(wd->blocks, itb)
4161 Elm_Genlist_Item *it;
4164 EINA_LIST_FOREACH(itb->items, l, it)
4166 if (it->realized) list = eina_list_append(list, it);
4178 * Get the item that is at the x, y canvas coords
4180 * This returns the item at the given coordinates (which are canvas
4181 * relative not object-relative). If an item is at that coordinate,
4182 * that item handle is returned, and if @p posret is not NULL, the
4183 * integer pointed to is set to a value of -1, 0 or 1, depending if
4184 * the coordinate is on the upper portion of that item (-1), on the
4185 * middle section (0) or on the lower part (1). If NULL is returned as
4186 * an item (no item found there), then posret may indicate -1 or 1
4187 * based if the coordinate is above or below all items respectively in
4190 * @param it The item
4191 * @param x The input x coordinate
4192 * @param y The input y coordinate
4193 * @param posret The position relative to the item returned here
4194 * @return The item at the coordinates or NULL if none
4198 EAPI Elm_Genlist_Item *
4199 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4204 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4205 Widget_Data *wd = elm_widget_data_get(obj);
4206 Evas_Coord ox, oy, ow, oh;
4209 if (!wd) return NULL;
4210 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4212 EINA_INLIST_FOREACH(wd->blocks, itb)
4215 Elm_Genlist_Item *it;
4217 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4218 oy + itb->y - itb->wd->pan_y,
4219 itb->w, itb->h, x, y, 1, 1))
4221 EINA_LIST_FOREACH(itb->items, l, it)
4223 Evas_Coord itx, ity;
4225 itx = ox + itb->x + it->x - itb->wd->pan_x;
4226 ity = oy + itb->y + it->y - itb->wd->pan_y;
4227 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4231 if (y <= (ity + (it->h / 4))) *posret = -1;
4232 else if (y >= (ity + it->h - (it->h / 4)))
4238 lasty = ity + it->h;
4243 if (y > lasty) *posret = 1;
4250 * Get the first item in the genlist
4252 * This returns the first item in the list.
4254 * @param obj The genlist object
4255 * @return The first item, or NULL if none
4259 EAPI Elm_Genlist_Item *
4260 elm_genlist_first_item_get(const Evas_Object *obj)
4262 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4263 Widget_Data *wd = elm_widget_data_get(obj);
4264 if (!wd) return NULL;
4265 if (!wd->items) return NULL;
4266 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4267 while ((it) && (it->delete_me))
4268 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4273 * Get the last item in the genlist
4275 * This returns the last item in the list.
4277 * @return The last item, or NULL if none
4281 EAPI Elm_Genlist_Item *
4282 elm_genlist_last_item_get(const Evas_Object *obj)
4284 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4285 Widget_Data *wd = elm_widget_data_get(obj);
4286 if (!wd) return NULL;
4287 if (!wd->items) return NULL;
4288 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4289 while ((it) && (it->delete_me))
4290 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4295 * Get the next item in the genlist
4297 * This returns the item after the item @p it.
4299 * @param it The item
4300 * @return The item after @p it, or NULL if none
4304 EAPI Elm_Genlist_Item *
4305 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4307 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4310 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4311 if ((it) && (!it->delete_me)) break;
4313 return (Elm_Genlist_Item *)it;
4317 * Get the previous item in the genlist
4319 * This returns the item before the item @p it.
4321 * @param it The item
4322 * @return The item before @p it, or NULL if none
4326 EAPI Elm_Genlist_Item *
4327 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4329 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4332 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4333 if ((it) && (!it->delete_me)) break;
4335 return (Elm_Genlist_Item *)it;
4339 * Get the genlist object from an item
4341 * This returns the genlist object itself that an item belongs to.
4343 * @param it The item
4344 * @return The genlist object
4349 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4351 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4352 return it->base.widget;
4356 * Get the parent item of the given item
4358 * This returns the parent item of the item @p it given.
4360 * @param it The item
4361 * @return The parent of the item or NULL if none
4365 EAPI Elm_Genlist_Item *
4366 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4368 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4373 * Clear all sub-items (children) of the given item
4375 * This clears all items that are children (or their descendants) of the
4378 * @param it The item
4383 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4385 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4386 Elm_Genlist_Item *it2;
4389 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4390 _item_subitems_clear(it);
4393 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4394 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4396 it->wd->expand_item = it;
4397 _item_flip_effect_show(it);
4398 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4399 it->wd->expand_item_end = y + h;
4403 it2 = elm_genlist_item_next_get(it2);
4405 } while (it2->expanded_depth > it->expanded_depth);
4407 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4409 it->wd->expand_item_gap = 0;
4411 evas_object_raise(it->wd->alpha_bg);
4412 evas_object_show(it->wd->alpha_bg);
4414 it->wd->start_time = current_time_get();
4415 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4418 _item_subitems_clear(it);
4423 * Set the selected state of an item
4425 * This sets the selected state (1 selected, 0 not selected) of the given
4428 * @param it The item
4429 * @param selected The selected state
4434 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4437 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4438 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4440 if ((it->delete_me) || (it->disabled)) return;
4441 selected = !!selected;
4442 if (it->selected == selected) return;
4448 while (wd->selected)
4449 _item_unselect(wd->selected->data);
4451 _item_highlight(it);
4459 * Get the selected state of an item
4461 * This gets the selected state of an item (1 selected, 0 not selected).
4463 * @param it The item
4464 * @return The selected state
4469 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4471 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4472 return it->selected;
4476 * Sets the expanded state of an item (if it's a parent)
4478 * This expands or contracts a parent item (thus showing or hiding the
4481 * @param it The item
4482 * @param expanded The expanded state (1 expanded, 0 not expanded).
4487 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4490 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4491 if (it->flags != ELM_GENLIST_ITEM_SUBITEMS) return;
4492 if (it->expanded == expanded) return;
4493 it->expanded = expanded;
4494 it->wd->expand_item = it;
4496 if (it->wd->effect_mode && !it->wd->alpha_bg)
4497 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4501 it->wd->auto_scrolled = EINA_FALSE;
4502 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4504 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4505 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4509 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4511 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4512 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4517 * Get the expanded state of an item
4519 * This gets the expanded state of an item
4521 * @param it The item
4522 * @return Thre expanded state
4527 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4529 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4530 return it->expanded;
4534 * Get the depth of expanded item
4536 * @param it The genlist item object
4537 * @return The depth of expanded item
4542 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4545 return it->expanded_depth;
4549 * Sets the disabled state of an item.
4551 * A disabled item cannot be selected or unselected. It will also
4552 * change appearance to appear disabled. This sets the disabled state
4553 * (1 disabled, 0 not disabled).
4555 * @param it The item
4556 * @param disabled The disabled state
4561 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4564 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4567 if (it->disabled == disabled) return;
4568 if (it->delete_me) return;
4569 it->disabled = disabled;
4571 elm_genlist_item_selected_set(it, EINA_FALSE);
4575 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4577 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4578 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4579 elm_widget_disabled_set(obj, disabled);
4584 * Get the disabled state of an item
4586 * This gets the disabled state of the given item.
4588 * @param it The item
4589 * @return The disabled state
4594 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4596 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4597 if (it->delete_me) return EINA_FALSE;
4598 return it->disabled;
4602 * Sets the display only state of an item.
4604 * A display only item cannot be selected or unselected. It is for
4605 * display only and not selecting or otherwise clicking, dragging
4606 * etc. by the user, thus finger size rules will not be applied to
4609 * @param it The item
4610 * @param display_only The display only state
4615 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4616 Eina_Bool display_only)
4618 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4619 if (it->display_only == display_only) return;
4620 if (it->delete_me) return;
4621 it->display_only = display_only;
4622 it->mincalcd = EINA_FALSE;
4623 it->updateme = EINA_TRUE;
4624 if (it->block) it->block->updateme = EINA_TRUE;
4625 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4626 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4630 * Get the display only state of an item
4632 * This gets the display only state of the given item.
4634 * @param it The item
4635 * @return The display only state
4640 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4642 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4643 if (it->delete_me) return EINA_FALSE;
4644 return it->display_only;
4648 * Show the given item
4650 * This causes genlist to jump to the given item @p it and show it (by
4651 * scrolling), if it is not fully visible.
4653 * @param it The item
4658 elm_genlist_item_show(Elm_Genlist_Item *it)
4660 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4661 Evas_Coord gith = 0;
4662 if (it->delete_me) return;
4663 if ((it->queued) || (!it->mincalcd))
4665 it->wd->show_item = it;
4666 it->wd->bring_in = EINA_TRUE;
4667 it->showme = EINA_TRUE;
4670 if (it->wd->show_item)
4672 it->wd->show_item->showme = EINA_FALSE;
4673 it->wd->show_item = NULL;
4675 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4676 gith = it->group_item->h;
4677 elm_smart_scroller_child_region_show(it->wd->scr,
4678 it->x + it->block->x,
4679 it->y + it->block->y - gith,
4680 it->block->w, it->h);
4684 * Bring in the given item
4686 * This causes genlist to jump to the given item @p it and show it (by
4687 * scrolling), if it is not fully visible. This may use animation to
4688 * do so and take a period of time
4690 * @param it The item
4695 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4697 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4698 Evas_Coord gith = 0;
4699 if (it->delete_me) return;
4700 if ((it->queued) || (!it->mincalcd))
4702 it->wd->show_item = it;
4703 it->wd->bring_in = EINA_TRUE;
4704 it->showme = EINA_TRUE;
4707 if (it->wd->show_item)
4709 it->wd->show_item->showme = EINA_FALSE;
4710 it->wd->show_item = NULL;
4712 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4713 gith = it->group_item->h;
4714 elm_smart_scroller_region_bring_in(it->wd->scr,
4715 it->x + it->block->x,
4716 it->y + it->block->y - gith,
4717 it->block->w, it->h);
4721 * Show the given item at the top
4723 * This causes genlist to jump to the given item @p it and show it (by
4724 * scrolling), if it is not fully visible.
4726 * @param it The item
4731 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4733 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4735 Evas_Coord gith = 0;
4737 if (it->delete_me) return;
4738 if ((it->queued) || (!it->mincalcd))
4740 it->wd->show_item = it;
4741 it->wd->bring_in = EINA_TRUE;
4742 it->showme = EINA_TRUE;
4745 if (it->wd->show_item)
4747 it->wd->show_item->showme = EINA_FALSE;
4748 it->wd->show_item = NULL;
4750 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4751 if (it->group_item) gith = it->group_item->h;
4752 elm_smart_scroller_child_region_show(it->wd->scr,
4753 it->x + it->block->x,
4754 it->y + it->block->y - gith,
4759 * Bring in the given item at the top
4761 * This causes genlist to jump to the given item @p it and show it (by
4762 * scrolling), if it is not fully visible. This may use animation to
4763 * do so and take a period of time
4765 * @param it The item
4770 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4772 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4774 Evas_Coord gith = 0;
4776 if (it->delete_me) return;
4777 if ((it->queued) || (!it->mincalcd))
4779 it->wd->show_item = it;
4780 it->wd->bring_in = EINA_TRUE;
4781 it->showme = EINA_TRUE;
4784 if (it->wd->show_item)
4786 it->wd->show_item->showme = EINA_FALSE;
4787 it->wd->show_item = NULL;
4789 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4790 if (it->group_item) gith = it->group_item->h;
4791 elm_smart_scroller_region_bring_in(it->wd->scr,
4792 it->x + it->block->x,
4793 it->y + it->block->y - gith,
4798 * Show the given item at the middle
4800 * This causes genlist to jump to the given item @p it and show it (by
4801 * scrolling), if it is not fully visible.
4803 * @param it The item
4808 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4810 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4813 if (it->delete_me) return;
4814 if ((it->queued) || (!it->mincalcd))
4816 it->wd->show_item = it;
4817 it->wd->bring_in = EINA_TRUE;
4818 it->showme = EINA_TRUE;
4821 if (it->wd->show_item)
4823 it->wd->show_item->showme = EINA_FALSE;
4824 it->wd->show_item = NULL;
4826 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4827 elm_smart_scroller_child_region_show(it->wd->scr,
4828 it->x + it->block->x,
4829 it->y + it->block->y - oh / 2 +
4830 it->h / 2, it->block->w, oh);
4834 * Bring in the given item at the middle
4836 * This causes genlist to jump to the given item @p it and show it (by
4837 * scrolling), if it is not fully visible. This may use animation to
4838 * do so and take a period of time
4840 * @param it The item
4845 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4847 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4850 if (it->delete_me) return;
4851 if ((it->queued) || (!it->mincalcd))
4853 it->wd->show_item = it;
4854 it->wd->bring_in = EINA_TRUE;
4855 it->showme = EINA_TRUE;
4858 if (it->wd->show_item)
4860 it->wd->show_item->showme = EINA_FALSE;
4861 it->wd->show_item = NULL;
4863 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4864 elm_smart_scroller_region_bring_in(it->wd->scr,
4865 it->x + it->block->x,
4866 it->y + it->block->y - oh / 2 + it->h / 2,
4871 * Delete a given item
4873 * This deletes the item from genlist and calls the genlist item del
4874 * class callback defined in the item class, if it is set. This clears all
4875 * subitems if it is a tree.
4877 * @param it The item
4882 elm_genlist_item_del(Elm_Genlist_Item *it)
4884 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4885 if ((it->relcount > 0) || (it->walking > 0))
4887 elm_widget_item_pre_notify_del(it);
4888 elm_genlist_item_subitems_clear(it);
4889 it->delete_me = EINA_TRUE;
4890 if (it->wd->show_item == it) it->wd->show_item = NULL;
4892 it->wd->selected = eina_list_remove(it->wd->selected,
4896 if (it->realized) _item_unrealize(it, EINA_FALSE);
4897 it->block->changed = EINA_TRUE;
4898 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4899 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4901 if (it->itc->func.del)
4902 it->itc->func.del((void *)it->base.data, it->base.widget);
4909 * Set the data item from the genlist item
4911 * This set the data value passed on the elm_genlist_item_append() and
4912 * related item addition calls. This function will also call
4913 * elm_genlist_item_update() so the item will be updated to reflect the
4916 * @param it The item
4917 * @param data The new data pointer to set
4922 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4925 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4926 elm_widget_item_data_set(it, data);
4927 elm_genlist_item_update(it);
4931 * Get the data item from the genlist item
4933 * This returns the data value passed on the elm_genlist_item_append()
4934 * and related item addition calls and elm_genlist_item_data_set().
4936 * @param it The item
4937 * @return The data pointer provided when created
4942 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4944 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4945 return elm_widget_item_data_get(it);
4949 * Tells genlist to "orphan" icons fetchs by the item class
4951 * This instructs genlist to release references to icons in the item,
4952 * meaning that they will no longer be managed by genlist and are
4953 * floating "orphans" that can be re-used elsewhere if the user wants
4956 * @param it The item
4961 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4964 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4965 EINA_LIST_FREE(it->icon_objs, icon)
4967 elm_widget_sub_object_del(it->base.widget, icon);
4968 evas_object_smart_member_del(icon);
4969 evas_object_hide(icon);
4974 * Get the real evas object of the genlist item
4976 * This returns the actual evas object used for the specified genlist
4977 * item. This may be NULL as it may not be created, and may be deleted
4978 * at any time by genlist. Do not modify this object (move, resize,
4979 * show, hide etc.) as genlist is controlling it. This function is for
4980 * querying, emitting custom signals or hooking lower level callbacks
4981 * for events. Do not delete this object under any circumstances.
4983 * @param it The item
4984 * @return The object pointer
4988 EAPI const Evas_Object *
4989 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4991 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4992 return it->base.view;
4996 * Update the contents of an item
4998 * This updates an item by calling all the item class functions again
4999 * to get the icons, labels and states. Use this when the original
5000 * item data has changed and the changes are desired to be reflected.
5002 * @param it The item
5007 elm_genlist_item_update(Elm_Genlist_Item *it)
5009 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5010 if (!it->block) return;
5011 if (it->delete_me) return;
5012 it->mincalcd = EINA_FALSE;
5013 it->updateme = EINA_TRUE;
5014 it->block->updateme = EINA_TRUE;
5015 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
5016 it->wd->update_job = ecore_job_add(_update_job, it->wd);
5020 * Update the item class of an item
5022 * @param it The item
5023 * @parem itc The item class for the item
5028 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
5029 const Elm_Genlist_Item_Class *itc)
5031 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5032 if (!it->block) return;
5033 EINA_SAFETY_ON_NULL_RETURN(itc);
5034 if (it->delete_me) return;
5036 it->nocache = EINA_TRUE;
5037 elm_genlist_item_update(it);
5040 static Evas_Object *
5041 _elm_genlist_item_label_create(void *data,
5043 void *item __UNUSED__)
5045 Evas_Object *label = elm_label_add(obj);
5048 elm_object_style_set(label, "tooltip");
5049 elm_label_label_set(label, data);
5054 _elm_genlist_item_label_del_cb(void *data,
5055 Evas_Object *obj __UNUSED__,
5056 void *event_info __UNUSED__)
5058 eina_stringshare_del(data);
5062 * Set the text to be shown in the genlist item.
5064 * @param item Target item
5065 * @param text The text to set in the content
5067 * Setup the text as tooltip to object. The item can have only one
5068 * tooltip, so any previous tooltip data is removed.
5073 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
5076 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5077 text = eina_stringshare_add(text);
5078 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
5080 _elm_genlist_item_label_del_cb);
5084 * Set the content to be shown in the tooltip item
5086 * Setup the tooltip to item. The item can have only one tooltip, so
5087 * any previous tooltip data is removed. @p func(with @p data) will be
5088 * called every time that need to show the tooltip and it should return a
5089 * valid Evas_Object. This object is then managed fully by tooltip
5090 * system and is deleted when the tooltip is gone.
5092 * @param item the genlist item being attached by a tooltip.
5093 * @param func the function used to create the tooltip contents.
5094 * @param data what to provide to @a func as callback data/context.
5095 * @param del_cb called when data is not needed anymore, either when
5096 * another callback replaces @func, the tooltip is unset with
5097 * elm_genlist_item_tooltip_unset() or the owner @a item
5098 * dies. This callback receives as the first parameter the
5099 * given @a data, and @c event_info is the item.
5104 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
5105 Elm_Tooltip_Item_Content_Cb func,
5107 Evas_Smart_Cb del_cb)
5109 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
5111 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
5114 if (item->tooltip.del_cb)
5115 item->tooltip.del_cb((void *)item->tooltip.data,
5116 item->base.widget, item);
5118 item->tooltip.content_cb = func;
5119 item->tooltip.data = data;
5120 item->tooltip.del_cb = del_cb;
5122 if (item->base.view)
5124 elm_widget_item_tooltip_content_cb_set(item,
5125 item->tooltip.content_cb,
5126 item->tooltip.data, NULL);
5127 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
5133 if (del_cb) del_cb((void *)data, NULL, NULL);
5137 * Unset tooltip from item
5139 * @param item genlist item to remove previously set tooltip.
5141 * Remove tooltip from item. The callback provided as del_cb to
5142 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
5143 * it is not used anymore.
5145 * @see elm_genlist_item_tooltip_content_cb_set()
5150 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
5152 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5153 if ((item->base.view) && (item->tooltip.content_cb))
5154 elm_widget_item_tooltip_unset(item);
5156 if (item->tooltip.del_cb)
5157 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
5158 item->tooltip.del_cb = NULL;
5159 item->tooltip.content_cb = NULL;
5160 item->tooltip.data = NULL;
5161 if (item->tooltip.style)
5162 elm_genlist_item_tooltip_style_set(item, NULL);
5166 * Sets a different style for this item tooltip.
5168 * @note before you set a style you should define a tooltip with
5169 * elm_genlist_item_tooltip_content_cb_set() or
5170 * elm_genlist_item_tooltip_text_set()
5172 * @param item genlist item with tooltip already set.
5173 * @param style the theme style to use (default, transparent, ...)
5178 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
5181 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5182 eina_stringshare_replace(&item->tooltip.style, style);
5183 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
5187 * Get the style for this item tooltip.
5189 * @param item genlist item with tooltip already set.
5190 * @return style the theme style in use, defaults to "default". If the
5191 * object does not have a tooltip set, then NULL is returned.
5196 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
5198 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5199 return item->tooltip.style;
5203 * Set the cursor to be shown when mouse is over the genlist item
5205 * @param item Target item
5206 * @param cursor the cursor name to be used.
5208 * @see elm_object_cursor_set()
5212 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
5215 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5216 eina_stringshare_replace(&item->mouse_cursor, cursor);
5217 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
5221 * Get the cursor to be shown when mouse is over the genlist item
5223 * @param item genlist item with cursor already set.
5224 * @return the cursor name.
5229 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
5231 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5232 return elm_widget_item_cursor_get(item);
5236 * Unset the cursor to be shown when mouse is over the genlist item
5238 * @param item Target item
5240 * @see elm_object_cursor_unset()
5244 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
5246 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5247 if (!item->mouse_cursor)
5250 if (item->base.view)
5251 elm_widget_item_cursor_unset(item);
5253 eina_stringshare_del(item->mouse_cursor);
5254 item->mouse_cursor = NULL;
5258 * Sets a different style for this item cursor.
5260 * @note before you set a style you should define a cursor with
5261 * elm_genlist_item_cursor_set()
5263 * @param item genlist item with cursor already set.
5264 * @param style the theme style to use (default, transparent, ...)
5269 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5272 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5273 elm_widget_item_cursor_style_set(item, style);
5277 * Get the style for this item cursor.
5279 * @param item genlist item with cursor already set.
5280 * @return style the theme style in use, defaults to "default". If the
5281 * object does not have a cursor set, then NULL is returned.
5286 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5288 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5289 return elm_widget_item_cursor_style_get(item);
5293 * Set if the cursor set should be searched on the theme or should use
5294 * the provided by the engine, only.
5296 * @note before you set if should look on theme you should define a
5297 * cursor with elm_object_cursor_set(). By default it will only look
5298 * for cursors provided by the engine.
5300 * @param item widget item with cursor already set.
5301 * @param engine_only boolean to define it cursors should be looked
5302 * only between the provided by the engine or searched on widget's
5308 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5309 Eina_Bool engine_only)
5311 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5312 elm_widget_item_cursor_engine_only_set(item, engine_only);
5316 * Get the cursor engine only usage for this item cursor.
5318 * @param item widget item with cursor already set.
5319 * @return engine_only boolean to define it cursors should be looked
5320 * only between the provided by the engine or searched on widget's
5321 * theme as well. If the object does not have a cursor set, then
5322 * EINA_FALSE is returned.
5327 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5329 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5330 return elm_widget_item_cursor_engine_only_get(item);
5334 * This sets the horizontal stretching mode
5336 * This sets the mode used for sizing items horizontally. Valid modes
5337 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5338 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5339 * the scroller will scroll horizontally. Otherwise items are expanded
5340 * to fill the width of the viewport of the scroller. If it is
5341 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5342 * limited to that size.
5344 * @param obj The genlist object
5345 * @param mode The mode to use
5350 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5353 ELM_CHECK_WIDTYPE(obj, widtype);
5354 Widget_Data *wd = elm_widget_data_get(obj);
5356 if (wd->mode == mode) return;
5362 * Gets the horizontal stretching mode
5364 * @param obj The genlist object
5365 * @return The mode to use
5366 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5371 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5373 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5374 Widget_Data *wd = elm_widget_data_get(obj);
5375 if (!wd) return ELM_LIST_LAST;
5380 * Set the always select mode.
5382 * Items will only call their selection func and callback when first
5383 * becoming selected. Any further clicks will do nothing, unless you
5384 * enable always select with elm_genlist_always_select_mode_set().
5385 * This means even if selected, every click will make the selected
5386 * callbacks be called.
5388 * @param obj The genlist object
5389 * @param always_select The always select mode
5390 * (EINA_TRUE = on, EINA_FALSE = off)
5395 elm_genlist_always_select_mode_set(Evas_Object *obj,
5396 Eina_Bool always_select)
5398 ELM_CHECK_WIDTYPE(obj, widtype);
5399 Widget_Data *wd = elm_widget_data_get(obj);
5401 wd->always_select = always_select;
5405 * Get the always select mode.
5407 * @param obj The genlist object
5408 * @return The always select mode
5409 * (EINA_TRUE = on, EINA_FALSE = off)
5414 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5416 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5417 Widget_Data *wd = elm_widget_data_get(obj);
5418 if (!wd) return EINA_FALSE;
5419 return wd->always_select;
5423 * Set no select mode
5425 * This will turn off the ability to select items entirely and they
5426 * will neither appear selected nor call selected callback functions.
5428 * @param obj The genlist object
5429 * @param no_select The no select mode
5430 * (EINA_TRUE = on, EINA_FALSE = off)
5435 elm_genlist_no_select_mode_set(Evas_Object *obj,
5436 Eina_Bool no_select)
5438 ELM_CHECK_WIDTYPE(obj, widtype);
5439 Widget_Data *wd = elm_widget_data_get(obj);
5441 wd->no_select = no_select;
5445 * Gets no select mode
5447 * @param obj The genlist object
5448 * @return The no select mode
5449 * (EINA_TRUE = on, EINA_FALSE = off)
5454 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5456 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5457 Widget_Data *wd = elm_widget_data_get(obj);
5458 if (!wd) return EINA_FALSE;
5459 return wd->no_select;
5465 * This will enable the compress mode where items are "compressed"
5466 * horizontally to fit the genlist scrollable viewport width. This is
5467 * special for genlist. Do not rely on
5468 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5469 * work as genlist needs to handle it specially.
5471 * @param obj The genlist object
5472 * @param compress The compress mode
5473 * (EINA_TRUE = on, EINA_FALSE = off)
5478 elm_genlist_compress_mode_set(Evas_Object *obj,
5481 ELM_CHECK_WIDTYPE(obj, widtype);
5482 Widget_Data *wd = elm_widget_data_get(obj);
5484 wd->compress = compress;
5488 * Get the compress mode
5490 * @param obj The genlist object
5491 * @return The compress mode
5492 * (EINA_TRUE = on, EINA_FALSE = off)
5497 elm_genlist_compress_mode_get(const Evas_Object *obj)
5499 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5500 Widget_Data *wd = elm_widget_data_get(obj);
5501 if (!wd) return EINA_FALSE;
5502 return wd->compress;
5506 * Set height-for-width mode
5508 * With height-for-width mode the item width will be fixed (restricted
5509 * to a minimum of) to the list width when calculating its size in
5510 * order to allow the height to be calculated based on it. This allows,
5511 * for instance, text block to wrap lines if the Edje part is
5512 * configured with "text.min: 0 1".
5514 * @note This mode will make list resize slower as it will have to
5515 * recalculate every item height again whenever the list width
5518 * @note When height-for-width mode is enabled, it also enables
5519 * compress mode (see elm_genlist_compress_mode_set()) and
5520 * disables homogeneous (see elm_genlist_homogeneous_set()).
5522 * @param obj The genlist object
5523 * @param setting The height-for-width mode (EINA_TRUE = on,
5529 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5530 Eina_Bool height_for_width)
5532 ELM_CHECK_WIDTYPE(obj, widtype);
5533 Widget_Data *wd = elm_widget_data_get(obj);
5535 wd->height_for_width = !!height_for_width;
5536 if (wd->height_for_width)
5538 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5539 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5544 * Get the height-for-width mode
5546 * @param obj The genlist object
5547 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5553 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5555 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5556 Widget_Data *wd = elm_widget_data_get(obj);
5557 if (!wd) return EINA_FALSE;
5558 return wd->height_for_width;
5564 * This will enable or disable the scroller bounce mode for the
5565 * genlist. See elm_scroller_bounce_set() for details
5567 * @param obj The genlist object
5568 * @param h_bounce Allow bounce horizontally
5569 * @param v_bounce Allow bounce vertically
5574 elm_genlist_bounce_set(Evas_Object *obj,
5578 ELM_CHECK_WIDTYPE(obj, widtype);
5579 Widget_Data *wd = elm_widget_data_get(obj);
5581 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5585 * Get the bounce mode
5587 * @param obj The genlist object
5588 * @param h_bounce Allow bounce horizontally
5589 * @param v_bounce Allow bounce vertically
5594 elm_genlist_bounce_get(const Evas_Object *obj,
5595 Eina_Bool *h_bounce,
5596 Eina_Bool *v_bounce)
5598 ELM_CHECK_WIDTYPE(obj, widtype);
5599 Widget_Data *wd = elm_widget_data_get(obj);
5601 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5605 * Set homogenous mode
5607 * This will enable the homogeneous mode where items are of the same
5608 * height and width so that genlist may do the lazy-loading at its
5609 * maximum. This implies 'compressed' mode.
5611 * @param obj The genlist object
5612 * @param homogeneous Assume the items within the genlist are of the
5613 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5618 elm_genlist_homogeneous_set(Evas_Object *obj,
5619 Eina_Bool homogeneous)
5621 ELM_CHECK_WIDTYPE(obj, widtype);
5622 Widget_Data *wd = elm_widget_data_get(obj);
5624 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5625 wd->homogeneous = homogeneous;
5629 * Get the homogenous mode
5631 * @param obj The genlist object
5632 * @return Assume the items within the genlist are of the same height
5633 * and width (EINA_TRUE = on, EINA_FALSE = off)
5638 elm_genlist_homogeneous_get(const Evas_Object *obj)
5640 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5641 Widget_Data *wd = elm_widget_data_get(obj);
5642 if (!wd) return EINA_FALSE;
5643 return wd->homogeneous;
5647 * Set the maximum number of items within an item block
5649 * This will configure the block count to tune to the target with
5650 * particular performance matrix.
5652 * @param obj The genlist object
5653 * @param n Maximum number of items within an item block
5658 elm_genlist_block_count_set(Evas_Object *obj,
5661 ELM_CHECK_WIDTYPE(obj, widtype);
5662 Widget_Data *wd = elm_widget_data_get(obj);
5664 wd->max_items_per_block = n;
5665 wd->item_cache_max = wd->max_items_per_block * 2;
5666 _item_cache_clean(wd);
5670 * Get the maximum number of items within an item block
5672 * @param obj The genlist object
5673 * @return Maximum number of items within an item block
5678 elm_genlist_block_count_get(const Evas_Object *obj)
5680 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5681 Widget_Data *wd = elm_widget_data_get(obj);
5683 return wd->max_items_per_block;
5687 * Set the timeout in seconds for the longpress event
5689 * @param obj The genlist object
5690 * @param timeout timeout in seconds
5695 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5698 ELM_CHECK_WIDTYPE(obj, widtype);
5699 Widget_Data *wd = elm_widget_data_get(obj);
5701 wd->longpress_timeout = timeout;
5705 * Get the timeout in seconds for the longpress event
5707 * @param obj The genlist object
5708 * @return timeout in seconds
5713 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5715 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5716 Widget_Data *wd = elm_widget_data_get(obj);
5718 return wd->longpress_timeout;
5722 * Set the scrollbar policy
5724 * This sets the scrollbar visibility policy for the given genlist
5725 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5726 * made visible if it is needed, and otherwise kept hidden.
5727 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5728 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5729 * respectively for the horizontal and vertical scrollbars.
5731 * @param obj The genlist object
5732 * @param policy_h Horizontal scrollbar policy
5733 * @param policy_v Vertical scrollbar policy
5738 elm_genlist_scroller_policy_set(Evas_Object *obj,
5739 Elm_Scroller_Policy policy_h,
5740 Elm_Scroller_Policy policy_v)
5742 ELM_CHECK_WIDTYPE(obj, widtype);
5743 Widget_Data *wd = elm_widget_data_get(obj);
5745 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5746 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5749 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5753 * Get the scrollbar policy
5755 * @param obj The genlist object
5756 * @param policy_h Horizontal scrollbar policy
5757 * @param policy_v Vertical scrollbar policy
5762 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5763 Elm_Scroller_Policy *policy_h,
5764 Elm_Scroller_Policy *policy_v)
5766 ELM_CHECK_WIDTYPE(obj, widtype);
5767 Widget_Data *wd = elm_widget_data_get(obj);
5768 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5769 if ((!wd) || (!wd->scr)) return;
5770 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5771 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5772 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5775 /****************************************************************************/
5780 * @param obj The genlist object
5781 * @param reorder_mode The reorder mode
5782 * (EINA_TRUE = on, EINA_FALSE = off)
5787 elm_genlist_reorder_mode_set(Evas_Object *obj,
5788 Eina_Bool reorder_mode)
5790 ELM_CHECK_WIDTYPE(obj, widtype);
5791 Widget_Data *wd = elm_widget_data_get(obj);
5793 wd->reorder_mode = reorder_mode;
5797 * Get the reorder mode
5799 * @param obj The genlist object
5800 * @return The reorder mode
5801 * (EINA_TRUE = on, EINA_FALSE = off)
5806 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5808 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5809 Widget_Data *wd = elm_widget_data_get(obj);
5810 if (!wd) return EINA_FALSE;
5811 return wd->reorder_mode;
5815 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5821 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5827 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5832 // printf("MOVE AFTER : it = %d after = %d \n", it->num, after->num);
5833 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5834 it->wd->reorder_deleted = EINA_TRUE;
5835 _item_block_del(it);
5837 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5839 it->rel->relcount++;
5840 it->before = EINA_FALSE;
5841 _item_queue(it->wd, it);
5843 if (it->itc->func.moved)
5844 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
5848 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5851 if (!before) return;
5853 // printf("MOVE BEFORE : it = %d before = %d \n", it->num, before->num);
5854 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5855 it->wd->reorder_deleted = EINA_TRUE;
5856 _item_block_del(it);
5857 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5859 it->rel->relcount++;
5860 it->before = EINA_TRUE;
5861 _item_queue(it->wd, it);
5863 if (it->itc->func.moved)
5864 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
5868 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5870 ELM_CHECK_WIDTYPE(obj, widtype);
5871 Widget_Data *wd = elm_widget_data_get(obj);
5873 wd->effect_mode = emode;
5874 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5875 // evas_object_resize(wd->point_rect, 10, 25);
5876 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5877 // evas_object_show(wd->point_rect);
5878 // evas_object_hide(wd->point_rect);
5882 _create_tray_alpha_bg(const Evas_Object *obj)
5884 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5885 Widget_Data *wd = elm_widget_data_get(obj);
5886 if (!wd) return NULL;
5888 Evas_Object *bg = NULL;
5889 Evas_Coord ox, oy, ow, oh;
5891 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5892 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5893 evas_object_color_set(bg,0,0,0,0);
5894 evas_object_resize(bg , ow, oh);
5895 evas_object_move(bg , ox, oy);
5896 evas_object_show(bg);
5897 evas_object_hide(bg);
5904 struct timeval timev;
5906 gettimeofday(&timev, NULL);
5907 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5910 // added for item moving animation.
5912 _item_moving_effect_timer_cb(void *data)
5914 Widget_Data *wd = data;
5915 if (!wd) return EINA_FALSE;
5917 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5918 Elm_Genlist_Item *it, *it2;
5920 double time = 0.3, t;
5922 Eina_Bool check, end = EINA_FALSE;
5925 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5927 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5928 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5929 if (t > time) end = EINA_TRUE;
5931 it2 = elm_genlist_item_next_get(wd->expand_item);
5934 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5935 it2 = elm_genlist_item_next_get(it2);
5940 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5941 dy = it2->scrl_y - it2->old_scrl_y;
5942 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5943 dy = wd->expand_item_gap;
5947 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5956 EINA_INLIST_FOREACH(wd->blocks, itb)
5959 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5960 itb->y - wd->pan_y + oy,
5962 cvx, cvy, cvw, cvh))
5964 EINA_LIST_FOREACH(itb->items, l, it)
5966 if (it == it2) check = EINA_TRUE;
5967 if (!check) continue;
5969 if (!it->old_scrl_y)
5970 it->old_scrl_y = it->scrl_y;
5971 if (it->old_scrl_y + y < oy + oh)
5973 if (!it->realized) _item_realize(it, in, 0);
5975 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5976 it->old_scrl_y = it->scrl_y - y;
5979 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5980 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5982 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5985 evas_object_resize(it->base.view, it->w, it->h);
5986 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5987 evas_object_show(it->base.view);
5988 evas_object_raise(it->base.view);
5991 if (it->group_item) evas_object_raise(it->group_item->base.view);
5997 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5999 it = elm_genlist_item_prev_get(it2);
6002 if (it->expanded_depth <= it2->expanded_depth) break;
6003 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
6005 if (!it->effect_done)
6007 edje_object_signal_emit(it->base.view, "flip_item", "");
6008 evas_object_show(it->base.view);
6009 it->effect_done = EINA_TRUE;
6012 it = elm_genlist_item_prev_get(it);
6015 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6017 it = elm_genlist_item_prev_get(it2);
6020 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
6022 if (!it->effect_done)
6024 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
6025 it->effect_done = EINA_TRUE;
6030 it = elm_genlist_item_prev_get(it);
6037 int expand_order = 0;
6038 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
6042 it = elm_genlist_item_next_get(it);
6044 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
6048 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
6049 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6051 if (!it->effect_done)
6053 if (t >= (((expand_order - 1) * time) / expand_num))
6055 edje_object_signal_emit(it->base.view, "flip_item", "");
6056 evas_object_show(it->base.view);
6057 it->effect_done = EINA_TRUE;
6061 it = elm_genlist_item_next_get(it);
6067 if (wd->item_moving_effect_timer)
6069 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6070 _item_subitems_clear(wd->expand_item);
6071 EINA_INLIST_FOREACH(wd->blocks, itb)
6073 EINA_LIST_FOREACH(itb->items, l, it)
6075 it->effect_done = EINA_TRUE;
6076 it->old_scrl_y = it->scrl_y;
6080 wd->item_moving_effect_timer = NULL;
6082 _item_auto_scroll(wd);
6083 evas_object_lower(wd->alpha_bg);
6084 evas_object_hide(wd->alpha_bg);
6085 if (wd->calc_job) ecore_job_del(wd->calc_job);
6086 wd->calc_job = ecore_job_add(_calc_job, wd);
6087 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
6088 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
6090 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
6091 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
6092 return ECORE_CALLBACK_CANCEL;
6094 return ECORE_CALLBACK_RENEW;
6098 _emit_contract(Elm_Genlist_Item *it)
6100 Elm_Genlist_Item *it2;
6103 // printf("%p is emited contract\n", it);
6104 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
6105 it->effect_done = EINA_FALSE;
6107 EINA_LIST_FOREACH(it->items, l, it2)
6109 _emit_contract(it2);
6112 // added for item moving animation.
6114 _item_flip_effect_show(Elm_Genlist_Item *it)
6116 Elm_Genlist_Item *it2;
6118 Widget_Data *wd = it->wd;
6119 Eina_Bool check = EINA_FALSE;
6121 it2 = elm_genlist_item_next_get(it);
6124 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
6125 it2 = elm_genlist_item_next_get(it2);
6127 EINA_LIST_FOREACH(it->items, l, it2)
6129 if (it2->parent && it == it2->parent)
6131 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6132 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
6133 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6134 _emit_contract(it2);
6138 return ECORE_CALLBACK_CANCEL;
6143 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
6145 printf("!!! NOW FIXING \n");
6150 * Set pinch zoom mode
6152 * @param obj The genlist object
6154 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
6159 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
6161 printf("!!! NOW FIXING \n");
6165 * Get pinch zoom mode
6167 * @param obj The genlist object
6168 * @return The pinch mode
6169 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
6174 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
6176 printf("!!! NOW FIXING \n");
6181 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
6183 printf("!!! NOW FIXING \n");
6187 ////////////////////////////////////////////////////////////////////////
6189 ////////////////////////////////////////////////////////////////////////
6192 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
6194 if (!it->wd->edit_mode) return;
6195 evas_object_resize(it->edit_obj,it->w, it->h);
6196 evas_object_move(it->edit_obj, itx, ity);
6200 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
6202 if ((it->effect_item_realized) || (it->delete_me)) return;
6205 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6206 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6207 _elm_config->scale);
6208 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6209 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6211 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6212 else strncpy(buf, "item", sizeof(buf));
6213 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6215 strncat(buf, "/", sizeof(buf) - strlen(buf));
6217 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
6219 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
6220 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6224 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
6227 if (it->wd->reorder_mode)
6229 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
6230 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
6232 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
6233 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
6235 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
6236 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
6239 if ((it->wd->edit_mode))
6241 if (it->itc->func.icon_get)
6246 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
6247 EINA_LIST_FOREACH(it->icons, l, key)
6249 Evas_Object *ic = it->itc->func.icon_get
6250 (it->base.data, it->base.widget, l->data);
6254 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6255 edje_object_part_swallow(it->edit_obj, key, ic);
6256 evas_object_show(ic);
6257 elm_widget_sub_object_add(it->base.widget, ic);
6259 elm_widget_disabled_set(ic, EINA_TRUE);
6264 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6265 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6266 evas_object_show(it->edit_obj);
6268 it->effect_item_realized = EINA_TRUE;
6269 it->want_unrealize = EINA_FALSE;
6273 _effect_item_unrealize(Elm_Genlist_Item *it)
6277 if (!it->effect_item_realized) return;
6278 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6280 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6281 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6282 edje_object_message_signal_process(it->edit_obj);
6283 edje_object_part_unswallow(it->edit_obj, it->base.view);
6284 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6285 elm_widget_sub_object_add(it->base.widget, it->base.view);
6286 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6287 // _item_cache_add(it);
6288 evas_object_del(it->edit_obj);
6289 it->edit_obj = NULL;
6290 EINA_LIST_FREE(it->edit_icon_objs, icon)
6291 evas_object_del(icon);
6293 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6294 it->effect_item_realized = EINA_FALSE;
6298 * Get Genlist edit mode
6300 * @param obj The genlist object
6301 * @return The edit mode status
6302 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6307 elm_genlist_edit_mode_get(const Evas_Object *obj)
6309 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
6310 Widget_Data *wd = elm_widget_data_get(obj);
6311 if (!wd) return EINA_FALSE;
6313 if (wd->edit_mode) return EINA_TRUE;
6314 else return EINA_FALSE;
6318 * Set Genlist edit mode
6320 * This sets Genlist edit mode.
6322 * @param obj The Genlist object
6323 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6324 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6329 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
6331 ELM_CHECK_WIDTYPE(obj, widtype);
6335 Elm_Genlist_Item *it;
6337 Widget_Data *wd = elm_widget_data_get(obj);
6339 if (wd->edit_mode == edit_mode) return;
6341 wd->edit_mode = edit_mode;
6344 EINA_INLIST_FOREACH(wd->blocks, itb)
6348 EINA_LIST_FOREACH(itb->items, l, it)
6350 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6352 _effect_item_unrealize(it);
6357 _item_cache_zero(wd);
6362 EINA_INLIST_FOREACH(wd->blocks, itb)
6366 EINA_LIST_FOREACH(itb->items, l, it)
6368 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6370 if(it->selected) _item_unselect(it);
6371 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
6378 if (wd->calc_job) ecore_job_del(wd->calc_job);
6379 wd->calc_job = ecore_job_add(_calc_job, wd);
6383 * Set a given item's rename mode
6385 * This renames the item's label from genlist
6387 * @param it The item
6388 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6393 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
6399 _item_unrealize(it, EINA_FALSE);
6400 it->renamed = EINA_TRUE;
6401 it->wd->rename_it = it;
6402 it->nocache = EINA_TRUE;
6403 if (it->selected) _item_unselect(it);
6405 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
6406 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
6412 it->renamed = EINA_FALSE;
6413 it->nocache = EINA_TRUE;
6414 it->wd->rename_it = NULL;
6415 _item_cache_zero(it->wd);
6416 elm_genlist_item_update(it);
6422 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
6424 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6425 return item->renamed;
6429 _item_auto_scroll(void *data)
6431 Widget_Data *wd = data;
6434 if ((wd->expand_item) && (!wd->auto_scrolled))
6436 Elm_Genlist_Item *it;
6438 Evas_Coord ox, oy, ow, oh;
6439 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6441 wd->auto_scrolled = EINA_TRUE;
6442 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6444 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6446 elm_genlist_item_bring_in(it);
6453 * Update the contents of all realized items
6455 * This updates all realized items by calling all the item class functions again
6456 * to get the icons, labels and states. Use this when the original
6457 * item data has changed and the changes are desired to be reflected.
6459 * @param it The item
6464 elm_genlist_realized_items_update(Evas_Object *obj)
6466 ELM_CHECK_WIDTYPE(obj, widtype);
6468 Eina_List *list, *l;
6469 Elm_Genlist_Item *it;
6471 list = elm_genlist_realized_items_get(obj);
6472 EINA_LIST_FOREACH(list, l, it)
6473 elm_genlist_item_update(it);
6477 * Set genlist item mode
6479 * @param item The genlist item
6480 * @param mode Mode name
6481 * @param mode_set Boolean to define set or unset mode.
6486 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
6487 const char *mode_type,
6490 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6491 Widget_Data *wd = it->wd;
6493 Elm_Genlist_Item *it2;
6496 if (!mode_type) return;
6497 if ((it->delete_me) || (it->disabled)) return;
6499 if ((wd->mode_item == it) &&
6500 (!strcmp(mode_type, wd->mode_type)) &&
6503 if (!it->itc->mode_item_style) return;
6507 EINA_LIST_FOREACH(wd->selected, l, it2)
6509 elm_genlist_item_selected_set(it2, EINA_FALSE);
6513 it2 = elm_genlist_selected_item_get(wd->obj);
6514 if ((it2) && (it2->realized))
6515 elm_genlist_item_selected_set(it2, EINA_FALSE);
6518 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
6520 ((it == wd->mode_item) && (!mode_set)))
6521 _item_mode_unset(wd);
6523 eina_stringshare_replace(&wd->mode_type, mode_type);
6524 if (mode_set) _item_mode_set(it);
6528 * Get active genlist mode type
6530 * @param obj The genlist object
6535 elm_genlist_mode_get(const Evas_Object *obj)
6537 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6538 Widget_Data *wd = elm_widget_data_get(obj);
6539 if (!wd) return NULL;
6540 return wd->mode_type;
6544 * Get active genlist mode item
6546 * @param obj The genlist object
6550 EAPI const Elm_Genlist_Item *
6551 elm_genlist_mode_item_get(const Evas_Object *obj)
6553 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6554 Widget_Data *wd = elm_widget_data_get(obj);
6555 if (!wd) return NULL;
6556 return wd->mode_item;