1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items.
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * unrealized - This is called just before an item is unrealized. After
58 * this call icon objects provided will be deleted and the item object
59 * itself delete or be put into a floating cache.
61 * drag,start,up - This is called when the item in the list has been dragged
64 * drag,start,down - This is called when the item in the list has been dragged
65 * (not scrolled) down.
67 * drag,start,left - This is called when the item in the list has been dragged
68 * (not scrolled) left.
70 * drag,start,right - This is called when the item in the list has been dragged
71 * (not scrolled) right.
73 * drag,stop - This is called when the item in the list has stopped being
76 * drag - This is called when the item in the list is being dragged.
78 * longpressed - This is called when the item is pressed for a certain amount
79 * of time. By default it's 1 second.
81 * scroll,edge,top - This is called when the genlist is scrolled until the top
84 * scroll,edge,bottom - This is called when the genlist is scrolled until the
87 * scroll,edge,left - This is called when the genlist is scrolled until the
90 * scroll,edge,right - This is called when the genlist is scrolled until the
93 * multi,swipe,left - This is called when the genlist is multi-touch swiped
96 * multi,swipe,right - This is called when the genlist is multi-touch swiped
99 * multi,swipe,up - This is called when the genlist is multi-touch swiped
102 * multi,swipe,down - This is called when the genlist is multi-touch swiped
105 * multi,pinch,out - This is called when the genlist is multi-touch pinched
108 * multi,pinch,in - This is called when the genlist is multi-touch pinched
111 * Genlist has a fairly large API, mostly because it's relatively complex,
112 * trying to be both expansive, powerful and efficient. First we will begin
113 * an overview on the theory behind genlist.
115 * Evas tracks every object you create. Every time it processes an event
116 * (mouse move, down, up etc.) it needs to walk through objects and find out
117 * what event that affects. Even worse every time it renders display updates,
118 * in order to just calculate what to re-draw, it needs to walk through many
119 * many many objects. Thus, the more objects you keep active, the more
120 * overhead Evas has in just doing its work. It is advisable to keep your
121 * active objects to the minimum working set you need. Also remember that
122 * object creation and deletion carries an overhead, so there is a
123 * middle-ground, which is not easily determined. But don't keep massive lists
124 * of objects you can't see or use. Genlist does this with list objects. It
125 * creates and destroys them dynamically as you scroll around. It groups them
126 * into blocks so it can determine the visibility etc. of a whole block at
127 * once as opposed to having to walk the whole list. This 2-level list allows
128 * for very large numbers of items to be in the list (tests have used up to
129 * 2,000,000 items). Also genlist employs a queue for adding items. As items
130 * may be different sizes, every item added needs to be calculated as to its
131 * size and thus this presents a lot of overhead on populating the list, this
132 * genlist employs a queue. Any item added is queued and spooled off over
133 * time, actually appearing some time later, so if your list has many members
134 * you may find it takes a while for them to all appear, with your process
135 * consuming a lot of CPU while it is busy spooling.
137 * Genlist also implements a tree structure, but it does so with callbacks to
138 * the application, with the application filling in tree structures when
139 * requested (allowing for efficient building of a very deep tree that could
140 * even be used for file-management). See the above smart signal callbacks for
143 * An item in the genlist world can have 0 or more text labels (they can be
144 * regular text or textblock ??that's up to the style to determine), 0 or
145 * more icons (which are simply objects swallowed into the genlist item) and
146 * 0 or more boolean states that can be used for check, radio or other
147 * indicators by the edje theme style. An item may be one of several styles
148 * (Elementary provides 4 by default - ?
\9cdefault?? ?
\9cdouble_label?? "group_index"
149 * and "icon_top_text_bottom", but this can be extended by system or
150 * application custom themes/overlays/extensions).
152 * In order to implement the ability to add and delete items on the fly,
153 * Genlist implements a class/callback system where the application provides
154 * a structure with information about that type of item (genlist may contain
155 * multiple different items with different classes, states and styles).
156 * Genlist will call the functions in this struct (methods) when an item is
157 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
158 * simply be deleted when no longer needed with evas_object_del(). The
159 * Elm_Genlist_Item_Class structure contains the following members:
161 * item_style - This is a constant string and simply defines the name of the
162 * item style. It must be specified and the default should be ?
\9cdefault??
164 * func.label_get - This function is called when an actual item object is
165 * created. The data parameter is the data parameter passed to
166 * elm_genlist_item_append() and related item creation functions. The obj
167 * parameter is the genlist object and the part parameter is the string name
168 * of the text part in the edje design that is listed as one of the possible
169 * labels that can be set. This function must return a strudup()'ed string as
170 * the caller will free() it when done.
172 * func.icon_get - This function is called when an actual item object is
173 * created. The data parameter is the data parameter passed to
174 * elm_genlist_item_append() and related item creation functions. The obj
175 * parameter is the genlist object and the part parameter is the string name
176 * of the icon part in the edje design that is listed as one of the possible
177 * icons that can be set. This must return NULL for no object or a valid
178 * object. The object will be deleted by genlist on shutdown or when the item
181 * func.state_get - This function is called when an actual item object is
182 * created. The data parameter is the data parameter passed to
183 * elm_genlist_item_append() and related item creation functions. The obj
184 * parameter is the genlist object and the part parameter is the string name
185 * of the state part in the edje design that is listed as one of the possible
186 * states that can be set. Return 0 for false or 1 for true. Genlist will
187 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
188 * true (the default is false), where XXX is the name of the part.
190 * func.del - This is called when elm_genlist_item_del() is called on an
191 * item, elm_genlist_clear() is called on the genlist, or
192 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
193 * intended for use when actual genlist items are deleted, so any backing
194 * data attached to the item (e.g. its data parameter on creation) can be
197 * Items can be added by several calls. All of them return a Elm_Genlist_Item
198 * handle that is an internal member inside the genlist. They all take a data
199 * parameter that is meant to be used for a handle to the applications
200 * internal data (eg the struct with the original item data). The parent
201 * parameter is the parent genlist item this belongs to if it is a tree or
202 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
203 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
204 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
205 * is displayed as an item that is able to expand and have child items.
206 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
207 * displayed at the top until the next group comes. The func parameter is a
208 * convenience callback that is called when the item is selected and the data
209 * parameter will be the func_data parameter, obj be the genlist object and
210 * event_info will be the genlist item.
212 * elm_genlist_item_append() appends an item to the end of the list, or if
213 * there is a parent, to the end of all the child items of the parent.
214 * elm_genlist_item_prepend() is the same but prepends to the beginning of
215 * the list or children list. elm_genlist_item_insert_before() inserts at
216 * item before another item and elm_genlist_item_insert_after() inserts after
217 * the indicated item.
219 * The application can clear the list with elm_genlist_clear() which deletes
220 * all the items in the list and elm_genlist_item_del() will delete a specific
221 * item. elm_genlist_item_subitems_clear() will clear all items that are
222 * children of the indicated parent item.
224 * If the application wants multiple items to be able to be selected,
225 * elm_genlist_multi_select_set() can enable this. If the list is
226 * single-selection only (the default), then elm_genlist_selected_item_get()
227 * will return the selected item, if any, or NULL I none is selected. If the
228 * list is multi-select then elm_genlist_selected_items_get() will return a
229 * list (that is only valid as long as no items are modified (added, deleted,
230 * selected or unselected)).
232 * To help inspect list items you can jump to the item at the top of the list
233 * with elm_genlist_first_item_get() which will return the item pointer, and
234 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
235 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
236 * and previous items respectively relative to the indicated item. Using
237 * these calls you can walk the entire item list/tree. Note that as a tree
238 * the items are flattened in the list, so elm_genlist_item_parent_get() will
239 * let you know which item is the parent (and thus know how to skip them if
242 * There are also convenience functions. elm_genlist_item_genlist_get() will
243 * return the genlist object the item belongs to. elm_genlist_item_show()
244 * will make the scroller scroll to show that specific item so its visible.
245 * elm_genlist_item_data_get() returns the data pointer set by the item
246 * creation functions.
248 * If an item changes (state of boolean changes, label or icons change),
249 * then use elm_genlist_item_update() to have genlist update the item with
250 * the new state. Genlist will re-realize the item thus call the functions
251 * in the _Elm_Genlist_Item_Class for that item.
253 * To programmatically (un)select an item use elm_genlist_item_selected_set().
254 * To get its selected state use elm_genlist_item_selected_get(). Similarly
255 * to expand/contract an item and get its expanded state, use
256 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
257 * again to make an item disabled (unable to be selected and appear
258 * differently) use elm_genlist_item_disabled_set() to set this and
259 * elm_genlist_item_disabled_get() to get the disabled state.
261 * In general to indicate how the genlist should expand items horizontally to
262 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
263 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
264 * mode means that if items are too wide to fit, the scroller will scroll
265 * horizontally. Otherwise items are expanded to fill the width of the
266 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
267 * to the viewport width and limited to that size. This can be combined with
268 * a different style that uses edjes' ellipsis feature (cutting text off like
269 * this: ?
\9ctex...??.
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
289 typedef struct _Edit_Data Edit_Data;
291 typedef enum _Elm_Genlist_Item_Move_effect_Mode
293 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
294 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
297 } Elm_Genlist_Item_Move_effect_Mode;
301 Evas_Object *obj, *scr, *pan_smart;
302 Eina_Inlist *items, *blocks;
303 Eina_List *group_items;
305 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
306 Ecore_Job *calc_job, *update_job;
307 Ecore_Idler *queue_idler;
308 Ecore_Idler *must_recalc_idler;
309 Eina_List *queue, *selected;
310 Elm_Genlist_Item *show_item;
311 Elm_Genlist_Item *last_selected_item;
312 Eina_Inlist *item_cache;
313 Elm_Genlist_Item *anchor_item;
314 Elm_Genlist_Item *reorder_it, *reorder_rel;
317 Ecore_Timer *multi_timer;
318 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
319 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
320 Evas_Coord reorder_start_y;
321 Eina_Bool mouse_down : 1;
322 Eina_Bool multi_down : 1;
323 Eina_Bool multi_timeout : 1;
324 Eina_Bool multitouched : 1;
325 Ecore_Animator *item_moving_effect_timer;
326 Evas_Object *alpha_bg;
327 Elm_Genlist_Item *expand_item;
328 Evas_Coord expand_item_end;
329 Evas_Coord expand_item_gap;
330 Eina_Bool on_hold : 1;
332 Eina_Bool always_select : 1;
333 Eina_Bool longpressed : 1;
334 Eina_Bool wasselected : 1;
335 Eina_Bool no_select : 1;
336 Eina_Bool bring_in : 1;
337 Eina_Bool compress : 1;
338 Eina_Bool height_for_width : 1;
339 Eina_Bool homogeneous : 1;
340 Eina_Bool clear_me : 1;
342 Eina_Bool auto_scrolled : 1;
346 } history[SWIPE_MOVES];
348 int item_cache_count;
354 int max_items_per_block;
355 int move_effect_mode;
356 unsigned int start_time;
357 double longpress_timeout;
359 // TODO : refactoring
360 Eina_Bool reorder_mode : 1;
361 Eina_Bool reorder_pan_move : 1;
362 Eina_Bool effect_mode : 1;
363 Eina_Bool select_all_check : 1;
366 Eina_List *edit_field;
367 Elm_Genlist_Item *select_all_item;
368 Eina_List *sweeped_items;
369 Ecore_Timer *scr_hold_timer;
371 int group_item_width;
372 int group_item_height;
383 Evas_Coord x, y, w, h, minw, minh;
384 Eina_Bool want_unrealize : 1;
385 Eina_Bool realized : 1;
386 Eina_Bool changed : 1;
387 Eina_Bool updateme : 1;
388 Eina_Bool showme : 1;
389 Eina_Bool must_recalc : 1;
392 struct _Elm_Genlist_Item
394 Elm_Widget_Item base;
399 Evas_Coord x, y, w, h, minw, minh;
400 const Elm_Genlist_Item_Class *itc;
401 Elm_Genlist_Item *parent;
402 Elm_Genlist_Item *group_item;
403 Elm_Genlist_Item_Flags flags;
411 Eina_List *labels, *icons, *states, *icon_objs;
412 Ecore_Timer *long_timer;
413 Ecore_Timer *swipe_timer;
414 Ecore_Animator *item_moving_effect_timer;
416 Evas_Coord scrl_x, scrl_y;
417 Evas_Coord old_scrl_x, old_scrl_y;
418 Evas_Coord pad_left, pad_right;
420 Elm_Genlist_Item *rel;
425 Elm_Tooltip_Item_Content_Cb content_cb;
426 Evas_Smart_Cb del_cb;
430 const char *mouse_cursor;
438 Eina_Bool before : 1;
440 Eina_Bool want_unrealize : 1;
441 Eina_Bool want_realize : 1;
442 Eina_Bool realized : 1;
443 Eina_Bool selected : 1;
444 Eina_Bool hilighted : 1;
445 Eina_Bool expanded : 1;
446 Eina_Bool disabled : 1;
447 Eina_Bool display_only : 1;
448 Eina_Bool mincalcd : 1;
449 Eina_Bool queued : 1;
450 Eina_Bool showme : 1;
451 Eina_Bool delete_me : 1;
453 Eina_Bool dragging : 1;
454 Eina_Bool updateme : 1;
455 Eina_Bool nocache : 1;
458 Eina_Bool move_effect_me : 1;
459 Eina_Bool effect_done : 1;
460 Eina_List *edit_icon_objs;
461 Evas_Object *edit_obj;
462 Eina_Bool reordering : 1;
463 Eina_Bool edit_select_check: 1;
464 Eina_Bool renamed : 1;
465 Eina_Bool effect_item_realized : 1;
466 Eina_Bool sweeped : 1;
467 Eina_Bool wassweeped : 1;
468 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
476 Evas_Object *base_view, *spacer;
478 const char *item_style; // it->itc->item_style
479 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
480 Eina_Bool compress : 1; // it->wd->compress
481 Eina_Bool odd : 1; // in & 0x1
483 Eina_Bool selected : 1; // it->selected
484 Eina_Bool disabled : 1; // it->disabled
485 Eina_Bool expanded : 1; // it->expanded
490 Elm_Genlist_Edit_Class *ec;
491 Elm_Genlist_Item *del_item;
492 Elm_Genlist_Item *reorder_item;
493 Elm_Genlist_Item *reorder_rel;
494 Evas_Object *del_confirm;
497 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
498 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
502 Evas_Object_Smart_Clipped_Data __clipped_data;
504 Ecore_Job *resize_job;
507 static const char *widtype = NULL;
508 static void _item_cache_zero(Widget_Data *wd);
509 static void _del_hook(Evas_Object *obj);
510 static void _theme_hook(Evas_Object *obj);
511 //static void _show_region_hook(void *data, Evas_Object *obj);
512 static void _sizing_eval(Evas_Object *obj);
513 static void _item_unrealize(Elm_Genlist_Item *it);
514 static void _item_block_unrealize(Item_Block *itb);
515 static void _calc_job(void *data);
516 static void _on_focus_hook(void *data,
518 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
519 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
520 static Eina_Bool _item_single_select_up(Widget_Data *wd);
521 static Eina_Bool _item_single_select_down(Widget_Data *wd);
522 static Eina_Bool _event_hook(Evas_Object *obj,
524 Evas_Callback_Type type,
526 static Eina_Bool _deselect_all_items(Widget_Data *wd);
527 static void _pan_calculate(Evas_Object *obj);
528 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
529 static unsigned int current_time_get();
530 static Eina_Bool _item_moving_effect_timer_cb(void *data);
531 static int _item_flip_effect_show(Elm_Genlist_Item *it);
532 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
533 static void _effect_item_realize(Elm_Genlist_Item *it);
534 static void _effect_item_unrealize(Elm_Genlist_Item *it);
536 // TODO : refactoring
537 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
538 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
539 static void _create_sweep_objs(Elm_Genlist_Item *it);
540 static void _delete_sweep_objs(Elm_Genlist_Item *it);
541 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
542 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
543 static void _group_items_recalc(void *data);
544 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked);
545 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
546 static void _item_auto_scroll(void *data);
548 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
551 _event_hook(Evas_Object *obj,
552 Evas_Object *src __UNUSED__,
553 Evas_Callback_Type type,
556 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
557 Evas_Event_Key_Down *ev = event_info;
558 Widget_Data *wd = elm_widget_data_get(obj);
559 if (!wd) return EINA_FALSE;
560 if (!wd->items) return EINA_FALSE;
561 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
562 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
564 Elm_Genlist_Item *it = NULL;
567 Evas_Coord step_x = 0;
568 Evas_Coord step_y = 0;
571 Evas_Coord page_x = 0;
572 Evas_Coord page_y = 0;
574 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
575 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
576 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
577 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
579 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
583 else if ((!strcmp(ev->keyname, "Right")) ||
584 (!strcmp(ev->keyname, "KP_Right")))
588 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
590 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
591 (_item_multi_select_up(wd)))
592 || (_item_single_select_up(wd)))
594 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
600 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
602 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
603 (_item_multi_select_down(wd)))
604 || (_item_single_select_down(wd)))
606 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
612 else if ((!strcmp(ev->keyname, "Home")) ||
613 (!strcmp(ev->keyname, "KP_Home")))
615 it = elm_genlist_first_item_get(obj);
616 elm_genlist_item_bring_in(it);
617 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
620 else if ((!strcmp(ev->keyname, "End")) ||
621 (!strcmp(ev->keyname, "KP_End")))
623 it = elm_genlist_last_item_get(obj);
624 elm_genlist_item_bring_in(it);
625 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
628 else if ((!strcmp(ev->keyname, "Prior")) ||
629 (!strcmp(ev->keyname, "KP_Prior")))
632 y -= -(page_y * v_h) / 100;
636 else if ((!strcmp(ev->keyname, "Next")) ||
637 (!strcmp(ev->keyname, "KP_Next")))
640 y += -(page_y * v_h) / 100;
644 else if(((!strcmp(ev->keyname, "Return")) ||
645 (!strcmp(ev->keyname, "KP_Enter")) ||
646 (!strcmp(ev->keyname, "space")))
647 && (!wd->multi) && (wd->selected))
649 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
650 elm_genlist_item_expanded_set(it,
651 !elm_genlist_item_expanded_get(it));
653 else if (!strcmp(ev->keyname, "Escape"))
655 if (!_deselect_all_items(wd)) return EINA_FALSE;
656 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
659 else return EINA_FALSE;
661 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
662 elm_smart_scroller_child_pos_set(wd->scr, x, y);
667 _deselect_all_items(Widget_Data *wd)
669 if (!wd->selected) return EINA_FALSE;
671 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
677 _item_multi_select_up(Widget_Data *wd)
679 if (!wd->selected) return EINA_FALSE;
680 if (!wd->multi) return EINA_FALSE;
682 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
683 if (!prev) return EINA_TRUE;
685 if (elm_genlist_item_selected_get(prev))
687 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
688 wd->last_selected_item = prev;
689 elm_genlist_item_show(wd->last_selected_item);
693 elm_genlist_item_selected_set(prev, EINA_TRUE);
694 elm_genlist_item_show(prev);
700 _item_multi_select_down(Widget_Data *wd)
702 if (!wd->selected) return EINA_FALSE;
703 if (!wd->multi) return EINA_FALSE;
705 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
706 if (!next) return EINA_TRUE;
708 if (elm_genlist_item_selected_get(next))
710 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
711 wd->last_selected_item = next;
712 elm_genlist_item_show(wd->last_selected_item);
716 elm_genlist_item_selected_set(next, EINA_TRUE);
717 elm_genlist_item_show(next);
723 _item_single_select_up(Widget_Data *wd)
725 Elm_Genlist_Item *prev;
728 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
729 while ((prev) && (prev->delete_me))
730 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
732 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
734 if (!prev) return EINA_FALSE;
736 _deselect_all_items(wd);
738 elm_genlist_item_selected_set(prev, EINA_TRUE);
739 elm_genlist_item_show(prev);
744 _item_single_select_down(Widget_Data *wd)
746 Elm_Genlist_Item *next;
749 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
750 while ((next) && (next->delete_me))
751 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
753 else next = elm_genlist_item_next_get(wd->last_selected_item);
755 if (!next) return EINA_FALSE;
757 _deselect_all_items(wd);
759 elm_genlist_item_selected_set(next, EINA_TRUE);
760 elm_genlist_item_show(next);
765 _on_focus_hook(void *data __UNUSED__,
768 Widget_Data *wd = elm_widget_data_get(obj);
770 if (elm_widget_focus_get(obj))
772 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
773 evas_object_focus_set(wd->obj, EINA_TRUE);
774 if ((wd->selected) && (!wd->last_selected_item))
775 wd->last_selected_item = eina_list_data_get(wd->selected);
779 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
780 evas_object_focus_set(wd->obj, EINA_FALSE);
785 _del_hook(Evas_Object *obj)
787 Widget_Data *wd = elm_widget_data_get(obj);
789 _item_cache_zero(wd);
790 if (wd->calc_job) ecore_job_del(wd->calc_job);
791 if (wd->update_job) ecore_job_del(wd->update_job);
792 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
793 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
794 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
799 _del_pre_hook(Evas_Object *obj)
801 Widget_Data *wd = elm_widget_data_get(obj);
803 evas_object_del(wd->pan_smart);
804 wd->pan_smart = NULL;
805 elm_genlist_clear(obj);
809 _theme_hook(Evas_Object *obj)
811 Widget_Data *wd = elm_widget_data_get(obj);
814 _item_cache_zero(wd);
815 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
816 elm_widget_style_get(obj));
817 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
818 wd->item_width = wd->item_height = 0;
819 wd->minw = wd->minh = wd->realminw = 0;
820 EINA_INLIST_FOREACH(wd->blocks, itb)
823 Elm_Genlist_Item *it;
825 if (itb->realized) _item_block_unrealize(itb);
826 EINA_LIST_FOREACH(itb->items, l, it)
827 it->mincalcd = EINA_FALSE;
829 itb->changed = EINA_TRUE;
831 if (wd->calc_job) ecore_job_del(wd->calc_job);
832 wd->calc_job = ecore_job_add(_calc_job, wd);
838 _show_region_hook(void *data, Evas_Object *obj)
840 Widget_Data *wd = elm_widget_data_get(data);
841 Evas_Coord x, y, w, h;
843 elm_widget_show_region_get(obj, &x, &y, &w, &h);
844 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
849 _sizing_eval(Evas_Object *obj)
851 Widget_Data *wd = elm_widget_data_get(obj);
852 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
854 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
855 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
857 if (wd->height_for_width)
861 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
862 if ((vw != 0) && (vw != wd->prev_viewport_w))
866 wd->prev_viewport_w = vw;
867 EINA_INLIST_FOREACH(wd->blocks, itb)
869 itb->must_recalc = EINA_TRUE;
871 if (wd->calc_job) ecore_job_del(wd->calc_job);
872 wd->calc_job = ecore_job_add(_calc_job, wd);
875 if (wd->mode == ELM_LIST_LIMIT)
877 Evas_Coord vmw, vmh, vw, vh;
881 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
882 if ((minw > 0) && (vw < minw)) vw = minw;
883 else if ((maxw > 0) && (vw > maxw))
885 edje_object_size_min_calc
886 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
893 edje_object_size_min_calc
894 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
898 evas_object_size_hint_min_set(obj, minw, minh);
899 evas_object_size_hint_max_set(obj, maxw, maxh);
903 _item_hilight(Elm_Genlist_Item *it)
905 const char *selectraise;
906 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
907 (it->disabled)) return;
908 if ((!it->sweeped) && (!it->wd->edit_mode))
909 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
910 selectraise = edje_object_data_get(it->base.view, "selectraise");
911 if ((selectraise) && (!strcmp(selectraise, "on")))
913 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
914 if ((it->group_item) && (it->group_item->realized))
915 evas_object_raise(it->group_item->base.view);
917 it->hilighted = EINA_TRUE;
918 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
923 _item_block_del(Elm_Genlist_Item *it)
926 Item_Block *itb = it->block;
928 itb->items = eina_list_remove(itb->items, it);
930 itb->changed = EINA_TRUE;
931 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
932 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
935 il = EINA_INLIST_GET(itb);
936 Item_Block *itbn = (Item_Block *)(il->next);
938 it->parent->items = eina_list_remove(it->parent->items, it);
940 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
942 if (itbn) itbn->changed = EINA_TRUE;
946 if (itb->count < itb->wd->max_items_per_block/2)
948 il = EINA_INLIST_GET(itb);
949 Item_Block *itbp = (Item_Block *)(il->prev);
950 Item_Block *itbn = (Item_Block *)(il->next);
951 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
953 Elm_Genlist_Item *it2;
955 EINA_LIST_FREE(itb->items, it2)
958 itbp->items = eina_list_append(itbp->items, it2);
960 itbp->changed = EINA_TRUE;
962 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
963 EINA_INLIST_GET(itb));
966 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
970 Eina_List *last = eina_list_last(itb->items);
971 Elm_Genlist_Item *it2 = last->data;
974 itb->items = eina_list_remove_list(itb->items, last);
975 itbn->items = eina_list_prepend(itbn->items, it2);
977 itbn->changed = EINA_TRUE;
980 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
988 _item_subitems_clear(Elm_Genlist_Item *it)
991 Eina_List *tl = NULL, *l;
992 Elm_Genlist_Item *it2;
994 EINA_LIST_FOREACH(it->items, l, it2)
995 tl = eina_list_append(tl, it2);
997 EINA_LIST_FREE(tl, it2)
998 elm_genlist_item_del(it2);
1002 _item_del(Elm_Genlist_Item *it)
1004 elm_widget_item_pre_notify_del(it);
1005 elm_genlist_item_subitems_clear(it);
1006 it->wd->walking -= it->walking;
1007 if (it->wd->show_item == it) it->wd->show_item = NULL;
1008 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1009 if (it->realized) _item_unrealize(it);
1010 if (it->effect_item_realized) _effect_item_unrealize(it);
1011 if (it->block) _item_block_del(it);
1012 if ((!it->delete_me) && (it->itc->func.del))
1013 it->itc->func.del((void *)it->base.data, it->base.widget);
1014 it->delete_me = EINA_TRUE;
1016 it->wd->queue = eina_list_remove(it->wd->queue, it);
1018 if (it->wd->anchor_item == it)
1020 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1021 if (!it->wd->anchor_item)
1022 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1025 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1027 it->parent->items = eina_list_remove(it->parent->items, it);
1028 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1029 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1030 if (it->long_timer) ecore_timer_del(it->long_timer);
1031 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1033 if (it->tooltip.del_cb)
1034 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1036 elm_widget_item_del(it);
1037 it->wd->total_num--; // todo : remove
1041 _item_select(Elm_Genlist_Item *it)
1043 if ((it->wd->no_select) || (it->delete_me)) return;
1044 if (it == it->wd->select_all_item)
1046 if(it->wd->select_all_check)
1047 _select_all_down_process(it->wd->select_all_item, EINA_FALSE);
1049 _select_all_down_process(it->wd->select_all_item, EINA_TRUE);
1054 if (it->wd->always_select) goto call;
1057 it->selected = EINA_TRUE;
1058 it->wd->selected = eina_list_append(it->wd->selected, it);
1062 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1064 evas_object_smart_callback_call(it->base.widget, "selected", it);
1067 if ((it->wd->clear_me) && (!it->wd->walking))
1068 elm_genlist_clear(it->base.widget);
1071 if ((!it->walking) && (it->delete_me))
1073 if (!it->relcount) _item_del(it);
1076 it->wd->last_selected_item = it;
1080 _item_unselect(Elm_Genlist_Item *it)
1082 const char *stacking, *selectraise;
1084 if (it == it->wd->select_all_item) return;
1085 if ((it->delete_me) || (!it->hilighted)) return;
1087 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1088 stacking = edje_object_data_get(it->base.view, "stacking");
1089 selectraise = edje_object_data_get(it->base.view, "selectraise");
1090 if ((selectraise) && (!strcmp(selectraise, "on")))
1092 if ((stacking) && (!strcmp(stacking, "below")))
1093 evas_object_lower(it->base.view);
1095 it->hilighted = EINA_FALSE;
1098 it->selected = EINA_FALSE;
1099 it->wd->selected = eina_list_remove(it->wd->selected, it);
1100 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1105 _mouse_move(void *data,
1106 Evas *evas __UNUSED__,
1110 Elm_Genlist_Item *it = data;
1111 Evas_Event_Mouse_Move *ev = event_info;
1112 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1114 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1116 if (!it->wd->on_hold)
1118 it->wd->on_hold = EINA_TRUE;
1119 if (!it->wd->wasselected)
1123 if (it->wd->multitouched)
1125 it->wd->cur_x = ev->cur.canvas.x;
1126 it->wd->cur_y = ev->cur.canvas.y;
1129 if ((it->dragging) && (it->down))
1131 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1134 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1135 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1136 if (abs((it->wd->history[it->wd->movements].x -
1137 it->wd->history[0].x)) > 40)
1138 it->wd->swipe = EINA_TRUE;
1140 it->wd->movements++;
1144 ecore_timer_del(it->long_timer);
1145 it->long_timer = NULL;
1147 evas_object_smart_callback_call(it->base.widget, "drag", it);
1150 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1154 ecore_timer_del(it->long_timer);
1155 it->long_timer = NULL;
1157 if (it->wd->reorder_mode && it->wd->reorder_it)
1159 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1160 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1161 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1162 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1164 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1165 if (it->wd->select_all_item)
1166 sel_all_h = it->wd->select_all_item->h;
1167 if (it_y < oy + sel_all_h)
1169 evas_object_move(it->base.view, it->scrl_x+it->pad_left,oy + sel_all_h);
1170 _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1172 else if (it_y + it->wd->reorder_it->h > oy+oh)
1174 evas_object_move(it->base.view, it->scrl_x+it->pad_left, oy + oh - it->wd->reorder_it->h);
1175 _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1179 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it_y);
1180 _effect_item_controls(it, it->scrl_x, it_y);
1182 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1183 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1187 if (!it->display_only)
1188 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1189 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1190 x = ev->cur.canvas.x - x;
1191 y = ev->cur.canvas.y - y;
1194 if (adx < 0) adx = -dx;
1197 if (ady < 0) ady = -dy;
1200 if ((adx > minw) || (ady > minh))
1202 it->dragging = EINA_TRUE;
1205 ecore_timer_del(it->long_timer);
1206 it->long_timer = NULL;
1208 if (!it->wd->wasselected)
1213 evas_object_smart_callback_call(it->base.widget,
1214 "drag,start,up", it);
1219 evas_object_smart_callback_call(it->base.widget,
1220 "drag,start,left", it);
1221 _item_slide(it, EINA_FALSE);
1225 evas_object_smart_callback_call(it->base.widget,
1226 "drag,start,right", it);
1227 _item_slide(it, EINA_TRUE);
1234 evas_object_smart_callback_call(it->base.widget,
1235 "drag,start,down", it);
1240 evas_object_smart_callback_call(it->base.widget,
1241 "drag,start,left", it);
1242 _item_slide(it, EINA_FALSE);
1246 evas_object_smart_callback_call(it->base.widget,
1247 "drag,start,right", it);
1248 _item_slide(it, EINA_TRUE);
1256 _long_press(void *data)
1258 Elm_Genlist_Item *it = data , *it_tmp;
1259 static Eina_Bool done = EINA_FALSE;
1260 //static Eina_Bool contracted = EINA_FALSE;
1264 it->long_timer = NULL;
1265 if ((it->disabled) || (it->dragging) || (it->display_only))
1266 return ECORE_CALLBACK_CANCEL;
1267 it->wd->longpressed = EINA_TRUE;
1268 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1269 if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1271 it->wd->reorder_it = it;
1272 it->wd->reorder_start_y = 0;
1273 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1274 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1276 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1281 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1283 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1285 _item_unselect(it_tmp);
1297 EINA_LIST_FOREACH(it->items, l, it_tmp)
1299 if (elm_genlist_item_expanded_get(it_tmp))
1301 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1302 return ECORE_CALLBACK_RENEW;
1306 if (elm_genlist_item_expanded_get(it)) {
1307 elm_genlist_item_expanded_set(it, EINA_FALSE);
1308 return ECORE_CALLBACK_RENEW;
1310 if (it->wd->edit_field && it->renamed)
1311 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1314 return ECORE_CALLBACK_CANCEL;
1318 _swipe(Elm_Genlist_Item *it)
1323 it->wd->swipe = EINA_FALSE;
1324 for (i = 0; i < it->wd->movements; i++)
1326 sum += it->wd->history[i].x;
1327 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1330 sum /= it->wd->movements;
1331 if (abs(sum - it->wd->history[0].x) <= 10) return;
1332 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1336 _swipe_cancel(void *data)
1338 Elm_Genlist_Item *it = data;
1340 if (!it) return ECORE_CALLBACK_CANCEL;
1341 it->wd->swipe = EINA_FALSE;
1342 it->wd->movements = 0;
1343 return ECORE_CALLBACK_RENEW;
1347 _multi_cancel(void *data)
1349 Widget_Data *wd = data;
1351 if (!wd) return ECORE_CALLBACK_CANCEL;
1352 wd->multi_timeout = EINA_TRUE;
1353 return ECORE_CALLBACK_RENEW;
1357 _multi_touch_gesture_eval(void *data)
1359 Elm_Genlist_Item *it = data;
1361 it->wd->multitouched = EINA_FALSE;
1362 if (it->wd->multi_timer)
1364 ecore_timer_del(it->wd->multi_timer);
1365 it->wd->multi_timer = NULL;
1367 if (it->wd->multi_timeout)
1369 it->wd->multi_timeout = EINA_FALSE;
1373 Evas_Coord minw = 0, minh = 0;
1374 Evas_Coord off_x, off_y, off_mx, off_my;
1376 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1377 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1378 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1379 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1380 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1382 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1384 if ((off_x + off_mx) > (off_y + off_my))
1386 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1387 evas_object_smart_callback_call(it->base.widget,
1388 "multi,swipe,right", it);
1389 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1390 evas_object_smart_callback_call(it->base.widget,
1391 "multi,swipe,left", it);
1392 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1393 evas_object_smart_callback_call(it->base.widget,
1394 "multi,pinch,out", it);
1396 evas_object_smart_callback_call(it->base.widget,
1397 "multi,pinch,in", it);
1401 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1402 evas_object_smart_callback_call(it->base.widget,
1403 "multi,swipe,down", it);
1404 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1405 evas_object_smart_callback_call(it->base.widget,
1406 "multi,swipe,up", it);
1407 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1408 evas_object_smart_callback_call(it->base.widget,
1409 "multi,pinch,out", it);
1411 evas_object_smart_callback_call(it->base.widget,
1412 "multi,pinch,in", it);
1415 it->wd->multi_timeout = EINA_FALSE;
1419 _multi_down(void *data,
1420 Evas *evas __UNUSED__,
1421 Evas_Object *obj __UNUSED__,
1424 Elm_Genlist_Item *it = data;
1425 Evas_Event_Multi_Down *ev = event_info;
1427 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1428 it->wd->multi_device = ev->device;
1429 it->wd->multi_down = EINA_TRUE;
1430 it->wd->multitouched = EINA_TRUE;
1431 it->wd->prev_mx = ev->canvas.x;
1432 it->wd->prev_my = ev->canvas.y;
1433 if (!it->wd->wasselected) _item_unselect(it);
1434 it->wd->wasselected = EINA_FALSE;
1435 it->wd->longpressed = EINA_FALSE;
1438 ecore_timer_del(it->long_timer);
1439 it->long_timer = NULL;
1443 it->dragging = EINA_FALSE;
1444 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1446 if (it->swipe_timer)
1448 ecore_timer_del(it->swipe_timer);
1449 it->swipe_timer = NULL;
1451 if (it->wd->on_hold)
1453 it->wd->swipe = EINA_FALSE;
1454 it->wd->movements = 0;
1455 it->wd->on_hold = EINA_FALSE;
1460 _multi_up(void *data,
1461 Evas *evas __UNUSED__,
1462 Evas_Object *obj __UNUSED__,
1465 Elm_Genlist_Item *it = data;
1466 Evas_Event_Multi_Up *ev = event_info;
1468 if (it->wd->multi_device != ev->device) return;
1469 it->wd->multi_device = 0;
1470 it->wd->multi_down = EINA_FALSE;
1471 if (it->wd->mouse_down) return;
1472 _multi_touch_gesture_eval(data);
1476 _multi_move(void *data,
1477 Evas *evas __UNUSED__,
1478 Evas_Object *obj __UNUSED__,
1481 Elm_Genlist_Item *it = data;
1482 Evas_Event_Multi_Move *ev = event_info;
1484 if (it->wd->multi_device != ev->device) return;
1485 it->wd->cur_mx = ev->cur.canvas.x;
1486 it->wd->cur_my = ev->cur.canvas.y;
1490 _mouse_down(void *data,
1491 Evas *evas __UNUSED__,
1495 Elm_Genlist_Item *it = data;
1496 Evas_Event_Mouse_Down *ev = event_info;
1499 if (ev->button != 1) return;
1500 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1502 it->wd->on_hold = EINA_TRUE;
1505 if (it->wd->edit_field && !it->renamed)
1506 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1507 it->down = EINA_TRUE;
1508 it->dragging = EINA_FALSE;
1509 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1510 it->dx = ev->canvas.x - x;
1511 it->dy = ev->canvas.y - y;
1512 it->wd->mouse_down = EINA_TRUE;
1513 if (!it->wd->multitouched)
1515 it->wd->prev_x = ev->canvas.x;
1516 it->wd->prev_y = ev->canvas.y;
1517 it->wd->multi_timeout = EINA_FALSE;
1518 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1519 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1521 it->wd->longpressed = EINA_FALSE;
1522 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1523 else it->wd->on_hold = EINA_FALSE;
1524 if (it->wd->on_hold) return;
1525 it->wd->wasselected = it->selected;
1527 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1528 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1529 if (it->long_timer) ecore_timer_del(it->long_timer);
1530 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1531 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1533 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1536 it->long_timer = NULL;
1537 it->wd->swipe = EINA_FALSE;
1538 it->wd->movements = 0;
1542 _mouse_up(void *data,
1543 Evas *evas __UNUSED__,
1544 Evas_Object *obj __UNUSED__,
1547 Elm_Genlist_Item *it = data;
1548 Evas_Event_Mouse_Up *ev = event_info;
1549 Eina_Bool dragged = EINA_FALSE;
1551 if (ev->button != 1) return;
1552 it->down = EINA_FALSE;
1553 it->wd->mouse_down = EINA_FALSE;
1554 if (it->wd->multitouched)
1556 if (it->wd->multi_down) return;
1557 _multi_touch_gesture_eval(data);
1560 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1561 else it->wd->on_hold = EINA_FALSE;
1564 ecore_timer_del(it->long_timer);
1565 it->long_timer = NULL;
1569 it->dragging = EINA_FALSE;
1570 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1573 if (it->swipe_timer)
1575 ecore_timer_del(it->swipe_timer);
1576 it->swipe_timer = NULL;
1578 if (it->wd->multi_timer)
1580 ecore_timer_del(it->wd->multi_timer);
1581 it->wd->multi_timer = NULL;
1582 it->wd->multi_timeout = EINA_FALSE;
1584 if (it->wd->on_hold)
1586 if (it->wd->swipe) _swipe(data);
1587 it->wd->longpressed = EINA_FALSE;
1588 it->wd->on_hold = EINA_FALSE;
1591 if (it->wd->reorder_mode)
1593 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1594 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1597 Evas_Coord ox,oy,oh,ow;
1598 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1599 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1600 if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h;
1601 if (it->wd->reorder_rel)
1603 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1605 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1606 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1608 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1611 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1612 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1613 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1615 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1616 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1619 if (it->wd->longpressed)
1621 it->wd->longpressed = EINA_FALSE;
1622 if (!it->wd->wasselected)
1624 it->wd->wasselected = EINA_FALSE;
1629 if (it->want_unrealize)
1631 _item_unrealize(it);
1632 if (it->block->want_unrealize)
1633 _item_block_unrealize(it->block);
1636 if ((it->disabled) || (dragged) || (it->display_only)) return;
1637 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1640 if ((!it->selected) && (!it->sweeped))
1645 else _item_unselect(it);
1651 Widget_Data *wd = it->wd;
1654 while (wd->selected) _item_unselect(wd->selected->data);
1659 const Eina_List *l, *l_next;
1660 Elm_Genlist_Item *it2;
1662 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1663 if (it2 != it) _item_unselect(it2);
1664 //_item_hilight(it);
1676 _signal_expand_toggle(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);
1686 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1690 _signal_expand(void *data,
1691 Evas_Object *obj __UNUSED__,
1692 const char *emission __UNUSED__,
1693 const char *source __UNUSED__)
1695 Elm_Genlist_Item *it = data;
1698 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1702 _signal_contract(void *data,
1703 Evas_Object *obj __UNUSED__,
1704 const char *emission __UNUSED__,
1705 const char *source __UNUSED__)
1707 Elm_Genlist_Item *it = data;
1710 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1714 _item_cache_clean(Widget_Data *wd)
1716 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1720 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1721 wd->item_cache = eina_inlist_remove(wd->item_cache,
1722 wd->item_cache->last);
1723 wd->item_cache_count--;
1724 if (itc->spacer) evas_object_del(itc->spacer);
1725 if (itc->base_view) evas_object_del(itc->base_view);
1726 if (itc->item_style) eina_stringshare_del(itc->item_style);
1732 _item_cache_zero(Widget_Data *wd)
1734 int pmax = wd->item_cache_max;
1735 wd->item_cache_max = 0;
1736 _item_cache_clean(wd);
1737 wd->item_cache_max = pmax;
1741 _item_cache_add(Elm_Genlist_Item *it)
1745 if (it->wd->item_cache_max <= 0)
1747 evas_object_del(it->base.view);
1748 it->base.view = NULL;
1749 evas_object_del(it->spacer);
1754 it->wd->item_cache_count++;
1755 itc = calloc(1, sizeof(Item_Cache));
1756 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1757 EINA_INLIST_GET(itc));
1758 itc->spacer = it->spacer;
1760 itc->base_view = it->base.view;
1761 it->base.view = NULL;
1762 evas_object_hide(itc->base_view);
1763 evas_object_move(itc->base_view, -9999, -9999);
1764 itc->item_style = eina_stringshare_add(it->itc->item_style);
1765 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1766 itc->compress = (it->wd->compress);
1767 itc->odd = (it->order_num_in & 0x1);
1768 itc->selected = it->selected;
1769 itc->disabled = it->disabled;
1770 itc->expanded = it->expanded;
1773 ecore_timer_del(it->long_timer);
1774 it->long_timer = NULL;
1776 if (it->swipe_timer)
1778 ecore_timer_del(it->swipe_timer);
1779 it->swipe_timer = NULL;
1781 // FIXME: other callbacks?
1782 edje_object_signal_callback_del_full(itc->base_view,
1783 "elm,action,expand,toggle",
1784 "elm", _signal_expand_toggle, it);
1785 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1787 _signal_expand, it);
1788 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1789 "elm", _signal_contract, it);
1790 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1792 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1794 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1796 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1798 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1800 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1802 _item_cache_clean(it->wd);
1806 _item_cache_find(Elm_Genlist_Item *it)
1809 Eina_Bool tree = 0, odd;
1811 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1812 odd = (it->order_num_in & 0x1);
1813 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1815 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1817 if ((itc->tree == tree) &&
1818 (itc->odd == odd) &&
1819 (itc->compress == it->wd->compress) &&
1820 (!strcmp(it->itc->item_style, itc->item_style)))
1822 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1823 EINA_INLIST_GET(itc));
1824 it->wd->item_cache_count--;
1832 _item_cache_free(Item_Cache *itc)
1834 if (itc->spacer) evas_object_del(itc->spacer);
1835 if (itc->base_view) evas_object_del(itc->base_view);
1836 if (itc->item_style) eina_stringshare_del(itc->item_style);
1841 _item_realize(Elm_Genlist_Item *it,
1845 if ((it->realized) || (it->delete_me)) return;
1847 Elm_Genlist_Item *it2;
1848 const char *stacking;
1849 const char *treesize;
1851 int depth, tsize = 20;
1852 Item_Cache *itc = NULL;
1854 it->order_num_in = in;
1857 it->nocache = EINA_FALSE;
1859 itc = _item_cache_find(it);
1860 if (!it->wd->effect_mode && itc)
1862 it->base.view = itc->base_view;
1863 itc->base_view = NULL;
1864 it->spacer = itc->spacer;
1869 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1870 edje_object_scale_set(it->base.view,
1871 elm_widget_scale_get(it->base.widget) *
1872 _elm_config->scale);
1873 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1874 elm_widget_sub_object_add(it->base.widget, it->base.view);
1876 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1877 strncpy(buf, "tree", sizeof(buf));
1878 else strncpy(buf, "item", sizeof(buf));
1879 if (it->wd->compress)
1880 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1882 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1883 strncat(buf, "/", sizeof(buf) - strlen(buf));
1884 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1886 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1887 elm_widget_style_get(it->base.widget));
1889 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1890 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1891 elm_widget_sub_object_add(it->base.widget, it->spacer);
1893 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1895 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1897 it->expanded_depth = depth;
1898 treesize = edje_object_data_get(it->base.view, "treesize");
1899 if (treesize) tsize = atoi(treesize);
1900 evas_object_size_hint_min_set(it->spacer,
1901 (depth * tsize) * _elm_config->scale, 1);
1902 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1905 edje_object_signal_callback_add(it->base.view,
1906 "elm,action,expand,toggle",
1907 "elm", _signal_expand_toggle, it);
1908 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1909 "elm", _signal_expand, it);
1910 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1911 "elm", _signal_contract, it);
1912 stacking = edje_object_data_get(it->base.view, "stacking");
1915 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1916 else if (!strcmp(stacking, "above"))
1917 evas_object_raise(it->base.view);
1919 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1921 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1923 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1925 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1927 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1929 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1933 if (it->selected != itc->selected)
1935 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1936 edje_object_signal_emit(it->base.view,
1937 "elm,state,selected", "elm");
1939 if (it->disabled != itc->disabled)
1942 edje_object_signal_emit(it->base.view,
1943 "elm,state,disabled", "elm");
1945 if (it->expanded != itc->expanded)
1948 edje_object_signal_emit(it->base.view,
1949 "elm,state,expanded", "elm");
1954 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1955 edje_object_signal_emit(it->base.view,
1956 "elm,state,selected", "elm");
1958 edje_object_signal_emit(it->base.view,
1959 "elm,state,disabled", "elm");
1961 edje_object_signal_emit(it->base.view,
1962 "elm,state,expanded", "elm");
1966 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1968 /* homogenous genlist shortcut */
1969 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1971 it->w = it->minw = it->wd->group_item_width;
1972 it->h = it->minh = it->wd->group_item_height;
1973 it->mincalcd = EINA_TRUE;
1975 else if (!it->mincalcd)
1977 it->w = it->minw = it->wd->item_width;
1978 it->h = it->minh = it->wd->item_height;
1979 it->mincalcd = EINA_TRUE;
1984 if (it->itc->func.label_get)
1990 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1992 EINA_LIST_FOREACH(it->labels, l, key)
1994 char *s = it->itc->func.label_get
1995 ((void *)it->base.data, it->base.widget, l->data);
1999 edje_object_part_text_set(it->base.view, l->data, s);
2003 edje_object_part_text_set(it->base.view, l->data, "");
2006 if (it->itc->func.icon_get)
2012 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2014 EINA_LIST_FOREACH(it->icons, l, key)
2016 Evas_Object *ic = it->itc->func.icon_get
2017 ((void *)it->base.data, it->base.widget, l->data);
2021 it->icon_objs = eina_list_append(it->icon_objs, ic);
2022 edje_object_part_swallow(it->base.view, key, ic);
2023 evas_object_show(ic);
2024 elm_widget_sub_object_add(it->base.widget, ic);
2028 if (it->itc->func.state_get)
2034 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2036 EINA_LIST_FOREACH(it->states, l, key)
2038 Eina_Bool on = it->itc->func.state_get
2039 ((void *)it->base.data, it->base.widget, l->data);
2043 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2044 edje_object_signal_emit(it->base.view, buf, "elm");
2048 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2049 edje_object_signal_emit(it->base.view, buf, "elm");
2055 _create_sweep_objs(it);
2059 Evas_Coord mw = -1, mh = -1;
2061 if (it->wd->height_for_width) mw = it->wd->w;
2063 if (!it->display_only)
2064 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2065 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2066 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2068 if (!it->display_only)
2069 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2070 it->w = it->minw = mw;
2071 it->h = it->minh = mh;
2072 it->mincalcd = EINA_TRUE;
2074 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2076 it->wd->group_item_width = mw;
2077 it->wd->group_item_height = mh;
2079 else if ((it->wd->homogeneous))
2080 // if ((!in) && (it->wd->homogeneous))
2082 it->wd->item_width = mw;
2083 it->wd->item_height = mh;
2085 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2087 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2089 it->wd->group_item_width = mw;
2090 it->wd->group_item_height = mh;
2094 if (!calc) evas_object_show(it->base.view);
2097 if (it->tooltip.content_cb)
2099 elm_widget_item_tooltip_content_cb_set(it,
2100 it->tooltip.content_cb,
2101 it->tooltip.data, NULL);
2102 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2105 if (it->mouse_cursor)
2106 elm_widget_item_cursor_set(it, it->mouse_cursor);
2108 it->realized = EINA_TRUE;
2109 it->want_unrealize = EINA_FALSE;
2111 if (itc) _item_cache_free(itc);
2112 evas_object_smart_callback_call(it->base.widget, "realized", it);
2114 if ((it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && (!calc)) _effect_item_realize(it);
2118 _item_unrealize(Elm_Genlist_Item *it)
2122 if (!it->realized) return;
2123 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2125 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2128 ecore_timer_del(it->long_timer);
2129 it->long_timer = NULL;
2131 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2133 it->sweeped = EINA_FALSE;
2134 it->wassweeped = EINA_FALSE;
2135 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2136 _delete_sweep_objs(it);
2137 evas_object_del(it->base.view);
2138 it->base.view = NULL;
2139 evas_object_del(it->spacer);
2143 _item_cache_add(it);
2144 elm_widget_stringlist_free(it->labels);
2146 elm_widget_stringlist_free(it->icons);
2148 elm_widget_stringlist_free(it->states);
2150 EINA_LIST_FREE(it->icon_objs, icon)
2151 evas_object_del(icon);
2154 it->realized = EINA_FALSE;
2155 it->want_unrealize = EINA_FALSE;
2157 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2161 _item_block_recalc(Item_Block *itb,
2167 Elm_Genlist_Item *it;
2168 Evas_Coord minw = 0, minh = 0;
2169 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2173 EINA_LIST_FOREACH(itb->items, l, it)
2175 if (it->delete_me) continue;
2176 showme |= it->showme;
2181 if (!it->mincalcd) changed = EINA_TRUE;
2184 _item_realize(it, in, 1);
2185 _item_unrealize(it);
2190 _item_realize(it, in, 1);
2191 _item_unrealize(it);
2195 _item_realize(it, in, 0);
2197 if (minw < it->minw) minw = it->minw;
2205 itb->changed = EINA_FALSE;
2206 /* force an evas norender to garbage collect deleted objects */
2207 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2212 _item_block_realize(Item_Block *itb,
2217 Elm_Genlist_Item *it;
2219 if (itb->realized) return;
2220 EINA_LIST_FOREACH(itb->items, l, it)
2222 if (it->delete_me) continue;
2223 if (full) _item_realize(it, in, 0);
2226 itb->realized = EINA_TRUE;
2227 itb->want_unrealize = EINA_FALSE;
2231 _item_block_unrealize(Item_Block *itb)
2234 Elm_Genlist_Item *it;
2235 Eina_Bool dragging = EINA_FALSE;
2237 if (!itb->realized) return;
2238 EINA_LIST_FOREACH(itb->items, l, it)
2240 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2244 dragging = EINA_TRUE;
2245 it->want_unrealize = EINA_TRUE;
2248 _item_unrealize(it);
2253 itb->realized = EINA_FALSE;
2254 itb->want_unrealize = EINA_TRUE;
2257 itb->want_unrealize = EINA_FALSE;
2261 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2263 Evas_Coord rox, roy, row, roh;
2264 Eina_Bool top = EINA_FALSE;
2265 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2266 if (!reorder_it) return 0;
2268 Evas_Coord ox,oy,oh,ow;
2269 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2270 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2272 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2274 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2275 if (it->block->count == 1)
2276 it->wd->reorder_rel = it;
2278 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2280 it->block->reorder_offset = it->wd->reorder_it->h;
2283 it->block->reorder_offset = 0;
2285 it->scrl_y += it->block->reorder_offset;
2287 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2288 rox, roy+roh/2, row, 1));
2291 it->wd->reorder_rel = it;
2292 it->scrl_y+=it->wd->reorder_it->h;
2293 return it->wd->reorder_it->h;
2300 _reorder_item_moving_effect_timer_cb(void *data)
2302 Elm_Genlist_Item *it = data;
2303 Eina_Bool down = EINA_FALSE;
2304 double time = 0.4, t;
2306 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2309 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2313 if (it->old_scrl_y < it->scrl_y)
2315 it->old_scrl_y += y;
2318 else if (it->old_scrl_y > it->scrl_y)
2320 it->old_scrl_y -= y;
2324 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2325 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y);
2326 evas_object_show(it->base.view);
2328 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2330 _group_items_recalc(it->wd);
2331 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2333 it->old_scrl_y = it->scrl_y;
2334 it->move_effect_me = EINA_FALSE;
2335 return ECORE_CALLBACK_CANCEL;
2337 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2339 it->old_scrl_y = it->scrl_y;
2340 it->move_effect_me = EINA_FALSE;
2341 return ECORE_CALLBACK_CANCEL;
2343 return ECORE_CALLBACK_RENEW;
2347 _item_block_position(Item_Block *itb,
2351 Elm_Genlist_Item *it;
2352 Elm_Genlist_Item *git;
2353 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2354 int vis = 0, sel_all_h = 0;
2355 Elm_Genlist_Item *select_all_item = NULL;
2357 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2358 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2361 if (itb->wd->select_all_item &&
2362 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2364 if (itb->wd->select_all_check)
2365 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,del_confirm", "elm");
2367 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,del,animated,enable", "elm");
2369 select_all_item = itb->wd->select_all_item;
2371 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2372 evas_object_move(select_all_item->base.view, ox, oy);
2373 evas_object_raise(select_all_item->base.view);
2375 y = select_all_item->h;
2376 sel_all_h = select_all_item->h;
2379 EINA_LIST_FOREACH(itb->items, l, it)
2381 if (it->delete_me) continue;
2382 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2387 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2388 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2390 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2391 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2392 cvx, cvy, cvw, cvh));
2393 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2395 if ((itb->realized) && (!it->realized))
2397 if (vis) _item_realize(it, in, 0);
2403 if(it->wd->reorder_mode)
2404 y += _get_space_for_reorder_item(it);
2405 git = it->group_item;
2408 git->scrl_x = it->scrl_x;
2409 if (git->scrl_y < oy + sel_all_h)
2410 git->scrl_y = oy + sel_all_h;
2411 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2412 git->scrl_y = (it->scrl_y + it->h) - git->h;
2413 git->want_realize = EINA_TRUE;
2415 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2417 if (!it->move_effect_me)
2419 it->move_effect_me = EINA_TRUE;
2420 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2424 if (!it->move_effect_me )
2425 if (!it->wd->effect_mode || (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || (it->parent == it->wd->expand_item))
2427 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2428 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2429 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2430 if(!it->wd->effect_mode || (it->expanded_depth == 0) || (it->parent != it->wd->expand_item) || it->effect_done || (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE))
2431 evas_object_show(it->base.view);
2433 evas_object_hide(it->base.view);
2434 it->old_scrl_x = it->scrl_x;
2435 it->old_scrl_y = it->scrl_y;
2440 if (!it->dragging) _item_unrealize(it);
2447 if (vis) it->want_realize = EINA_TRUE;
2455 _group_items_recalc(void *data)
2457 Widget_Data *wd = data;
2459 Elm_Genlist_Item *git;
2461 EINA_LIST_FOREACH(wd->group_items, l, git)
2463 if (git->want_realize)
2466 _item_realize(git, 0, 0);
2467 evas_object_resize(git->base.view, wd->minw, git->h);
2468 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2469 evas_object_show(git->base.view);
2470 evas_object_raise(git->base.view);
2472 else if (!git->want_realize && git->realized)
2475 _item_unrealize(git);
2481 _must_recalc_idler(void *data)
2483 Widget_Data *wd = data;
2484 if (wd->calc_job) ecore_job_del(wd->calc_job);
2485 wd->calc_job = ecore_job_add(_calc_job, wd);
2486 wd->must_recalc_idler = NULL;
2487 return ECORE_CALLBACK_CANCEL;
2491 _calc_job(void *data)
2493 Widget_Data *wd = data;
2495 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2496 Item_Block *chb = NULL;
2497 int in = 0, minw_change = 0;
2498 Eina_Bool changed = EINA_FALSE;
2500 Eina_Bool did_must_recalc = EINA_FALSE;
2503 t0 = ecore_time_get();
2504 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2508 // if (wd->height_for_width) changed = EINA_TRUE;
2511 EINA_INLIST_FOREACH(wd->blocks, itb)
2513 Eina_Bool showme = EINA_FALSE;
2516 showme = itb->showme;
2517 itb->showme = EINA_FALSE;
2520 if (itb->realized) _item_block_unrealize(itb);
2522 if ((itb->changed) || (changed) ||
2523 ((itb->must_recalc) && (!did_must_recalc)))
2525 if ((changed) || (itb->must_recalc))
2528 Elm_Genlist_Item *it;
2529 EINA_LIST_FOREACH(itb->items, l, it)
2530 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2531 itb->changed = EINA_TRUE;
2532 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2533 itb->must_recalc = EINA_FALSE;
2535 if (itb->realized) _item_block_unrealize(itb);
2536 showme = _item_block_recalc(itb, in, 0, 1);
2542 if (minw == -1) minw = itb->minw;
2543 else if ((!itb->must_recalc) && (minw < itb->minw))
2552 if ((showme) && (wd->show_item))
2554 wd->show_item->showme = EINA_FALSE;
2556 elm_smart_scroller_region_bring_in(wd->scr,
2558 wd->show_item->block->x,
2560 wd->show_item->block->y,
2561 wd->show_item->block->w,
2564 elm_smart_scroller_child_region_show(wd->scr,
2566 wd->show_item->block->x,
2568 wd->show_item->block->y,
2569 wd->show_item->block->w,
2571 wd->show_item = NULL;
2576 EINA_INLIST_FOREACH(wd->blocks, itb)
2582 if ((chb) && (EINA_INLIST_GET(chb)->next))
2584 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2586 if (itb->realized) _item_block_unrealize(itb);
2589 wd->realminw = minw;
2590 if (minw < wd->w) minw = wd->w;
2591 if ((minw != wd->minw) || (minh != wd->minh)|| wd->select_all_item)
2595 if (wd->select_all_item)
2596 wd->minh += wd->select_all_item->h;
2597 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2598 _sizing_eval(wd->obj);
2600 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2602 Elm_Genlist_Item *it;
2605 it = wd->anchor_item;
2606 it_y = wd->anchor_y;
2607 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2608 it->block->y + it->y + it_y);
2609 wd->anchor_item = it;
2610 wd->anchor_y = it_y;
2614 t = ecore_time_get();
2615 if (did_must_recalc)
2617 if (!wd->must_recalc_idler)
2618 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2620 wd->calc_job = NULL;
2621 evas_object_smart_changed(wd->pan_smart);
2625 _update_job(void *data)
2627 Widget_Data *wd = data;
2630 int num, num0, position = 0, recalc = 0;
2632 wd->update_job = NULL;
2634 EINA_INLIST_FOREACH(wd->blocks, itb)
2636 Evas_Coord itminw, itminh;
2637 Elm_Genlist_Item *it;
2643 _item_block_position(itb, num);
2648 EINA_LIST_FOREACH(itb->items, l2, it)
2655 it->updateme = EINA_FALSE;
2658 _item_unrealize(it);
2659 _item_realize(it, num, 0);
2664 _item_realize(it, num, 1);
2665 _item_unrealize(it);
2667 if ((it->minw != itminw) || (it->minh != itminh))
2672 itb->updateme = EINA_FALSE;
2676 itb->changed = EINA_TRUE;
2677 _item_block_recalc(itb, num0, 0, 1);
2678 _item_block_position(itb, num0);
2683 if (wd->calc_job) ecore_job_del(wd->calc_job);
2684 wd->calc_job = ecore_job_add(_calc_job, wd);
2689 _pan_set(Evas_Object *obj,
2693 Pan *sd = evas_object_smart_data_get(obj);
2696 // Evas_Coord ow, oh;
2697 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2698 // ow = sd->wd->minw - ow;
2699 // if (ow < 0) ow = 0;
2700 // oh = sd->wd->minh - oh;
2701 // if (oh < 0) oh = 0;
2702 // if (x < 0) x = 0;
2703 // if (y < 0) y = 0;
2704 // if (x > ow) x = ow;
2705 // if (y > oh) y = oh;
2706 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2711 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2713 if ((itb->y + itb->h) > y)
2715 Elm_Genlist_Item *it;
2718 EINA_LIST_FOREACH(itb->items, l2, it)
2720 if ((itb->y + it->y) >= y)
2722 sd->wd->anchor_item = it;
2723 sd->wd->anchor_y = -(itb->y + it->y - y);
2731 evas_object_smart_changed(obj);
2735 _pan_get(Evas_Object *obj,
2739 Pan *sd = evas_object_smart_data_get(obj);
2741 if (x) *x = sd->wd->pan_x;
2742 if (y) *y = sd->wd->pan_y;
2746 _pan_max_get(Evas_Object *obj,
2750 Pan *sd = evas_object_smart_data_get(obj);
2753 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2754 ow = sd->wd->minw - ow;
2756 oh = sd->wd->minh - oh;
2763 _pan_min_get(Evas_Object *obj __UNUSED__,
2772 _pan_child_size_get(Evas_Object *obj,
2776 Pan *sd = evas_object_smart_data_get(obj);
2778 if (w) *w = sd->wd->minw;
2779 if (h) *h = sd->wd->minh;
2783 _pan_add(Evas_Object *obj)
2786 Evas_Object_Smart_Clipped_Data *cd;
2789 cd = evas_object_smart_data_get(obj);
2792 sd->__clipped_data = *cd;
2794 evas_object_smart_data_set(obj, sd);
2798 _pan_del(Evas_Object *obj)
2800 Pan *sd = evas_object_smart_data_get(obj);
2805 ecore_job_del(sd->resize_job);
2806 sd->resize_job = NULL;
2812 _pan_resize_job(void *data)
2815 _sizing_eval(sd->wd->obj);
2816 sd->resize_job = NULL;
2820 _pan_resize(Evas_Object *obj,
2824 Pan *sd = evas_object_smart_data_get(obj);
2827 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2828 if ((ow == w) && (oh == h)) return;
2829 if ((sd->wd->height_for_width) && (ow != w))
2831 if (sd->resize_job) ecore_job_del(sd->resize_job);
2832 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2834 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2835 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2839 _pan_calculate(Evas_Object *obj)
2841 Pan *sd = evas_object_smart_data_get(obj);
2843 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2844 static Evas_Coord old_pan_y = 0;
2846 Elm_Genlist_Item *git;
2849 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2850 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2851 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2853 git->want_realize = EINA_FALSE;
2855 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2857 itb->w = sd->wd->minw;
2858 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2859 itb->y - sd->wd->pan_y + oy,
2861 cvx, cvy, cvw, cvh))
2863 if ((!itb->realized) || (itb->changed))
2864 _item_block_realize(itb, in, 0);
2865 _item_block_position(itb, in);
2869 if (itb->realized) _item_block_unrealize(itb);
2873 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2874 _group_items_recalc(sd->wd);
2876 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2878 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2879 else sd->wd->reorder_pan_move = EINA_FALSE;
2880 evas_object_raise(sd->wd->reorder_it->base.view);
2881 old_pan_y = sd->wd->pan_y;
2884 if (sd->wd->effect_mode &&
2885 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2887 _item_flip_effect_show(sd->wd->expand_item);
2888 evas_object_raise(sd->wd->alpha_bg);
2889 evas_object_show(sd->wd->alpha_bg);
2890 sd->wd->start_time = current_time_get();
2891 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2893 else _item_auto_scroll(sd->wd);
2894 if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view);
2898 _pan_move(Evas_Object *obj,
2899 Evas_Coord x __UNUSED__,
2900 Evas_Coord y __UNUSED__)
2902 Pan *sd = evas_object_smart_data_get(obj);
2904 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2905 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2909 _hold_on(void *data __UNUSED__,
2911 void *event_info __UNUSED__)
2913 Widget_Data *wd = elm_widget_data_get(obj);
2915 elm_smart_scroller_hold_set(wd->scr, 1);
2919 _hold_off(void *data __UNUSED__,
2921 void *event_info __UNUSED__)
2923 Widget_Data *wd = elm_widget_data_get(obj);
2925 elm_smart_scroller_hold_set(wd->scr, 0);
2929 _freeze_on(void *data __UNUSED__,
2931 void *event_info __UNUSED__)
2933 Widget_Data *wd = elm_widget_data_get(obj);
2935 elm_smart_scroller_freeze_set(wd->scr, 1);
2939 _freeze_off(void *data __UNUSED__,
2941 void *event_info __UNUSED__)
2943 Widget_Data *wd = elm_widget_data_get(obj);
2945 elm_smart_scroller_freeze_set(wd->scr, 0);
2949 _scroll_edge_left(void *data,
2950 Evas_Object *scr __UNUSED__,
2951 void *event_info __UNUSED__)
2953 Evas_Object *obj = data;
2954 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2958 _scroll_edge_right(void *data,
2959 Evas_Object *scr __UNUSED__,
2960 void *event_info __UNUSED__)
2962 Evas_Object *obj = data;
2963 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2967 _scroll_edge_top(void *data,
2968 Evas_Object *scr __UNUSED__,
2969 void *event_info __UNUSED__)
2971 Evas_Object *obj = data;
2972 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2976 _scroll_edge_bottom(void *data,
2977 Evas_Object *scr __UNUSED__,
2978 void *event_info __UNUSED__)
2980 Evas_Object *obj = data;
2981 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2985 * Add a new Genlist object
2987 * @param parent The parent object
2988 * @return The new object or NULL if it cannot be created
2993 elm_genlist_add(Evas_Object *parent)
2998 Evas_Coord minw, minh;
2999 static Evas_Smart *smart = NULL;
3001 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3005 static Evas_Smart_Class sc;
3007 evas_object_smart_clipped_smart_set(&_pan_sc);
3009 sc.name = "elm_genlist_pan";
3010 sc.version = EVAS_SMART_CLASS_VERSION;
3013 sc.resize = _pan_resize;
3014 sc.move = _pan_move;
3015 sc.calculate = _pan_calculate;
3016 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3018 wd = ELM_NEW(Widget_Data);
3019 e = evas_object_evas_get(parent);
3020 if (!e) return NULL;
3021 obj = elm_widget_add(e);
3022 ELM_SET_WIDTYPE(widtype, "genlist");
3023 elm_widget_type_set(obj, "genlist");
3024 elm_widget_sub_object_add(parent, obj);
3025 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3026 elm_widget_data_set(obj, wd);
3027 elm_widget_del_hook_set(obj, _del_hook);
3028 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3029 elm_widget_theme_hook_set(obj, _theme_hook);
3030 elm_widget_can_focus_set(obj, EINA_TRUE);
3031 elm_widget_event_hook_set(obj, _event_hook);
3033 wd->scr = elm_smart_scroller_add(e);
3034 elm_smart_scroller_widget_set(wd->scr, obj);
3035 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3036 elm_widget_style_get(obj));
3037 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3038 _elm_config->thumbscroll_bounce_enable);
3039 elm_widget_resize_object_set(obj, wd->scr);
3041 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3042 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3044 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3045 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3049 wd->mode = ELM_LIST_SCROLL;
3050 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3051 wd->item_cache_max = wd->max_items_per_block * 2;
3052 wd->longpress_timeout = _elm_config->longpress_timeout;
3053 //wd->effect_mode = _elm_config->effect_enable;
3054 //wd->effect_mode = EINA_TRUE;
3056 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3057 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3058 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3059 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3061 wd->pan_smart = evas_object_smart_add(e, smart);
3062 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3065 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3066 _pan_set, _pan_get, _pan_max_get,
3067 _pan_min_get, _pan_child_size_get);
3069 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3071 evas_object_size_hint_min_set(obj, minw, minh);
3077 static Elm_Genlist_Item *
3078 _item_new(Widget_Data *wd,
3079 const Elm_Genlist_Item_Class *itc,
3081 Elm_Genlist_Item *parent,
3082 Elm_Genlist_Item_Flags flags,
3084 const void *func_data)
3086 Elm_Genlist_Item *it;
3088 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3089 if (!it) return NULL;
3092 it->base.data = data;
3093 it->parent = parent;
3095 it->func.func = func;
3096 it->func.data = func_data;
3097 it->mouse_cursor = NULL;
3098 it->expanded_depth = 0;
3099 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3100 if ((!it->parent) && (it->wd->select_all_item))
3101 _select_all_down_process(it->wd->select_all_item, EINA_FALSE);
3102 it->num = ++wd->total_num; // todo : remov
3108 _item_block_add(Widget_Data *wd,
3109 Elm_Genlist_Item *it)
3111 Item_Block *itb = NULL;
3118 itb = calloc(1, sizeof(Item_Block));
3121 if (!it->rel->block)
3124 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3125 itb->items = eina_list_append(itb->items, it);
3131 wd->blocks = eina_inlist_prepend_relative
3132 (wd->blocks, EINA_INLIST_GET(itb),
3133 EINA_INLIST_GET(it->rel->block));
3135 eina_list_prepend_relative(itb->items, it, it->rel);
3139 wd->blocks = eina_inlist_append_relative
3140 (wd->blocks, EINA_INLIST_GET(itb),
3141 EINA_INLIST_GET(it->rel->block));
3143 eina_list_append_relative(itb->items, it, it->rel);
3153 itb = (Item_Block *)(wd->blocks);
3154 if (itb->count >= wd->max_items_per_block)
3156 itb = calloc(1, sizeof(Item_Block));
3160 eina_inlist_prepend(wd->blocks,
3161 EINA_INLIST_GET(itb));
3166 itb = calloc(1, sizeof(Item_Block));
3170 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3172 itb->items = eina_list_prepend(itb->items, it);
3178 itb = (Item_Block *)(wd->blocks->last);
3179 if (itb->count >= wd->max_items_per_block)
3181 itb = calloc(1, sizeof(Item_Block));
3185 eina_inlist_append(wd->blocks,
3186 EINA_INLIST_GET(itb));
3191 itb = calloc(1, sizeof(Item_Block));
3195 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3197 itb->items = eina_list_append(itb->items, it);
3203 itb = it->rel->block;
3204 if (!itb) goto newblock;
3206 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3208 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3211 itb->changed = EINA_TRUE;
3213 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3214 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3217 it->rel->relcount--;
3218 if ((it->rel->delete_me) && (!it->rel->relcount))
3222 if (itb->count > itb->wd->max_items_per_block)
3226 Elm_Genlist_Item *it2;
3228 newc = itb->count / 2;
3229 itb2 = calloc(1, sizeof(Item_Block));
3233 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3234 EINA_INLIST_GET(itb));
3235 itb2->changed = EINA_TRUE;
3236 while ((itb->count > newc) && (itb->items))
3240 l = eina_list_last(itb->items);
3242 itb->items = eina_list_remove_list(itb->items, l);
3245 itb2->items = eina_list_prepend(itb2->items, it2);
3253 _queue_proecess(Widget_Data *wd,
3257 Eina_Bool showme = EINA_FALSE;
3260 t0 = ecore_time_get();
3261 for (n = 0; (wd->queue) && (n < 128); n++)
3263 Elm_Genlist_Item *it;
3265 it = wd->queue->data;
3266 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3267 it->queued = EINA_FALSE;
3268 _item_block_add(wd, it);
3269 t = ecore_time_get();
3270 if (it->block->changed)
3272 showme = _item_block_recalc(it->block, it->block->num, 1,
3274 it->block->changed = 0;
3276 if (showme) it->block->showme = EINA_TRUE;
3277 if (eina_inlist_count(wd->blocks) > 1)
3279 if ((t - t0) > (ecore_animator_frametime_get())) break;
3286 _item_idler(void *data)
3288 Widget_Data *wd = data;
3291 //static double q_start = 0.0;
3292 //if (q_start == 0.0) q_start = ecore_time_get();
3295 if (_queue_proecess(wd, 1) > 0)
3297 if (wd->calc_job) ecore_job_del(wd->calc_job);
3298 wd->calc_job = ecore_job_add(_calc_job, wd);
3303 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3305 wd->queue_idler = NULL;
3306 return ECORE_CALLBACK_CANCEL;
3308 return ECORE_CALLBACK_RENEW;
3312 _item_queue(Widget_Data *wd,
3313 Elm_Genlist_Item *it)
3315 if (it->queued) return;
3316 it->queued = EINA_TRUE;
3317 wd->queue = eina_list_append(wd->queue, it);
3318 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3320 if (wd->queue_idler)
3322 ecore_idler_del(wd->queue_idler);
3323 wd->queue_idler = NULL;
3325 _queue_proecess(wd, 0);
3327 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3331 * Append item to the end of the genlist
3333 * This appends the given item to the end of the list or the end of
3334 * the children if the parent is given.
3336 * @param obj The genlist object
3337 * @param itc The item class for the item
3338 * @param data The item data
3339 * @param parent The parent item, or NULL if none
3340 * @param flags Item flags
3341 * @param func Convenience function called when item selected
3342 * @param func_data Data passed to @p func above.
3343 * @return A handle to the item added or NULL if not possible
3347 EAPI Elm_Genlist_Item *
3348 elm_genlist_item_append(Evas_Object *obj,
3349 const Elm_Genlist_Item_Class *itc,
3351 Elm_Genlist_Item *parent,
3352 Elm_Genlist_Item_Flags flags,
3354 const void *func_data)
3356 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3357 Widget_Data *wd = elm_widget_data_get(obj);
3358 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3360 if (!wd) return NULL;
3361 if (!it) return NULL;
3364 if (flags & ELM_GENLIST_ITEM_GROUP)
3365 wd->group_items = eina_list_append(wd->group_items, it);
3366 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3371 Elm_Genlist_Item *it2 = NULL;
3372 Eina_List *ll = eina_list_last(it->parent->items);
3373 if (ll) it2 = ll->data;
3374 it->parent->items = eina_list_append(it->parent->items, it);
3375 if (!it2) it2 = it->parent;
3377 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3378 EINA_INLIST_GET(it2));
3380 it->rel->relcount++;
3382 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3383 it->group_item = parent;
3384 else if (it->parent->group_item)
3385 it->group_item = it->parent->group_item;
3387 it->before = EINA_FALSE;
3388 _item_queue(wd, it);
3393 * Prepend item at start of the genlist
3395 * This adds an item to the beginning of the list or beginning of the
3396 * children of the parent if given.
3398 * @param obj The genlist object
3399 * @param itc The item class for the item
3400 * @param data The item data
3401 * @param parent The parent item, or NULL if none
3402 * @param flags Item flags
3403 * @param func Convenience function called when item selected
3404 * @param func_data Data passed to @p func above.
3405 * @return A handle to the item added or NULL if not possible
3409 EAPI Elm_Genlist_Item *
3410 elm_genlist_item_prepend(Evas_Object *obj,
3411 const Elm_Genlist_Item_Class *itc,
3413 Elm_Genlist_Item *parent,
3414 Elm_Genlist_Item_Flags flags,
3416 const void *func_data)
3418 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3419 Widget_Data *wd = elm_widget_data_get(obj);
3420 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3422 if (!wd) return NULL;
3423 if (!it) return NULL;
3426 if (flags & ELM_GENLIST_ITEM_GROUP)
3427 wd->group_items = eina_list_prepend(wd->group_items, it);
3428 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3433 Elm_Genlist_Item *it2 = NULL;
3434 Eina_List *ll = it->parent->items;
3435 if (ll) it2 = ll->data;
3436 it->parent->items = eina_list_prepend(it->parent->items, it);
3437 if (!it2) it2 = it->parent;
3439 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3440 EINA_INLIST_GET(it2));
3442 it->rel->relcount++;
3444 it->before = EINA_TRUE;
3445 _item_queue(wd, it);
3450 * Insert item before another in the genlist
3452 * This inserts an item before another in the list. It will be in the
3453 * same tree level or group as the item it is inseted before.
3455 * @param obj The genlist object
3456 * @param itc The item class for the item
3457 * @param data The item data
3458 * @param before The item to insert before
3459 * @param flags Item flags
3460 * @param func Convenience function called when item selected
3461 * @param func_data Data passed to @p func above.
3462 * @return A handle to the item added or NULL if not possible
3466 EAPI Elm_Genlist_Item *
3467 elm_genlist_item_insert_before(Evas_Object *obj,
3468 const Elm_Genlist_Item_Class *itc,
3470 Elm_Genlist_Item *parent,
3471 Elm_Genlist_Item *before,
3472 Elm_Genlist_Item_Flags flags,
3474 const void *func_data)
3476 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3477 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3478 Widget_Data *wd = elm_widget_data_get(obj);
3479 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3481 if (!wd) return NULL;
3482 if (!it) return NULL;
3485 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3488 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3489 EINA_INLIST_GET(before));
3491 it->rel->relcount++;
3492 it->before = EINA_TRUE;
3493 _item_queue(wd, it);
3498 * Insert an item after another in the genlst
3500 * This inserts an item after another in the list. It will be in the
3501 * same tree level or group as the item it is inseted after.
3503 * @param obj The genlist object
3504 * @param itc The item class for the item
3505 * @param data The item data
3506 * @param after The item to insert after
3507 * @param flags Item flags
3508 * @param func Convenience function called when item selected
3509 * @param func_data Data passed to @p func above.
3510 * @return A handle to the item added or NULL if not possible
3514 EAPI Elm_Genlist_Item *
3515 elm_genlist_item_insert_after(Evas_Object *obj,
3516 const Elm_Genlist_Item_Class *itc,
3518 Elm_Genlist_Item *parent,
3519 Elm_Genlist_Item *after,
3520 Elm_Genlist_Item_Flags flags,
3522 const void *func_data)
3524 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3525 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3526 Widget_Data *wd = elm_widget_data_get(obj);
3527 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3529 if (!wd) return NULL;
3530 if (!it) return NULL;
3531 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3532 EINA_INLIST_GET(after));
3535 it->parent->items = eina_list_append_relative(it->parent->items, it,
3539 it->rel->relcount++;
3540 it->before = EINA_FALSE;
3541 _item_queue(wd, it);
3548 * This clears all items in the list, leaving it empty.
3550 * @param obj The genlist object
3555 elm_genlist_clear(Evas_Object *obj)
3557 ELM_CHECK_WIDTYPE(obj, widtype);
3558 Widget_Data *wd = elm_widget_data_get(obj);
3560 if (wd->walking > 0)
3562 Elm_Genlist_Item *it;
3564 wd->clear_me = EINA_TRUE;
3565 EINA_INLIST_FOREACH(wd->items, it)
3567 it->delete_me = EINA_TRUE;
3571 wd->clear_me = EINA_FALSE;
3574 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3577 if (wd->anchor_item == it)
3579 wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3580 if (!wd->anchor_item)
3582 (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3585 wd->items = eina_inlist_remove(wd->items, wd->items);
3586 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3587 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3588 elm_widget_item_pre_notify_del(it);
3589 if (it->realized) _item_unrealize(it);
3590 if (it->itc->func.del)
3591 it->itc->func.del((void *)it->base.data, it->base.widget);
3592 if (it->long_timer) ecore_timer_del(it->long_timer);
3593 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3594 elm_widget_item_del(it);
3596 wd->anchor_item = NULL;
3599 Item_Block *itb = (Item_Block *)(wd->blocks);
3601 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3602 if (itb->items) eina_list_free(itb->items);
3607 ecore_job_del(wd->calc_job);
3608 wd->calc_job = NULL;
3610 if (wd->queue_idler)
3612 ecore_idler_del(wd->queue_idler);
3613 wd->queue_idler = NULL;
3615 if (wd->must_recalc_idler)
3617 ecore_idler_del(wd->must_recalc_idler);
3618 wd->must_recalc_idler = NULL;
3622 eina_list_free(wd->queue);
3627 eina_list_free(wd->selected);
3628 wd->selected = NULL;
3632 Evas_Object *editfield;
3633 EINA_LIST_FREE(wd->edit_field, editfield)
3634 evas_object_del(editfield);
3635 wd->edit_field = NULL;
3637 wd->show_item = NULL;
3644 evas_object_del(wd->alpha_bg);
3645 wd->alpha_bg = NULL;
3649 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3650 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3656 * Enable or disable multi-select in the genlist
3658 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3659 * the list. This allows more than 1 item to be selected.
3661 * @param obj The genlist object
3662 * @param multi Multi-select enable/disable
3667 elm_genlist_multi_select_set(Evas_Object *obj,
3670 ELM_CHECK_WIDTYPE(obj, widtype);
3671 Widget_Data *wd = elm_widget_data_get(obj);
3677 * Gets if multi-select in genlist is enable or disable
3679 * @param obj The genlist object
3680 * @return Multi-select enable/disable
3681 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3686 elm_genlist_multi_select_get(const Evas_Object *obj)
3688 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3689 Widget_Data *wd = elm_widget_data_get(obj);
3690 if (!wd) return EINA_FALSE;
3695 * Get the selectd item in the genlist
3697 * This gets the selected item in the list (if multi-select is enabled
3698 * only the first item in the list is selected - which is not very
3699 * useful, so see elm_genlist_selected_items_get() for when
3700 * multi-select is used).
3702 * If no item is selected, NULL is returned.
3704 * @param obj The genlist object
3705 * @return The selected item, or NULL if none.
3709 EAPI Elm_Genlist_Item *
3710 elm_genlist_selected_item_get(const Evas_Object *obj)
3712 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3713 Widget_Data *wd = elm_widget_data_get(obj);
3714 if (!wd) return NULL;
3715 if (wd->selected) return wd->selected->data;
3720 * Get a list of selected items in the genlist
3722 * This returns a list of the selected items. This list pointer is
3723 * only valid so long as no items are selected or unselected (or
3724 * unselected implicitly by deletion). The list contains
3725 * Elm_Genlist_Item pointers.
3727 * @param obj The genlist object
3728 * @return The list of selected items, nor NULL if none are selected.
3732 EAPI const Eina_List *
3733 elm_genlist_selected_items_get(const Evas_Object *obj)
3735 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3736 Widget_Data *wd = elm_widget_data_get(obj);
3737 if (!wd) return NULL;
3738 return wd->selected;
3742 * Get a list of realized items in genlist
3744 * This returns a list of the realized items in the genlist. The list
3745 * contains Elm_Genlist_Item pointers. The list must be freed by the
3746 * caller when done with eina_list_free(). The item pointers in the
3747 * list are only valid so long as those items are not deleted or the
3748 * genlist is not deleted.
3750 * @param obj The genlist object
3751 * @return The list of realized items, nor NULL if none are realized.
3756 elm_genlist_realized_items_get(const Evas_Object *obj)
3758 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3759 Widget_Data *wd = elm_widget_data_get(obj);
3760 Eina_List *list = NULL;
3762 Eina_Bool done = EINA_FALSE;
3763 if (!wd) return NULL;
3764 EINA_INLIST_FOREACH(wd->blocks, itb)
3769 Elm_Genlist_Item *it;
3772 EINA_LIST_FOREACH(itb->items, l, it)
3774 if (it->realized) list = eina_list_append(list, it);
3786 * Get the item that is at the x, y canvas coords
3788 * This returns the item at the given coordinates (which are canvas
3789 * relative not object-relative). If an item is at that coordinate,
3790 * that item handle is returned, and if @p posret is not NULL, the
3791 * integer pointed to is set to a value of -1, 0 or 1, depending if
3792 * the coordinate is on the upper portion of that item (-1), on the
3793 * middle section (0) or on the lower part (1). If NULL is returned as
3794 * an item (no item found there), then posret may indicate -1 or 1
3795 * based if the coordinate is above or below all items respectively in
3798 * @param it The item
3799 * @param x The input x coordinate
3800 * @param y The input y coordinate
3801 * @param posret The position relative to the item returned here
3802 * @return The item at the coordinates or NULL if none
3806 EAPI Elm_Genlist_Item *
3807 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3813 Widget_Data *wd = elm_widget_data_get(obj);
3814 Evas_Coord ox, oy, ow, oh;
3817 if (!wd) return NULL;
3818 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3820 EINA_INLIST_FOREACH(wd->blocks, itb)
3823 Elm_Genlist_Item *it;
3825 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3826 oy + itb->y - itb->wd->pan_y,
3827 itb->w, itb->h, x, y, 1, 1))
3829 EINA_LIST_FOREACH(itb->items, l, it)
3831 Evas_Coord itx, ity;
3833 itx = ox + itb->x + it->x - itb->wd->pan_x;
3834 ity = oy + itb->y + it->y - itb->wd->pan_y;
3835 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3839 if (y <= (ity + (it->h / 4))) *posret = -1;
3840 else if (y >= (ity + it->h - (it->h / 4)))
3846 lasty = ity + it->h;
3851 if (y > lasty) *posret = 1;
3858 * Get the first item in the genlist
3860 * This returns the first item in the list.
3862 * @param obj The genlist object
3863 * @return The first item, or NULL if none
3867 EAPI Elm_Genlist_Item *
3868 elm_genlist_first_item_get(const Evas_Object *obj)
3870 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3871 Widget_Data *wd = elm_widget_data_get(obj);
3872 if (!wd) return NULL;
3873 if (!wd->items) return NULL;
3874 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3875 while ((it) && (it->delete_me))
3876 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3881 * Get the last item in the genlist
3883 * This returns the last item in the list.
3885 * @return The last item, or NULL if none
3889 EAPI Elm_Genlist_Item *
3890 elm_genlist_last_item_get(const Evas_Object *obj)
3892 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3893 Widget_Data *wd = elm_widget_data_get(obj);
3894 if (!wd) return NULL;
3895 if (!wd->items) return NULL;
3896 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3897 while ((it) && (it->delete_me))
3898 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3903 * Get the next item in the genlist
3905 * This returns the item after the item @p it.
3907 * @param it The item
3908 * @return The item after @p it, or NULL if none
3912 EAPI Elm_Genlist_Item *
3913 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3915 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3918 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3919 if ((it) && (!it->delete_me)) break;
3921 return (Elm_Genlist_Item *)it;
3925 * Get the previous item in the genlist
3927 * This returns the item before the item @p it.
3929 * @param it The item
3930 * @return The item before @p it, or NULL if none
3934 EAPI Elm_Genlist_Item *
3935 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3937 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3940 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3941 if ((it) && (!it->delete_me)) break;
3943 return (Elm_Genlist_Item *)it;
3947 * Get the genlist object from an item
3949 * This returns the genlist object itself that an item belongs to.
3951 * @param it The item
3952 * @return The genlist object
3957 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3959 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3960 return it->base.widget;
3964 * Get the parent item of the given item
3966 * This returns the parent item of the item @p it given.
3968 * @param it The item
3969 * @return The parent of the item or NULL if none
3973 EAPI Elm_Genlist_Item *
3974 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3976 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3981 * Clear all sub-items (children) of the given item
3983 * This clears all items that are children (or their descendants) of the
3986 * @param it The item
3991 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3993 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3994 Elm_Genlist_Item *it2;
3997 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
3998 _item_subitems_clear(it);
4001 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP))
4003 it->wd->expand_item = it;
4004 _item_flip_effect_show(it);
4005 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4006 it->wd->expand_item_end = y + h;
4010 it2 = elm_genlist_item_next_get(it2);
4012 } while (it2->expanded_depth > it->expanded_depth);
4014 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4016 it->wd->expand_item_gap = 0;
4018 evas_object_raise(it->wd->alpha_bg);
4019 evas_object_show(it->wd->alpha_bg);
4021 it->wd->start_time = current_time_get();
4022 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4025 _item_subitems_clear(it);
4030 * Set the selected state of an item
4032 * This sets the selected state (1 selected, 0 not selected) of the given
4035 * @param it The item
4036 * @param selected The selected state
4041 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4044 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4045 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4047 if (it->delete_me) return;
4048 selected = !!selected;
4049 if (it->selected == selected) return;
4055 while (wd->selected)
4056 _item_unselect(wd->selected->data);
4066 * Get the selected state of an item
4068 * This gets the selected state of an item (1 selected, 0 not selected).
4070 * @param it The item
4071 * @return The selected state
4076 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4078 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4079 return it->selected;
4083 * Sets the expanded state of an item (if it's a parent)
4085 * This expands or contracts a parent item (thus showing or hiding the
4088 * @param it The item
4089 * @param expanded The expanded state (1 expanded, 0 not expanded).
4094 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4097 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4098 if (it->expanded == expanded) return;
4099 it->expanded = expanded;
4100 it->wd->expand_item = it;
4102 if(it->wd->effect_mode && !it->wd->alpha_bg)
4103 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4107 it->wd->auto_scrolled = EINA_FALSE;
4108 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4110 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4111 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4115 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4117 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4118 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4123 * Get the expanded state of an item
4125 * This gets the expanded state of an item
4127 * @param it The item
4128 * @return Thre expanded state
4133 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4135 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4136 return it->expanded;
4140 * Get the depth of expanded item
4142 * @param it The genlist item object
4143 * @return The depth of expanded item
4148 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4150 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4151 return it->expanded_depth;
4155 * Sets the disabled state of an item.
4157 * A disabled item cannot be selected or unselected. It will also
4158 * change appearance to appear disabled. This sets the disabled state
4159 * (1 disabled, 0 not disabled).
4161 * @param it The item
4162 * @param disabled The disabled state
4167 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4170 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4171 if (it->disabled == disabled) return;
4172 if (it->delete_me) return;
4173 it->disabled = disabled;
4177 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4179 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4184 * Get the disabled state of an item
4186 * This gets the disabled state of the given item.
4188 * @param it The item
4189 * @return The disabled state
4194 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4196 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4197 if (it->delete_me) return EINA_FALSE;
4198 return it->disabled;
4202 * Sets the display only state of an item.
4204 * A display only item cannot be selected or unselected. It is for
4205 * display only and not selecting or otherwise clicking, dragging
4206 * etc. by the user, thus finger size rules will not be applied to
4209 * @param it The item
4210 * @param display_only The display only state
4215 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4216 Eina_Bool display_only)
4218 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4219 if (!it->block) return;
4220 if (it->display_only == display_only) return;
4221 if (it->delete_me) return;
4222 it->display_only = display_only;
4223 it->mincalcd = EINA_FALSE;
4224 it->updateme = EINA_TRUE;
4225 it->block->updateme = EINA_TRUE;
4226 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4227 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4231 * Get the display only state of an item
4233 * This gets the display only state of the given item.
4235 * @param it The item
4236 * @return The display only state
4241 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4243 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4244 if (it->delete_me) return EINA_FALSE;
4245 return it->display_only;
4249 * Show the given item
4251 * This causes genlist to jump to the given item @p it and show it (by
4252 * scrolling), if it is not fully visible.
4254 * @param it The item
4259 elm_genlist_item_show(Elm_Genlist_Item *it)
4261 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4262 Evas_Coord gith = 0;
4263 if (it->delete_me) return;
4264 if ((it->queued) || (!it->mincalcd))
4266 it->wd->show_item = it;
4267 it->wd->bring_in = EINA_TRUE;
4268 it->showme = EINA_TRUE;
4271 if (it->wd->show_item)
4273 it->wd->show_item->showme = EINA_FALSE;
4274 it->wd->show_item = NULL;
4276 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4277 gith = it->group_item->h;
4278 elm_smart_scroller_child_region_show(it->wd->scr,
4279 it->x + it->block->x,
4280 it->y + it->block->y - gith,
4281 it->block->w, it->h);
4285 * Bring in the given item
4287 * This causes genlist to jump to the given item @p it and show it (by
4288 * scrolling), if it is not fully visible. This may use animation to
4289 * do so and take a period of time
4291 * @param it The item
4296 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4298 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4299 Evas_Coord gith = 0;
4300 if (it->delete_me) return;
4301 if ((it->queued) || (!it->mincalcd))
4303 it->wd->show_item = it;
4304 it->wd->bring_in = EINA_TRUE;
4305 it->showme = EINA_TRUE;
4308 if (it->wd->show_item)
4310 it->wd->show_item->showme = EINA_FALSE;
4311 it->wd->show_item = NULL;
4313 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4314 gith = it->group_item->h;
4315 elm_smart_scroller_region_bring_in(it->wd->scr,
4316 it->x + it->block->x,
4317 it->y + it->block->y - gith,
4318 it->block->w, it->h);
4322 * Show the given item at the top
4324 * This causes genlist to jump to the given item @p it and show it (by
4325 * scrolling), if it is not fully visible.
4327 * @param it The item
4332 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4334 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4336 Evas_Coord gith = 0;
4338 if (it->delete_me) return;
4339 if ((it->queued) || (!it->mincalcd))
4341 it->wd->show_item = it;
4342 it->wd->bring_in = EINA_TRUE;
4343 it->showme = EINA_TRUE;
4346 if (it->wd->show_item)
4348 it->wd->show_item->showme = EINA_FALSE;
4349 it->wd->show_item = NULL;
4351 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4352 if (it->group_item) gith = it->group_item->h;
4353 elm_smart_scroller_child_region_show(it->wd->scr,
4354 it->x + it->block->x,
4355 it->y + it->block->y - gith,
4360 * Bring in the given item at the top
4362 * This causes genlist to jump to the given item @p it and show it (by
4363 * scrolling), if it is not fully visible. This may use animation to
4364 * do so and take a period of time
4366 * @param it The item
4371 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4373 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4375 Evas_Coord gith = 0;
4377 if (it->delete_me) return;
4378 if ((it->queued) || (!it->mincalcd))
4380 it->wd->show_item = it;
4381 it->wd->bring_in = EINA_TRUE;
4382 it->showme = EINA_TRUE;
4385 if (it->wd->show_item)
4387 it->wd->show_item->showme = EINA_FALSE;
4388 it->wd->show_item = NULL;
4390 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4391 if (it->group_item) gith = it->group_item->h;
4392 elm_smart_scroller_region_bring_in(it->wd->scr,
4393 it->x + it->block->x,
4394 it->y + it->block->y - gith,
4399 * Show the given item at the middle
4401 * This causes genlist to jump to the given item @p it and show it (by
4402 * scrolling), if it is not fully visible.
4404 * @param it The item
4409 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4411 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4414 if (it->delete_me) return;
4415 if ((it->queued) || (!it->mincalcd))
4417 it->wd->show_item = it;
4418 it->wd->bring_in = EINA_TRUE;
4419 it->showme = EINA_TRUE;
4422 if (it->wd->show_item)
4424 it->wd->show_item->showme = EINA_FALSE;
4425 it->wd->show_item = NULL;
4427 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4428 elm_smart_scroller_child_region_show(it->wd->scr,
4429 it->x + it->block->x,
4430 it->y + it->block->y - oh / 2 +
4431 it->h / 2, it->block->w, oh);
4435 * Bring in the given item at the middle
4437 * This causes genlist to jump to the given item @p it and show it (by
4438 * scrolling), if it is not fully visible. This may use animation to
4439 * do so and take a period of time
4441 * @param it The item
4446 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4448 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4451 if (it->delete_me) return;
4452 if ((it->queued) || (!it->mincalcd))
4454 it->wd->show_item = it;
4455 it->wd->bring_in = EINA_TRUE;
4456 it->showme = EINA_TRUE;
4459 if (it->wd->show_item)
4461 it->wd->show_item->showme = EINA_FALSE;
4462 it->wd->show_item = NULL;
4464 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4465 elm_smart_scroller_region_bring_in(it->wd->scr,
4466 it->x + it->block->x,
4467 it->y + it->block->y - oh / 2 + it->h / 2,
4472 * Delete a given item
4474 * This deletes the item from genlist and calls the genlist item del
4475 * class callback defined in the item class, if it is set. This clears all
4476 * subitems if it is a tree.
4478 * @param it The item
4483 elm_genlist_item_del(Elm_Genlist_Item *it)
4485 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4486 if ((it->relcount > 0) || (it->walking > 0))
4488 elm_widget_item_pre_notify_del(it);
4489 elm_genlist_item_subitems_clear(it);
4490 it->delete_me = EINA_TRUE;
4491 if (it->wd->show_item == it) it->wd->show_item = NULL;
4493 it->wd->selected = eina_list_remove(it->wd->selected,
4497 if (it->realized) _item_unrealize(it);
4498 if (it->effect_item_realized) _effect_item_unrealize(it);
4499 it->block->changed = EINA_TRUE;
4500 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4501 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4503 // if (it->itc->func.del)
4504 // it->itc->func.del((void *)it->base.data, it->base.widget);
4511 * Set the data item from the genlist item
4513 * This set the data value passed on the elm_genlist_item_append() and
4514 * related item addition calls. This function will also call
4515 * elm_genlist_item_update() so the item will be updated to reflect the
4518 * @param it The item
4519 * @param data The new data pointer to set
4524 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4527 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4528 elm_widget_item_data_set(it, data);
4529 elm_genlist_item_update(it);
4533 * Get the data item from the genlist item
4535 * This returns the data value passed on the elm_genlist_item_append()
4536 * and related item addition calls and elm_genlist_item_data_set().
4538 * @param it The item
4539 * @return The data pointer provided when created
4544 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4546 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4547 return elm_widget_item_data_get(it);
4551 * Tells genlist to "orphan" icons fetchs by the item class
4553 * This instructs genlist to release references to icons in the item,
4554 * meaning that they will no longer be managed by genlist and are
4555 * floating "orphans" that can be re-used elsewhere if the user wants
4558 * @param it The item
4563 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4566 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4567 EINA_LIST_FREE(it->icon_objs, icon)
4569 elm_widget_sub_object_del(it->base.widget, icon);
4570 evas_object_smart_member_del(icon);
4571 evas_object_hide(icon);
4576 * Get the real evas object of the genlist item
4578 * This returns the actual evas object used for the specified genlist
4579 * item. This may be NULL as it may not be created, and may be deleted
4580 * at any time by genlist. Do not modify this object (move, resize,
4581 * show, hide etc.) as genlist is controlling it. This function is for
4582 * querying, emitting custom signals or hooking lower level callbacks
4583 * for events. Do not delete this object under any circumstances.
4585 * @param it The item
4586 * @return The object pointer
4590 EAPI const Evas_Object *
4591 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4593 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4594 return it->base.view;
4598 * Update the contents of an item
4600 * This updates an item by calling all the item class functions again
4601 * to get the icons, labels and states. Use this when the original
4602 * item data has changed and the changes are desired to be reflected.
4604 * @param it The item
4609 elm_genlist_item_update(Elm_Genlist_Item *it)
4611 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4612 if (!it->block) return;
4613 if (it->delete_me) return;
4614 it->mincalcd = EINA_FALSE;
4615 it->updateme = EINA_TRUE;
4616 it->block->updateme = EINA_TRUE;
4617 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4618 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4622 * Update the item class of an item
4624 * @param it The item
4625 * @parem itc The item class for the item
4630 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4631 const Elm_Genlist_Item_Class *itc)
4633 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4634 if (!it->block) return;
4635 EINA_SAFETY_ON_NULL_RETURN(itc);
4636 if (it->delete_me) return;
4638 it->nocache = EINA_TRUE;
4639 elm_genlist_item_update(it);
4642 static Evas_Object *
4643 _elm_genlist_item_label_create(void *data,
4645 void *item __UNUSED__)
4647 Evas_Object *label = elm_label_add(obj);
4650 elm_object_style_set(label, "tooltip");
4651 elm_label_label_set(label, data);
4656 _elm_genlist_item_label_del_cb(void *data,
4657 Evas_Object *obj __UNUSED__,
4658 void *event_info __UNUSED__)
4660 eina_stringshare_del(data);
4664 * Set the text to be shown in the genlist item.
4666 * @param item Target item
4667 * @param text The text to set in the content
4669 * Setup the text as tooltip to object. The item can have only one
4670 * tooltip, so any previous tooltip data is removed.
4675 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4678 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4679 text = eina_stringshare_add(text);
4680 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4682 _elm_genlist_item_label_del_cb);
4686 * Set the content to be shown in the tooltip item
4688 * Setup the tooltip to item. The item can have only one tooltip, so
4689 * any previous tooltip data is removed. @p func(with @p data) will be
4690 * called every time that need to show the tooltip and it should return a
4691 * valid Evas_Object. This object is then managed fully by tooltip
4692 * system and is deleted when the tooltip is gone.
4694 * @param item the genlist item being attached by a tooltip.
4695 * @param func the function used to create the tooltip contents.
4696 * @param data what to provide to @a func as callback data/context.
4697 * @param del_cb called when data is not needed anymore, either when
4698 * another callback replaces @func, the tooltip is unset with
4699 * elm_genlist_item_tooltip_unset() or the owner @a item
4700 * dies. This callback receives as the first parameter the
4701 * given @a data, and @c event_info is the item.
4706 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4707 Elm_Tooltip_Item_Content_Cb func,
4709 Evas_Smart_Cb del_cb)
4711 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4713 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4716 if (item->tooltip.del_cb)
4717 item->tooltip.del_cb((void *)item->tooltip.data,
4718 item->base.widget, item);
4720 item->tooltip.content_cb = func;
4721 item->tooltip.data = data;
4722 item->tooltip.del_cb = del_cb;
4724 if (item->base.view)
4726 elm_widget_item_tooltip_content_cb_set(item,
4727 item->tooltip.content_cb,
4728 item->tooltip.data, NULL);
4729 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4735 if (del_cb) del_cb((void *)data, NULL, NULL);
4739 * Unset tooltip from item
4741 * @param item genlist item to remove previously set tooltip.
4743 * Remove tooltip from item. The callback provided as del_cb to
4744 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4745 * it is not used anymore.
4747 * @see elm_genlist_item_tooltip_content_cb_set()
4752 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4754 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4755 if ((item->base.view) && (item->tooltip.content_cb))
4756 elm_widget_item_tooltip_unset(item);
4758 if (item->tooltip.del_cb)
4759 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4760 item->tooltip.del_cb = NULL;
4761 item->tooltip.content_cb = NULL;
4762 item->tooltip.data = NULL;
4763 if (item->tooltip.style)
4764 elm_genlist_item_tooltip_style_set(item, NULL);
4768 * Sets a different style for this item tooltip.
4770 * @note before you set a style you should define a tooltip with
4771 * elm_genlist_item_tooltip_content_cb_set() or
4772 * elm_genlist_item_tooltip_text_set()
4774 * @param item genlist item with tooltip already set.
4775 * @param style the theme style to use (default, transparent, ...)
4780 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4783 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4784 eina_stringshare_replace(&item->tooltip.style, style);
4785 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4789 * Get the style for this item tooltip.
4791 * @param item genlist item with tooltip already set.
4792 * @return style the theme style in use, defaults to "default". If the
4793 * object does not have a tooltip set, then NULL is returned.
4798 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4800 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4801 return item->tooltip.style;
4805 * Set the cursor to be shown when mouse is over the genlist item
4807 * @param item Target item
4808 * @param cursor the cursor name to be used.
4810 * @see elm_object_cursor_set()
4814 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4817 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4818 eina_stringshare_replace(&item->mouse_cursor, cursor);
4819 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4823 * Get the cursor to be shown when mouse is over the genlist item
4825 * @param item genlist item with cursor already set.
4826 * @return the cursor name.
4831 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4833 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4834 return elm_widget_item_cursor_get(item);
4838 * Unset the cursor to be shown when mouse is over the genlist item
4840 * @param item Target item
4842 * @see elm_object_cursor_unset()
4846 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4848 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4849 if (!item->mouse_cursor)
4852 if (item->base.view)
4853 elm_widget_item_cursor_unset(item);
4855 eina_stringshare_del(item->mouse_cursor);
4856 item->mouse_cursor = NULL;
4860 * Sets a different style for this item cursor.
4862 * @note before you set a style you should define a cursor with
4863 * elm_genlist_item_cursor_set()
4865 * @param item genlist item with cursor already set.
4866 * @param style the theme style to use (default, transparent, ...)
4871 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4874 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4875 elm_widget_item_cursor_style_set(item, style);
4879 * Get the style for this item cursor.
4881 * @param item genlist item with cursor already set.
4882 * @return style the theme style in use, defaults to "default". If the
4883 * object does not have a cursor set, then NULL is returned.
4888 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4890 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4891 return elm_widget_item_cursor_style_get(item);
4895 * Set if the cursor set should be searched on the theme or should use
4896 * the provided by the engine, only.
4898 * @note before you set if should look on theme you should define a
4899 * cursor with elm_object_cursor_set(). By default it will only look
4900 * for cursors provided by the engine.
4902 * @param item widget item with cursor already set.
4903 * @param engine_only boolean to define it cursors should be looked
4904 * only between the provided by the engine or searched on widget's
4910 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4911 Eina_Bool engine_only)
4913 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4914 elm_widget_item_cursor_engine_only_set(item, engine_only);
4918 * Get the cursor engine only usage for this item cursor.
4920 * @param item widget item with cursor already set.
4921 * @return engine_only boolean to define it cursors should be looked
4922 * only between the provided by the engine or searched on widget's
4923 * theme as well. If the object does not have a cursor set, then
4924 * EINA_FALSE is returned.
4929 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4931 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4932 return elm_widget_item_cursor_engine_only_get(item);
4936 * This sets the horizontal stretching mode
4938 * This sets the mode used for sizing items horizontally. Valid modes
4939 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4940 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4941 * the scroller will scroll horizontally. Otherwise items are expanded
4942 * to fill the width of the viewport of the scroller. If it is
4943 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4944 * limited to that size.
4946 * @param obj The genlist object
4947 * @param mode The mode to use
4952 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4955 ELM_CHECK_WIDTYPE(obj, widtype);
4956 Widget_Data *wd = elm_widget_data_get(obj);
4958 if (wd->mode == mode) return;
4964 * Gets the horizontal stretching mode
4966 * @param obj The genlist object
4967 * @return The mode to use
4968 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4973 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4975 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4976 Widget_Data *wd = elm_widget_data_get(obj);
4977 if (!wd) return ELM_LIST_LAST;
4982 * Set the always select mode.
4984 * Items will only call their selection func and callback when first
4985 * becoming selected. Any further clicks will do nothing, unless you
4986 * enable always select with elm_genlist_always_select_mode_set().
4987 * This means even if selected, every click will make the selected
4988 * callbacks be called.
4990 * @param obj The genlist object
4991 * @param always_select The always select mode
4992 * (EINA_TRUE = on, EINA_FALSE = off)
4997 elm_genlist_always_select_mode_set(Evas_Object *obj,
4998 Eina_Bool always_select)
5000 ELM_CHECK_WIDTYPE(obj, widtype);
5001 Widget_Data *wd = elm_widget_data_get(obj);
5003 wd->always_select = always_select;
5007 * Get the always select mode.
5009 * @param obj The genlist object
5010 * @return The always select mode
5011 * (EINA_TRUE = on, EINA_FALSE = off)
5016 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5018 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5019 Widget_Data *wd = elm_widget_data_get(obj);
5020 if (!wd) return EINA_FALSE;
5021 return wd->always_select;
5025 * Set no select mode
5027 * This will turn off the ability to select items entirely and they
5028 * will neither appear selected nor call selected callback functions.
5030 * @param obj The genlist object
5031 * @param no_select The no select mode
5032 * (EINA_TRUE = on, EINA_FALSE = off)
5037 elm_genlist_no_select_mode_set(Evas_Object *obj,
5038 Eina_Bool no_select)
5040 ELM_CHECK_WIDTYPE(obj, widtype);
5041 Widget_Data *wd = elm_widget_data_get(obj);
5043 wd->no_select = no_select;
5047 * Gets no select mode
5049 * @param obj The genlist object
5050 * @return The no select mode
5051 * (EINA_TRUE = on, EINA_FALSE = off)
5056 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5058 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5059 Widget_Data *wd = elm_widget_data_get(obj);
5060 if (!wd) return EINA_FALSE;
5061 return wd->no_select;
5067 * This will enable the compress mode where items are "compressed"
5068 * horizontally to fit the genlist scrollable viewport width. This is
5069 * special for genlist. Do not rely on
5070 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5071 * work as genlist needs to handle it specially.
5073 * @param obj The genlist object
5074 * @param compress The compress mode
5075 * (EINA_TRUE = on, EINA_FALSE = off)
5080 elm_genlist_compress_mode_set(Evas_Object *obj,
5083 ELM_CHECK_WIDTYPE(obj, widtype);
5084 Widget_Data *wd = elm_widget_data_get(obj);
5086 wd->compress = compress;
5090 * Get the compress mode
5092 * @param obj The genlist object
5093 * @return The compress mode
5094 * (EINA_TRUE = on, EINA_FALSE = off)
5099 elm_genlist_compress_mode_get(const Evas_Object *obj)
5101 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5102 Widget_Data *wd = elm_widget_data_get(obj);
5103 if (!wd) return EINA_FALSE;
5104 return wd->compress;
5108 * Set height-for-width mode
5110 * With height-for-width mode the item width will be fixed (restricted
5111 * to a minimum of) to the list width when calculating its size in
5112 * order to allow the height to be calculated based on it. This allows,
5113 * for instance, text block to wrap lines if the Edje part is
5114 * configured with "text.min: 0 1".
5116 * @note This mode will make list resize slower as it will have to
5117 * recalculate every item height again whenever the list width
5120 * @note When height-for-width mode is enabled, it also enables
5121 * compress mode (see elm_genlist_compress_mode_set()) and
5122 * disables homogeneous (see elm_genlist_homogeneous_set()).
5124 * @param obj The genlist object
5125 * @param setting The height-for-width mode (EINA_TRUE = on,
5131 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5132 Eina_Bool height_for_width)
5134 ELM_CHECK_WIDTYPE(obj, widtype);
5135 Widget_Data *wd = elm_widget_data_get(obj);
5137 wd->height_for_width = !!height_for_width;
5138 if (wd->height_for_width)
5140 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5141 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5146 * Get the height-for-width mode
5148 * @param obj The genlist object
5149 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5155 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5157 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5158 Widget_Data *wd = elm_widget_data_get(obj);
5159 if (!wd) return EINA_FALSE;
5160 return wd->height_for_width;
5166 * This will enable or disable the scroller bounce mode for the
5167 * genlist. See elm_scroller_bounce_set() for details
5169 * @param obj The genlist object
5170 * @param h_bounce Allow bounce horizontally
5171 * @param v_bounce Allow bounce vertically
5176 elm_genlist_bounce_set(Evas_Object *obj,
5180 ELM_CHECK_WIDTYPE(obj, widtype);
5181 Widget_Data *wd = elm_widget_data_get(obj);
5183 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5187 * Get the bounce mode
5189 * @param obj The genlist object
5190 * @param h_bounce Allow bounce horizontally
5191 * @param v_bounce Allow bounce vertically
5196 elm_genlist_bounce_get(const Evas_Object *obj,
5197 Eina_Bool *h_bounce,
5198 Eina_Bool *v_bounce)
5200 ELM_CHECK_WIDTYPE(obj, widtype);
5201 Widget_Data *wd = elm_widget_data_get(obj);
5203 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5207 * Set homogenous mode
5209 * This will enable the homogeneous mode where items are of the same
5210 * height and width so that genlist may do the lazy-loading at its
5211 * maximum. This implies 'compressed' mode.
5213 * @param obj The genlist object
5214 * @param homogeneous Assume the items within the genlist are of the
5215 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5220 elm_genlist_homogeneous_set(Evas_Object *obj,
5221 Eina_Bool homogeneous)
5223 ELM_CHECK_WIDTYPE(obj, widtype);
5224 Widget_Data *wd = elm_widget_data_get(obj);
5226 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5227 wd->homogeneous = homogeneous;
5231 * Get the homogenous mode
5233 * @param obj The genlist object
5234 * @return Assume the items within the genlist are of the same height
5235 * and width (EINA_TRUE = on, EINA_FALSE = off)
5240 elm_genlist_homogeneous_get(const Evas_Object *obj)
5242 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5243 Widget_Data *wd = elm_widget_data_get(obj);
5244 if (!wd) return EINA_FALSE;
5245 return wd->homogeneous;
5249 * Set the maximum number of items within an item block
5251 * This will configure the block count to tune to the target with
5252 * particular performance matrix.
5254 * @param obj The genlist object
5255 * @param n Maximum number of items within an item block
5260 elm_genlist_block_count_set(Evas_Object *obj,
5263 ELM_CHECK_WIDTYPE(obj, widtype);
5264 Widget_Data *wd = elm_widget_data_get(obj);
5266 wd->max_items_per_block = n;
5267 wd->item_cache_max = wd->max_items_per_block * 2;
5268 _item_cache_clean(wd);
5272 * Get the maximum number of items within an item block
5274 * @param obj The genlist object
5275 * @return Maximum number of items within an item block
5280 elm_genlist_block_count_get(const Evas_Object *obj)
5282 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5283 Widget_Data *wd = elm_widget_data_get(obj);
5285 return wd->max_items_per_block;
5289 * Set the timeout in seconds for the longpress event
5291 * @param obj The genlist object
5292 * @param timeout timeout in seconds
5297 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5300 ELM_CHECK_WIDTYPE(obj, widtype);
5301 Widget_Data *wd = elm_widget_data_get(obj);
5303 wd->longpress_timeout = timeout;
5307 * Get the timeout in seconds for the longpress event
5309 * @param obj The genlist object
5310 * @return timeout in seconds
5315 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5317 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5318 Widget_Data *wd = elm_widget_data_get(obj);
5320 return wd->longpress_timeout;
5324 * Set the scrollbar policy
5326 * This sets the scrollbar visibility policy for the given genlist
5327 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5328 * made visible if it is needed, and otherwise kept hidden.
5329 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5330 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5331 * respectively for the horizontal and vertical scrollbars.
5333 * @param obj The genlist object
5334 * @param policy_h Horizontal scrollbar policy
5335 * @param policy_v Vertical scrollbar policy
5340 elm_genlist_scroller_policy_set(Evas_Object *obj,
5341 Elm_Scroller_Policy policy_h,
5342 Elm_Scroller_Policy policy_v)
5344 ELM_CHECK_WIDTYPE(obj, widtype);
5345 Widget_Data *wd = elm_widget_data_get(obj);
5347 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5348 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5351 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5355 * Get the scrollbar policy
5357 * @param obj The genlist object
5358 * @param policy_h Horizontal scrollbar policy
5359 * @param policy_v Vertical scrollbar policy
5364 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5365 Elm_Scroller_Policy *policy_h,
5366 Elm_Scroller_Policy *policy_v)
5368 ELM_CHECK_WIDTYPE(obj, widtype);
5369 Widget_Data *wd = elm_widget_data_get(obj);
5370 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5371 if ((!wd) || (!wd->scr)) return;
5372 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5373 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5374 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5377 /****************************************************************************/
5382 * @param obj The genlist object
5383 * @param reorder_mode The reorder mode
5384 * (EINA_TRUE = on, EINA_FALSE = off)
5389 elm_genlist_reorder_mode_set(Evas_Object *obj,
5390 Eina_Bool reorder_mode)
5392 ELM_CHECK_WIDTYPE(obj, widtype);
5393 Widget_Data *wd = elm_widget_data_get(obj);
5395 wd->reorder_mode = reorder_mode;
5399 * Get the reorder mode
5401 * @param obj The genlist object
5402 * @return The reorder mode
5403 * (EINA_TRUE = on, EINA_FALSE = off)
5408 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5410 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5411 Widget_Data *wd = elm_widget_data_get(obj);
5412 if (!wd) return EINA_FALSE;
5413 return wd->reorder_mode;
5417 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5423 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5429 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5434 if (it->wd->ed->ec->move)
5435 it->wd->ed->ec->move(it->base.widget, it, it->wd->ed->reorder_rel, EINA_TRUE);
5437 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5438 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5439 _item_block_del(it);
5441 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5443 it->rel->relcount++;
5444 it->before = EINA_FALSE;
5445 _item_queue(it->wd, it);
5449 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5452 if (!before) return;
5454 if (it->wd->ed->ec->move)
5455 it->wd->ed->ec->move(it->base.widget, it, it->wd->ed->reorder_rel, EINA_TRUE);
5457 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5458 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5459 _item_block_del(it);
5460 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5462 it->rel->relcount++;
5463 it->before = EINA_TRUE;
5464 _item_queue(it->wd, it);
5468 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5470 ELM_CHECK_WIDTYPE(obj, widtype);
5471 Widget_Data *wd = elm_widget_data_get(obj);
5473 wd->effect_mode = emode;
5474 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5475 // evas_object_resize(wd->point_rect, 10, 25);
5476 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5477 // evas_object_show(wd->point_rect);
5478 // evas_object_hide(wd->point_rect);
5482 _create_tray_alpha_bg(const Evas_Object *obj)
5484 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5485 Widget_Data *wd = elm_widget_data_get(obj);
5486 if (!wd) return NULL;
5488 Evas_Object *bg = NULL;
5489 Evas_Coord ox, oy, ow, oh;
5491 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5492 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5493 evas_object_color_set(bg,0,0,0,0);
5494 evas_object_resize(bg , ow, oh);
5495 evas_object_move(bg , ox, oy);
5496 evas_object_show(bg);
5497 evas_object_hide(bg);
5504 struct timeval timev;
5506 gettimeofday(&timev, NULL);
5507 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5510 // added for item moving animation.
5512 _item_moving_effect_timer_cb(void *data)
5514 Widget_Data *wd = data;
5515 if (!wd) return EINA_FALSE;
5517 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5518 Elm_Genlist_Item *it, *it2;
5520 double time = 0.4, t;
5522 Eina_Bool check, end = EINA_FALSE;
5523 // static Eina_Bool first = EINA_TRUE;
5526 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5528 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5529 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5531 EINA_INLIST_FOREACH(wd->blocks, itb)
5534 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5535 itb->y - wd->pan_y + oy,
5537 cvx, cvy, cvw, cvh))
5539 EINA_LIST_FOREACH(itb->items, l, it)
5544 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5549 // printf("item : %p - ", it);
5552 //printf(" s: %d %d ", oy, oh);
5553 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5554 dy = it->scrl_y - it->old_scrl_y;
5555 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5557 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5558 if(wd->expand_item_end < it->old_scrl_y)
5559 dy = wd->expand_item_gap;
5561 // printf(" dy - %d -", dy);
5563 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5569 //printf("s : %d os : %d y : %d t : %2.2f time : %2.2f dy : %d\n", it->scrl_y, it->old_scrl_y, y, t, time, dy);
5571 if (!it->old_scrl_y)
5572 it->old_scrl_y = it->scrl_y;
5575 //printf(" %d | ", it->old_scrl_y + y);
5576 if (it->old_scrl_y + y < oy + oh)
5578 // printf("%p in pan | ", it);
5579 //if (!it->realized) printf("%p is not realized %d :: \n", it, it->old_scrl_y + y);
5581 if (!it->realized) _item_realize(it, in, 0);
5583 /* else if(first && wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5585 printf("1 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5586 it->old_scrl_y = it->old_scrl_y - ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5587 wd->expand_item_gap = wd->expand_item_gap + ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5588 printf("2 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5592 // printf("%p :: %d\n", it, it->old_scrl_y + y);
5593 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5594 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5595 evas_object_show(it->base.view);
5596 evas_object_raise(it->base.view);
5598 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5600 it2 = elm_genlist_item_prev_get(it);
5603 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5605 if(!it2->effect_done)
5607 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5608 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5609 evas_object_show(it2->base.view);
5610 it2->effect_done = EINA_TRUE;
5614 it2 = elm_genlist_item_prev_get(it2);
5617 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5619 it2 = elm_genlist_item_prev_get(it);
5622 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5624 if(!it2->effect_done)
5626 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5627 it2->effect_done = EINA_TRUE;
5632 it2 = elm_genlist_item_prev_get(it2);
5638 // first = EINA_FALSE;
5642 if (wd->item_moving_effect_timer)
5644 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5645 _item_subitems_clear(wd->expand_item);
5646 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5647 EINA_INLIST_FOREACH(wd->blocks, itb)
5649 EINA_LIST_FOREACH(itb->items, l, it)
5651 it->effect_done = EINA_TRUE;
5652 it->list_expanded = 0;
5653 it->old_scrl_y = it->scrl_y;
5657 //evas_render(evas_object_evas_get(wd->obj));
5658 wd->item_moving_effect_timer = NULL;
5659 // first = EINA_TRUE;
5661 _item_auto_scroll(wd);
5662 evas_object_lower(wd->alpha_bg);
5663 evas_object_hide(wd->alpha_bg);
5665 if (wd->calc_job) ecore_job_del(wd->calc_job);
5666 wd->calc_job = ecore_job_add(_calc_job, wd);
5667 return ECORE_CALLBACK_CANCEL;
5669 return ECORE_CALLBACK_RENEW;
5673 _emit_contract(Elm_Genlist_Item *it)
5675 Elm_Genlist_Item *it2;
5678 // printf("%p is emited contract\n", it);
5679 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5680 it->effect_done = EINA_FALSE;
5682 EINA_LIST_FOREACH(it->items, l, it2)
5684 _emit_contract(it2);
5687 // added for item moving animation.
5689 _item_flip_effect_show(Elm_Genlist_Item *it)
5691 Elm_Genlist_Item *it2;
5693 Widget_Data *wd = it->wd;
5694 Eina_Bool check = EINA_FALSE;
5696 it2 = elm_genlist_item_next_get(it);
5699 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5700 it2 = elm_genlist_item_next_get(it2);
5702 EINA_LIST_FOREACH(it->items, l, it2)
5704 if (it2->parent && it == it2->parent)
5706 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5708 // edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5709 edje_object_signal_emit(it2->base.view, "flip_item", "");
5711 evas_object_move(it2->base.view, -9999, -9999);
5713 evas_object_show(it2->base.view);
5715 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5716 _emit_contract(it2);
5720 return ECORE_CALLBACK_CANCEL;
5725 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5727 printf("!!! NOW FIXING \n");
5732 * Set pinch zoom mode
5734 * @param obj The genlist object
5736 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5741 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5743 printf("!!! NOW FIXING \n");
5747 * Get pinch zoom mode
5749 * @param obj The genlist object
5750 * @return The pinch mode
5751 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5756 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5758 printf("!!! NOW FIXING \n");
5763 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5765 printf("!!! NOW FIXING \n");
5769 ////////////////////////////////////////////////////////////////////////
5771 ////////////////////////////////////////////////////////////////////////
5773 _effect_item_update(Elm_Genlist_Item *it)
5775 if (it->edit_select_check)
5777 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5778 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
5782 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5783 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
5788 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5791 if (edit_select_check_state)
5793 it->edit_select_check = EINA_TRUE;
5794 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5795 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
5799 it->edit_select_check = EINA_FALSE;
5800 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5801 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
5803 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5804 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5808 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5811 Eina_List *tl = NULL, *l;
5812 Elm_Genlist_Item *it2;
5814 EINA_LIST_FOREACH(it->items, l, it2)
5815 tl = eina_list_append(tl, it2);
5816 EINA_LIST_FREE(tl, it2)
5817 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5821 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5824 Elm_Genlist_Item *tmp_it;
5825 Eina_Bool parent_check = EINA_TRUE;
5827 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5829 if (tmp_it->parent && it->parent)
5830 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5834 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5835 else it->parent->edit_select_check = EINA_FALSE;
5840 _effect_item_update(it->parent);
5841 return _edit_parent_items_checkbox_set(it->parent);
5846 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked)
5848 if (!select_all_it || !select_all_it->wd) return;
5850 Eina_Bool old_check_state;
5851 Elm_Genlist_Item *it;
5852 Widget_Data *wd = select_all_it->wd;
5854 wd->select_all_check = checked;
5855 if (wd->select_all_check)
5856 edje_object_signal_emit(select_all_it->base.view, "elm,state,del_confirm", "elm");
5858 edje_object_signal_emit(select_all_it->base.view, "elm,state,del,animated,enable", "elm");
5860 EINA_INLIST_FOREACH(wd->items, it)
5862 old_check_state = it->edit_select_check;
5863 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5864 else it->edit_select_check = EINA_FALSE;
5866 // TODO : check this
5867 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5868 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5871 if (wd->ed->ec->item_selected)
5872 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
5874 if (wd->calc_job) ecore_job_del(wd->calc_job);
5875 wd->calc_job = ecore_job_add(_calc_job, wd);
5879 _checkbox_item_select_process(Elm_Genlist_Item *it)
5881 Elm_Genlist_Item *tmp_it;
5882 Eina_Bool old_check_state;
5883 int check_cnt = 0, total_cnt = 0;
5886 _edit_item_checkbox_set(it, it->edit_select_check);
5887 _edit_subitems_checkbox_set(it);
5888 _edit_parent_items_checkbox_set(it);
5890 if (it->wd->ed) it->wd->ed->del_item = it;
5892 if (it->edit_select_check)
5893 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
5895 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
5897 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5899 if (tmp_it->edit_select_check) check_cnt++;
5903 if (it->wd->select_all_item)
5905 old_check_state = it->wd->select_all_check;
5906 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
5907 else it->wd->select_all_check = EINA_FALSE;
5909 if (check_cnt == total_cnt)
5911 it->wd->select_all_check = EINA_TRUE;
5912 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del_confirm", "elm");
5916 it->wd->select_all_check = EINA_FALSE;
5917 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del,animated,enable", "elm");
5920 if (old_check_state != it->wd->select_all_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5921 it->wd->ed->ec->item_selected(it->wd->select_all_item->base.data, it->wd->select_all_item, it->wd->select_all_check);
5926 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5928 Elm_Genlist_Item *it = data;
5930 it->edit_select_check = !it->edit_select_check;
5931 _checkbox_item_select_process(it);
5935 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5937 Elm_Genlist_Item *select_all_it = data;
5938 Widget_Data *wd = select_all_it->wd;
5941 _select_all_down_process(select_all_it, !wd->select_all_check);
5946 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5948 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5950 evas_object_resize(it->edit_obj,it->w, it->h);
5951 evas_object_move(it->edit_obj, itx, ity);
5952 evas_object_raise(it->edit_obj);
5954 if (it->wd->select_all_check)
5955 it->edit_select_check = EINA_TRUE;
5958 if (it->edit_select_check)
5960 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
5961 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5965 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
5966 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5972 _effect_item_realize(Elm_Genlist_Item *it)
5974 if ((it->effect_item_realized) || (it->delete_me)) return;
5975 int itmode = 0, pad = 0;
5976 const char *pad_str;
5978 it->pad_left = it->pad_right = 0;
5980 if (it->itc->func.editmode_get)
5981 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
5982 itmode &= it->wd->edit_mode;
5984 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5985 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5987 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5988 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5989 _elm_config->scale);
5990 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5991 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5993 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5994 else strncpy(buf, "item", sizeof(buf));
5995 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5997 strncat(buf, "/", sizeof(buf) - strlen(buf));
5999 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
6001 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
6002 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6006 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6009 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6010 if (pad_str) pad = atoi(pad_str);
6012 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6014 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6015 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
6016 "elm", _checkbox_item_select_cb);
6018 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
6019 "elm", _checkbox_item_select_cb, it);
6020 it->pad_left += pad * _elm_config->scale;
6024 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6026 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
6027 "elm", _checkbox_item_select_cb);
6030 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6032 if (it->itc->func.icon_get)
6037 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6038 EINA_LIST_FOREACH(it->icons, l, key)
6040 Evas_Object *ic = it->itc->func.icon_get
6041 (it->base.data, it->base.widget, l->data);
6045 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6046 edje_object_part_swallow(it->edit_obj, key, ic);
6047 evas_object_show(ic);
6048 elm_widget_sub_object_add(it->base.widget, ic);
6054 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6055 evas_object_show(it->edit_obj);
6057 it->effect_item_realized = EINA_TRUE;
6058 it->want_unrealize = EINA_FALSE;
6062 _effect_item_unrealize(Elm_Genlist_Item *it)
6064 Evas_Object *icon, *editfield;
6066 if (!it->effect_item_realized) return;
6067 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6069 it->pad_left = it->pad_right = 0;
6070 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6071 // _item_cache_add(it);
6072 evas_object_del(it->edit_obj);
6073 it->edit_obj = NULL;
6074 EINA_LIST_FREE(it->edit_icon_objs, icon)
6075 evas_object_del(icon);
6077 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6078 it->effect_item_realized = EINA_FALSE;
6082 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6084 fprintf(stderr, "=================> Caution!!! <========================\n");
6085 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6086 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6087 fprintf(stderr, "=======================================================\n");
6089 elm_genlist_edit_mode_set(obj, emode, edit_class);
6093 * Set Genlist edit mode
6095 * This sets Genlist edit mode.
6097 * @param obj The Genlist object
6098 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6099 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6104 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6106 ELM_CHECK_WIDTYPE(obj, widtype);
6109 Eina_Bool done = EINA_FALSE;
6110 static Elm_Genlist_Item_Class itc;
6112 Elm_Genlist_Item *it;
6114 Widget_Data *wd = elm_widget_data_get(obj);
6116 if (wd->edit_mode == emode) return;
6118 wd->edit_mode = emode;
6120 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6121 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6124 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6126 EINA_INLIST_FOREACH(wd->blocks, itb)
6131 EINA_LIST_FOREACH(itb->items, l, it)
6133 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6135 it->pad_left = it->pad_right = 0;
6136 if (it->realized) _effect_item_unrealize(it);
6137 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
6146 if (wd->ed) free (wd->ed);
6148 wd->reorder_mode = EINA_FALSE;
6149 if (wd->select_all_item)
6151 wd->select_all_check = EINA_FALSE;
6152 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,press", "elm", _select_all_down);
6153 elm_widget_item_pre_notify_del(wd->select_all_item);
6154 _item_unrealize(wd->select_all_item);
6155 elm_widget_item_del(wd->select_all_item);
6157 EINA_INLIST_FOREACH(wd->items, it)
6159 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
6160 else it->edit_select_check = EINA_FALSE;
6163 wd->select_all_item = NULL;
6166 Evas_Object *editfield;
6167 EINA_LIST_FREE(wd->edit_field, editfield)
6168 evas_object_del(editfield);
6169 wd->edit_field = NULL;
6174 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6175 wd->reorder_mode = EINA_TRUE;
6178 wd->ed = calloc(1, sizeof(Edit_Data));
6180 wd->ed->ec = edit_class;
6182 EINA_INLIST_FOREACH(wd->blocks, itb)
6187 EINA_LIST_FOREACH(itb->items, l, it)
6189 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6191 if(it->selected) _item_unselect(it);
6192 _effect_item_realize(it);
6202 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6204 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6205 itc.item_style = edit_class->select_all_item_style;
6207 itc.item_style = "select_all";
6208 itc.func.label_get = NULL;
6209 itc.func.icon_get = NULL;
6210 itc.func.del = NULL;
6211 itc.func.editmode_get = NULL;
6212 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6215 if (!wd->select_all_item) return;
6217 _item_realize(wd->select_all_item, 0, 0);
6218 // edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
6220 wd->select_all_item->rel = NULL;
6221 wd->select_all_item->block = NULL;
6225 if (wd->calc_job) ecore_job_del(wd->calc_job);
6226 wd->calc_job = ecore_job_add(_calc_job, wd);
6230 * Delete selected items in genlist edit mode.
6232 * @param obj The genlist object
6237 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6239 ELM_CHECK_WIDTYPE(obj, widtype);
6240 Widget_Data *wd = elm_widget_data_get(obj);
6242 if (!wd->blocks) return;
6243 Elm_Genlist_Item *it;
6244 Eina_List *edit_selected_list, *l;
6247 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6248 cnt = eina_list_count(edit_selected_list);
6249 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6251 EINA_LIST_FOREACH(edit_selected_list, l, it)
6253 if (it->flags != ELM_GENLIST_ITEM_GROUP) elm_genlist_item_del(it);
6255 eina_list_free(edit_selected_list);
6257 evas_render(evas_object_evas_get(wd->obj));
6258 if (wd->calc_job) ecore_job_del(wd->calc_job);
6259 wd->calc_job = ecore_job_add(_calc_job, wd);
6263 elm_genlist_selected_items_del(Evas_Object *obj)
6265 fprintf(stderr, "=================> Caution!!! <========================\n");
6266 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6267 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6268 fprintf(stderr, "=======================================================\n");
6269 elm_genlist_edit_selected_items_del(obj);
6273 * Get a list of selected items in genlist
6275 * This returns a list of the selected items in the genlist. The list
6276 * contains Elm_Genlist_Item pointers. The list must be freed by the
6277 * caller when done with eina_list_free(). The item pointers in the list
6278 * are only vallid so long as those items are not deleted or the genlist is
6281 * @param obj The genlist object
6282 * @return The list of selected items, nor NULL if none are selected.
6287 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6289 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6290 Widget_Data *wd = elm_widget_data_get(obj);
6291 Eina_List *list = NULL;
6292 Elm_Genlist_Item *it;
6293 if (!wd) return NULL;
6295 EINA_INLIST_FOREACH(wd->items, it)
6297 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6303 // TODO : add comment
6305 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6308 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6309 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6311 selected = !!selected;
6312 if (it->edit_select_check == selected) return;
6314 if (it->wd->edit_mode)
6316 it->edit_select_check = selected;
6317 _checkbox_item_select_process(it);
6321 // TODO : add comment
6322 EAPI const Eina_Bool
6323 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6325 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6326 return it->edit_select_check;
6330 * Set a given item's rename mode
6332 * This renames the item's label from genlist
6334 * @param it The item
6335 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6340 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6344 const Eina_List *l, *list, *l2;
6345 const char *label, *rename_swallow_part;
6347 Eina_Bool done = EINA_FALSE;
6348 int label_cnt = 0 , swallow_part_cnt = 0;
6351 Evas_Object *editfield;
6352 Evas_Object *entry = NULL;
6353 int edit_field_cnt = 0;
6355 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6360 Elm_Genlist_Item *it;
6362 EINA_LIST_FOREACH(itb->items, l, it)
6366 it->renamed = EINA_FALSE;
6367 if (it->selected) _item_unselect(it);
6368 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6370 entry = elm_editfield_entry_get(editfield);
6371 const char *text = elm_entry_entry_get(entry);
6372 if (it->itc->func.label_changed)
6373 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6375 EINA_LIST_FREE(it->wd->edit_field, editfield)
6376 evas_object_del(editfield);
6377 it->wd->edit_field = NULL;
6379 if (it->wd->edit_mode)
6381 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6382 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6383 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6384 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6387 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6400 it->renamed = EINA_TRUE;
6401 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6403 it->wd->edit_mode = 0xF0;
6404 _effect_item_realize(it);
6405 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6408 EINA_LIST_FOREACH(it->labels, list, label)
6410 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6411 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6412 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6413 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6415 if (it->itc->func.label_get)
6417 swallow_part_cnt = 0;
6419 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6420 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6422 if (label_cnt == swallow_part_cnt)
6424 editfield = elm_editfield_add(it->base.widget);
6425 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6427 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6428 elm_editfield_eraser_set(editfield, EINA_TRUE);
6429 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6430 elm_widget_sub_object_add(it->edit_obj, editfield);
6432 evas_object_show(editfield);
6434 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6437 entry = elm_editfield_entry_get(editfield);
6438 elm_entry_entry_set(entry,s);
6442 elm_editfield_guide_text_set(editfield, "Text Input");
6454 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6456 Elm_Genlist_Item *it = data;
6458 _delete_sweep_objs(it);
6462 _scr_hold_timer_cb(void *data)
6464 Elm_Genlist_Item *it = data;
6465 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6466 it->wd->scr_hold_timer = NULL;
6467 return ECORE_CALLBACK_CANCEL;
6471 _delete_sweep_objs(Elm_Genlist_Item *it)
6475 elm_widget_stringlist_free(it->sweep_labels);
6476 it->sweep_labels = NULL;
6477 elm_widget_stringlist_free(it->sweep_icons);
6478 it->sweep_icons = NULL;
6479 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6480 evas_object_del(ic);
6484 _create_sweep_objs(Elm_Genlist_Item *it)
6490 if (it->itc->func.label_get)
6493 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6495 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6497 char *s = it->itc->func.label_get
6498 ((void *)it->base.data, it->base.widget, l->data);
6502 edje_object_part_text_set(it->base.view, l->data, s);
6507 if (it->itc->func.icon_get)
6510 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6512 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6514 ic = it->itc->func.icon_get
6515 ((void *)it->base.data, it->base.widget, l->data);
6519 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6520 edje_object_part_swallow(it->base.view, key, ic);
6521 evas_object_show(ic);
6522 elm_widget_sub_object_add(it->base.widget, ic);
6529 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6532 Elm_Genlist_Item *it2;
6533 const char *allow_slide;
6535 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6536 if ((!allow_slide) || (atoi(allow_slide) != 1))
6541 if (it->sweeped) return;
6542 if (it->wd->scr_hold_timer)
6544 ecore_timer_del(it->wd->scr_hold_timer);
6545 it->wd->scr_hold_timer = NULL;
6547 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6548 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6550 _delete_sweep_objs(it);
6551 _create_sweep_objs(it);
6552 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6553 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6554 it->wassweeped = EINA_TRUE;
6555 it->sweeped = EINA_TRUE;
6557 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6561 it2->sweeped = EINA_FALSE;
6562 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6563 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6564 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6570 if (!it->sweeped) return;
6571 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6572 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6573 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6574 it->sweeped = EINA_FALSE;
6579 _item_auto_scroll(void *data)
6581 Widget_Data *wd = data;
6584 if ((wd->expand_item) && (!wd->auto_scrolled))
6586 Elm_Genlist_Item *it;
6588 Evas_Coord ox, oy, ow, oh;
6589 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6591 wd->auto_scrolled = EINA_TRUE;
6592 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6594 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6596 elm_genlist_item_bring_in(it);