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;
332 Eina_Bool contracting : 1;
335 Elm_Genlist_Item *reorder_it, *reorder_rel;
336 Evas_Coord reorder_start_y;
337 Ecore_Animator *item_moving_effect_timer;
338 Evas_Object *alpha_bg;
339 Elm_Genlist_Item *expand_item;
340 Evas_Coord expand_item_end;
341 Evas_Coord expand_item_gap;
342 int move_effect_mode;
343 unsigned int start_time;
344 Ecore_Job *changed_job;
345 Elm_Genlist_Item *rename_it;
346 const char *mode_type;
347 Elm_Genlist_Item *mode_item;
348 Ecore_Timer *scr_hold_timer;
358 Evas_Coord x, y, w, h, minw, minh;
359 Eina_Bool want_unrealize : 1;
360 Eina_Bool realized : 1;
361 Eina_Bool changed : 1;
362 Eina_Bool updateme : 1;
363 Eina_Bool showme : 1;
364 Eina_Bool must_recalc : 1;
368 struct _Elm_Genlist_Item
370 Elm_Widget_Item base;
375 Evas_Coord x, y, w, h, minw, minh;
376 const Elm_Genlist_Item_Class *itc;
377 Elm_Genlist_Item *parent;
378 Elm_Genlist_Item *group_item;
379 Elm_Genlist_Item_Flags flags;
387 Eina_List *labels, *icons, *states, *icon_objs;
388 Eina_List *mode_labels, *mode_icons, *mode_states, *mode_icon_objs;
389 Ecore_Timer *long_timer;
390 Ecore_Timer *swipe_timer;
392 Evas_Coord scrl_x, scrl_y;
394 Elm_Genlist_Item *rel;
395 Evas_Object *mode_view;
400 Elm_Tooltip_Item_Content_Cb content_cb;
401 Evas_Smart_Cb del_cb;
405 const char *mouse_cursor;
412 Eina_Bool before : 1;
414 Eina_Bool want_unrealize : 1;
415 Eina_Bool want_realize : 1;
416 Eina_Bool realized : 1;
417 Eina_Bool selected : 1;
418 Eina_Bool highlighted : 1;
419 Eina_Bool expanded : 1;
420 Eina_Bool disabled : 1;
421 Eina_Bool display_only : 1;
422 Eina_Bool mincalcd : 1;
423 Eina_Bool queued : 1;
424 Eina_Bool showme : 1;
425 Eina_Bool delete_me : 1;
427 Eina_Bool dragging : 1;
428 Eina_Bool updateme : 1;
429 Eina_Bool nocache : 1;
432 Eina_Bool move_effect_me : 1;
433 Eina_Bool effect_done : 1;
434 Eina_Bool reordering : 1;
435 Eina_Bool renamed : 1;
436 Eina_Bool effect_item_realized : 1;
437 Eina_List *edit_icon_objs;
438 Evas_Object *edit_obj;
440 Ecore_Animator *item_moving_effect_timer;
441 Evas_Coord old_scrl_x, old_scrl_y;
448 Evas_Object *base_view, *spacer;
450 const char *item_style; // it->itc->item_style
451 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
452 Eina_Bool compress : 1; // it->wd->compress
453 Eina_Bool odd : 1; // in & 0x1
455 Eina_Bool selected : 1; // it->selected
456 Eina_Bool disabled : 1; // it->disabled
457 Eina_Bool expanded : 1; // it->expanded
460 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
461 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
465 Evas_Object_Smart_Clipped_Data __clipped_data;
467 Ecore_Job *resize_job;
470 static const char *widtype = NULL;
471 static void _item_cache_zero(Widget_Data *wd);
472 static void _del_hook(Evas_Object *obj);
473 static void _mirrored_set(Evas_Object *obj,
475 static void _theme_hook(Evas_Object *obj);
476 static void _show_region_hook(void *data,
478 static void _sizing_eval(Evas_Object *obj);
479 static void _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc);
480 static void _item_block_unrealize(Item_Block *itb);
481 static void _calc_job(void *data);
482 static void _on_focus_hook(void *data,
484 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
485 static void _changed_job(void *data);
486 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
487 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
488 static Eina_Bool _item_single_select_up(Widget_Data *wd);
489 static Eina_Bool _item_single_select_down(Widget_Data *wd);
490 static Eina_Bool _event_hook(Evas_Object *obj,
492 Evas_Callback_Type type,
494 static void _signal_emit_hook(Evas_Object *obj,
495 const char *emission,
497 static Eina_Bool _deselect_all_items(Widget_Data *wd);
498 static void _pan_calculate(Evas_Object *obj);
499 static void _item_position(Elm_Genlist_Item *it, Evas_Object *obj);
500 static void _mode_item_realize(Elm_Genlist_Item *it);
501 static void _mode_item_unrealize(Elm_Genlist_Item *it);
502 static void _item_mode_set(Elm_Genlist_Item *it);
503 static void _item_mode_unset(Widget_Data *wd);
505 // TODO : refactoring
506 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
507 static unsigned int current_time_get();
508 static Eina_Bool _item_moving_effect_timer_cb(void *data);
509 static int _item_flip_effect_show(Elm_Genlist_Item *it);
510 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
511 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
512 static void _effect_item_unrealize(Elm_Genlist_Item *it);
513 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
514 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
515 static void _group_items_recalc(void *data);
516 static void _item_auto_scroll(void *data);
518 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
521 _event_hook(Evas_Object *obj,
522 Evas_Object *src __UNUSED__,
523 Evas_Callback_Type type,
526 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
527 Evas_Event_Key_Down *ev = event_info;
528 Widget_Data *wd = elm_widget_data_get(obj);
529 if (!wd) return EINA_FALSE;
530 if (!wd->items) return EINA_FALSE;
531 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
532 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
534 Elm_Genlist_Item *it = NULL;
537 Evas_Coord step_x = 0;
538 Evas_Coord step_y = 0;
541 Evas_Coord page_x = 0;
542 Evas_Coord page_y = 0;
544 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
545 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
546 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
547 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
549 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
553 else if ((!strcmp(ev->keyname, "Right")) ||
554 (!strcmp(ev->keyname, "KP_Right")))
558 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
560 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
561 (_item_multi_select_up(wd)))
562 || (_item_single_select_up(wd)))
564 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
570 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
572 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
573 (_item_multi_select_down(wd)))
574 || (_item_single_select_down(wd)))
576 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
582 else if ((!strcmp(ev->keyname, "Home")) ||
583 (!strcmp(ev->keyname, "KP_Home")))
585 it = elm_genlist_first_item_get(obj);
586 elm_genlist_item_bring_in(it);
587 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
590 else if ((!strcmp(ev->keyname, "End")) ||
591 (!strcmp(ev->keyname, "KP_End")))
593 it = elm_genlist_last_item_get(obj);
594 elm_genlist_item_bring_in(it);
595 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
598 else if ((!strcmp(ev->keyname, "Prior")) ||
599 (!strcmp(ev->keyname, "KP_Prior")))
602 y -= -(page_y * v_h) / 100;
606 else if ((!strcmp(ev->keyname, "Next")) ||
607 (!strcmp(ev->keyname, "KP_Next")))
610 y += -(page_y * v_h) / 100;
614 else if(((!strcmp(ev->keyname, "Return")) ||
615 (!strcmp(ev->keyname, "KP_Enter")) ||
616 (!strcmp(ev->keyname, "space")))
617 && (!wd->multi) && (wd->selected))
619 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
620 elm_genlist_item_expanded_set(it,
621 !elm_genlist_item_expanded_get(it));
623 else if (!strcmp(ev->keyname, "Escape"))
625 if (!_deselect_all_items(wd)) return EINA_FALSE;
626 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
629 else return EINA_FALSE;
631 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
632 elm_smart_scroller_child_pos_set(wd->scr, x, y);
637 _deselect_all_items(Widget_Data *wd)
639 if (!wd->selected) return EINA_FALSE;
641 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
647 _item_multi_select_up(Widget_Data *wd)
649 if (!wd->selected) return EINA_FALSE;
650 if (!wd->multi) return EINA_FALSE;
652 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
653 if (!prev) return EINA_TRUE;
655 if (elm_genlist_item_selected_get(prev))
657 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
658 wd->last_selected_item = prev;
659 elm_genlist_item_show(wd->last_selected_item);
663 elm_genlist_item_selected_set(prev, EINA_TRUE);
664 elm_genlist_item_show(prev);
670 _item_multi_select_down(Widget_Data *wd)
672 if (!wd->selected) return EINA_FALSE;
673 if (!wd->multi) return EINA_FALSE;
675 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
676 if (!next) return EINA_TRUE;
678 if (elm_genlist_item_selected_get(next))
680 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
681 wd->last_selected_item = next;
682 elm_genlist_item_show(wd->last_selected_item);
686 elm_genlist_item_selected_set(next, EINA_TRUE);
687 elm_genlist_item_show(next);
693 _item_single_select_up(Widget_Data *wd)
695 Elm_Genlist_Item *prev;
698 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
699 while ((prev) && (prev->delete_me))
700 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
702 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
704 if (!prev) return EINA_FALSE;
706 _deselect_all_items(wd);
708 elm_genlist_item_selected_set(prev, EINA_TRUE);
709 elm_genlist_item_show(prev);
714 _item_single_select_down(Widget_Data *wd)
716 Elm_Genlist_Item *next;
719 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
720 while ((next) && (next->delete_me))
721 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
723 else next = elm_genlist_item_next_get(wd->last_selected_item);
725 if (!next) return EINA_FALSE;
727 _deselect_all_items(wd);
729 elm_genlist_item_selected_set(next, EINA_TRUE);
730 elm_genlist_item_show(next);
735 _on_focus_hook(void *data __UNUSED__,
738 Widget_Data *wd = elm_widget_data_get(obj);
740 if (elm_widget_focus_get(obj))
742 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
743 evas_object_focus_set(wd->obj, EINA_TRUE);
744 if ((wd->selected) && (!wd->last_selected_item))
745 wd->last_selected_item = eina_list_data_get(wd->selected);
749 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
750 evas_object_focus_set(wd->obj, EINA_FALSE);
755 _del_hook(Evas_Object *obj)
757 Widget_Data *wd = elm_widget_data_get(obj);
759 _item_cache_zero(wd);
760 if (wd->calc_job) ecore_job_del(wd->calc_job);
761 if (wd->update_job) ecore_job_del(wd->update_job);
762 if (wd->queue_idle_enterer) ecore_idle_enterer_del(wd->queue_idle_enterer);
763 if (wd->changed_job) ecore_job_del(wd->changed_job);
764 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
765 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
766 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
767 if (wd->mode_type) eina_stringshare_del(wd->mode_type);
768 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
773 _del_pre_hook(Evas_Object *obj)
775 Widget_Data *wd = elm_widget_data_get(obj);
777 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE);
778 evas_object_del(wd->pan_smart);
779 wd->pan_smart = NULL;
780 elm_genlist_clear(obj);
784 _mirrored_set(Evas_Object *obj,
787 Widget_Data *wd = elm_widget_data_get(obj);
789 _item_cache_zero(wd);
790 elm_smart_scroller_mirrored_set(wd->scr, rtl);
794 _theme_hook(Evas_Object *obj)
796 Widget_Data *wd = elm_widget_data_get(obj);
799 evas_event_freeze(evas_object_evas_get(wd->obj));
800 _item_cache_zero(wd);
801 _elm_widget_mirrored_reload(obj);
802 _mirrored_set(obj, elm_widget_mirrored_get(obj));
803 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
804 elm_widget_style_get(obj));
805 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
806 wd->item_width = wd->item_height = 0;
807 wd->group_item_width = wd->group_item_height = 0;
808 wd->minw = wd->minh = wd->realminw = 0;
809 EINA_INLIST_FOREACH(wd->blocks, itb)
812 Elm_Genlist_Item *it;
814 if (itb->realized) _item_block_unrealize(itb);
815 EINA_LIST_FOREACH(itb->items, l, it)
816 it->mincalcd = EINA_FALSE;
818 itb->changed = EINA_TRUE;
820 if (wd->calc_job) ecore_job_del(wd->calc_job);
821 wd->calc_job = ecore_job_add(_calc_job, wd);
823 evas_event_thaw(evas_object_evas_get(wd->obj));
824 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
828 _show_region_hook(void *data,
831 Widget_Data *wd = elm_widget_data_get(data);
832 Evas_Coord x, y, w, h;
834 elm_widget_show_region_get(obj, &x, &y, &w, &h);
835 //x & y are screen coordinates, Add with pan coordinates
838 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
842 _sizing_eval(Evas_Object *obj)
844 Widget_Data *wd = elm_widget_data_get(obj);
845 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
847 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
848 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
850 if (wd->height_for_width)
854 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
855 if ((vw != 0) && (vw != wd->prev_viewport_w))
859 wd->prev_viewport_w = vw;
860 EINA_INLIST_FOREACH(wd->blocks, itb)
862 itb->must_recalc = EINA_TRUE;
864 if (wd->calc_job) ecore_job_del(wd->calc_job);
865 wd->calc_job = ecore_job_add(_calc_job, wd);
868 if (wd->mode == ELM_LIST_LIMIT)
870 Evas_Coord vmw, vmh, vw, vh;
874 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
875 if ((minw > 0) && (vw < minw)) vw = minw;
876 else if ((maxw > 0) && (vw > maxw))
878 edje_object_size_min_calc
879 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
886 edje_object_size_min_calc
887 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
891 evas_object_size_hint_min_set(obj, minw, minh);
892 evas_object_size_hint_max_set(obj, maxw, maxh);
896 _signal_emit_hook(Evas_Object *obj,
897 const char *emission,
900 Widget_Data *wd = elm_widget_data_get(obj);
901 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
906 _item_highlight(Elm_Genlist_Item *it)
908 const char *selectraise;
909 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) ||
910 (it->disabled) || (it->display_only) || (it->mode_view))
912 if (!it->wd->edit_mode)
913 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
914 selectraise = edje_object_data_get(it->base.view, "selectraise");
915 if ((selectraise) && (!strcmp(selectraise, "on")))
917 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
918 if ((it->group_item) && (it->group_item->realized))
919 evas_object_raise(it->group_item->base.view);
921 it->highlighted = EINA_TRUE;
925 _item_block_del(Elm_Genlist_Item *it)
928 Item_Block *itb = it->block;
930 itb->items = eina_list_remove(itb->items, it);
932 itb->changed = EINA_TRUE;
933 if (!it->wd->reorder_deleted)
935 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
936 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
940 il = EINA_INLIST_GET(itb);
941 Item_Block *itbn = (Item_Block *)(il->next);
943 it->parent->items = eina_list_remove(it->parent->items, it);
945 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
947 if (itbn) itbn->changed = EINA_TRUE;
951 if (itb->count < itb->wd->max_items_per_block/2)
953 il = EINA_INLIST_GET(itb);
954 Item_Block *itbp = (Item_Block *)(il->prev);
955 Item_Block *itbn = (Item_Block *)(il->next);
956 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
958 Elm_Genlist_Item *it2;
960 EINA_LIST_FREE(itb->items, it2)
963 itbp->items = eina_list_append(itbp->items, it2);
965 itbp->changed = EINA_TRUE;
967 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
968 EINA_INLIST_GET(itb));
971 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
975 Eina_List *last = eina_list_last(itb->items);
976 Elm_Genlist_Item *it2 = last->data;
979 itb->items = eina_list_remove_list(itb->items, last);
980 itbn->items = eina_list_prepend(itbn->items, it2);
982 itbn->changed = EINA_TRUE;
985 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
993 _item_subitems_clear(Elm_Genlist_Item *it)
996 Eina_List *tl = NULL, *l;
997 Elm_Genlist_Item *it2;
999 EINA_LIST_FOREACH(it->items, l, it2)
1000 tl = eina_list_append(tl, it2);
1002 EINA_LIST_FREE(tl, it2)
1003 elm_genlist_item_del(it2);
1007 _item_del(Elm_Genlist_Item *it)
1009 Evas_Object *tob = it->wd->obj;
1011 evas_event_freeze(evas_object_evas_get(tob));
1012 elm_widget_item_pre_notify_del(it);
1013 elm_genlist_item_subitems_clear(it);
1014 it->wd->walking -= it->walking;
1015 if (it->wd->show_item == it) it->wd->show_item = NULL;
1016 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1017 if (it->realized) _item_unrealize(it, EINA_FALSE);
1018 if (it->effect_item_realized) _effect_item_unrealize(it);
1019 if (it->block) _item_block_del(it);
1020 if ((!it->delete_me) && (it->itc->func.del))
1021 it->itc->func.del((void *)it->base.data, it->base.widget);
1022 it->delete_me = EINA_TRUE;
1024 it->wd->queue = eina_list_remove(it->wd->queue, it);
1026 if (it->wd->anchor_item == it)
1028 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1029 if (!it->wd->anchor_item)
1030 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1033 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1035 it->parent->items = eina_list_remove(it->parent->items, it);
1036 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1037 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1038 if (it->long_timer) ecore_timer_del(it->long_timer);
1039 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1041 if (it->tooltip.del_cb)
1042 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1044 evas_event_thaw(evas_object_evas_get(tob));
1045 evas_event_thaw_eval(evas_object_evas_get(tob));
1047 elm_widget_item_del(it);
1048 it->wd->total_num--; // todo : remove
1052 _item_select(Elm_Genlist_Item *it)
1054 if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
1057 if (it->wd->always_select) goto call;
1060 it->selected = EINA_TRUE;
1061 it->wd->selected = eina_list_append(it->wd->selected, it);
1065 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1067 evas_object_smart_callback_call(it->base.widget, "selected", it);
1070 if ((it->wd->clear_me) && (!it->wd->walking))
1072 elm_genlist_clear(it->base.widget);
1077 if ((!it->walking) && (it->delete_me))
1079 if (!it->relcount) _item_del(it);
1082 if (it && it->wd) it->wd->last_selected_item = it;
1086 _item_unselect(Elm_Genlist_Item *it)
1088 const char *stacking, *selectraise;
1090 if ((it->delete_me) || (!it->highlighted)) return;
1091 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1092 stacking = edje_object_data_get(it->base.view, "stacking");
1093 selectraise = edje_object_data_get(it->base.view, "selectraise");
1094 if ((selectraise) && (!strcmp(selectraise, "on")))
1096 if ((stacking) && (!strcmp(stacking, "below")))
1097 evas_object_lower(it->base.view);
1099 it->highlighted = EINA_FALSE;
1102 it->selected = EINA_FALSE;
1103 it->wd->selected = eina_list_remove(it->wd->selected, it);
1104 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1109 _mouse_move(void *data,
1110 Evas *evas __UNUSED__,
1114 Elm_Genlist_Item *it = data;
1115 Evas_Event_Mouse_Move *ev = event_info;
1116 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1118 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1120 if (!it->wd->on_hold)
1122 it->wd->on_hold = EINA_TRUE;
1123 if (!it->wd->wasselected)
1127 if (it->wd->multitouched)
1129 it->wd->cur_x = ev->cur.canvas.x;
1130 it->wd->cur_y = ev->cur.canvas.y;
1133 if ((it->dragging) && (it->down))
1135 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1138 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1139 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1140 if (abs((it->wd->history[it->wd->movements].x -
1141 it->wd->history[0].x)) > 40)
1142 it->wd->swipe = EINA_TRUE;
1144 it->wd->movements++;
1148 ecore_timer_del(it->long_timer);
1149 it->long_timer = NULL;
1151 evas_object_smart_callback_call(it->base.widget, "drag", it);
1154 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1158 ecore_timer_del(it->long_timer);
1159 it->long_timer = NULL;
1161 if (it->wd->reorder_mode && it->wd->reorder_it)
1163 Evas_Coord ox,oy,oh,ow;
1164 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1165 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1166 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1168 if (it_y < oy) _effect_item_controls(it, it->scrl_x, oy);
1169 else if (it_y + it->wd->reorder_it->h > oy+oh) _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1170 else _effect_item_controls(it, it->scrl_x, it_y);
1172 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1173 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1177 if (!it->display_only)
1178 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1179 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1180 x = ev->cur.canvas.x - x;
1181 y = ev->cur.canvas.y - y;
1184 if (adx < 0) adx = -dx;
1187 if (ady < 0) ady = -dy;
1190 if ((adx > minw) || (ady > minh))
1192 it->dragging = EINA_TRUE;
1195 ecore_timer_del(it->long_timer);
1196 it->long_timer = NULL;
1198 if (!it->wd->wasselected)
1203 evas_object_smart_callback_call(it->base.widget,
1204 "drag,start,up", it);
1208 evas_object_smart_callback_call(it->base.widget,
1209 "drag,start,left", it);
1211 evas_object_smart_callback_call(it->base.widget,
1212 "drag,start,right", it);
1218 evas_object_smart_callback_call(it->base.widget,
1219 "drag,start,down", it);
1223 evas_object_smart_callback_call(it->base.widget,
1224 "drag,start,left", it);
1226 evas_object_smart_callback_call(it->base.widget,
1227 "drag,start,right", it);
1234 _long_press(void *data)
1236 Elm_Genlist_Item *it = data;
1237 Elm_Genlist_Item *it_tmp;
1238 static Eina_Bool done = EINA_FALSE;
1239 //static Eina_Bool contracted = EINA_FALSE;
1243 it->long_timer = NULL;
1244 if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it))
1245 return ECORE_CALLBACK_CANCEL;
1246 it->wd->longpressed = EINA_TRUE;
1247 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1248 if ((it->wd->reorder_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1250 it->wd->reorder_it = it;
1251 it->wd->reorder_start_y = 0;
1252 evas_object_raise(it->edit_obj);
1253 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1254 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1256 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1261 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1263 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1265 _item_unselect(it_tmp);
1277 EINA_LIST_FOREACH(it->items, l, it_tmp)
1279 if (elm_genlist_item_expanded_get(it_tmp))
1281 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1282 return ECORE_CALLBACK_RENEW;
1286 if (elm_genlist_item_expanded_get(it)) {
1287 elm_genlist_item_expanded_set(it, EINA_FALSE);
1288 return ECORE_CALLBACK_RENEW;
1292 return ECORE_CALLBACK_CANCEL;
1296 _swipe(Elm_Genlist_Item *it)
1301 if ((it->display_only) || (it->disabled)) return;
1302 it->wd->swipe = EINA_FALSE;
1303 for (i = 0; i < it->wd->movements; i++)
1305 sum += it->wd->history[i].x;
1306 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1309 sum /= it->wd->movements;
1310 if (abs(sum - it->wd->history[0].x) <= 10) return;
1311 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1315 _swipe_cancel(void *data)
1317 Elm_Genlist_Item *it = data;
1319 if (!it) return ECORE_CALLBACK_CANCEL;
1320 it->wd->swipe = EINA_FALSE;
1321 it->wd->movements = 0;
1322 return ECORE_CALLBACK_RENEW;
1326 _multi_cancel(void *data)
1328 Widget_Data *wd = data;
1330 if (!wd) return ECORE_CALLBACK_CANCEL;
1331 wd->multi_timeout = EINA_TRUE;
1332 return ECORE_CALLBACK_RENEW;
1336 _multi_touch_gesture_eval(void *data)
1338 Elm_Genlist_Item *it = data;
1340 it->wd->multitouched = EINA_FALSE;
1341 if (it->wd->multi_timer)
1343 ecore_timer_del(it->wd->multi_timer);
1344 it->wd->multi_timer = NULL;
1346 if (it->wd->multi_timeout)
1348 it->wd->multi_timeout = EINA_FALSE;
1352 Evas_Coord minw = 0, minh = 0;
1353 Evas_Coord off_x, off_y, off_mx, off_my;
1355 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1356 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1357 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1358 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1359 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1361 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1363 if ((off_x + off_mx) > (off_y + off_my))
1365 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1366 evas_object_smart_callback_call(it->base.widget,
1367 "multi,swipe,right", it);
1368 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1369 evas_object_smart_callback_call(it->base.widget,
1370 "multi,swipe,left", it);
1371 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1372 evas_object_smart_callback_call(it->base.widget,
1373 "multi,pinch,out", it);
1375 evas_object_smart_callback_call(it->base.widget,
1376 "multi,pinch,in", it);
1380 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1381 evas_object_smart_callback_call(it->base.widget,
1382 "multi,swipe,down", it);
1383 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1384 evas_object_smart_callback_call(it->base.widget,
1385 "multi,swipe,up", it);
1386 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1387 evas_object_smart_callback_call(it->base.widget,
1388 "multi,pinch,out", it);
1390 evas_object_smart_callback_call(it->base.widget,
1391 "multi,pinch,in", it);
1394 it->wd->multi_timeout = EINA_FALSE;
1398 _multi_down(void *data,
1399 Evas *evas __UNUSED__,
1400 Evas_Object *obj __UNUSED__,
1403 Elm_Genlist_Item *it = data;
1404 Evas_Event_Multi_Down *ev = event_info;
1406 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1407 it->wd->multi_device = ev->device;
1408 it->wd->multi_down = EINA_TRUE;
1409 it->wd->multitouched = EINA_TRUE;
1410 it->wd->prev_mx = ev->canvas.x;
1411 it->wd->prev_my = ev->canvas.y;
1412 if (!it->wd->wasselected) _item_unselect(it);
1413 it->wd->wasselected = EINA_FALSE;
1414 it->wd->longpressed = EINA_FALSE;
1417 ecore_timer_del(it->long_timer);
1418 it->long_timer = NULL;
1422 it->dragging = EINA_FALSE;
1423 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1425 if (it->swipe_timer)
1427 ecore_timer_del(it->swipe_timer);
1428 it->swipe_timer = NULL;
1430 if (it->wd->on_hold)
1432 it->wd->swipe = EINA_FALSE;
1433 it->wd->movements = 0;
1434 it->wd->on_hold = EINA_FALSE;
1439 _multi_up(void *data,
1440 Evas *evas __UNUSED__,
1441 Evas_Object *obj __UNUSED__,
1444 Elm_Genlist_Item *it = data;
1445 Evas_Event_Multi_Up *ev = event_info;
1447 if (it->wd->multi_device != ev->device) return;
1448 it->wd->multi_device = 0;
1449 it->wd->multi_down = EINA_FALSE;
1450 if (it->wd->mouse_down) return;
1451 _multi_touch_gesture_eval(data);
1455 _multi_move(void *data,
1456 Evas *evas __UNUSED__,
1457 Evas_Object *obj __UNUSED__,
1460 Elm_Genlist_Item *it = data;
1461 Evas_Event_Multi_Move *ev = event_info;
1463 if (it->wd->multi_device != ev->device) return;
1464 it->wd->cur_mx = ev->cur.canvas.x;
1465 it->wd->cur_my = ev->cur.canvas.y;
1469 _mouse_down(void *data,
1470 Evas *evas __UNUSED__,
1474 Elm_Genlist_Item *it = data;
1475 Evas_Event_Mouse_Down *ev = event_info;
1478 if (ev->button != 1) return;
1479 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1481 it->wd->on_hold = EINA_TRUE;
1483 it->down = EINA_TRUE;
1484 it->dragging = EINA_FALSE;
1485 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1486 it->dx = ev->canvas.x - x;
1487 it->dy = ev->canvas.y - y;
1488 it->wd->mouse_down = EINA_TRUE;
1489 if (!it->wd->multitouched)
1491 it->wd->prev_x = ev->canvas.x;
1492 it->wd->prev_y = ev->canvas.y;
1493 it->wd->multi_timeout = EINA_FALSE;
1494 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1495 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1497 it->wd->longpressed = EINA_FALSE;
1498 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1499 else it->wd->on_hold = EINA_FALSE;
1500 if (it->wd->on_hold) return;
1501 it->wd->wasselected = it->selected;
1502 _item_highlight(it);
1503 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1504 if ((!it->disabled) && (!it->display_only))
1505 evas_object_smart_callback_call(it->base.widget, "clicked,double", it);
1506 if (it->long_timer) ecore_timer_del(it->long_timer);
1507 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1508 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1510 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1513 it->long_timer = NULL;
1514 it->wd->swipe = EINA_FALSE;
1515 it->wd->movements = 0;
1519 _mouse_up(void *data,
1520 Evas *evas __UNUSED__,
1521 Evas_Object *obj __UNUSED__,
1524 Elm_Genlist_Item *it = data;
1525 Evas_Event_Mouse_Up *ev = event_info;
1526 Eina_Bool dragged = EINA_FALSE;
1528 if (ev->button != 1) return;
1529 it->down = EINA_FALSE;
1530 it->wd->mouse_down = EINA_FALSE;
1531 if (it->wd->multitouched)
1533 // in single selection modes, some multi touching can make multi highlighted items.
1534 // if a item not selected and highlighted, it should be unhighlighted.
1535 if ((!it->wd->multi) && (!it->selected) && (it->highlighted)) _item_unselect(it);
1536 if (it->wd->multi_down) return;
1537 _multi_touch_gesture_eval(data);
1540 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1541 else it->wd->on_hold = EINA_FALSE;
1544 ecore_timer_del(it->long_timer);
1545 it->long_timer = NULL;
1549 it->dragging = EINA_FALSE;
1550 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1553 if (it->swipe_timer)
1555 ecore_timer_del(it->swipe_timer);
1556 it->swipe_timer = NULL;
1558 if (it->wd->multi_timer)
1560 ecore_timer_del(it->wd->multi_timer);
1561 it->wd->multi_timer = NULL;
1562 it->wd->multi_timeout = EINA_FALSE;
1564 if (it->wd->on_hold)
1566 if (it->wd->swipe) _swipe(data);
1567 it->wd->longpressed = EINA_FALSE;
1568 it->wd->on_hold = EINA_FALSE;
1571 if (it->wd->reorder_mode)
1573 Evas_Coord rox, roy, row, roh;
1574 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1577 Evas_Coord ox,oy,oh,ow;
1578 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1579 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1580 if (it->wd->reorder_rel)
1582 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1584 if (roy + oy <= it->wd->reorder_rel->scrl_y)
1585 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1587 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1590 it->wd->reorder_deleted = EINA_FALSE;
1591 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1592 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1593 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1596 if (it->wd->longpressed)
1598 it->wd->longpressed = EINA_FALSE;
1599 if (!it->wd->wasselected)
1601 it->wd->wasselected = EINA_FALSE;
1606 if (it->want_unrealize)
1608 _item_unrealize(it, EINA_FALSE);
1609 if (it->block->want_unrealize)
1610 _item_block_unrealize(it->block);
1613 if ((it->disabled) || (dragged) || (it->display_only)) return;
1614 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1619 _item_highlight(it);
1622 else _item_unselect(it);
1628 Widget_Data *wd = it->wd;
1631 while (wd->selected) _item_unselect(wd->selected->data);
1636 const Eina_List *l, *l_next;
1637 Elm_Genlist_Item *it2;
1639 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1640 if (it2 != it) _item_unselect(it2);
1641 //_item_highlight(it);
1644 _item_highlight(it);
1650 _signal_expand_toggle(void *data,
1651 Evas_Object *obj __UNUSED__,
1652 const char *emission __UNUSED__,
1653 const char *source __UNUSED__)
1655 Elm_Genlist_Item *it = data;
1658 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1660 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1664 _signal_expand(void *data,
1665 Evas_Object *obj __UNUSED__,
1666 const char *emission __UNUSED__,
1667 const char *source __UNUSED__)
1669 Elm_Genlist_Item *it = data;
1672 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1676 _signal_contract(void *data,
1677 Evas_Object *obj __UNUSED__,
1678 const char *emission __UNUSED__,
1679 const char *source __UNUSED__)
1681 Elm_Genlist_Item *it = data;
1684 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1688 _scr_hold_timer_cb(void *data)
1690 if (!data) return ECORE_CALLBACK_CANCEL;
1691 Widget_Data *wd = data;
1692 elm_smart_scroller_hold_set(wd->scr, EINA_FALSE);
1693 wd->scr_hold_timer = NULL;
1694 return ECORE_CALLBACK_CANCEL;
1698 _mode_finished_signal_cb(void *data,
1700 const char *emission __UNUSED__,
1701 const char *source __UNUSED__)
1705 Elm_Genlist_Item *it = data;
1706 if ((it->delete_me) || (!it->realized) || (!it->mode_view)) return;
1708 Evas *te = evas_object_evas_get(obj);
1710 evas_event_freeze(te);
1711 it->nocache = EINA_FALSE;
1712 _mode_item_unrealize(it);
1713 snprintf(buf, sizeof(buf), "elm,state,%s,passive,finished", it->wd->mode_type);
1714 edje_object_signal_callback_del_full(obj, buf, "elm", _mode_finished_signal_cb, it);
1715 evas_event_thaw(te);
1716 evas_event_thaw_eval(te);
1720 _item_cache_clean(Widget_Data *wd)
1722 evas_event_freeze(evas_object_evas_get(wd->obj));
1723 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1727 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1728 wd->item_cache = eina_inlist_remove(wd->item_cache,
1729 wd->item_cache->last);
1730 wd->item_cache_count--;
1731 if (itc->spacer) evas_object_del(itc->spacer);
1732 if (itc->base_view) evas_object_del(itc->base_view);
1733 if (itc->item_style) eina_stringshare_del(itc->item_style);
1736 evas_event_thaw(evas_object_evas_get(wd->obj));
1737 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
1741 _item_cache_zero(Widget_Data *wd)
1743 int pmax = wd->item_cache_max;
1744 wd->item_cache_max = 0;
1745 _item_cache_clean(wd);
1746 wd->item_cache_max = pmax;
1750 _item_cache_add(Elm_Genlist_Item *it)
1754 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1755 if (it->wd->item_cache_max <= 0)
1757 evas_object_del(it->base.view);
1758 it->base.view = NULL;
1759 evas_object_del(it->spacer);
1761 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1762 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1766 it->wd->item_cache_count++;
1767 itc = calloc(1, sizeof(Item_Cache));
1770 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1771 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1774 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1775 EINA_INLIST_GET(itc));
1776 itc->spacer = it->spacer;
1778 itc->base_view = it->base.view;
1779 it->base.view = NULL;
1780 evas_object_hide(itc->base_view);
1781 evas_object_move(itc->base_view, -9999, -9999);
1782 itc->item_style = eina_stringshare_add(it->itc->item_style);
1783 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1784 itc->compress = (it->wd->compress);
1785 itc->odd = (it->order_num_in & 0x1);
1786 itc->selected = it->selected;
1787 itc->disabled = it->disabled;
1788 itc->expanded = it->expanded;
1791 ecore_timer_del(it->long_timer);
1792 it->long_timer = NULL;
1794 if (it->swipe_timer)
1796 ecore_timer_del(it->swipe_timer);
1797 it->swipe_timer = NULL;
1799 // FIXME: other callbacks?
1800 edje_object_signal_callback_del_full(itc->base_view,
1801 "elm,action,expand,toggle",
1802 "elm", _signal_expand_toggle, it);
1803 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1805 _signal_expand, it);
1806 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1807 "elm", _signal_contract, it);
1808 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1810 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1812 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1814 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1816 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1818 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1820 _item_cache_clean(it->wd);
1821 evas_event_thaw(evas_object_evas_get(it->wd->obj));
1822 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
1826 _item_cache_find(Elm_Genlist_Item *it)
1829 Eina_Bool tree = 0, odd;
1831 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1832 odd = (it->order_num_in & 0x1);
1833 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1835 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1837 if ((itc->tree == tree) &&
1838 (itc->odd == odd) &&
1839 (itc->compress == it->wd->compress) &&
1840 (!strcmp(it->itc->item_style, itc->item_style)))
1842 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1843 EINA_INLIST_GET(itc));
1844 it->wd->item_cache_count--;
1852 _item_cache_free(Item_Cache *itc)
1854 if (itc->spacer) evas_object_del(itc->spacer);
1855 if (itc->base_view) evas_object_del(itc->base_view);
1856 if (itc->item_style) eina_stringshare_del(itc->item_style);
1861 _item_realize(Elm_Genlist_Item *it,
1865 Elm_Genlist_Item *it2;
1866 const char *stacking;
1867 const char *treesize;
1869 int depth, tsize = 20;
1870 Item_Cache *itc = NULL;
1872 if ((it->realized) || (it->delete_me)) return;
1873 evas_event_freeze(evas_object_evas_get(it->wd->obj));
1874 it->order_num_in = in;
1875 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1876 if ((it->nocache) && (!it->renamed))
1877 it->nocache = EINA_FALSE;
1879 itc = _item_cache_find(it);
1880 if (itc && (!it->wd->effect_mode))
1882 it->base.view = itc->base_view;
1883 itc->base_view = NULL;
1884 it->spacer = itc->spacer;
1889 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1890 edje_object_scale_set(it->base.view,
1891 elm_widget_scale_get(it->base.widget) *
1892 _elm_config->scale);
1893 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1894 elm_widget_sub_object_add(it->base.widget, it->base.view);
1896 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1897 strncpy(buf, "tree", sizeof(buf));
1898 else strncpy(buf, "item", sizeof(buf));
1899 if (it->wd->compress)
1900 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1902 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1903 strncat(buf, "/", sizeof(buf) - strlen(buf));
1904 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1906 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1907 elm_widget_style_get(it->base.widget));
1908 edje_object_mirrored_set(it->base.view,
1909 elm_widget_mirrored_get(it->base.widget));
1911 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1912 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1913 elm_widget_sub_object_add(it->base.widget, it->spacer);
1915 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1917 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1919 it->expanded_depth = depth;
1920 treesize = edje_object_data_get(it->base.view, "treesize");
1921 if (treesize) tsize = atoi(treesize);
1922 evas_object_size_hint_min_set(it->spacer,
1923 (depth * tsize) * _elm_config->scale, 1);
1924 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1927 edje_object_signal_callback_add(it->base.view,
1928 "elm,action,expand,toggle",
1929 "elm", _signal_expand_toggle, it);
1930 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1931 "elm", _signal_expand, it);
1932 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1933 "elm", _signal_contract, it);
1934 stacking = edje_object_data_get(it->base.view, "stacking");
1937 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1938 else if (!strcmp(stacking, "above"))
1939 evas_object_raise(it->base.view);
1941 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1943 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1945 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1947 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1949 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1951 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1955 if (it->selected != itc->selected)
1957 if ((it->selected) && (!it->wd->edit_mode))
1958 edje_object_signal_emit(it->base.view,
1959 "elm,state,selected", "elm");
1961 if (it->disabled != itc->disabled)
1964 edje_object_signal_emit(it->base.view,
1965 "elm,state,disabled", "elm");
1967 if (it->expanded != itc->expanded)
1970 edje_object_signal_emit(it->base.view,
1971 "elm,state,expanded", "elm");
1976 if ((it->selected) && (!it->wd->edit_mode))
1977 edje_object_signal_emit(it->base.view,
1978 "elm,state,selected", "elm");
1980 edje_object_signal_emit(it->base.view,
1981 "elm,state,disabled", "elm");
1983 edje_object_signal_emit(it->base.view,
1984 "elm,state,expanded", "elm");
1988 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1990 /* homogenous genlist shortcut */
1993 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1995 it->w = it->minw = it->wd->group_item_width;
1996 it->h = it->minh = it->wd->group_item_height;
2000 it->w = it->minw = it->wd->item_width;
2001 it->h = it->minh = it->wd->item_height;
2003 it->mincalcd = EINA_TRUE;
2008 if (it->itc->func.label_get)
2014 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2016 EINA_LIST_FOREACH(it->labels, l, key)
2018 char *s = it->itc->func.label_get
2019 ((void *)it->base.data, it->base.widget, l->data);
2023 edje_object_part_text_set(it->base.view, l->data, s);
2027 edje_object_part_text_set(it->base.view, l->data, "");
2030 if (it->itc->func.icon_get)
2036 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2038 EINA_LIST_FOREACH(it->icons, l, key)
2040 Evas_Object *ic = it->itc->func.icon_get
2041 ((void *)it->base.data, it->base.widget, l->data);
2045 it->icon_objs = eina_list_append(it->icon_objs, ic);
2046 edje_object_part_swallow(it->base.view, key, ic);
2047 evas_object_show(ic);
2048 elm_widget_sub_object_add(it->base.widget, ic);
2049 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2051 elm_widget_disabled_set(ic, EINA_TRUE);
2054 if (it->wd->rename_it && it->renamed)
2057 elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames"));
2058 EINA_LIST_FOREACH(it->icons, l, key)
2060 Evas_Object *ic = it->itc->func.icon_get
2061 ((void *)it->base.data, it->base.widget, l->data);
2064 it->icon_objs = eina_list_append(it->icon_objs, ic);
2065 edje_object_part_swallow(it->base.view, key, ic);
2066 evas_object_show(ic);
2067 elm_widget_sub_object_add(it->base.widget, ic);
2072 if (it->itc->func.state_get)
2078 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2080 EINA_LIST_FOREACH(it->states, l, key)
2082 Eina_Bool on = it->itc->func.state_get
2083 ((void *)it->base.data, it->base.widget, l->data);
2087 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2088 edje_object_signal_emit(it->base.view, buf, "elm");
2092 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2093 edje_object_signal_emit(it->base.view, buf, "elm");
2099 Evas_Coord mw = -1, mh = -1;
2101 if (it->wd->height_for_width) mw = it->wd->w;
2103 if (!it->display_only)
2104 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2105 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2106 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2108 if (!it->display_only)
2109 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2110 it->w = it->minw = mw;
2111 it->h = it->minh = mh;
2112 it->mincalcd = EINA_TRUE;
2114 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2116 it->wd->group_item_width = mw;
2117 it->wd->group_item_height = mh;
2119 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2121 it->wd->item_width = mw;
2122 it->wd->item_height = mh;
2125 if (!calc) evas_object_show(it->base.view);
2128 if (it->tooltip.content_cb)
2130 elm_widget_item_tooltip_content_cb_set(it,
2131 it->tooltip.content_cb,
2132 it->tooltip.data, NULL);
2133 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2136 if (it->mouse_cursor)
2137 elm_widget_item_cursor_set(it, it->mouse_cursor);
2139 it->realized = EINA_TRUE;
2140 it->want_unrealize = EINA_FALSE;
2142 if (itc) _item_cache_free(itc);
2143 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2144 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2145 if (!calc) 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);
2157 _item_unrealize(Elm_Genlist_Item *it, Eina_Bool calc)
2161 if (!it->realized) return;
2162 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2163 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2164 if (!calc) evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2167 ecore_timer_del(it->long_timer);
2168 it->long_timer = NULL;
2172 evas_object_del(it->base.view);
2173 it->base.view = NULL;
2174 evas_object_del(it->spacer);
2179 edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2180 _item_cache_add(it);
2182 elm_widget_stringlist_free(it->labels);
2184 elm_widget_stringlist_free(it->icons);
2186 elm_widget_stringlist_free(it->states);
2188 EINA_LIST_FREE(it->icon_objs, icon)
2189 evas_object_del(icon);
2191 _mode_item_unrealize(it);
2193 it->realized = EINA_FALSE;
2194 it->want_unrealize = EINA_FALSE;
2195 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2196 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2197 if (it->wd->edit_mode) _effect_item_unrealize(it);
2201 _item_block_recalc(Item_Block *itb,
2207 Elm_Genlist_Item *it;
2208 Evas_Coord minw = 0, minh = 0;
2209 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2212 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2214 EINA_LIST_FOREACH(itb->items, l, it)
2216 if (it->delete_me) continue;
2217 showme |= it->showme;
2222 if (!it->mincalcd) changed = EINA_TRUE;
2225 _item_realize(it, in, EINA_TRUE);
2226 _item_unrealize(it, EINA_TRUE);
2231 _item_realize(it, in, EINA_TRUE);
2232 if (!it->wd->contracting) _item_unrealize(it, EINA_TRUE);
2236 _item_realize(it, in, EINA_FALSE);
2238 if (minw < it->minw) minw = it->minw;
2246 itb->changed = EINA_FALSE;
2247 /* force an evas norender to garbage collect deleted objects */
2248 //if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2249 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2250 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2255 _item_block_realize(Item_Block *itb,
2260 Elm_Genlist_Item *it;
2262 if (itb->realized) return;
2263 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2264 EINA_LIST_FOREACH(itb->items, l, it)
2266 if (it->delete_me) continue;
2267 if (full) _item_realize(it, in, EINA_FALSE);
2270 itb->realized = EINA_TRUE;
2271 itb->want_unrealize = EINA_FALSE;
2272 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2273 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2277 _item_block_unrealize(Item_Block *itb)
2280 Elm_Genlist_Item *it;
2281 Eina_Bool dragging = EINA_FALSE;
2283 if (!itb->realized) return;
2284 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2285 EINA_LIST_FOREACH(itb->items, l, it)
2287 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2291 dragging = EINA_TRUE;
2292 it->want_unrealize = EINA_TRUE;
2295 if (!it->wd->contracting) _item_unrealize(it, EINA_FALSE);
2300 itb->realized = EINA_FALSE;
2301 itb->want_unrealize = EINA_TRUE;
2304 itb->want_unrealize = EINA_FALSE;
2305 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2306 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2310 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2312 Evas_Coord rox, roy, row, roh;
2313 Eina_Bool top = EINA_FALSE;
2314 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2315 if (!reorder_it) return 0;
2317 Evas_Coord ox,oy,oh,ow;
2318 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2319 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2321 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2323 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2324 if (it->block->count == 1)
2325 it->wd->reorder_rel = it;
2327 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2329 it->block->reorder_offset = it->wd->reorder_it->h;
2332 it->block->reorder_offset = 0;
2334 it->scrl_y += it->block->reorder_offset;
2336 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2337 rox, roy+roh/2, row, 1));
2340 it->wd->reorder_rel = it;
2341 it->scrl_y+=it->wd->reorder_it->h;
2342 return it->wd->reorder_it->h;
2349 _reorder_item_moving_effect_timer_cb(void *data)
2351 Elm_Genlist_Item *it = data;
2352 Eina_Bool down = EINA_FALSE;
2353 double time = 0.4, t;
2355 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2358 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2362 if (it->old_scrl_y < it->scrl_y)
2364 it->old_scrl_y += y;
2367 else if (it->old_scrl_y > it->scrl_y)
2369 it->old_scrl_y -= y;
2373 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2375 _group_items_recalc(it->wd);
2376 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2378 it->old_scrl_y = it->scrl_y;
2379 it->move_effect_me = EINA_FALSE;
2380 it->wd->item_moving_effect_timer = NULL;
2381 return ECORE_CALLBACK_CANCEL;
2383 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2385 it->old_scrl_y = it->scrl_y;
2386 it->move_effect_me = EINA_FALSE;
2387 it->wd->item_moving_effect_timer = NULL;
2388 return ECORE_CALLBACK_CANCEL;
2390 return ECORE_CALLBACK_RENEW;
2394 _item_position(Elm_Genlist_Item *it, Evas_Object *view)
2399 evas_event_freeze(evas_object_evas_get(it->wd->obj));
2400 evas_object_resize(view, it->w, it->h);
2401 evas_object_move(view, it->scrl_x, it->scrl_y);
2402 evas_object_show(view);
2403 evas_event_thaw(evas_object_evas_get(it->wd->obj));
2404 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
2408 _item_block_position(Item_Block *itb,
2412 Elm_Genlist_Item *it;
2413 Elm_Genlist_Item *git;
2414 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2417 evas_event_freeze(evas_object_evas_get(itb->wd->obj));
2418 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2419 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2421 EINA_LIST_FOREACH(itb->items, l, it)
2423 if (it->delete_me) continue;
2424 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2429 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2430 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2432 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2433 cvx, cvy, cvw, cvh));
2434 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2436 if ((itb->realized) && (!it->realized))
2440 _item_realize(it, in, EINA_FALSE);
2443 if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm");
2444 edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm");
2452 if(it->wd->reorder_mode)
2453 y += _get_space_for_reorder_item(it);
2454 git = it->group_item;
2457 git->scrl_x = it->scrl_x;
2458 if (git->scrl_y < oy)
2460 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2461 git->scrl_y = (it->scrl_y + it->h) - git->h;
2462 git->want_realize = EINA_TRUE;
2464 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2466 if (!it->move_effect_me)
2468 it->move_effect_me = EINA_TRUE;
2469 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2473 if (!it->move_effect_me )
2474 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))
2476 if (it->wd->edit_mode && it->itc->edit_item_style)
2478 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2482 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)))
2485 _item_position(it, it->mode_view);
2487 _item_position(it, it->base.view);
2491 evas_object_resize(it->base.view, it->w, it->h);
2492 evas_object_move(it->base.view, it->scrl_x, it->scrl_y);
2493 evas_object_hide(it->base.view);
2496 it->old_scrl_x = it->scrl_x;
2497 it->old_scrl_y = it->scrl_y;
2502 if (!it->dragging) _item_unrealize(it, EINA_FALSE);
2509 if (vis) it->want_realize = EINA_TRUE;
2513 evas_event_thaw(evas_object_evas_get(itb->wd->obj));
2514 evas_event_thaw_eval(evas_object_evas_get(itb->wd->obj));
2518 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2520 Elm_Genlist_Item *it = data;
2522 it->mincalcd = EINA_FALSE;
2523 it->block->updateme = EINA_TRUE;
2524 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2525 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2529 _group_items_recalc(void *data)
2531 Widget_Data *wd = data;
2533 Elm_Genlist_Item *git;
2535 evas_event_freeze(evas_object_evas_get(wd->obj));
2536 EINA_LIST_FOREACH(wd->group_items, l, git)
2538 if (git->want_realize)
2541 _item_realize(git, 0, EINA_FALSE);
2542 evas_object_resize(git->base.view, wd->minw, git->h);
2543 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2544 evas_object_show(git->base.view);
2545 evas_object_raise(git->base.view);
2547 else if (!git->want_realize && git->realized)
2550 _item_unrealize(git, EINA_FALSE);
2553 evas_event_thaw(evas_object_evas_get(wd->obj));
2554 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2558 _must_recalc_idler(void *data)
2560 Widget_Data *wd = data;
2561 if (wd->calc_job) ecore_job_del(wd->calc_job);
2562 wd->calc_job = ecore_job_add(_calc_job, wd);
2563 wd->must_recalc_idler = NULL;
2564 return ECORE_CALLBACK_CANCEL;
2568 _calc_job(void *data)
2570 Widget_Data *wd = data;
2572 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2573 Item_Block *chb = NULL;
2574 int in = 0, minw_change = 0;
2575 Eina_Bool changed = EINA_FALSE;
2577 Eina_Bool did_must_recalc = EINA_FALSE;
2580 t0 = ecore_time_get();
2581 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2585 // if (wd->height_for_width) changed = EINA_TRUE;
2588 evas_event_freeze(evas_object_evas_get(wd->obj));
2589 EINA_INLIST_FOREACH(wd->blocks, itb)
2591 Eina_Bool showme = EINA_FALSE;
2594 showme = itb->showme;
2595 itb->showme = EINA_FALSE;
2598 if (itb->realized) _item_block_unrealize(itb);
2600 if ((itb->changed) || (changed) ||
2601 ((itb->must_recalc) && (!did_must_recalc)))
2603 if ((changed) || (itb->must_recalc))
2606 Elm_Genlist_Item *it;
2607 EINA_LIST_FOREACH(itb->items, l, it)
2608 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2609 itb->changed = EINA_TRUE;
2610 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2611 itb->must_recalc = EINA_FALSE;
2613 if (itb->realized) _item_block_unrealize(itb);
2614 showme = _item_block_recalc(itb, in, 0, 1);
2620 if (minw == -1) minw = itb->minw;
2621 else if ((!itb->must_recalc) && (minw < itb->minw))
2630 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2632 wd->show_item->showme = EINA_FALSE;
2634 elm_smart_scroller_region_bring_in(wd->scr,
2636 wd->show_item->block->x,
2638 wd->show_item->block->y,
2639 wd->show_item->block->w,
2642 elm_smart_scroller_child_region_show(wd->scr,
2644 wd->show_item->block->x,
2646 wd->show_item->block->y,
2647 wd->show_item->block->w,
2649 wd->show_item = NULL;
2654 EINA_INLIST_FOREACH(wd->blocks, itb)
2660 if ((chb) && (EINA_INLIST_GET(chb)->next))
2662 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2664 if (itb->realized) _item_block_unrealize(itb);
2667 wd->realminw = minw;
2668 if (minw < wd->w) minw = wd->w;
2669 if ((minw != wd->minw) || (minh != wd->minh))
2673 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2674 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2675 _sizing_eval(wd->obj);
2677 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2679 Elm_Genlist_Item *it;
2682 it = wd->anchor_item;
2683 it_y = wd->anchor_y;
2684 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2685 it->block->y + it->y + it_y);
2686 wd->anchor_item = it;
2687 wd->anchor_y = it_y;
2691 t = ecore_time_get();
2692 if (did_must_recalc)
2694 if (!wd->must_recalc_idler)
2695 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2697 wd->calc_job = NULL;
2698 evas_object_smart_changed(wd->pan_smart);
2699 evas_event_thaw(evas_object_evas_get(wd->obj));
2700 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2704 _update_job(void *data)
2706 Widget_Data *wd = data;
2709 int num, num0, position = 0, recalc = 0;
2711 wd->update_job = NULL;
2714 evas_event_freeze(evas_object_evas_get(wd->obj));
2715 EINA_INLIST_FOREACH(wd->blocks, itb)
2717 Evas_Coord itminw, itminh;
2718 Elm_Genlist_Item *it;
2724 _item_block_position(itb, num);
2729 EINA_LIST_FOREACH(itb->items, l2, it)
2736 it->updateme = EINA_FALSE;
2739 _item_unrealize(it, EINA_FALSE);
2740 _item_realize(it, num, EINA_FALSE);
2745 _item_realize(it, num, EINA_TRUE);
2746 _item_unrealize(it, EINA_TRUE);
2748 if ((it->minw != itminw) || (it->minh != itminh))
2753 itb->updateme = EINA_FALSE;
2757 itb->changed = EINA_TRUE;
2758 _item_block_recalc(itb, num0, 0, 1);
2759 _item_block_position(itb, num0);
2764 if (wd->calc_job) ecore_job_del(wd->calc_job);
2765 wd->calc_job = ecore_job_add(_calc_job, wd);
2767 evas_event_thaw(evas_object_evas_get(wd->obj));
2768 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
2772 _changed_job(void *data)
2774 Widget_Data *wd = data; Eina_List *l2;
2776 int num, num0, position = 0;
2777 Eina_Bool width_changed = EINA_FALSE, height_changed = EINA_FALSE;
2779 wd->changed_job = NULL;
2781 EINA_INLIST_FOREACH(wd->blocks, itb)
2783 Evas_Coord itminw, itminh;
2784 Elm_Genlist_Item *it;
2790 _item_block_position(itb, num);
2794 width_changed = height_changed = EINA_FALSE;
2795 EINA_LIST_FOREACH(itb->items, l2, it)
2797 if ((!it->mincalcd) && (it->realized))
2799 Evas_Coord mw = -1, mh = -1;
2803 if (it->wd->height_for_width) mw = it->wd->w;
2804 if (!it->display_only)
2805 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2806 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2807 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2808 if (!it->display_only)
2809 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2810 it->w = it->minw = mw;
2811 it->h = it->minh = mh;
2812 it->mincalcd = EINA_TRUE;
2814 //if ((it->minw != itminw) || (it->minh != itminh))
2815 //if ((it->minh != itminh))
2817 if ((it->minw != itminw))
2818 width_changed = EINA_TRUE;
2819 if ((it->minh != itminh))
2820 height_changed = EINA_TRUE;
2822 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2824 it->wd->group_item_width = mw;
2825 it->wd->group_item_height = mh;
2827 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2829 it->wd->item_width = mw;
2830 it->wd->item_height = mh;
2835 itb->updateme = EINA_FALSE;
2836 // TODO: why this is separated.
2840 itb->changed = EINA_TRUE;
2841 _item_block_recalc(itb, num0, 0, 1);
2842 _item_block_position(itb, num0);
2844 else if (width_changed)
2846 _item_block_position(itb, num0);
2851 if (wd->calc_job) ecore_job_del(wd->calc_job);
2852 wd->calc_job = ecore_job_add(_calc_job, wd);
2857 _pan_set(Evas_Object *obj,
2861 Pan *sd = evas_object_smart_data_get(obj);
2866 // Evas_Coord ow, oh;
2867 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2868 // ow = sd->wd->minw - ow;
2869 // if (ow < 0) ow = 0;
2870 // oh = sd->wd->minh - oh;
2871 // if (oh < 0) oh = 0;
2872 // if (x < 0) x = 0;
2873 // if (y < 0) y = 0;
2874 // if (x > ow) x = ow;
2875 // if (y > oh) y = oh;
2876 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2881 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2883 if ((itb->y + itb->h) > y)
2885 Elm_Genlist_Item *it;
2888 EINA_LIST_FOREACH(itb->items, l2, it)
2890 if ((itb->y + it->y) >= y)
2892 sd->wd->anchor_item = it;
2893 sd->wd->anchor_y = -(itb->y + it->y - y);
2901 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2905 _pan_get(Evas_Object *obj,
2909 Pan *sd = evas_object_smart_data_get(obj);
2911 if (x) *x = sd->wd->pan_x;
2912 if (y) *y = sd->wd->pan_y;
2916 _pan_max_get(Evas_Object *obj,
2920 Pan *sd = evas_object_smart_data_get(obj);
2923 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2924 ow = sd->wd->minw - ow;
2926 oh = sd->wd->minh - oh;
2933 _pan_min_get(Evas_Object *obj __UNUSED__,
2942 _pan_child_size_get(Evas_Object *obj,
2946 Pan *sd = evas_object_smart_data_get(obj);
2948 if (w) *w = sd->wd->minw;
2949 if (h) *h = sd->wd->minh;
2953 _pan_add(Evas_Object *obj)
2956 Evas_Object_Smart_Clipped_Data *cd;
2959 cd = evas_object_smart_data_get(obj);
2962 sd->__clipped_data = *cd;
2964 evas_object_smart_data_set(obj, sd);
2968 _pan_del(Evas_Object *obj)
2970 Pan *sd = evas_object_smart_data_get(obj);
2975 ecore_job_del(sd->resize_job);
2976 sd->resize_job = NULL;
2982 _pan_resize_job(void *data)
2985 _sizing_eval(sd->wd->obj);
2986 sd->resize_job = NULL;
2990 _pan_resize(Evas_Object *obj,
2994 Pan *sd = evas_object_smart_data_get(obj);
2997 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2998 if ((ow == w) && (oh == h)) return;
2999 if ((sd->wd->height_for_width) && (ow != w))
3001 if (sd->resize_job) ecore_job_del(sd->resize_job);
3002 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
3004 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3005 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3009 _pan_calculate(Evas_Object *obj)
3011 Pan *sd = evas_object_smart_data_get(obj);
3013 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
3014 static Evas_Coord old_pan_y = 0;
3016 Elm_Genlist_Item *git;
3019 evas_event_freeze(evas_object_evas_get(obj));
3020 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
3021 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
3022 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
3024 git->want_realize = EINA_FALSE;
3026 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
3028 itb->w = sd->wd->minw;
3029 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
3030 itb->y - sd->wd->pan_y + oy,
3032 cvx, cvy, cvw, cvh))
3034 if ((!itb->realized) || (itb->changed))
3035 _item_block_realize(itb, in, 0);
3036 _item_block_position(itb, in);
3040 if (itb->realized) _item_block_unrealize(itb);
3044 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
3045 _group_items_recalc(sd->wd);
3047 if (sd->wd->reorder_mode && sd->wd->reorder_it)
3049 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
3050 else sd->wd->reorder_pan_move = EINA_FALSE;
3051 evas_object_raise(sd->wd->reorder_it->edit_obj);
3052 old_pan_y = sd->wd->pan_y;
3055 if (sd->wd->effect_mode &&
3056 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
3057 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
3058 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
3060 if (!sd->wd->item_moving_effect_timer)
3062 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
3063 _item_flip_effect_show(sd->wd->expand_item);
3065 evas_object_raise(sd->wd->alpha_bg);
3066 evas_object_show(sd->wd->alpha_bg);
3067 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3068 sd->wd->start_time = current_time_get();
3069 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3072 else _item_auto_scroll(sd->wd);
3073 sd->wd->contracting = EINA_FALSE;
3074 evas_event_thaw(evas_object_evas_get(obj));
3075 evas_event_thaw_eval(evas_object_evas_get(obj));
3079 _pan_move(Evas_Object *obj,
3080 Evas_Coord x __UNUSED__,
3081 Evas_Coord y __UNUSED__)
3083 Pan *sd = evas_object_smart_data_get(obj);
3085 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3086 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3090 _hold_on(void *data __UNUSED__,
3092 void *event_info __UNUSED__)
3094 Widget_Data *wd = elm_widget_data_get(obj);
3096 elm_smart_scroller_hold_set(wd->scr, 1);
3100 _hold_off(void *data __UNUSED__,
3102 void *event_info __UNUSED__)
3104 Widget_Data *wd = elm_widget_data_get(obj);
3106 elm_smart_scroller_hold_set(wd->scr, 0);
3110 _freeze_on(void *data __UNUSED__,
3112 void *event_info __UNUSED__)
3114 Widget_Data *wd = elm_widget_data_get(obj);
3116 elm_smart_scroller_freeze_set(wd->scr, 1);
3120 _freeze_off(void *data __UNUSED__,
3122 void *event_info __UNUSED__)
3124 Widget_Data *wd = elm_widget_data_get(obj);
3126 elm_smart_scroller_freeze_set(wd->scr, 0);
3130 _scroll_edge_left(void *data,
3131 Evas_Object *scr __UNUSED__,
3132 void *event_info __UNUSED__)
3134 Evas_Object *obj = data;
3135 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3139 _scroll_edge_right(void *data,
3140 Evas_Object *scr __UNUSED__,
3141 void *event_info __UNUSED__)
3143 Evas_Object *obj = data;
3144 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3148 _scroll_edge_top(void *data,
3149 Evas_Object *scr __UNUSED__,
3150 void *event_info __UNUSED__)
3152 Evas_Object *obj = data;
3153 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3157 _scroll_edge_bottom(void *data,
3158 Evas_Object *scr __UNUSED__,
3159 void *event_info __UNUSED__)
3161 Evas_Object *obj = data;
3162 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3166 _mode_item_realize(Elm_Genlist_Item *it)
3170 if ((it->mode_view) || (it->delete_me)) return;
3172 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3173 it->mode_view = edje_object_add(evas_object_evas_get(it->base.widget));
3174 edje_object_scale_set(it->mode_view,
3175 elm_widget_scale_get(it->base.widget) *
3176 _elm_config->scale);
3177 evas_object_smart_member_add(it->mode_view, it->wd->pan_smart);
3178 elm_widget_sub_object_add(it->base.widget, it->mode_view);
3180 strncpy(buf, "item", sizeof(buf));
3181 if (it->wd->compress)
3182 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
3184 if (it->order_num_in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
3185 strncat(buf, "/", sizeof(buf) - strlen(buf));
3186 strncat(buf, it->itc->mode_item_style, sizeof(buf) - strlen(buf));
3188 _elm_theme_object_set(it->base.widget, it->mode_view, "genlist", buf,
3189 elm_widget_style_get(it->base.widget));
3190 //edje_object_mirrored_set(it->mode_view,
3191 // elm_widget_mirrored_get(it->base.widget));
3193 /* signal callback add */
3194 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_DOWN,
3196 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_UP,
3198 evas_object_event_callback_add(it->mode_view, EVAS_CALLBACK_MOUSE_MOVE,
3201 /* label_get, icon_get, state_get */
3202 if (it->itc->func.label_get)
3208 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3210 EINA_LIST_FOREACH(it->mode_labels, l, key)
3212 char *s = it->itc->func.label_get
3213 ((void *)it->base.data, it->base.widget, l->data);
3217 edje_object_part_text_set(it->mode_view, l->data, s);
3222 if (it->itc->func.icon_get)
3228 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3230 EINA_LIST_FOREACH(it->mode_icons, l, key)
3232 Evas_Object *ic = it->itc->func.icon_get
3233 ((void *)it->base.data, it->base.widget, l->data);
3237 it->mode_icon_objs = eina_list_append(it->mode_icon_objs, ic);
3238 edje_object_part_swallow(it->mode_view, key, ic);
3239 evas_object_show(ic);
3240 elm_widget_sub_object_add(it->base.widget, ic);
3242 elm_widget_disabled_set(ic, EINA_TRUE);
3246 if (it->itc->func.state_get)
3252 elm_widget_stringlist_get(edje_object_data_get(it->mode_view,
3254 EINA_LIST_FOREACH(it->mode_states, l, key)
3256 Eina_Bool on = it->itc->func.state_get
3257 ((void *)it->base.data, it->base.widget, l->data);
3261 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
3262 edje_object_signal_emit(it->mode_view, buf, "elm");
3267 edje_object_part_swallow(it->mode_view,
3268 edje_object_data_get(it->mode_view, "mode_part"),
3271 it->want_unrealize = EINA_FALSE;
3272 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3273 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3277 _mode_item_unrealize(Elm_Genlist_Item *it)
3279 Widget_Data *wd = it->wd;
3281 if (!it->mode_view) return;
3283 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3284 elm_widget_stringlist_free(it->mode_labels);
3285 it->mode_labels = NULL;
3286 elm_widget_stringlist_free(it->mode_icons);
3287 it->mode_icons = NULL;
3288 elm_widget_stringlist_free(it->mode_states);
3290 EINA_LIST_FREE(it->mode_icon_objs, icon)
3291 evas_object_del(icon);
3293 edje_object_part_unswallow(it->mode_view, it->base.view);
3294 evas_object_smart_member_add(it->base.view, wd->pan_smart);
3295 evas_object_del(it->mode_view);
3296 it->mode_view = NULL;
3298 if (wd->mode_item == it)
3299 wd->mode_item = NULL;
3300 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3301 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3305 _item_mode_set(Elm_Genlist_Item *it)
3308 Widget_Data *wd = it->wd;
3313 it->nocache = EINA_TRUE;
3315 if (wd->scr_hold_timer)
3317 ecore_timer_del(wd->scr_hold_timer);
3318 wd->scr_hold_timer = NULL;
3320 elm_smart_scroller_hold_set(wd->scr, EINA_TRUE);
3321 wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, wd);
3323 evas_event_freeze(evas_object_evas_get(it->wd->obj));
3324 _mode_item_realize(it);
3325 _item_position(it, it->mode_view);
3326 evas_event_thaw(evas_object_evas_get(it->wd->obj));
3327 evas_event_thaw_eval(evas_object_evas_get(it->wd->obj));
3329 snprintf(buf, sizeof(buf), "elm,state,%s,active", wd->mode_type);
3330 edje_object_signal_emit(it->mode_view, buf, "elm");
3334 _item_mode_unset(Widget_Data *wd)
3337 if (!wd->mode_item) return;
3338 char buf[1024], buf2[1024];
3339 Elm_Genlist_Item *it;
3342 it->nocache = EINA_TRUE;
3344 snprintf(buf, sizeof(buf), "elm,state,%s,passive", wd->mode_type);
3345 snprintf(buf2, sizeof(buf2), "elm,state,%s,passive,finished", wd->mode_type);
3347 edje_object_signal_emit(it->mode_view, buf, "elm");
3348 edje_object_signal_callback_add(it->mode_view, buf2, "elm", _mode_finished_signal_cb, it);
3350 wd->mode_item = NULL;
3354 * Add a new Genlist object
3356 * @param parent The parent object
3357 * @return The new object or NULL if it cannot be created
3362 elm_genlist_add(Evas_Object *parent)
3367 Evas_Coord minw, minh;
3368 static Evas_Smart *smart = NULL;
3372 static Evas_Smart_Class sc;
3374 evas_object_smart_clipped_smart_set(&_pan_sc);
3376 sc.name = "elm_genlist_pan";
3377 sc.version = EVAS_SMART_CLASS_VERSION;
3380 sc.resize = _pan_resize;
3381 sc.move = _pan_move;
3382 sc.calculate = _pan_calculate;
3383 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3386 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
3388 ELM_SET_WIDTYPE(widtype, "genlist");
3389 elm_widget_type_set(obj, "genlist");
3390 elm_widget_sub_object_add(parent, obj);
3391 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3392 elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
3393 elm_widget_data_set(obj, wd);
3394 elm_widget_del_hook_set(obj, _del_hook);
3395 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3396 elm_widget_theme_hook_set(obj, _theme_hook);
3397 elm_widget_can_focus_set(obj, EINA_TRUE);
3398 elm_widget_event_hook_set(obj, _event_hook);
3399 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3401 wd->scr = elm_smart_scroller_add(e);
3402 elm_smart_scroller_widget_set(wd->scr, obj);
3403 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3404 elm_widget_style_get(obj));
3405 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3406 _elm_config->thumbscroll_bounce_enable);
3407 elm_widget_resize_object_set(obj, wd->scr);
3409 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3410 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3412 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3413 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3417 wd->mode = ELM_LIST_SCROLL;
3418 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3419 wd->item_cache_max = wd->max_items_per_block * 2;
3420 wd->longpress_timeout = _elm_config->longpress_timeout;
3421 wd->effect_mode = _elm_config->effect_enable;
3423 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3424 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3425 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3426 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3428 wd->pan_smart = evas_object_smart_add(e, smart);
3429 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3432 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3433 _pan_set, _pan_get, _pan_max_get,
3434 _pan_min_get, _pan_child_size_get);
3436 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3438 evas_object_size_hint_min_set(obj, minw, minh);
3440 _mirrored_set(obj, elm_widget_mirrored_get(obj));
3445 static Elm_Genlist_Item *
3446 _item_new(Widget_Data *wd,
3447 const Elm_Genlist_Item_Class *itc,
3449 Elm_Genlist_Item *parent,
3450 Elm_Genlist_Item_Flags flags,
3452 const void *func_data)
3454 Elm_Genlist_Item *it;
3456 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3457 if (!it) return NULL;
3460 it->base.data = data;
3461 it->parent = parent;
3463 it->func.func = func;
3464 it->func.data = func_data;
3465 it->mouse_cursor = NULL;
3466 it->expanded_depth = 0;
3467 it->num = ++wd->total_num; // todo : remove
3472 _item_block_add(Widget_Data *wd,
3473 Elm_Genlist_Item *it)
3475 Item_Block *itb = NULL;
3482 itb = calloc(1, sizeof(Item_Block));
3485 if (!it->rel->block)
3488 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3489 itb->items = eina_list_append(itb->items, it);
3495 wd->blocks = eina_inlist_prepend_relative
3496 (wd->blocks, EINA_INLIST_GET(itb),
3497 EINA_INLIST_GET(it->rel->block));
3499 eina_list_prepend_relative(itb->items, it, it->rel);
3503 wd->blocks = eina_inlist_append_relative
3504 (wd->blocks, EINA_INLIST_GET(itb),
3505 EINA_INLIST_GET(it->rel->block));
3507 eina_list_append_relative(itb->items, it, it->rel);
3517 itb = (Item_Block *)(wd->blocks);
3518 if (itb->count >= wd->max_items_per_block)
3520 itb = calloc(1, sizeof(Item_Block));
3524 eina_inlist_prepend(wd->blocks,
3525 EINA_INLIST_GET(itb));
3530 itb = calloc(1, sizeof(Item_Block));
3534 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3536 itb->items = eina_list_prepend(itb->items, it);
3542 itb = (Item_Block *)(wd->blocks->last);
3543 if (itb->count >= wd->max_items_per_block)
3545 itb = calloc(1, sizeof(Item_Block));
3549 eina_inlist_append(wd->blocks,
3550 EINA_INLIST_GET(itb));
3555 itb = calloc(1, sizeof(Item_Block));
3559 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3561 itb->items = eina_list_append(itb->items, it);
3567 itb = it->rel->block;
3568 if (!itb) goto newblock;
3570 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3572 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3575 itb->changed = EINA_TRUE;
3577 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3578 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3581 it->rel->relcount--;
3582 if ((it->rel->delete_me) && (!it->rel->relcount))
3586 if (itb->count > itb->wd->max_items_per_block)
3590 Elm_Genlist_Item *it2;
3592 newc = itb->count / 2;
3593 itb2 = calloc(1, sizeof(Item_Block));
3597 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3598 EINA_INLIST_GET(itb));
3599 itb2->changed = EINA_TRUE;
3600 while ((itb->count > newc) && (itb->items))
3604 l = eina_list_last(itb->items);
3606 itb->items = eina_list_remove_list(itb->items, l);
3609 itb2->items = eina_list_prepend(itb2->items, it2);
3617 _queue_process(Widget_Data *wd,
3621 Eina_Bool showme = EINA_FALSE;
3624 t0 = ecore_time_get();
3625 evas_event_freeze(evas_object_evas_get(wd->obj));
3626 for (n = 0; (wd->queue) && (n < 128); n++)
3628 Elm_Genlist_Item *it;
3630 it = wd->queue->data;
3631 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3632 it->queued = EINA_FALSE;
3633 _item_block_add(wd, it);
3634 t = ecore_time_get();
3635 if (it->block->changed)
3637 showme = _item_block_recalc(it->block, it->block->num, 1,
3639 it->block->changed = 0;
3641 if (showme) it->block->showme = EINA_TRUE;
3642 if (eina_inlist_count(wd->blocks) > 1)
3644 if ((t - t0) > (ecore_animator_frametime_get())) break;
3647 evas_event_thaw(evas_object_evas_get(wd->obj));
3648 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3653 _idle_process(void *data, Eina_Bool *wakeup)
3655 Widget_Data *wd = data;
3658 //static double q_start = 0.0;
3659 //if (q_start == 0.0) q_start = ecore_time_get();
3661 if (_queue_process(wd, 1) > 0) *wakeup = EINA_TRUE;
3665 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3667 return ECORE_CALLBACK_CANCEL;
3669 return ECORE_CALLBACK_RENEW;
3673 _item_idle_enterer(void *data)
3675 Widget_Data *wd = data;
3676 Eina_Bool wakeup = EINA_FALSE;
3677 Eina_Bool ok = _idle_process(data, &wakeup);
3682 if (wd->calc_job) ecore_job_del(wd->calc_job);
3683 wd->calc_job = ecore_job_add(_calc_job, wd);
3685 if (ok == ECORE_CALLBACK_CANCEL) wd->queue_idle_enterer = NULL;
3690 _item_queue(Widget_Data *wd,
3691 Elm_Genlist_Item *it)
3693 if (it->queued) return;
3694 it->queued = EINA_TRUE;
3695 wd->queue = eina_list_append(wd->queue, it);
3696 // FIXME: why does a freeze then thaw here cause some genlist
3697 // elm_genlist_item_append() to be much much slower?
3698 // evas_event_freeze(evas_object_evas_get(wd->obj));
3699 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3701 if (wd->queue_idle_enterer)
3703 ecore_idle_enterer_del(wd->queue_idle_enterer);
3704 wd->queue_idle_enterer = NULL;
3706 _queue_process(wd, 0);
3708 // evas_event_thaw(evas_object_evas_get(wd->obj));
3709 // evas_event_thaw_eval(evas_object_evas_get(wd->obj));
3710 if (!wd->queue_idle_enterer)
3711 wd->queue_idle_enterer = ecore_idle_enterer_add(_item_idle_enterer, wd);
3715 * Append item to the end of the genlist
3717 * This appends the given item to the end of the list or the end of
3718 * the children if the parent is given.
3720 * @param obj The genlist object
3721 * @param itc The item class for the item
3722 * @param data The item data
3723 * @param parent The parent item, or NULL if none
3724 * @param flags Item flags
3725 * @param func Convenience function called when item selected
3726 * @param func_data Data passed to @p func above.
3727 * @return A handle to the item added or NULL if not possible
3731 EAPI Elm_Genlist_Item *
3732 elm_genlist_item_append(Evas_Object *obj,
3733 const Elm_Genlist_Item_Class *itc,
3735 Elm_Genlist_Item *parent,
3736 Elm_Genlist_Item_Flags flags,
3738 const void *func_data)
3740 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3741 Widget_Data *wd = elm_widget_data_get(obj);
3742 if (!wd) return NULL;
3743 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3745 if (!it) return NULL;
3748 if (flags & ELM_GENLIST_ITEM_GROUP)
3749 wd->group_items = eina_list_append(wd->group_items, it);
3750 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3755 Elm_Genlist_Item *it2 = NULL;
3756 Eina_List *ll = eina_list_last(it->parent->items);
3757 if (ll) it2 = ll->data;
3758 it->parent->items = eina_list_append(it->parent->items, it);
3759 if (!it2) it2 = it->parent;
3761 it2 = elm_genlist_item_prev_get(it2);
3763 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3764 EINA_INLIST_GET(it2));
3766 it->rel->relcount++;
3768 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3769 it->group_item = parent;
3770 else if (it->parent->group_item)
3771 it->group_item = it->parent->group_item;
3773 it->before = EINA_FALSE;
3774 _item_queue(wd, it);
3779 * Prepend item at start of the genlist
3781 * This adds an item to the beginning of the list or beginning of the
3782 * children of the parent if given.
3784 * @param obj The genlist object
3785 * @param itc The item class for the item
3786 * @param data The item data
3787 * @param parent The parent item, or NULL if none
3788 * @param flags Item flags
3789 * @param func Convenience function called when item selected
3790 * @param func_data Data passed to @p func above.
3791 * @return A handle to the item added or NULL if not possible
3795 EAPI Elm_Genlist_Item *
3796 elm_genlist_item_prepend(Evas_Object *obj,
3797 const Elm_Genlist_Item_Class *itc,
3799 Elm_Genlist_Item *parent,
3800 Elm_Genlist_Item_Flags flags,
3802 const void *func_data)
3804 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3805 Widget_Data *wd = elm_widget_data_get(obj);
3806 if (!wd) return NULL;
3807 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3809 if (!it) return NULL;
3812 if (flags & ELM_GENLIST_ITEM_GROUP)
3813 wd->group_items = eina_list_prepend(wd->group_items, it);
3814 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3819 Elm_Genlist_Item *it2 = NULL;
3820 Eina_List *ll = it->parent->items;
3821 if (ll) it2 = ll->data;
3822 it->parent->items = eina_list_prepend(it->parent->items, it);
3823 if (!it2) it2 = it->parent;
3825 it2 = elm_genlist_item_next_get(it2);
3827 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3828 EINA_INLIST_GET(it2));
3830 it->rel->relcount++;
3832 it->before = EINA_TRUE;
3833 _item_queue(wd, it);
3838 * Insert item before another in the genlist
3840 * This inserts an item before another in the list. It will be in the
3841 * same tree level or group as the item it is inseted before.
3843 * @param obj The genlist object
3844 * @param itc The item class for the item
3845 * @param data The item data
3846 * @param before The item to insert before
3847 * @param flags Item flags
3848 * @param func Convenience function called when item selected
3849 * @param func_data Data passed to @p func above.
3850 * @return A handle to the item added or NULL if not possible
3854 EAPI Elm_Genlist_Item *
3855 elm_genlist_item_insert_before(Evas_Object *obj,
3856 const Elm_Genlist_Item_Class *itc,
3858 Elm_Genlist_Item *parent,
3859 Elm_Genlist_Item *before,
3860 Elm_Genlist_Item_Flags flags,
3862 const void *func_data)
3864 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3865 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3866 Widget_Data *wd = elm_widget_data_get(obj);
3867 if (!wd) return NULL;
3868 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3870 if (!it) return NULL;
3873 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3876 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3877 EINA_INLIST_GET(before));
3879 it->rel->relcount++;
3880 it->before = EINA_TRUE;
3881 _item_queue(wd, it);
3886 * Insert an item after another in the genlst
3888 * This inserts an item after another in the list. It will be in the
3889 * same tree level or group as the item it is inseted after.
3891 * @param obj The genlist object
3892 * @param itc The item class for the item
3893 * @param data The item data
3894 * @param after The item to insert after
3895 * @param flags Item flags
3896 * @param func Convenience function called when item selected
3897 * @param func_data Data passed to @p func above.
3898 * @return A handle to the item added or NULL if not possible
3902 EAPI Elm_Genlist_Item *
3903 elm_genlist_item_insert_after(Evas_Object *obj,
3904 const Elm_Genlist_Item_Class *itc,
3906 Elm_Genlist_Item *parent,
3907 Elm_Genlist_Item *after,
3908 Elm_Genlist_Item_Flags flags,
3910 const void *func_data)
3912 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3913 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3914 Widget_Data *wd = elm_widget_data_get(obj);
3915 if (!wd) return NULL;
3916 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3918 if (!it) return NULL;
3919 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3920 EINA_INLIST_GET(after));
3923 it->parent->items = eina_list_append_relative(it->parent->items, it,
3927 it->rel->relcount++;
3928 it->before = EINA_FALSE;
3929 _item_queue(wd, it);
3936 * This clears all items in the list, leaving it empty.
3938 * @param obj The genlist object
3943 elm_genlist_clear(Evas_Object *obj)
3945 ELM_CHECK_WIDTYPE(obj, widtype);
3946 Widget_Data *wd = elm_widget_data_get(obj);
3948 if (wd->walking > 0)
3950 Elm_Genlist_Item *it;
3952 wd->clear_me = EINA_TRUE;
3953 EINA_INLIST_FOREACH(wd->items, it)
3955 it->delete_me = EINA_TRUE;
3959 evas_event_freeze(evas_object_evas_get(wd->obj));
3962 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3963 it->nocache = EINA_TRUE;
3964 it->highlighted = EINA_FALSE;
3966 if (wd->anchor_item == it)
3968 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3969 if (!wd->anchor_item)
3971 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3974 wd->items = eina_inlist_remove(wd->items, wd->items);
3975 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3976 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3977 elm_widget_item_pre_notify_del(it);
3978 if (it->realized) _item_unrealize(it, EINA_FALSE);
3979 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3980 it->itc->func.del((void *)it->base.data, it->base.widget);
3981 if (it->long_timer) ecore_timer_del(it->long_timer);
3982 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3983 elm_widget_item_del(it);
3985 wd->clear_me = EINA_FALSE;
3986 wd->anchor_item = NULL;
3989 Item_Block *itb = (Item_Block *)(wd->blocks);
3991 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3992 if (itb->items) eina_list_free(itb->items);
3997 ecore_job_del(wd->calc_job);
3998 wd->calc_job = NULL;
4000 if (wd->queue_idle_enterer)
4002 ecore_idle_enterer_del(wd->queue_idle_enterer);
4003 wd->queue_idle_enterer = NULL;
4005 if (wd->must_recalc_idler)
4007 ecore_idler_del(wd->must_recalc_idler);
4008 wd->must_recalc_idler = NULL;
4012 eina_list_free(wd->queue);
4017 eina_list_free(wd->selected);
4018 wd->selected = NULL;
4020 if (wd->item_moving_effect_timer)
4022 ecore_animator_del(wd->item_moving_effect_timer);
4023 wd->item_moving_effect_timer = NULL;
4025 wd->show_item = NULL;
4032 evas_object_del(wd->alpha_bg);
4033 wd->alpha_bg = NULL;
4037 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
4038 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
4041 evas_event_thaw(evas_object_evas_get(wd->obj));
4042 evas_event_thaw_eval(evas_object_evas_get(wd->obj));
4046 * Enable or disable multi-select in the genlist
4048 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
4049 * the list. This allows more than 1 item to be selected.
4051 * @param obj The genlist object
4052 * @param multi Multi-select enable/disable
4057 elm_genlist_multi_select_set(Evas_Object *obj,
4060 ELM_CHECK_WIDTYPE(obj, widtype);
4061 Widget_Data *wd = elm_widget_data_get(obj);
4067 * Gets if multi-select in genlist is enable or disable
4069 * @param obj The genlist object
4070 * @return Multi-select enable/disable
4071 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
4076 elm_genlist_multi_select_get(const Evas_Object *obj)
4078 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4079 Widget_Data *wd = elm_widget_data_get(obj);
4080 if (!wd) return EINA_FALSE;
4085 * Get the selectd item in the genlist
4087 * This gets the selected item in the list (if multi-select is enabled
4088 * only the first item in the list is selected - which is not very
4089 * useful, so see elm_genlist_selected_items_get() for when
4090 * multi-select is used).
4092 * If no item is selected, NULL is returned.
4094 * @param obj The genlist object
4095 * @return The selected item, or NULL if none.
4099 EAPI Elm_Genlist_Item *
4100 elm_genlist_selected_item_get(const Evas_Object *obj)
4102 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4103 Widget_Data *wd = elm_widget_data_get(obj);
4104 if (!wd) return NULL;
4105 if (wd->selected) return wd->selected->data;
4110 * Get a list of selected items in the genlist
4112 * This returns a list of the selected items. This list pointer is
4113 * only valid so long as no items are selected or unselected (or
4114 * unselected implicitly by deletion). The list contains
4115 * Elm_Genlist_Item pointers.
4117 * @param obj The genlist object
4118 * @return The list of selected items, nor NULL if none are selected.
4122 EAPI const Eina_List *
4123 elm_genlist_selected_items_get(const Evas_Object *obj)
4125 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4126 Widget_Data *wd = elm_widget_data_get(obj);
4127 if (!wd) return NULL;
4128 return wd->selected;
4132 * Get a list of realized items in genlist
4134 * This returns a list of the realized items in the genlist. The list
4135 * contains Elm_Genlist_Item pointers. The list must be freed by the
4136 * caller when done with eina_list_free(). The item pointers in the
4137 * list are only valid so long as those items are not deleted or the
4138 * genlist is not deleted.
4140 * @param obj The genlist object
4141 * @return The list of realized items, nor NULL if none are realized.
4146 elm_genlist_realized_items_get(const Evas_Object *obj)
4148 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4149 Widget_Data *wd = elm_widget_data_get(obj);
4150 Eina_List *list = NULL;
4152 Eina_Bool done = EINA_FALSE;
4153 if (!wd) return NULL;
4154 EINA_INLIST_FOREACH(wd->blocks, itb)
4159 Elm_Genlist_Item *it;
4162 EINA_LIST_FOREACH(itb->items, l, it)
4164 if (it->realized) list = eina_list_append(list, it);
4176 * Get the item that is at the x, y canvas coords
4178 * This returns the item at the given coordinates (which are canvas
4179 * relative not object-relative). If an item is at that coordinate,
4180 * that item handle is returned, and if @p posret is not NULL, the
4181 * integer pointed to is set to a value of -1, 0 or 1, depending if
4182 * the coordinate is on the upper portion of that item (-1), on the
4183 * middle section (0) or on the lower part (1). If NULL is returned as
4184 * an item (no item found there), then posret may indicate -1 or 1
4185 * based if the coordinate is above or below all items respectively in
4188 * @param it The item
4189 * @param x The input x coordinate
4190 * @param y The input y coordinate
4191 * @param posret The position relative to the item returned here
4192 * @return The item at the coordinates or NULL if none
4196 EAPI Elm_Genlist_Item *
4197 elm_genlist_at_xy_item_get(const Evas_Object *obj,
4202 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4203 Widget_Data *wd = elm_widget_data_get(obj);
4204 Evas_Coord ox, oy, ow, oh;
4207 if (!wd) return NULL;
4208 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
4210 EINA_INLIST_FOREACH(wd->blocks, itb)
4213 Elm_Genlist_Item *it;
4215 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
4216 oy + itb->y - itb->wd->pan_y,
4217 itb->w, itb->h, x, y, 1, 1))
4219 EINA_LIST_FOREACH(itb->items, l, it)
4221 Evas_Coord itx, ity;
4223 itx = ox + itb->x + it->x - itb->wd->pan_x;
4224 ity = oy + itb->y + it->y - itb->wd->pan_y;
4225 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
4229 if (y <= (ity + (it->h / 4))) *posret = -1;
4230 else if (y >= (ity + it->h - (it->h / 4)))
4236 lasty = ity + it->h;
4241 if (y > lasty) *posret = 1;
4248 * Get the first item in the genlist
4250 * This returns the first item in the list.
4252 * @param obj The genlist object
4253 * @return The first item, or NULL if none
4257 EAPI Elm_Genlist_Item *
4258 elm_genlist_first_item_get(const Evas_Object *obj)
4260 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4261 Widget_Data *wd = elm_widget_data_get(obj);
4262 if (!wd) return NULL;
4263 if (!wd->items) return NULL;
4264 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4265 while ((it) && (it->delete_me))
4266 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4271 * Get the last item in the genlist
4273 * This returns the last item in the list.
4275 * @return The last item, or NULL if none
4279 EAPI Elm_Genlist_Item *
4280 elm_genlist_last_item_get(const Evas_Object *obj)
4282 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4283 Widget_Data *wd = elm_widget_data_get(obj);
4284 if (!wd) return NULL;
4285 if (!wd->items) return NULL;
4286 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4287 while ((it) && (it->delete_me))
4288 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4293 * Get the next item in the genlist
4295 * This returns the item after the item @p it.
4297 * @param it The item
4298 * @return The item after @p it, or NULL if none
4302 EAPI Elm_Genlist_Item *
4303 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4305 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4308 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4309 if ((it) && (!it->delete_me)) break;
4311 return (Elm_Genlist_Item *)it;
4315 * Get the previous item in the genlist
4317 * This returns the item before the item @p it.
4319 * @param it The item
4320 * @return The item before @p it, or NULL if none
4324 EAPI Elm_Genlist_Item *
4325 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4327 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4330 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4331 if ((it) && (!it->delete_me)) break;
4333 return (Elm_Genlist_Item *)it;
4337 * Get the genlist object from an item
4339 * This returns the genlist object itself that an item belongs to.
4341 * @param it The item
4342 * @return The genlist object
4347 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4349 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4350 return it->base.widget;
4354 * Get the parent item of the given item
4356 * This returns the parent item of the item @p it given.
4358 * @param it The item
4359 * @return The parent of the item or NULL if none
4363 EAPI Elm_Genlist_Item *
4364 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4366 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4371 * Clear all sub-items (children) of the given item
4373 * This clears all items that are children (or their descendants) of the
4376 * @param it The item
4381 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4383 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4384 Elm_Genlist_Item *it2;
4387 if (!it->wd->effect_mode || !it->wd->move_effect_mode)
4388 _item_subitems_clear(it);
4391 if ((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4392 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4394 it->wd->expand_item = it;
4395 _item_flip_effect_show(it);
4396 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4397 it->wd->expand_item_end = y + h;
4401 it2 = elm_genlist_item_next_get(it2);
4403 } while (it2->expanded_depth > it->expanded_depth);
4405 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4407 it->wd->expand_item_gap = 0;
4409 evas_object_raise(it->wd->alpha_bg);
4410 evas_object_show(it->wd->alpha_bg);
4412 it->wd->start_time = current_time_get();
4413 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4416 _item_subitems_clear(it);
4421 * Set the selected state of an item
4423 * This sets the selected state (1 selected, 0 not selected) of the given
4426 * @param it The item
4427 * @param selected The selected state
4432 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4435 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4436 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4438 if ((it->delete_me) || (it->disabled)) return;
4439 selected = !!selected;
4440 if (it->selected == selected) return;
4446 while (wd->selected)
4447 _item_unselect(wd->selected->data);
4449 _item_highlight(it);
4457 * Get the selected state of an item
4459 * This gets the selected state of an item (1 selected, 0 not selected).
4461 * @param it The item
4462 * @return The selected state
4467 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4469 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4470 return it->selected;
4474 * Sets the expanded state of an item (if it's a parent)
4476 * This expands or contracts a parent item (thus showing or hiding the
4479 * @param it The item
4480 * @param expanded The expanded state (1 expanded, 0 not expanded).
4485 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4488 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4489 if (it->expanded == expanded) return;
4490 it->expanded = expanded;
4491 it->wd->expand_item = it;
4493 if (it->wd->effect_mode && !it->wd->alpha_bg)
4494 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4498 it->wd->auto_scrolled = EINA_FALSE;
4499 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4501 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4502 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4506 it->wd->contracting = EINA_TRUE;
4507 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4509 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4510 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4515 * Get the expanded state of an item
4517 * This gets the expanded state of an item
4519 * @param it The item
4520 * @return Thre expanded state
4525 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4528 return it->expanded;
4532 * Get the depth of expanded item
4534 * @param it The genlist item object
4535 * @return The depth of expanded item
4540 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4542 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4543 return it->expanded_depth;
4547 * Sets the disabled state of an item.
4549 * A disabled item cannot be selected or unselected. It will also
4550 * change appearance to appear disabled. This sets the disabled state
4551 * (1 disabled, 0 not disabled).
4553 * @param it The item
4554 * @param disabled The disabled state
4559 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4562 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4565 if (it->disabled == disabled) return;
4566 if (it->delete_me) return;
4567 it->disabled = disabled;
4569 elm_genlist_item_selected_set(it, EINA_FALSE);
4573 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4575 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4576 EINA_LIST_FOREACH(it->icon_objs, l, obj)
4577 elm_widget_disabled_set(obj, disabled);
4582 * Get the disabled state of an item
4584 * This gets the disabled state of the given item.
4586 * @param it The item
4587 * @return The disabled state
4592 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4594 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4595 if (it->delete_me) return EINA_FALSE;
4596 return it->disabled;
4600 * Sets the display only state of an item.
4602 * A display only item cannot be selected or unselected. It is for
4603 * display only and not selecting or otherwise clicking, dragging
4604 * etc. by the user, thus finger size rules will not be applied to
4607 * @param it The item
4608 * @param display_only The display only state
4613 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4614 Eina_Bool display_only)
4616 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4617 if (it->display_only == display_only) return;
4618 if (it->delete_me) return;
4619 it->display_only = display_only;
4620 it->mincalcd = EINA_FALSE;
4621 it->updateme = EINA_TRUE;
4622 if (it->block) it->block->updateme = EINA_TRUE;
4623 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4624 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4628 * Get the display only state of an item
4630 * This gets the display only state of the given item.
4632 * @param it The item
4633 * @return The display only state
4638 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4640 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4641 if (it->delete_me) return EINA_FALSE;
4642 return it->display_only;
4646 * Show the given item
4648 * This causes genlist to jump to the given item @p it and show it (by
4649 * scrolling), if it is not fully visible.
4651 * @param it The item
4656 elm_genlist_item_show(Elm_Genlist_Item *it)
4658 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4659 Evas_Coord gith = 0;
4660 if (it->delete_me) return;
4661 if ((it->queued) || (!it->mincalcd))
4663 it->wd->show_item = it;
4664 it->wd->bring_in = EINA_TRUE;
4665 it->showme = EINA_TRUE;
4668 if (it->wd->show_item)
4670 it->wd->show_item->showme = EINA_FALSE;
4671 it->wd->show_item = NULL;
4673 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4674 gith = it->group_item->h;
4675 elm_smart_scroller_child_region_show(it->wd->scr,
4676 it->x + it->block->x,
4677 it->y + it->block->y - gith,
4678 it->block->w, it->h);
4682 * Bring in the given item
4684 * This causes genlist to jump to the given item @p it and show it (by
4685 * scrolling), if it is not fully visible. This may use animation to
4686 * do so and take a period of time
4688 * @param it The item
4693 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4695 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4696 Evas_Coord gith = 0;
4697 if (it->delete_me) return;
4698 if ((it->queued) || (!it->mincalcd))
4700 it->wd->show_item = it;
4701 it->wd->bring_in = EINA_TRUE;
4702 it->showme = EINA_TRUE;
4705 if (it->wd->show_item)
4707 it->wd->show_item->showme = EINA_FALSE;
4708 it->wd->show_item = NULL;
4710 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4711 gith = it->group_item->h;
4712 elm_smart_scroller_region_bring_in(it->wd->scr,
4713 it->x + it->block->x,
4714 it->y + it->block->y - gith,
4715 it->block->w, it->h);
4719 * Show the given item at the top
4721 * This causes genlist to jump to the given item @p it and show it (by
4722 * scrolling), if it is not fully visible.
4724 * @param it The item
4729 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4731 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4733 Evas_Coord gith = 0;
4735 if (it->delete_me) return;
4736 if ((it->queued) || (!it->mincalcd))
4738 it->wd->show_item = it;
4739 it->wd->bring_in = EINA_TRUE;
4740 it->showme = EINA_TRUE;
4743 if (it->wd->show_item)
4745 it->wd->show_item->showme = EINA_FALSE;
4746 it->wd->show_item = NULL;
4748 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4749 if (it->group_item) gith = it->group_item->h;
4750 elm_smart_scroller_child_region_show(it->wd->scr,
4751 it->x + it->block->x,
4752 it->y + it->block->y - gith,
4757 * Bring in the given item at the top
4759 * This causes genlist to jump to the given item @p it and show it (by
4760 * scrolling), if it is not fully visible. This may use animation to
4761 * do so and take a period of time
4763 * @param it The item
4768 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4770 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4772 Evas_Coord gith = 0;
4774 if (it->delete_me) return;
4775 if ((it->queued) || (!it->mincalcd))
4777 it->wd->show_item = it;
4778 it->wd->bring_in = EINA_TRUE;
4779 it->showme = EINA_TRUE;
4782 if (it->wd->show_item)
4784 it->wd->show_item->showme = EINA_FALSE;
4785 it->wd->show_item = NULL;
4787 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4788 if (it->group_item) gith = it->group_item->h;
4789 elm_smart_scroller_region_bring_in(it->wd->scr,
4790 it->x + it->block->x,
4791 it->y + it->block->y - gith,
4796 * Show the given item at the middle
4798 * This causes genlist to jump to the given item @p it and show it (by
4799 * scrolling), if it is not fully visible.
4801 * @param it The item
4806 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4808 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4811 if (it->delete_me) return;
4812 if ((it->queued) || (!it->mincalcd))
4814 it->wd->show_item = it;
4815 it->wd->bring_in = EINA_TRUE;
4816 it->showme = EINA_TRUE;
4819 if (it->wd->show_item)
4821 it->wd->show_item->showme = EINA_FALSE;
4822 it->wd->show_item = NULL;
4824 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4825 elm_smart_scroller_child_region_show(it->wd->scr,
4826 it->x + it->block->x,
4827 it->y + it->block->y - oh / 2 +
4828 it->h / 2, it->block->w, oh);
4832 * Bring in the given item at the middle
4834 * This causes genlist to jump to the given item @p it and show it (by
4835 * scrolling), if it is not fully visible. This may use animation to
4836 * do so and take a period of time
4838 * @param it The item
4843 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4845 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4848 if (it->delete_me) return;
4849 if ((it->queued) || (!it->mincalcd))
4851 it->wd->show_item = it;
4852 it->wd->bring_in = EINA_TRUE;
4853 it->showme = EINA_TRUE;
4856 if (it->wd->show_item)
4858 it->wd->show_item->showme = EINA_FALSE;
4859 it->wd->show_item = NULL;
4861 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4862 elm_smart_scroller_region_bring_in(it->wd->scr,
4863 it->x + it->block->x,
4864 it->y + it->block->y - oh / 2 + it->h / 2,
4869 * Delete a given item
4871 * This deletes the item from genlist and calls the genlist item del
4872 * class callback defined in the item class, if it is set. This clears all
4873 * subitems if it is a tree.
4875 * @param it The item
4880 elm_genlist_item_del(Elm_Genlist_Item *it)
4882 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4883 if ((it->relcount > 0) || (it->walking > 0))
4885 elm_widget_item_pre_notify_del(it);
4886 elm_genlist_item_subitems_clear(it);
4887 it->delete_me = EINA_TRUE;
4888 if (it->wd->show_item == it) it->wd->show_item = NULL;
4890 it->wd->selected = eina_list_remove(it->wd->selected,
4894 if (it->realized) _item_unrealize(it, EINA_FALSE);
4895 it->block->changed = EINA_TRUE;
4896 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4897 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4899 if (it->itc->func.del)
4900 it->itc->func.del((void *)it->base.data, it->base.widget);
4907 * Set the data item from the genlist item
4909 * This set the data value passed on the elm_genlist_item_append() and
4910 * related item addition calls. This function will also call
4911 * elm_genlist_item_update() so the item will be updated to reflect the
4914 * @param it The item
4915 * @param data The new data pointer to set
4920 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4923 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4924 elm_widget_item_data_set(it, data);
4925 elm_genlist_item_update(it);
4929 * Get the data item from the genlist item
4931 * This returns the data value passed on the elm_genlist_item_append()
4932 * and related item addition calls and elm_genlist_item_data_set().
4934 * @param it The item
4935 * @return The data pointer provided when created
4940 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4942 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4943 return elm_widget_item_data_get(it);
4947 * Tells genlist to "orphan" icons fetchs by the item class
4949 * This instructs genlist to release references to icons in the item,
4950 * meaning that they will no longer be managed by genlist and are
4951 * floating "orphans" that can be re-used elsewhere if the user wants
4954 * @param it The item
4959 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4962 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4963 EINA_LIST_FREE(it->icon_objs, icon)
4965 elm_widget_sub_object_del(it->base.widget, icon);
4966 evas_object_smart_member_del(icon);
4967 evas_object_hide(icon);
4972 * Get the real evas object of the genlist item
4974 * This returns the actual evas object used for the specified genlist
4975 * item. This may be NULL as it may not be created, and may be deleted
4976 * at any time by genlist. Do not modify this object (move, resize,
4977 * show, hide etc.) as genlist is controlling it. This function is for
4978 * querying, emitting custom signals or hooking lower level callbacks
4979 * for events. Do not delete this object under any circumstances.
4981 * @param it The item
4982 * @return The object pointer
4986 EAPI const Evas_Object *
4987 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4989 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4990 return it->base.view;
4994 * Update the contents of an item
4996 * This updates an item by calling all the item class functions again
4997 * to get the icons, labels and states. Use this when the original
4998 * item data has changed and the changes are desired to be reflected.
5000 * @param it The item
5005 elm_genlist_item_update(Elm_Genlist_Item *it)
5007 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5008 if (!it->block) return;
5009 if (it->delete_me) return;
5010 it->mincalcd = EINA_FALSE;
5011 it->updateme = EINA_TRUE;
5012 it->block->updateme = EINA_TRUE;
5013 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
5014 it->wd->update_job = ecore_job_add(_update_job, it->wd);
5018 * Update the item class of an item
5020 * @param it The item
5021 * @parem itc The item class for the item
5026 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
5027 const Elm_Genlist_Item_Class *itc)
5029 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
5030 if (!it->block) return;
5031 EINA_SAFETY_ON_NULL_RETURN(itc);
5032 if (it->delete_me) return;
5034 it->nocache = EINA_TRUE;
5035 elm_genlist_item_update(it);
5038 static Evas_Object *
5039 _elm_genlist_item_label_create(void *data,
5041 void *item __UNUSED__)
5043 Evas_Object *label = elm_label_add(obj);
5046 elm_object_style_set(label, "tooltip");
5047 elm_label_label_set(label, data);
5052 _elm_genlist_item_label_del_cb(void *data,
5053 Evas_Object *obj __UNUSED__,
5054 void *event_info __UNUSED__)
5056 eina_stringshare_del(data);
5060 * Set the text to be shown in the genlist item.
5062 * @param item Target item
5063 * @param text The text to set in the content
5065 * Setup the text as tooltip to object. The item can have only one
5066 * tooltip, so any previous tooltip data is removed.
5071 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
5074 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5075 text = eina_stringshare_add(text);
5076 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
5078 _elm_genlist_item_label_del_cb);
5082 * Set the content to be shown in the tooltip item
5084 * Setup the tooltip to item. The item can have only one tooltip, so
5085 * any previous tooltip data is removed. @p func(with @p data) will be
5086 * called every time that need to show the tooltip and it should return a
5087 * valid Evas_Object. This object is then managed fully by tooltip
5088 * system and is deleted when the tooltip is gone.
5090 * @param item the genlist item being attached by a tooltip.
5091 * @param func the function used to create the tooltip contents.
5092 * @param data what to provide to @a func as callback data/context.
5093 * @param del_cb called when data is not needed anymore, either when
5094 * another callback replaces @func, the tooltip is unset with
5095 * elm_genlist_item_tooltip_unset() or the owner @a item
5096 * dies. This callback receives as the first parameter the
5097 * given @a data, and @c event_info is the item.
5102 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
5103 Elm_Tooltip_Item_Content_Cb func,
5105 Evas_Smart_Cb del_cb)
5107 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
5109 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
5112 if (item->tooltip.del_cb)
5113 item->tooltip.del_cb((void *)item->tooltip.data,
5114 item->base.widget, item);
5116 item->tooltip.content_cb = func;
5117 item->tooltip.data = data;
5118 item->tooltip.del_cb = del_cb;
5120 if (item->base.view)
5122 elm_widget_item_tooltip_content_cb_set(item,
5123 item->tooltip.content_cb,
5124 item->tooltip.data, NULL);
5125 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
5131 if (del_cb) del_cb((void *)data, NULL, NULL);
5135 * Unset tooltip from item
5137 * @param item genlist item to remove previously set tooltip.
5139 * Remove tooltip from item. The callback provided as del_cb to
5140 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
5141 * it is not used anymore.
5143 * @see elm_genlist_item_tooltip_content_cb_set()
5148 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
5150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5151 if ((item->base.view) && (item->tooltip.content_cb))
5152 elm_widget_item_tooltip_unset(item);
5154 if (item->tooltip.del_cb)
5155 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
5156 item->tooltip.del_cb = NULL;
5157 item->tooltip.content_cb = NULL;
5158 item->tooltip.data = NULL;
5159 if (item->tooltip.style)
5160 elm_genlist_item_tooltip_style_set(item, NULL);
5164 * Sets a different style for this item tooltip.
5166 * @note before you set a style you should define a tooltip with
5167 * elm_genlist_item_tooltip_content_cb_set() or
5168 * elm_genlist_item_tooltip_text_set()
5170 * @param item genlist item with tooltip already set.
5171 * @param style the theme style to use (default, transparent, ...)
5176 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
5179 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5180 eina_stringshare_replace(&item->tooltip.style, style);
5181 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
5185 * Get the style for this item tooltip.
5187 * @param item genlist item with tooltip already set.
5188 * @return style the theme style in use, defaults to "default". If the
5189 * object does not have a tooltip set, then NULL is returned.
5194 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
5196 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5197 return item->tooltip.style;
5201 * Set the cursor to be shown when mouse is over the genlist item
5203 * @param item Target item
5204 * @param cursor the cursor name to be used.
5206 * @see elm_object_cursor_set()
5210 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
5213 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5214 eina_stringshare_replace(&item->mouse_cursor, cursor);
5215 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
5219 * Get the cursor to be shown when mouse is over the genlist item
5221 * @param item genlist item with cursor already set.
5222 * @return the cursor name.
5227 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
5229 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5230 return elm_widget_item_cursor_get(item);
5234 * Unset the cursor to be shown when mouse is over the genlist item
5236 * @param item Target item
5238 * @see elm_object_cursor_unset()
5242 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
5244 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5245 if (!item->mouse_cursor)
5248 if (item->base.view)
5249 elm_widget_item_cursor_unset(item);
5251 eina_stringshare_del(item->mouse_cursor);
5252 item->mouse_cursor = NULL;
5256 * Sets a different style for this item cursor.
5258 * @note before you set a style you should define a cursor with
5259 * elm_genlist_item_cursor_set()
5261 * @param item genlist item with cursor already set.
5262 * @param style the theme style to use (default, transparent, ...)
5267 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5270 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5271 elm_widget_item_cursor_style_set(item, style);
5275 * Get the style for this item cursor.
5277 * @param item genlist item with cursor already set.
5278 * @return style the theme style in use, defaults to "default". If the
5279 * object does not have a cursor set, then NULL is returned.
5284 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5286 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5287 return elm_widget_item_cursor_style_get(item);
5291 * Set if the cursor set should be searched on the theme or should use
5292 * the provided by the engine, only.
5294 * @note before you set if should look on theme you should define a
5295 * cursor with elm_object_cursor_set(). By default it will only look
5296 * for cursors provided by the engine.
5298 * @param item widget item with cursor already set.
5299 * @param engine_only boolean to define it cursors should be looked
5300 * only between the provided by the engine or searched on widget's
5306 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5307 Eina_Bool engine_only)
5309 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5310 elm_widget_item_cursor_engine_only_set(item, engine_only);
5314 * Get the cursor engine only usage for this item cursor.
5316 * @param item widget item with cursor already set.
5317 * @return engine_only boolean to define it cursors should be looked
5318 * only between the provided by the engine or searched on widget's
5319 * theme as well. If the object does not have a cursor set, then
5320 * EINA_FALSE is returned.
5325 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5327 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5328 return elm_widget_item_cursor_engine_only_get(item);
5332 * This sets the horizontal stretching mode
5334 * This sets the mode used for sizing items horizontally. Valid modes
5335 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5336 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5337 * the scroller will scroll horizontally. Otherwise items are expanded
5338 * to fill the width of the viewport of the scroller. If it is
5339 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5340 * limited to that size.
5342 * @param obj The genlist object
5343 * @param mode The mode to use
5348 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5351 ELM_CHECK_WIDTYPE(obj, widtype);
5352 Widget_Data *wd = elm_widget_data_get(obj);
5354 if (wd->mode == mode) return;
5360 * Gets the horizontal stretching mode
5362 * @param obj The genlist object
5363 * @return The mode to use
5364 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5369 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5371 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5372 Widget_Data *wd = elm_widget_data_get(obj);
5373 if (!wd) return ELM_LIST_LAST;
5378 * Set the always select mode.
5380 * Items will only call their selection func and callback when first
5381 * becoming selected. Any further clicks will do nothing, unless you
5382 * enable always select with elm_genlist_always_select_mode_set().
5383 * This means even if selected, every click will make the selected
5384 * callbacks be called.
5386 * @param obj The genlist object
5387 * @param always_select The always select mode
5388 * (EINA_TRUE = on, EINA_FALSE = off)
5393 elm_genlist_always_select_mode_set(Evas_Object *obj,
5394 Eina_Bool always_select)
5396 ELM_CHECK_WIDTYPE(obj, widtype);
5397 Widget_Data *wd = elm_widget_data_get(obj);
5399 wd->always_select = always_select;
5403 * Get the always select mode.
5405 * @param obj The genlist object
5406 * @return The always select mode
5407 * (EINA_TRUE = on, EINA_FALSE = off)
5412 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5414 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5415 Widget_Data *wd = elm_widget_data_get(obj);
5416 if (!wd) return EINA_FALSE;
5417 return wd->always_select;
5421 * Set no select mode
5423 * This will turn off the ability to select items entirely and they
5424 * will neither appear selected nor call selected callback functions.
5426 * @param obj The genlist object
5427 * @param no_select The no select mode
5428 * (EINA_TRUE = on, EINA_FALSE = off)
5433 elm_genlist_no_select_mode_set(Evas_Object *obj,
5434 Eina_Bool no_select)
5436 ELM_CHECK_WIDTYPE(obj, widtype);
5437 Widget_Data *wd = elm_widget_data_get(obj);
5439 wd->no_select = no_select;
5443 * Gets no select mode
5445 * @param obj The genlist object
5446 * @return The no select mode
5447 * (EINA_TRUE = on, EINA_FALSE = off)
5452 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5454 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5455 Widget_Data *wd = elm_widget_data_get(obj);
5456 if (!wd) return EINA_FALSE;
5457 return wd->no_select;
5463 * This will enable the compress mode where items are "compressed"
5464 * horizontally to fit the genlist scrollable viewport width. This is
5465 * special for genlist. Do not rely on
5466 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5467 * work as genlist needs to handle it specially.
5469 * @param obj The genlist object
5470 * @param compress The compress mode
5471 * (EINA_TRUE = on, EINA_FALSE = off)
5476 elm_genlist_compress_mode_set(Evas_Object *obj,
5479 ELM_CHECK_WIDTYPE(obj, widtype);
5480 Widget_Data *wd = elm_widget_data_get(obj);
5482 wd->compress = compress;
5486 * Get the compress mode
5488 * @param obj The genlist object
5489 * @return The compress mode
5490 * (EINA_TRUE = on, EINA_FALSE = off)
5495 elm_genlist_compress_mode_get(const Evas_Object *obj)
5497 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5498 Widget_Data *wd = elm_widget_data_get(obj);
5499 if (!wd) return EINA_FALSE;
5500 return wd->compress;
5504 * Set height-for-width mode
5506 * With height-for-width mode the item width will be fixed (restricted
5507 * to a minimum of) to the list width when calculating its size in
5508 * order to allow the height to be calculated based on it. This allows,
5509 * for instance, text block to wrap lines if the Edje part is
5510 * configured with "text.min: 0 1".
5512 * @note This mode will make list resize slower as it will have to
5513 * recalculate every item height again whenever the list width
5516 * @note When height-for-width mode is enabled, it also enables
5517 * compress mode (see elm_genlist_compress_mode_set()) and
5518 * disables homogeneous (see elm_genlist_homogeneous_set()).
5520 * @param obj The genlist object
5521 * @param setting The height-for-width mode (EINA_TRUE = on,
5527 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5528 Eina_Bool height_for_width)
5530 ELM_CHECK_WIDTYPE(obj, widtype);
5531 Widget_Data *wd = elm_widget_data_get(obj);
5533 wd->height_for_width = !!height_for_width;
5534 if (wd->height_for_width)
5536 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5537 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5542 * Get the height-for-width mode
5544 * @param obj The genlist object
5545 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5551 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5553 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5554 Widget_Data *wd = elm_widget_data_get(obj);
5555 if (!wd) return EINA_FALSE;
5556 return wd->height_for_width;
5562 * This will enable or disable the scroller bounce mode for the
5563 * genlist. See elm_scroller_bounce_set() for details
5565 * @param obj The genlist object
5566 * @param h_bounce Allow bounce horizontally
5567 * @param v_bounce Allow bounce vertically
5572 elm_genlist_bounce_set(Evas_Object *obj,
5576 ELM_CHECK_WIDTYPE(obj, widtype);
5577 Widget_Data *wd = elm_widget_data_get(obj);
5579 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5583 * Get the bounce mode
5585 * @param obj The genlist object
5586 * @param h_bounce Allow bounce horizontally
5587 * @param v_bounce Allow bounce vertically
5592 elm_genlist_bounce_get(const Evas_Object *obj,
5593 Eina_Bool *h_bounce,
5594 Eina_Bool *v_bounce)
5596 ELM_CHECK_WIDTYPE(obj, widtype);
5597 Widget_Data *wd = elm_widget_data_get(obj);
5599 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5603 * Set homogenous mode
5605 * This will enable the homogeneous mode where items are of the same
5606 * height and width so that genlist may do the lazy-loading at its
5607 * maximum. This implies 'compressed' mode.
5609 * @param obj The genlist object
5610 * @param homogeneous Assume the items within the genlist are of the
5611 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5616 elm_genlist_homogeneous_set(Evas_Object *obj,
5617 Eina_Bool homogeneous)
5619 ELM_CHECK_WIDTYPE(obj, widtype);
5620 Widget_Data *wd = elm_widget_data_get(obj);
5622 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5623 wd->homogeneous = homogeneous;
5627 * Get the homogenous mode
5629 * @param obj The genlist object
5630 * @return Assume the items within the genlist are of the same height
5631 * and width (EINA_TRUE = on, EINA_FALSE = off)
5636 elm_genlist_homogeneous_get(const Evas_Object *obj)
5638 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5639 Widget_Data *wd = elm_widget_data_get(obj);
5640 if (!wd) return EINA_FALSE;
5641 return wd->homogeneous;
5645 * Set the maximum number of items within an item block
5647 * This will configure the block count to tune to the target with
5648 * particular performance matrix.
5650 * @param obj The genlist object
5651 * @param n Maximum number of items within an item block
5656 elm_genlist_block_count_set(Evas_Object *obj,
5659 ELM_CHECK_WIDTYPE(obj, widtype);
5660 Widget_Data *wd = elm_widget_data_get(obj);
5662 wd->max_items_per_block = n;
5663 wd->item_cache_max = wd->max_items_per_block * 2;
5664 _item_cache_clean(wd);
5668 * Get the maximum number of items within an item block
5670 * @param obj The genlist object
5671 * @return Maximum number of items within an item block
5676 elm_genlist_block_count_get(const Evas_Object *obj)
5678 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5679 Widget_Data *wd = elm_widget_data_get(obj);
5681 return wd->max_items_per_block;
5685 * Set the timeout in seconds for the longpress event
5687 * @param obj The genlist object
5688 * @param timeout timeout in seconds
5693 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5696 ELM_CHECK_WIDTYPE(obj, widtype);
5697 Widget_Data *wd = elm_widget_data_get(obj);
5699 wd->longpress_timeout = timeout;
5703 * Get the timeout in seconds for the longpress event
5705 * @param obj The genlist object
5706 * @return timeout in seconds
5711 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5713 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5714 Widget_Data *wd = elm_widget_data_get(obj);
5716 return wd->longpress_timeout;
5720 * Set the scrollbar policy
5722 * This sets the scrollbar visibility policy for the given genlist
5723 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5724 * made visible if it is needed, and otherwise kept hidden.
5725 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5726 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5727 * respectively for the horizontal and vertical scrollbars.
5729 * @param obj The genlist object
5730 * @param policy_h Horizontal scrollbar policy
5731 * @param policy_v Vertical scrollbar policy
5736 elm_genlist_scroller_policy_set(Evas_Object *obj,
5737 Elm_Scroller_Policy policy_h,
5738 Elm_Scroller_Policy policy_v)
5740 ELM_CHECK_WIDTYPE(obj, widtype);
5741 Widget_Data *wd = elm_widget_data_get(obj);
5743 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5744 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5747 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5751 * Get the scrollbar policy
5753 * @param obj The genlist object
5754 * @param policy_h Horizontal scrollbar policy
5755 * @param policy_v Vertical scrollbar policy
5760 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5761 Elm_Scroller_Policy *policy_h,
5762 Elm_Scroller_Policy *policy_v)
5764 ELM_CHECK_WIDTYPE(obj, widtype);
5765 Widget_Data *wd = elm_widget_data_get(obj);
5766 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5767 if ((!wd) || (!wd->scr)) return;
5768 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5769 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5770 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5773 /****************************************************************************/
5778 * @param obj The genlist object
5779 * @param reorder_mode The reorder mode
5780 * (EINA_TRUE = on, EINA_FALSE = off)
5785 elm_genlist_reorder_mode_set(Evas_Object *obj,
5786 Eina_Bool reorder_mode)
5788 ELM_CHECK_WIDTYPE(obj, widtype);
5789 Widget_Data *wd = elm_widget_data_get(obj);
5791 wd->reorder_mode = reorder_mode;
5795 * Get the reorder mode
5797 * @param obj The genlist object
5798 * @return The reorder mode
5799 * (EINA_TRUE = on, EINA_FALSE = off)
5804 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5806 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5807 Widget_Data *wd = elm_widget_data_get(obj);
5808 if (!wd) return EINA_FALSE;
5809 return wd->reorder_mode;
5813 elm_genlist_item_move_after(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *after __UNUSED__)
5819 elm_genlist_item_move_before(Elm_Genlist_Item *it __UNUSED__, Elm_Genlist_Item *before __UNUSED__)
5825 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5830 // printf("MOVE AFTER : it = %d after = %d \n", it->num, after->num);
5831 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5832 it->wd->reorder_deleted = EINA_TRUE;
5833 _item_block_del(it);
5835 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5837 it->rel->relcount++;
5838 it->before = EINA_FALSE;
5839 _item_queue(it->wd, it);
5841 if (it->itc->func.moved)
5842 it->itc->func.moved(it->base.widget, it, after, EINA_TRUE);
5846 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5849 if (!before) return;
5851 // printf("MOVE BEFORE : it = %d before = %d \n", it->num, before->num);
5852 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5853 it->wd->reorder_deleted = EINA_TRUE;
5854 _item_block_del(it);
5855 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5857 it->rel->relcount++;
5858 it->before = EINA_TRUE;
5859 _item_queue(it->wd, it);
5861 if (it->itc->func.moved)
5862 it->itc->func.moved(it->base.widget, it, before, EINA_FALSE);
5866 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5868 ELM_CHECK_WIDTYPE(obj, widtype);
5869 Widget_Data *wd = elm_widget_data_get(obj);
5871 wd->effect_mode = emode;
5872 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5873 // evas_object_resize(wd->point_rect, 10, 25);
5874 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5875 // evas_object_show(wd->point_rect);
5876 // evas_object_hide(wd->point_rect);
5880 _create_tray_alpha_bg(const Evas_Object *obj)
5882 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5883 Widget_Data *wd = elm_widget_data_get(obj);
5884 if (!wd) return NULL;
5886 Evas_Object *bg = NULL;
5887 Evas_Coord ox, oy, ow, oh;
5889 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5890 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5891 evas_object_color_set(bg,0,0,0,0);
5892 evas_object_resize(bg , ow, oh);
5893 evas_object_move(bg , ox, oy);
5894 evas_object_show(bg);
5895 evas_object_hide(bg);
5902 struct timeval timev;
5904 gettimeofday(&timev, NULL);
5905 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5908 // added for item moving animation.
5910 _item_moving_effect_timer_cb(void *data)
5912 Widget_Data *wd = data;
5913 if (!wd) return EINA_FALSE;
5915 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5916 Elm_Genlist_Item *it, *it2;
5918 double time = 0.3, t;
5920 Eina_Bool check, end = EINA_FALSE;
5923 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5925 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5926 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5927 if (t > time) end = EINA_TRUE;
5929 it2 = elm_genlist_item_next_get(wd->expand_item);
5932 if (wd->expand_item->expanded_depth >= it2->expanded_depth) break;
5933 it2 = elm_genlist_item_next_get(it2);
5938 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5939 dy = it2->scrl_y - it2->old_scrl_y;
5940 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5941 dy = wd->expand_item_gap;
5945 y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
5954 EINA_INLIST_FOREACH(wd->blocks, itb)
5957 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5958 itb->y - wd->pan_y + oy,
5960 cvx, cvy, cvw, cvh))
5962 EINA_LIST_FOREACH(itb->items, l, it)
5964 if (it == it2) check = EINA_TRUE;
5965 if (!check) continue;
5967 if (!it->old_scrl_y)
5968 it->old_scrl_y = it->scrl_y;
5969 if (it->old_scrl_y + y < oy + oh)
5971 if (!it->realized) _item_realize(it, in, 0);
5973 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5974 it->old_scrl_y = it->scrl_y - y;
5977 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5978 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5980 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5983 evas_object_resize(it->base.view, it->w, it->h);
5984 evas_object_move(it->base.view, it->scrl_x, it->old_scrl_y + y);
5985 evas_object_show(it->base.view);
5986 evas_object_raise(it->base.view);
5989 if (it->group_item) evas_object_raise(it->group_item->base.view);
5995 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5997 it = elm_genlist_item_prev_get(it2);
6000 if ((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
6002 if (!it->effect_done)
6004 edje_object_signal_emit(it->base.view, "flip_item", "");
6005 evas_object_show(it->base.view);
6006 it->effect_done = EINA_TRUE;
6009 it = elm_genlist_item_prev_get(it);
6010 if (it->expanded_depth <= it2->expanded_depth) break;
6013 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6015 it = elm_genlist_item_prev_get(it2);
6018 if ((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
6020 if (!it->effect_done)
6022 edje_object_signal_emit(it->base.view, "elm,state,hide", "");
6023 it->effect_done = EINA_TRUE;
6028 it = elm_genlist_item_prev_get(it);
6035 int expand_order = 0;
6036 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
6040 it = elm_genlist_item_next_get(it);
6042 if (wd->expand_item) it = elm_genlist_item_next_get(wd->expand_item);
6046 if (wd->expand_item->expanded_depth >= it->expanded_depth) break;
6047 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6049 if (!it->effect_done)
6051 if (t >= (((expand_order - 1) * time) / expand_num))
6053 edje_object_signal_emit(it->base.view, "flip_item", "");
6054 evas_object_show(it->base.view);
6055 it->effect_done = EINA_TRUE;
6059 it = elm_genlist_item_next_get(it);
6065 if (wd->item_moving_effect_timer)
6067 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6068 _item_subitems_clear(wd->expand_item);
6069 EINA_INLIST_FOREACH(wd->blocks, itb)
6071 EINA_LIST_FOREACH(itb->items, l, it)
6073 it->effect_done = EINA_TRUE;
6074 it->old_scrl_y = it->scrl_y;
6078 wd->item_moving_effect_timer = NULL;
6080 _item_auto_scroll(wd);
6081 evas_object_lower(wd->alpha_bg);
6082 evas_object_hide(wd->alpha_bg);
6083 if (wd->calc_job) ecore_job_del(wd->calc_job);
6084 wd->calc_job = ecore_job_add(_calc_job, wd);
6085 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
6086 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
6088 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
6089 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
6090 return ECORE_CALLBACK_CANCEL;
6092 return ECORE_CALLBACK_RENEW;
6096 _emit_contract(Elm_Genlist_Item *it)
6098 Elm_Genlist_Item *it2;
6101 // printf("%p is emited contract\n", it);
6102 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
6103 it->effect_done = EINA_FALSE;
6105 EINA_LIST_FOREACH(it->items, l, it2)
6107 _emit_contract(it2);
6110 // added for item moving animation.
6112 _item_flip_effect_show(Elm_Genlist_Item *it)
6114 Elm_Genlist_Item *it2;
6116 Widget_Data *wd = it->wd;
6117 Eina_Bool check = EINA_FALSE;
6119 it2 = elm_genlist_item_next_get(it);
6122 if (it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
6123 it2 = elm_genlist_item_next_get(it2);
6125 EINA_LIST_FOREACH(it->items, l, it2)
6127 if (it2->parent && it == it2->parent)
6129 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
6130 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
6131 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
6132 _emit_contract(it2);
6136 return ECORE_CALLBACK_CANCEL;
6141 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
6143 printf("!!! NOW FIXING \n");
6148 * Set pinch zoom mode
6150 * @param obj The genlist object
6152 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
6157 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
6159 printf("!!! NOW FIXING \n");
6163 * Get pinch zoom mode
6165 * @param obj The genlist object
6166 * @return The pinch mode
6167 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
6172 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj __UNUSED__)
6174 printf("!!! NOW FIXING \n");
6179 elm_genlist_pinch_zoom_set(Evas_Object *obj __UNUSED__, Eina_Bool emode __UNUSED__)
6181 printf("!!! NOW FIXING \n");
6185 ////////////////////////////////////////////////////////////////////////
6187 ////////////////////////////////////////////////////////////////////////
6190 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
6192 if (!it->wd->edit_mode) return;
6193 evas_object_resize(it->edit_obj,it->w, it->h);
6194 evas_object_move(it->edit_obj, itx, ity);
6198 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
6200 if ((it->effect_item_realized) || (it->delete_me)) return;
6203 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6204 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6205 _elm_config->scale);
6206 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6207 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6209 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6210 else strncpy(buf, "item", sizeof(buf));
6211 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6213 strncat(buf, "/", sizeof(buf) - strlen(buf));
6215 if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default"))
6217 strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf));
6218 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6222 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget));
6225 if (it->wd->reorder_mode)
6227 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled_effect", "elm");
6228 else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enabled", "elm");
6230 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled_effect", "elm");
6231 else edje_object_signal_emit(it->edit_obj, "elm,state,emode_enabled", "elm");
6233 if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm");
6234 else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm");
6237 if ((it->wd->edit_mode))
6239 if (it->itc->func.icon_get)
6244 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons"));
6245 EINA_LIST_FOREACH(it->icons, l, key)
6247 Evas_Object *ic = it->itc->func.icon_get
6248 (it->base.data, it->base.widget, l->data);
6252 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6253 edje_object_part_swallow(it->edit_obj, key, ic);
6254 evas_object_show(ic);
6255 elm_widget_sub_object_add(it->base.widget, ic);
6257 elm_widget_disabled_set(ic, EINA_TRUE);
6262 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6263 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6264 evas_object_show(it->edit_obj);
6266 it->effect_item_realized = EINA_TRUE;
6267 it->want_unrealize = EINA_FALSE;
6271 _effect_item_unrealize(Elm_Genlist_Item *it)
6275 if (!it->effect_item_realized) return;
6276 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6278 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6279 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6280 edje_object_message_signal_process(it->edit_obj);
6281 edje_object_part_unswallow(it->edit_obj, it->base.view);
6282 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6283 elm_widget_sub_object_add(it->base.widget, it->base.view);
6284 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6285 // _item_cache_add(it);
6286 evas_object_del(it->edit_obj);
6287 it->edit_obj = NULL;
6288 EINA_LIST_FREE(it->edit_icon_objs, icon)
6289 evas_object_del(icon);
6291 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6292 it->effect_item_realized = EINA_FALSE;
6296 * Get Genlist edit mode
6298 * @param obj The genlist object
6299 * @return The edit mode status
6300 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6305 elm_genlist_edit_mode_get(const Evas_Object *obj)
6307 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
6308 Widget_Data *wd = elm_widget_data_get(obj);
6309 if (!wd) return EINA_FALSE;
6311 if (wd->edit_mode) return EINA_TRUE;
6312 else return EINA_FALSE;
6316 * Set Genlist edit mode
6318 * This sets Genlist edit mode.
6320 * @param obj The Genlist object
6321 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6322 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6327 elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode)
6329 ELM_CHECK_WIDTYPE(obj, widtype);
6333 Elm_Genlist_Item *it;
6335 Widget_Data *wd = elm_widget_data_get(obj);
6337 if (wd->edit_mode == edit_mode) return;
6339 wd->edit_mode = edit_mode;
6342 EINA_INLIST_FOREACH(wd->blocks, itb)
6346 EINA_LIST_FOREACH(itb->items, l, it)
6348 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6350 _effect_item_unrealize(it);
6355 _item_cache_zero(wd);
6360 EINA_INLIST_FOREACH(wd->blocks, itb)
6364 EINA_LIST_FOREACH(itb->items, l, it)
6366 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6368 if(it->selected) _item_unselect(it);
6369 if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE);
6376 if (wd->calc_job) ecore_job_del(wd->calc_job);
6377 wd->calc_job = ecore_job_add(_calc_job, wd);
6381 * Delete selected items in genlist edit mode.
6383 * @param obj The genlist object
6388 elm_genlist_edit_selected_items_del(Evas_Object *obj __UNUSED__)
6390 fprintf(stderr, "=================> Caution!!! <========================\n");
6391 fprintf(stderr, "==> elm_genlist_edit_selected_items_del() is deprecated. <=======\n");
6392 fprintf(stderr, "=======================================================\n");
6396 elm_genlist_selected_items_del(Evas_Object *obj __UNUSED__)
6398 fprintf(stderr, "=================> Caution!!! <========================\n");
6399 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6400 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6401 fprintf(stderr, "=======================================================\n");
6405 * Get a list of selected items in genlist
6407 * This returns a list of the selected items in the genlist. The list
6408 * contains Elm_Genlist_Item pointers. The list must be freed by the
6409 * caller when done with eina_list_free(). The item pointers in the list
6410 * are only vallid so long as those items are not deleted or the genlist is
6413 * @param obj The genlist object
6414 * @return The list of selected items, nor NULL if none are selected.
6419 elm_genlist_edit_selected_items_get(const Evas_Object *obj __UNUSED__)
6421 fprintf(stderr, "========================> Caution!!! <==========================\n");
6422 fprintf(stderr, "==> elm_genlist_edit_selected_items_get() is deprecated. <=======\n");
6423 fprintf(stderr, "================================================================\n");
6427 // TODO : add comment
6429 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it __UNUSED__,
6430 Eina_Bool selected __UNUSED__)
6432 fprintf(stderr, "========================> Caution!!! <==========================\n");
6433 fprintf(stderr, "==> elm_genlist_edit_item_selected_set() is deprecated. <=======\n");
6434 fprintf(stderr, "================================================================\n");
6437 // TODO : add comment
6439 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it __UNUSED__)
6441 fprintf(stderr, "========================> Caution!!! <==========================\n");
6442 fprintf(stderr, "==> elm_genlist_edit_item_selected_get() is deprecated. <=======\n");
6443 fprintf(stderr, "================================================================\n");
6448 * Set a given item's rename mode
6450 * This renames the item's label from genlist
6452 * @param it The item
6453 * @param renamed set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6458 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed)
6464 _item_unrealize(it, EINA_FALSE);
6465 it->renamed = EINA_TRUE;
6466 it->wd->rename_it = it;
6467 it->nocache = EINA_TRUE;
6468 if (it->selected) _item_unselect(it);
6470 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
6471 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
6477 it->renamed = EINA_FALSE;
6478 it->nocache = EINA_TRUE;
6479 it->wd->rename_it = NULL;
6480 _item_cache_zero(it->wd);
6481 elm_genlist_item_update(it);
6487 elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item)
6489 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
6490 return item->renamed;
6494 _item_auto_scroll(void *data)
6496 Widget_Data *wd = data;
6499 if ((wd->expand_item) && (!wd->auto_scrolled))
6501 Elm_Genlist_Item *it;
6503 Evas_Coord ox, oy, ow, oh;
6504 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6506 wd->auto_scrolled = EINA_TRUE;
6507 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6509 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6511 elm_genlist_item_bring_in(it);
6518 * Update the contents of all realized items
6520 * This updates all realized items by calling all the item class functions again
6521 * to get the icons, labels and states. Use this when the original
6522 * item data has changed and the changes are desired to be reflected.
6524 * @param it The item
6529 elm_genlist_realized_items_update(Evas_Object *obj)
6531 ELM_CHECK_WIDTYPE(obj, widtype);
6533 Eina_List *list, *l;
6534 Elm_Genlist_Item *it;
6536 list = elm_genlist_realized_items_get(obj);
6537 EINA_LIST_FOREACH(list, l, it)
6538 elm_genlist_item_update(it);
6542 * Set genlist item mode
6544 * @param item The genlist item
6545 * @param mode Mode name
6546 * @param mode_set Boolean to define set or unset mode.
6551 elm_genlist_item_mode_set(Elm_Genlist_Item *it,
6552 const char *mode_type,
6555 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6556 Widget_Data *wd = it->wd;
6558 Elm_Genlist_Item *it2;
6561 if (!mode_type) return;
6562 if ((it->delete_me) || (it->disabled)) return;
6564 if ((wd->mode_item == it) &&
6565 (!strcmp(mode_type, wd->mode_type)) &&
6568 if (!it->itc->mode_item_style) return;
6572 EINA_LIST_FOREACH(wd->selected, l, it2)
6574 elm_genlist_item_selected_set(it2, EINA_FALSE);
6578 it2 = elm_genlist_selected_item_get(wd->obj);
6579 if ((it2) && (it2->realized))
6580 elm_genlist_item_selected_set(it2, EINA_FALSE);
6583 if (((wd->mode_type) && (strcmp(mode_type, wd->mode_type))) ||
6585 ((it == wd->mode_item) && (!mode_set)))
6586 _item_mode_unset(wd);
6588 eina_stringshare_replace(&wd->mode_type, mode_type);
6589 if (mode_set) _item_mode_set(it);
6593 * Get active genlist mode type
6595 * @param obj The genlist object
6600 elm_genlist_mode_get(const Evas_Object *obj)
6602 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6603 Widget_Data *wd = elm_widget_data_get(obj);
6604 if (!wd) return NULL;
6605 return wd->mode_type;
6609 * Get active genlist mode item
6611 * @param obj The genlist object
6615 EAPI const Elm_Genlist_Item *
6616 elm_genlist_mode_item_get(const Evas_Object *obj)
6618 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6619 Widget_Data *wd = elm_widget_data_get(obj);
6620 if (!wd) return NULL;
6621 return wd->mode_item;