1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items.
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * unrealized - This is called just before an item is unrealized. After
58 * this call icon objects provided will be deleted and the item object
59 * itself delete or be put into a floating cache.
61 * drag,start,up - This is called when the item in the list has been dragged
64 * drag,start,down - This is called when the item in the list has been dragged
65 * (not scrolled) down.
67 * drag,start,left - This is called when the item in the list has been dragged
68 * (not scrolled) left.
70 * drag,start,right - This is called when the item in the list has been dragged
71 * (not scrolled) right.
73 * drag,stop - This is called when the item in the list has stopped being
76 * drag - This is called when the item in the list is being dragged.
78 * longpressed - This is called when the item is pressed for a certain amount
79 * of time. By default it's 1 second.
81 * scroll,edge,top - This is called when the genlist is scrolled until the top
84 * scroll,edge,bottom - This is called when the genlist is scrolled until the
87 * scroll,edge,left - This is called when the genlist is scrolled until the
90 * scroll,edge,right - This is called when the genlist is scrolled until the
93 * multi,swipe,left - This is called when the genlist is multi-touch swiped
96 * multi,swipe,right - This is called when the genlist is multi-touch swiped
99 * multi,swipe,up - This is called when the genlist is multi-touch swiped
102 * multi,swipe,down - This is called when the genlist is multi-touch swiped
105 * multi,pinch,out - This is called when the genlist is multi-touch pinched
108 * multi,pinch,in - This is called when the genlist is multi-touch pinched
111 * Genlist has a fairly large API, mostly because it's relatively complex,
112 * trying to be both expansive, powerful and efficient. First we will begin
113 * an overview on the theory behind genlist.
115 * Evas tracks every object you create. Every time it processes an event
116 * (mouse move, down, up etc.) it needs to walk through objects and find out
117 * what event that affects. Even worse every time it renders display updates,
118 * in order to just calculate what to re-draw, it needs to walk through many
119 * many many objects. Thus, the more objects you keep active, the more
120 * overhead Evas has in just doing its work. It is advisable to keep your
121 * active objects to the minimum working set you need. Also remember that
122 * object creation and deletion carries an overhead, so there is a
123 * middle-ground, which is not easily determined. But don't keep massive lists
124 * of objects you can't see or use. Genlist does this with list objects. It
125 * creates and destroys them dynamically as you scroll around. It groups them
126 * into blocks so it can determine the visibility etc. of a whole block at
127 * once as opposed to having to walk the whole list. This 2-level list allows
128 * for very large numbers of items to be in the list (tests have used up to
129 * 2,000,000 items). Also genlist employs a queue for adding items. As items
130 * may be different sizes, every item added needs to be calculated as to its
131 * size and thus this presents a lot of overhead on populating the list, this
132 * genlist employs a queue. Any item added is queued and spooled off over
133 * time, actually appearing some time later, so if your list has many members
134 * you may find it takes a while for them to all appear, with your process
135 * consuming a lot of CPU while it is busy spooling.
137 * Genlist also implements a tree structure, but it does so with callbacks to
138 * the application, with the application filling in tree structures when
139 * requested (allowing for efficient building of a very deep tree that could
140 * even be used for file-management). See the above smart signal callbacks for
143 * An item in the genlist world can have 0 or more text labels (they can be
144 * regular text or textblock - that's up to the style to determine), 0 or
145 * more icons (which are simply objects swallowed into the genlist item) and
146 * 0 or more boolean states that can be used for check, radio or other
147 * indicators by the edje theme style. An item may be one of several styles
148 * (Elementary provides 4 by default - "default", "double_label", "group_index"
149 * and "icon_top_text_bottom", but this can be extended by system or
150 * application custom themes/overlays/extensions).
152 * In order to implement the ability to add and delete items on the fly,
153 * Genlist implements a class/callback system where the application provides
154 * a structure with information about that type of item (genlist may contain
155 * multiple different items with different classes, states and styles).
156 * Genlist will call the functions in this struct (methods) when an item is
157 * "realized" (that is created dynamically while scrolling). All objects will
158 * simply be deleted when no longer needed with evas_object_del(). The
159 * Elm_Genlist_Item_Class structure contains the following members:
161 * item_style - This is a constant string and simply defines the name of the
162 * item style. It must be specified and the default should be "default".
164 * func.label_get - This function is called when an actual item object is
165 * created. The data parameter is the data parameter passed to
166 * elm_genlist_item_append() and related item creation functions. The obj
167 * parameter is the genlist object and the part parameter is the string name
168 * of the text part in the edje design that is listed as one of the possible
169 * labels that can be set. This function must return a strudup()'ed string as
170 * the caller will free() it when done.
172 * func.icon_get - This function is called when an actual item object is
173 * created. The data parameter is the data parameter passed to
174 * elm_genlist_item_append() and related item creation functions. The obj
175 * parameter is the genlist object and the part parameter is the string name
176 * of the icon part in the edje design that is listed as one of the possible
177 * icons that can be set. This must return NULL for no object or a valid
178 * object. The object will be deleted by genlist on shutdown or when the item
181 * func.state_get - This function is called when an actual item object is
182 * created. The data parameter is the data parameter passed to
183 * elm_genlist_item_append() and related item creation functions. The obj
184 * parameter is the genlist object and the part parameter is the string name
185 * of the state part in the edje design that is listed as one of the possible
186 * states that can be set. Return 0 for false or 1 for true. Genlist will
187 * emit a signal to the edje object with "elm,state,XXX,active" "elm" when
188 * true (the default is false), where XXX is the name of the part.
190 * func.del - This is called when elm_genlist_item_del() is called on an
191 * item, elm_genlist_clear() is called on the genlist, or
192 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
193 * intended for use when actual genlist items are deleted, so any backing
194 * data attached to the item (e.g. its data parameter on creation) can be
197 * Items can be added by several calls. All of them return a Elm_Genlist_Item
198 * handle that is an internal member inside the genlist. They all take a data
199 * parameter that is meant to be used for a handle to the applications
200 * internal data (eg the struct with the original item data). The parent
201 * parameter is the parent genlist item this belongs to if it is a tree or
202 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
203 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
204 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
205 * is displayed as an item that is able to expand and have child items.
206 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
207 * displayed at the top until the next group comes. The func parameter is a
208 * convenience callback that is called when the item is selected and the data
209 * parameter will be the func_data parameter, obj be the genlist object and
210 * event_info will be the genlist item.
212 * elm_genlist_item_append() appends an item to the end of the list, or if
213 * there is a parent, to the end of all the child items of the parent.
214 * elm_genlist_item_prepend() is the same but prepends to the beginning of
215 * the list or children list. elm_genlist_item_insert_before() inserts at
216 * item before another item and elm_genlist_item_insert_after() inserts after
217 * the indicated item.
219 * The application can clear the list with elm_genlist_clear() which deletes
220 * all the items in the list and elm_genlist_item_del() will delete a specific
221 * item. elm_genlist_item_subitems_clear() will clear all items that are
222 * children of the indicated parent item.
224 * If the application wants multiple items to be able to be selected,
225 * elm_genlist_multi_select_set() can enable this. If the list is
226 * single-selection only (the default), then elm_genlist_selected_item_get()
227 * will return the selected item, if any, or NULL I none is selected. If the
228 * list is multi-select then elm_genlist_selected_items_get() will return a
229 * list (that is only valid as long as no items are modified (added, deleted,
230 * selected or unselected)).
232 * To help inspect list items you can jump to the item at the top of the list
233 * with elm_genlist_first_item_get() which will return the item pointer, and
234 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
235 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
236 * and previous items respectively relative to the indicated item. Using
237 * these calls you can walk the entire item list/tree. Note that as a tree
238 * the items are flattened in the list, so elm_genlist_item_parent_get() will
239 * let you know which item is the parent (and thus know how to skip them if
242 * There are also convenience functions. elm_genlist_item_genlist_get() will
243 * return the genlist object the item belongs to. elm_genlist_item_show()
244 * will make the scroller scroll to show that specific item so its visible.
245 * elm_genlist_item_data_get() returns the data pointer set by the item
246 * creation functions.
248 * If an item changes (state of boolean changes, label or icons change),
249 * then use elm_genlist_item_update() to have genlist update the item with
250 * the new state. Genlist will re-realize the item thus call the functions
251 * in the _Elm_Genlist_Item_Class for that item.
253 * To programmatically (un)select an item use elm_genlist_item_selected_set().
254 * To get its selected state use elm_genlist_item_selected_get(). Similarly
255 * to expand/contract an item and get its expanded state, use
256 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
257 * again to make an item disabled (unable to be selected and appear
258 * differently) use elm_genlist_item_disabled_set() to set this and
259 * elm_genlist_item_disabled_get() to get the disabled state.
261 * In general to indicate how the genlist should expand items horizontally to
262 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
263 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
264 * mode means that if items are too wide to fit, the scroller will scroll
265 * horizontally. Otherwise items are expanded to fill the width of the
266 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
267 * to the viewport width and limited to that size. This can be combined with
268 * a different style that uses edjes' ellipsis feature (cutting text off like
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
289 typedef struct _Edit_Data Edit_Data;
291 typedef enum _Elm_Genlist_Item_Move_effect_Mode
293 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
294 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
297 ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE = (1 << 3),
298 } Elm_Genlist_Item_Move_effect_Mode;
302 Evas_Object *obj, *scr, *pan_smart;
303 Eina_Inlist *items, *blocks;
304 Eina_List *group_items;
306 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
307 Ecore_Job *calc_job, *update_job;
308 Ecore_Idler *queue_idler;
309 Ecore_Idler *must_recalc_idler;
310 Eina_List *queue, *selected;
311 Elm_Genlist_Item *show_item;
312 Elm_Genlist_Item *last_selected_item;
313 Eina_Inlist *item_cache;
314 Elm_Genlist_Item *anchor_item;
317 Ecore_Timer *multi_timer;
318 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
319 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
320 Eina_Bool mouse_down : 1;
321 Eina_Bool multi_down : 1;
322 Eina_Bool multi_timeout : 1;
323 Eina_Bool multitouched : 1;
324 Eina_Bool on_hold : 1;
326 Eina_Bool always_select : 1;
327 Eina_Bool longpressed : 1;
328 Eina_Bool wasselected : 1;
329 Eina_Bool no_select : 1;
330 Eina_Bool bring_in : 1;
331 Eina_Bool compress : 1;
332 Eina_Bool height_for_width : 1;
333 Eina_Bool homogeneous : 1;
334 Eina_Bool clear_me : 1;
339 } history[SWIPE_MOVES];
341 int item_cache_count;
347 int group_item_width;
348 int group_item_height;
349 int max_items_per_block;
350 double longpress_timeout;
352 // TODO : refactoring
353 Eina_Bool reorder_mode : 1;
354 Eina_Bool reorder_pan_move : 1;
355 Eina_Bool reorder_deleted : 1;
356 Eina_Bool effect_mode : 1;
357 Eina_Bool select_all_check : 1;
358 Eina_Bool auto_scrolled : 1;
359 Eina_Bool contracting : 1;
362 Eina_List *edit_field;
363 Elm_Genlist_Item *select_all_item;
364 Eina_List *sweeped_items;
365 Ecore_Timer *scr_hold_timer;
367 Elm_Genlist_Item *reorder_it, *reorder_rel;
368 Evas_Coord reorder_start_y;
369 Ecore_Animator *item_moving_effect_timer;
370 Evas_Object *alpha_bg;
371 Elm_Genlist_Item *expand_item;
372 Evas_Coord expand_item_end;
373 Evas_Coord expand_item_gap;
374 int move_effect_mode;
375 unsigned int start_time;
376 Ecore_Job *changed_job;
386 Evas_Coord x, y, w, h, minw, minh;
387 Eina_Bool want_unrealize : 1;
388 Eina_Bool realized : 1;
389 Eina_Bool changed : 1;
390 Eina_Bool updateme : 1;
391 Eina_Bool showme : 1;
392 Eina_Bool must_recalc : 1;
396 struct _Elm_Genlist_Item
398 Elm_Widget_Item base;
403 Evas_Coord x, y, w, h, minw, minh;
404 const Elm_Genlist_Item_Class *itc;
405 Elm_Genlist_Item *parent;
406 Elm_Genlist_Item *group_item;
407 Elm_Genlist_Item_Flags flags;
415 Eina_List *labels, *icons, *states, *icon_objs;
416 Ecore_Timer *long_timer;
417 Ecore_Timer *swipe_timer;
419 Evas_Coord scrl_x, scrl_y;
421 Elm_Genlist_Item *rel;
426 Elm_Tooltip_Item_Content_Cb content_cb;
427 Evas_Smart_Cb del_cb;
431 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 highlighted : 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_Bool reordering : 1;
461 Eina_Bool edit_select_check: 1;
462 Eina_Bool renamed : 1;
463 Eina_Bool effect_item_realized : 1;
464 Eina_Bool sweeped : 1;
465 Eina_Bool wassweeped : 1;
466 Eina_List *edit_icon_objs;
467 Evas_Object *edit_obj;
468 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
470 Ecore_Animator *item_moving_effect_timer;
471 Evas_Coord old_scrl_x, old_scrl_y;
472 Evas_Coord pad_left, pad_right;
480 Evas_Object *base_view, *spacer;
482 const char *item_style; // it->itc->item_style
483 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
484 Eina_Bool compress : 1; // it->wd->compress
485 Eina_Bool odd : 1; // in & 0x1
487 Eina_Bool selected : 1; // it->selected
488 Eina_Bool disabled : 1; // it->disabled
489 Eina_Bool expanded : 1; // it->expanded
494 Elm_Genlist_Edit_Class *ec;
495 Elm_Genlist_Item *del_item;
496 Elm_Genlist_Item *reorder_item;
497 Elm_Genlist_Item *reorder_rel;
498 Evas_Object *del_confirm;
501 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
502 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
506 Evas_Object_Smart_Clipped_Data __clipped_data;
508 Ecore_Job *resize_job;
511 static const char *widtype = NULL;
512 static void _item_cache_zero(Widget_Data *wd);
513 static void _del_hook(Evas_Object *obj);
514 static void _mirrored_set(Evas_Object *obj,
516 static void _theme_hook(Evas_Object *obj);
517 static void _show_region_hook(void *data,
519 static void _sizing_eval(Evas_Object *obj);
520 static void _item_unrealize(Elm_Genlist_Item *it);
521 static void _item_block_unrealize(Item_Block *itb);
522 static void _calc_job(void *data);
523 static void _on_focus_hook(void *data,
525 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
526 static void _changed_job(void *data);
527 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
528 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
529 static Eina_Bool _item_single_select_up(Widget_Data *wd);
530 static Eina_Bool _item_single_select_down(Widget_Data *wd);
531 static Eina_Bool _event_hook(Evas_Object *obj,
533 Evas_Callback_Type type,
535 static Eina_Bool _deselect_all_items(Widget_Data *wd);
536 static void _pan_calculate(Evas_Object *obj);
537 // TODO : refactoring
538 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
539 static unsigned int current_time_get();
540 static Eina_Bool _item_moving_effect_timer_cb(void *data);
541 static int _item_flip_effect_show(Elm_Genlist_Item *it);
542 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
543 static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on);
544 static void _effect_item_unrealize(Elm_Genlist_Item *it);
545 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
546 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
547 static void _create_sweep_objs(Elm_Genlist_Item *it);
548 static void _delete_sweep_objs(Elm_Genlist_Item *it);
549 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
550 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
551 static void _group_items_recalc(void *data);
552 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items);
553 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
554 static void _item_auto_scroll(void *data);
556 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
559 _event_hook(Evas_Object *obj,
560 Evas_Object *src __UNUSED__,
561 Evas_Callback_Type type,
564 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
565 Evas_Event_Key_Down *ev = event_info;
566 Widget_Data *wd = elm_widget_data_get(obj);
567 if (!wd) return EINA_FALSE;
568 if (!wd->items) return EINA_FALSE;
569 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
570 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
572 Elm_Genlist_Item *it = NULL;
575 Evas_Coord step_x = 0;
576 Evas_Coord step_y = 0;
579 Evas_Coord page_x = 0;
580 Evas_Coord page_y = 0;
582 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
583 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
584 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
585 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
587 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
591 else if ((!strcmp(ev->keyname, "Right")) ||
592 (!strcmp(ev->keyname, "KP_Right")))
596 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
598 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
599 (_item_multi_select_up(wd)))
600 || (_item_single_select_up(wd)))
602 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
608 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
610 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
611 (_item_multi_select_down(wd)))
612 || (_item_single_select_down(wd)))
614 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
620 else if ((!strcmp(ev->keyname, "Home")) ||
621 (!strcmp(ev->keyname, "KP_Home")))
623 it = elm_genlist_first_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, "End")) ||
629 (!strcmp(ev->keyname, "KP_End")))
631 it = elm_genlist_last_item_get(obj);
632 elm_genlist_item_bring_in(it);
633 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
636 else if ((!strcmp(ev->keyname, "Prior")) ||
637 (!strcmp(ev->keyname, "KP_Prior")))
640 y -= -(page_y * v_h) / 100;
644 else if ((!strcmp(ev->keyname, "Next")) ||
645 (!strcmp(ev->keyname, "KP_Next")))
648 y += -(page_y * v_h) / 100;
652 else if(((!strcmp(ev->keyname, "Return")) ||
653 (!strcmp(ev->keyname, "KP_Enter")) ||
654 (!strcmp(ev->keyname, "space")))
655 && (!wd->multi) && (wd->selected))
657 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
658 elm_genlist_item_expanded_set(it,
659 !elm_genlist_item_expanded_get(it));
661 else if (!strcmp(ev->keyname, "Escape"))
663 if (!_deselect_all_items(wd)) return EINA_FALSE;
664 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
667 else return EINA_FALSE;
669 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
670 elm_smart_scroller_child_pos_set(wd->scr, x, y);
675 _deselect_all_items(Widget_Data *wd)
677 if (!wd->selected) return EINA_FALSE;
679 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
685 _item_multi_select_up(Widget_Data *wd)
687 if (!wd->selected) return EINA_FALSE;
688 if (!wd->multi) return EINA_FALSE;
690 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
691 if (!prev) return EINA_TRUE;
693 if (elm_genlist_item_selected_get(prev))
695 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
696 wd->last_selected_item = prev;
697 elm_genlist_item_show(wd->last_selected_item);
701 elm_genlist_item_selected_set(prev, EINA_TRUE);
702 elm_genlist_item_show(prev);
708 _item_multi_select_down(Widget_Data *wd)
710 if (!wd->selected) return EINA_FALSE;
711 if (!wd->multi) return EINA_FALSE;
713 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
714 if (!next) return EINA_TRUE;
716 if (elm_genlist_item_selected_get(next))
718 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
719 wd->last_selected_item = next;
720 elm_genlist_item_show(wd->last_selected_item);
724 elm_genlist_item_selected_set(next, EINA_TRUE);
725 elm_genlist_item_show(next);
731 _item_single_select_up(Widget_Data *wd)
733 Elm_Genlist_Item *prev;
736 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
737 while ((prev) && (prev->delete_me))
738 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
740 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
742 if (!prev) return EINA_FALSE;
744 _deselect_all_items(wd);
746 elm_genlist_item_selected_set(prev, EINA_TRUE);
747 elm_genlist_item_show(prev);
752 _item_single_select_down(Widget_Data *wd)
754 Elm_Genlist_Item *next;
757 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
758 while ((next) && (next->delete_me))
759 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
761 else next = elm_genlist_item_next_get(wd->last_selected_item);
763 if (!next) return EINA_FALSE;
765 _deselect_all_items(wd);
767 elm_genlist_item_selected_set(next, EINA_TRUE);
768 elm_genlist_item_show(next);
773 _on_focus_hook(void *data __UNUSED__,
776 Widget_Data *wd = elm_widget_data_get(obj);
778 if (elm_widget_focus_get(obj))
780 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
781 evas_object_focus_set(wd->obj, EINA_TRUE);
782 if ((wd->selected) && (!wd->last_selected_item))
783 wd->last_selected_item = eina_list_data_get(wd->selected);
787 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
788 evas_object_focus_set(wd->obj, EINA_FALSE);
793 _del_hook(Evas_Object *obj)
795 Widget_Data *wd = elm_widget_data_get(obj);
797 _item_cache_zero(wd);
798 if (wd->calc_job) ecore_job_del(wd->calc_job);
799 if (wd->update_job) ecore_job_del(wd->update_job);
800 if (wd->changed_job) ecore_job_del(wd->changed_job);
801 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
802 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
803 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
808 _del_pre_hook(Evas_Object *obj)
810 Widget_Data *wd = elm_widget_data_get(obj);
812 if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, ELM_GENLIST_EDIT_MODE_NONE, NULL);
813 evas_object_del(wd->pan_smart);
814 wd->pan_smart = NULL;
815 elm_genlist_clear(obj);
819 _mirrored_set(Evas_Object *obj,
822 Widget_Data *wd = elm_widget_data_get(obj);
824 _item_cache_zero(wd);
825 // TODO: uncomment this after upstream merge
826 //elm_smart_scroller_mirrored_set(wd->scr, rtl);
830 _theme_hook(Evas_Object *obj)
832 Widget_Data *wd = elm_widget_data_get(obj);
835 _item_cache_zero(wd);
836 // TODO: uncomment this after upstream merge
837 //_elm_widget_mirrored_reload(obj);
838 //_mirrored_set(obj, elm_widget_mirrored_get(obj));
839 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
840 elm_widget_style_get(obj));
841 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
842 wd->item_width = wd->item_height = 0;
843 wd->group_item_width = wd->group_item_height = 0;
844 wd->minw = wd->minh = wd->realminw = 0;
845 EINA_INLIST_FOREACH(wd->blocks, itb)
848 Elm_Genlist_Item *it;
850 if (itb->realized) _item_block_unrealize(itb);
851 EINA_LIST_FOREACH(itb->items, l, it)
852 it->mincalcd = EINA_FALSE;
854 itb->changed = EINA_TRUE;
856 if (wd->calc_job) ecore_job_del(wd->calc_job);
857 wd->calc_job = ecore_job_add(_calc_job, wd);
862 _show_region_hook(void *data,
865 Widget_Data *wd = elm_widget_data_get(data);
866 Evas_Coord x, y, w, h;
868 elm_widget_show_region_get(obj, &x, &y, &w, &h);
869 //x & y are screen coordinates, Add with pan coordinates
872 if (y > 0) elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
876 _sizing_eval(Evas_Object *obj)
878 Widget_Data *wd = elm_widget_data_get(obj);
879 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
881 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
882 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
884 if (wd->height_for_width)
888 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
889 if ((vw != 0) && (vw != wd->prev_viewport_w))
893 wd->prev_viewport_w = vw;
894 EINA_INLIST_FOREACH(wd->blocks, itb)
896 itb->must_recalc = EINA_TRUE;
898 if (wd->calc_job) ecore_job_del(wd->calc_job);
899 wd->calc_job = ecore_job_add(_calc_job, wd);
902 if (wd->mode == ELM_LIST_LIMIT)
904 Evas_Coord vmw, vmh, vw, vh;
908 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
909 if ((minw > 0) && (vw < minw)) vw = minw;
910 else if ((maxw > 0) && (vw > maxw))
912 edje_object_size_min_calc
913 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
920 edje_object_size_min_calc
921 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
925 evas_object_size_hint_min_set(obj, minw, minh);
926 evas_object_size_hint_max_set(obj, maxw, maxh);
930 _item_highlight(Elm_Genlist_Item *it)
932 const char *selectraise;
933 if ((it->wd->no_select) || (it->delete_me) || (it->highlighted) || (it->disabled) || (it->display_only)) return;
934 if ((!it->sweeped) && (!it->wd->edit_mode))
935 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
936 selectraise = edje_object_data_get(it->base.view, "selectraise");
937 if ((selectraise) && (!strcmp(selectraise, "on")))
939 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
940 if ((it->group_item) && (it->group_item->realized))
941 evas_object_raise(it->group_item->base.view);
943 it->highlighted = EINA_TRUE;
944 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
948 _item_block_del(Elm_Genlist_Item *it)
951 Item_Block *itb = it->block;
953 itb->items = eina_list_remove(itb->items, it);
955 itb->changed = EINA_TRUE;
956 if (!it->wd->reorder_deleted)
958 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
959 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
963 il = EINA_INLIST_GET(itb);
964 Item_Block *itbn = (Item_Block *)(il->next);
966 it->parent->items = eina_list_remove(it->parent->items, it);
968 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
970 if (itbn) itbn->changed = EINA_TRUE;
974 if (itb->count < itb->wd->max_items_per_block/2)
976 il = EINA_INLIST_GET(itb);
977 Item_Block *itbp = (Item_Block *)(il->prev);
978 Item_Block *itbn = (Item_Block *)(il->next);
979 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
981 Elm_Genlist_Item *it2;
983 EINA_LIST_FREE(itb->items, it2)
986 itbp->items = eina_list_append(itbp->items, it2);
988 itbp->changed = EINA_TRUE;
990 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
991 EINA_INLIST_GET(itb));
994 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
998 Eina_List *last = eina_list_last(itb->items);
999 Elm_Genlist_Item *it2 = last->data;
1002 itb->items = eina_list_remove_list(itb->items, last);
1003 itbn->items = eina_list_prepend(itbn->items, it2);
1005 itbn->changed = EINA_TRUE;
1008 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
1016 _item_subitems_clear(Elm_Genlist_Item *it)
1019 Eina_List *tl = NULL, *l;
1020 Elm_Genlist_Item *it2;
1022 EINA_LIST_FOREACH(it->items, l, it2)
1023 tl = eina_list_append(tl, it2);
1025 EINA_LIST_FREE(tl, it2)
1026 elm_genlist_item_del(it2);
1030 _item_del(Elm_Genlist_Item *it)
1032 elm_widget_item_pre_notify_del(it);
1033 elm_genlist_item_subitems_clear(it);
1034 it->wd->walking -= it->walking;
1035 if (it->wd->show_item == it) it->wd->show_item = NULL;
1036 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1037 if (it->realized) _item_unrealize(it);
1038 if (it->effect_item_realized) _effect_item_unrealize(it);
1039 if (it->block) _item_block_del(it);
1040 if ((!it->delete_me) && (it->itc->func.del))
1041 it->itc->func.del((void *)it->base.data, it->base.widget);
1042 it->delete_me = EINA_TRUE;
1044 it->wd->queue = eina_list_remove(it->wd->queue, it);
1046 if (it->wd->anchor_item == it)
1048 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1049 if (!it->wd->anchor_item)
1050 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1053 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1055 it->parent->items = eina_list_remove(it->parent->items, it);
1056 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1057 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1058 if (it->long_timer) ecore_timer_del(it->long_timer);
1059 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1061 if (it->tooltip.del_cb)
1062 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1064 elm_widget_item_del(it);
1065 it->wd->total_num--; // todo : remove
1069 _item_select(Elm_Genlist_Item *it)
1071 if ((it->wd->no_select) || (it->delete_me)) return;
1072 if (it == it->wd->select_all_item)
1074 if(it->wd->select_all_check)
1075 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE);
1077 _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE);
1082 if (it->wd->always_select) goto call;
1085 it->selected = EINA_TRUE;
1086 it->wd->selected = eina_list_append(it->wd->selected, it);
1090 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1092 evas_object_smart_callback_call(it->base.widget, "selected", it);
1095 if ((it->wd->clear_me) && (!it->wd->walking))
1097 elm_genlist_clear(it->base.widget);
1102 if ((!it->walking) && (it->delete_me))
1104 if (!it->relcount) _item_del(it);
1107 if (it && it->wd) it->wd->last_selected_item = it;
1111 _item_unselect(Elm_Genlist_Item *it)
1113 const char *stacking, *selectraise;
1115 if (it == it->wd->select_all_item) return;
1116 if ((it->delete_me) || (!it->highlighted)) return;
1118 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1119 stacking = edje_object_data_get(it->base.view, "stacking");
1120 selectraise = edje_object_data_get(it->base.view, "selectraise");
1121 if ((selectraise) && (!strcmp(selectraise, "on")))
1123 if ((stacking) && (!strcmp(stacking, "below")))
1124 evas_object_lower(it->base.view);
1126 it->highlighted = EINA_FALSE;
1129 it->selected = EINA_FALSE;
1130 it->wd->selected = eina_list_remove(it->wd->selected, it);
1131 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1136 _mouse_move(void *data,
1137 Evas *evas __UNUSED__,
1141 Elm_Genlist_Item *it = data;
1142 Evas_Event_Mouse_Move *ev = event_info;
1143 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1145 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1147 if (!it->wd->on_hold)
1149 it->wd->on_hold = EINA_TRUE;
1150 if (!it->wd->wasselected)
1154 if (it->wd->multitouched)
1156 it->wd->cur_x = ev->cur.canvas.x;
1157 it->wd->cur_y = ev->cur.canvas.y;
1160 if ((it->dragging) && (it->down))
1162 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1165 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1166 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1167 if (abs((it->wd->history[it->wd->movements].x -
1168 it->wd->history[0].x)) > 40)
1169 it->wd->swipe = EINA_TRUE;
1171 it->wd->movements++;
1175 ecore_timer_del(it->long_timer);
1176 it->long_timer = NULL;
1178 evas_object_smart_callback_call(it->base.widget, "drag", it);
1181 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1185 ecore_timer_del(it->long_timer);
1186 it->long_timer = NULL;
1188 if (it->wd->reorder_mode && it->wd->reorder_it)
1190 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1191 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1192 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1193 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1195 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1196 if (it->wd->select_all_item)
1197 sel_all_h = it->wd->select_all_item->h;
1198 if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1199 else if (it_y + it->wd->reorder_it->h > oy+oh) _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1200 else _effect_item_controls(it, it->scrl_x, it_y);
1202 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1203 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1207 if (!it->display_only)
1208 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1209 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1210 x = ev->cur.canvas.x - x;
1211 y = ev->cur.canvas.y - y;
1214 if (adx < 0) adx = -dx;
1217 if (ady < 0) ady = -dy;
1220 if ((adx > minw) || (ady > minh))
1222 it->dragging = EINA_TRUE;
1225 ecore_timer_del(it->long_timer);
1226 it->long_timer = NULL;
1228 if (!it->wd->wasselected)
1233 evas_object_smart_callback_call(it->base.widget,
1234 "drag,start,up", it);
1239 evas_object_smart_callback_call(it->base.widget,
1240 "drag,start,left", it);
1241 _item_slide(it, EINA_FALSE);
1245 evas_object_smart_callback_call(it->base.widget,
1246 "drag,start,right", it);
1247 _item_slide(it, EINA_TRUE);
1254 evas_object_smart_callback_call(it->base.widget,
1255 "drag,start,down", it);
1260 evas_object_smart_callback_call(it->base.widget,
1261 "drag,start,left", it);
1262 _item_slide(it, EINA_FALSE);
1266 evas_object_smart_callback_call(it->base.widget,
1267 "drag,start,right", it);
1268 _item_slide(it, EINA_TRUE);
1276 _long_press(void *data)
1278 Elm_Genlist_Item *it = data;
1279 Elm_Genlist_Item *it_tmp;
1280 static Eina_Bool done = EINA_FALSE;
1281 //static Eina_Bool contracted = EINA_FALSE;
1285 it->long_timer = NULL;
1286 if ((it->disabled) || (it->dragging) || (it->display_only))
1287 return ECORE_CALLBACK_CANCEL;
1288 it->wd->longpressed = EINA_TRUE;
1289 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1290 if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1292 it->wd->reorder_it = it;
1293 it->wd->reorder_start_y = 0;
1294 evas_object_raise(it->edit_obj);
1295 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1296 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1298 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1303 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1305 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1307 _item_unselect(it_tmp);
1319 EINA_LIST_FOREACH(it->items, l, it_tmp)
1321 if (elm_genlist_item_expanded_get(it_tmp))
1323 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1324 return ECORE_CALLBACK_RENEW;
1328 if (elm_genlist_item_expanded_get(it)) {
1329 elm_genlist_item_expanded_set(it, EINA_FALSE);
1330 return ECORE_CALLBACK_RENEW;
1332 if (it->wd->edit_field && it->renamed)
1333 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1336 return ECORE_CALLBACK_CANCEL;
1340 _swipe(Elm_Genlist_Item *it)
1345 if ((it->display_only) || (it->disabled)) return;
1346 it->wd->swipe = EINA_FALSE;
1347 for (i = 0; i < it->wd->movements; i++)
1349 sum += it->wd->history[i].x;
1350 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1353 sum /= it->wd->movements;
1354 if (abs(sum - it->wd->history[0].x) <= 10) return;
1355 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1359 _swipe_cancel(void *data)
1361 Elm_Genlist_Item *it = data;
1363 if (!it) return ECORE_CALLBACK_CANCEL;
1364 it->wd->swipe = EINA_FALSE;
1365 it->wd->movements = 0;
1366 return ECORE_CALLBACK_RENEW;
1370 _multi_cancel(void *data)
1372 Widget_Data *wd = data;
1374 if (!wd) return ECORE_CALLBACK_CANCEL;
1375 wd->multi_timeout = EINA_TRUE;
1376 return ECORE_CALLBACK_RENEW;
1380 _multi_touch_gesture_eval(void *data)
1382 Elm_Genlist_Item *it = data;
1384 it->wd->multitouched = EINA_FALSE;
1385 if (it->wd->multi_timer)
1387 ecore_timer_del(it->wd->multi_timer);
1388 it->wd->multi_timer = NULL;
1390 if (it->wd->multi_timeout)
1392 it->wd->multi_timeout = EINA_FALSE;
1396 Evas_Coord minw = 0, minh = 0;
1397 Evas_Coord off_x, off_y, off_mx, off_my;
1399 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1400 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1401 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1402 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1403 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1405 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1407 if ((off_x + off_mx) > (off_y + off_my))
1409 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1410 evas_object_smart_callback_call(it->base.widget,
1411 "multi,swipe,right", it);
1412 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1413 evas_object_smart_callback_call(it->base.widget,
1414 "multi,swipe,left", it);
1415 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1416 evas_object_smart_callback_call(it->base.widget,
1417 "multi,pinch,out", it);
1419 evas_object_smart_callback_call(it->base.widget,
1420 "multi,pinch,in", it);
1424 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1425 evas_object_smart_callback_call(it->base.widget,
1426 "multi,swipe,down", it);
1427 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1428 evas_object_smart_callback_call(it->base.widget,
1429 "multi,swipe,up", it);
1430 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1431 evas_object_smart_callback_call(it->base.widget,
1432 "multi,pinch,out", it);
1434 evas_object_smart_callback_call(it->base.widget,
1435 "multi,pinch,in", it);
1438 it->wd->multi_timeout = EINA_FALSE;
1442 _multi_down(void *data,
1443 Evas *evas __UNUSED__,
1444 Evas_Object *obj __UNUSED__,
1447 Elm_Genlist_Item *it = data;
1448 Evas_Event_Multi_Down *ev = event_info;
1450 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1451 it->wd->multi_device = ev->device;
1452 it->wd->multi_down = EINA_TRUE;
1453 it->wd->multitouched = EINA_TRUE;
1454 it->wd->prev_mx = ev->canvas.x;
1455 it->wd->prev_my = ev->canvas.y;
1456 if (!it->wd->wasselected) _item_unselect(it);
1457 it->wd->wasselected = EINA_FALSE;
1458 it->wd->longpressed = EINA_FALSE;
1461 ecore_timer_del(it->long_timer);
1462 it->long_timer = NULL;
1466 it->dragging = EINA_FALSE;
1467 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1469 if (it->swipe_timer)
1471 ecore_timer_del(it->swipe_timer);
1472 it->swipe_timer = NULL;
1474 if (it->wd->on_hold)
1476 it->wd->swipe = EINA_FALSE;
1477 it->wd->movements = 0;
1478 it->wd->on_hold = EINA_FALSE;
1483 _multi_up(void *data,
1484 Evas *evas __UNUSED__,
1485 Evas_Object *obj __UNUSED__,
1488 Elm_Genlist_Item *it = data;
1489 Evas_Event_Multi_Up *ev = event_info;
1491 if (it->wd->multi_device != ev->device) return;
1492 it->wd->multi_device = 0;
1493 it->wd->multi_down = EINA_FALSE;
1494 if (it->wd->mouse_down) return;
1495 _multi_touch_gesture_eval(data);
1499 _multi_move(void *data,
1500 Evas *evas __UNUSED__,
1501 Evas_Object *obj __UNUSED__,
1504 Elm_Genlist_Item *it = data;
1505 Evas_Event_Multi_Move *ev = event_info;
1507 if (it->wd->multi_device != ev->device) return;
1508 it->wd->cur_mx = ev->cur.canvas.x;
1509 it->wd->cur_my = ev->cur.canvas.y;
1513 _mouse_down(void *data,
1514 Evas *evas __UNUSED__,
1518 Elm_Genlist_Item *it = data;
1519 Evas_Event_Mouse_Down *ev = event_info;
1522 if (ev->button != 1) return;
1523 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1525 it->wd->on_hold = EINA_TRUE;
1528 if (it->wd->edit_field && !it->renamed)
1529 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1530 it->down = EINA_TRUE;
1531 it->dragging = EINA_FALSE;
1532 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1533 it->dx = ev->canvas.x - x;
1534 it->dy = ev->canvas.y - y;
1535 it->wd->mouse_down = EINA_TRUE;
1536 if (!it->wd->multitouched)
1538 it->wd->prev_x = ev->canvas.x;
1539 it->wd->prev_y = ev->canvas.y;
1540 it->wd->multi_timeout = EINA_FALSE;
1541 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1542 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1544 it->wd->longpressed = EINA_FALSE;
1545 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1546 else it->wd->on_hold = EINA_FALSE;
1547 if (it->wd->on_hold) return;
1548 it->wd->wasselected = it->selected;
1549 _item_highlight(it);
1550 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1551 if ((!it->disabled) && (!it->display_only))
1552 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1553 if (it->long_timer) ecore_timer_del(it->long_timer);
1554 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1555 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1557 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1560 it->long_timer = NULL;
1561 it->wd->swipe = EINA_FALSE;
1562 it->wd->movements = 0;
1566 _mouse_up(void *data,
1567 Evas *evas __UNUSED__,
1568 Evas_Object *obj __UNUSED__,
1571 Elm_Genlist_Item *it = data;
1572 Evas_Event_Mouse_Up *ev = event_info;
1573 Eina_Bool dragged = EINA_FALSE;
1575 if (ev->button != 1) return;
1576 it->down = EINA_FALSE;
1577 it->wd->mouse_down = EINA_FALSE;
1578 if (it->wd->multitouched)
1580 if (it->wd->multi_down) return;
1581 _multi_touch_gesture_eval(data);
1584 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1585 else it->wd->on_hold = EINA_FALSE;
1588 ecore_timer_del(it->long_timer);
1589 it->long_timer = NULL;
1593 it->dragging = EINA_FALSE;
1594 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1597 if (it->swipe_timer)
1599 ecore_timer_del(it->swipe_timer);
1600 it->swipe_timer = NULL;
1602 if (it->wd->multi_timer)
1604 ecore_timer_del(it->wd->multi_timer);
1605 it->wd->multi_timer = NULL;
1606 it->wd->multi_timeout = EINA_FALSE;
1608 if (it->wd->on_hold)
1610 if (it->wd->swipe) _swipe(data);
1611 it->wd->longpressed = EINA_FALSE;
1612 it->wd->on_hold = EINA_FALSE;
1615 if (it->wd->reorder_mode)
1617 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1618 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1621 Evas_Coord ox,oy,oh,ow;
1622 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1623 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1624 if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h;
1625 if (it->wd->reorder_rel)
1627 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1629 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1630 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1632 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1635 it->wd->reorder_deleted = EINA_FALSE;
1636 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1637 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1638 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1641 if (it->wd->longpressed)
1643 it->wd->longpressed = EINA_FALSE;
1644 if (!it->wd->wasselected)
1646 it->wd->wasselected = EINA_FALSE;
1651 if (it->want_unrealize)
1653 _item_unrealize(it);
1654 if (it->block->want_unrealize)
1655 _item_block_unrealize(it->block);
1658 if ((it->disabled) || (dragged) || (it->display_only)) return;
1659 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1662 if ((!it->selected) && (!it->sweeped))
1664 _item_highlight(it);
1667 else _item_unselect(it);
1673 Widget_Data *wd = it->wd;
1676 while (wd->selected) _item_unselect(wd->selected->data);
1681 const Eina_List *l, *l_next;
1682 Elm_Genlist_Item *it2;
1684 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1685 if (it2 != it) _item_unselect(it2);
1686 //_item_highlight(it);
1691 _item_highlight(it);
1698 _signal_expand_toggle(void *data,
1699 Evas_Object *obj __UNUSED__,
1700 const char *emission __UNUSED__,
1701 const char *source __UNUSED__)
1703 Elm_Genlist_Item *it = data;
1706 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1708 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1712 _signal_expand(void *data,
1713 Evas_Object *obj __UNUSED__,
1714 const char *emission __UNUSED__,
1715 const char *source __UNUSED__)
1717 Elm_Genlist_Item *it = data;
1720 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1724 _signal_contract(void *data,
1725 Evas_Object *obj __UNUSED__,
1726 const char *emission __UNUSED__,
1727 const char *source __UNUSED__)
1729 Elm_Genlist_Item *it = data;
1732 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1736 _item_cache_clean(Widget_Data *wd)
1738 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1742 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1743 wd->item_cache = eina_inlist_remove(wd->item_cache,
1744 wd->item_cache->last);
1745 wd->item_cache_count--;
1746 if (itc->spacer) evas_object_del(itc->spacer);
1747 if (itc->base_view) evas_object_del(itc->base_view);
1748 if (itc->item_style) eina_stringshare_del(itc->item_style);
1754 _item_cache_zero(Widget_Data *wd)
1756 int pmax = wd->item_cache_max;
1757 wd->item_cache_max = 0;
1758 _item_cache_clean(wd);
1759 wd->item_cache_max = pmax;
1763 _item_cache_add(Elm_Genlist_Item *it)
1767 if (it->wd->item_cache_max <= 0)
1769 evas_object_del(it->base.view);
1770 it->base.view = NULL;
1771 evas_object_del(it->spacer);
1776 it->wd->item_cache_count++;
1777 itc = calloc(1, sizeof(Item_Cache));
1779 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1780 EINA_INLIST_GET(itc));
1781 itc->spacer = it->spacer;
1783 itc->base_view = it->base.view;
1784 it->base.view = NULL;
1785 evas_object_hide(itc->base_view);
1786 evas_object_move(itc->base_view, -9999, -9999);
1787 itc->item_style = eina_stringshare_add(it->itc->item_style);
1788 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1789 itc->compress = (it->wd->compress);
1790 itc->odd = (it->order_num_in & 0x1);
1791 itc->selected = it->selected;
1792 itc->disabled = it->disabled;
1793 itc->expanded = it->expanded;
1796 ecore_timer_del(it->long_timer);
1797 it->long_timer = NULL;
1799 if (it->swipe_timer)
1801 ecore_timer_del(it->swipe_timer);
1802 it->swipe_timer = NULL;
1804 // FIXME: other callbacks?
1805 edje_object_signal_callback_del_full(itc->base_view,
1806 "elm,action,expand,toggle",
1807 "elm", _signal_expand_toggle, it);
1808 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1810 _signal_expand, it);
1811 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1812 "elm", _signal_contract, it);
1813 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1815 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1817 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1819 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1821 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1823 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1825 _item_cache_clean(it->wd);
1829 _item_cache_find(Elm_Genlist_Item *it)
1832 Eina_Bool tree = 0, odd;
1834 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1835 odd = (it->order_num_in & 0x1);
1836 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1838 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1840 if ((itc->tree == tree) &&
1841 (itc->odd == odd) &&
1842 (itc->compress == it->wd->compress) &&
1843 (!strcmp(it->itc->item_style, itc->item_style)))
1845 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1846 EINA_INLIST_GET(itc));
1847 it->wd->item_cache_count--;
1855 _item_cache_free(Item_Cache *itc)
1857 if (itc->spacer) evas_object_del(itc->spacer);
1858 if (itc->base_view) evas_object_del(itc->base_view);
1859 if (itc->item_style) eina_stringshare_del(itc->item_style);
1864 _item_realize(Elm_Genlist_Item *it,
1868 Elm_Genlist_Item *it2;
1869 const char *stacking;
1870 const char *treesize;
1872 int depth, tsize = 20;
1873 Item_Cache *itc = NULL;
1875 if ((it->realized) || (it->delete_me)) return;
1876 it->order_num_in = in;
1877 if (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) calc = EINA_FALSE;
1879 it->nocache = EINA_FALSE;
1881 itc = _item_cache_find(it);
1882 if ((!it->wd->effect_mode) && (itc))
1884 it->base.view = itc->base_view;
1885 itc->base_view = NULL;
1886 it->spacer = itc->spacer;
1891 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1892 edje_object_scale_set(it->base.view,
1893 elm_widget_scale_get(it->base.widget) *
1894 _elm_config->scale);
1895 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1896 elm_widget_sub_object_add(it->base.widget, it->base.view);
1898 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1899 strncpy(buf, "tree", sizeof(buf));
1900 else strncpy(buf, "item", sizeof(buf));
1901 if (it->wd->compress)
1902 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1904 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1905 strncat(buf, "/", sizeof(buf) - strlen(buf));
1906 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1908 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1909 elm_widget_style_get(it->base.widget));
1910 // TODO: uncomment this after upstream merge
1911 //edje_object_mirrored_set(it->base.view,
1912 // elm_widget_mirrored_get(it->base.widget));
1914 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1915 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1916 elm_widget_sub_object_add(it->base.widget, it->spacer);
1918 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1920 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1922 it->expanded_depth = depth;
1923 treesize = edje_object_data_get(it->base.view, "treesize");
1924 if (treesize) tsize = atoi(treesize);
1925 evas_object_size_hint_min_set(it->spacer,
1926 (depth * tsize) * _elm_config->scale, 1);
1927 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1930 edje_object_signal_callback_add(it->base.view,
1931 "elm,action,expand,toggle",
1932 "elm", _signal_expand_toggle, it);
1933 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1934 "elm", _signal_expand, it);
1935 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1936 "elm", _signal_contract, it);
1937 stacking = edje_object_data_get(it->base.view, "stacking");
1940 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1941 else if (!strcmp(stacking, "above"))
1942 evas_object_raise(it->base.view);
1944 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1946 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1948 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1950 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1952 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1954 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1958 if (it->selected != itc->selected)
1960 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1961 edje_object_signal_emit(it->base.view,
1962 "elm,state,selected", "elm");
1964 if (it->disabled != itc->disabled)
1967 edje_object_signal_emit(it->base.view,
1968 "elm,state,disabled", "elm");
1970 if (it->expanded != itc->expanded)
1973 edje_object_signal_emit(it->base.view,
1974 "elm,state,expanded", "elm");
1979 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1980 edje_object_signal_emit(it->base.view,
1981 "elm,state,selected", "elm");
1983 edje_object_signal_emit(it->base.view,
1984 "elm,state,disabled", "elm");
1986 edje_object_signal_emit(it->base.view,
1987 "elm,state,expanded", "elm");
1991 if ((calc) && (it->wd->homogeneous) && ((it->wd->item_width) || ((it->wd->item_width) && (it->wd->group_item_width))))
1993 /* homogenous genlist shortcut */
1996 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1998 it->w = it->minw = it->wd->group_item_width;
1999 it->h = it->minh = it->wd->group_item_height;
2003 it->w = it->minw = it->wd->item_width;
2004 it->h = it->minh = it->wd->item_height;
2006 it->mincalcd = EINA_TRUE;
2011 if (it->itc->func.label_get)
2017 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2019 EINA_LIST_FOREACH(it->labels, l, key)
2021 char *s = it->itc->func.label_get
2022 ((void *)it->base.data, it->base.widget, l->data);
2026 edje_object_part_text_set(it->base.view, l->data, s);
2030 edje_object_part_text_set(it->base.view, l->data, "");
2033 if (it->itc->func.icon_get)
2039 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2041 EINA_LIST_FOREACH(it->icons, l, key)
2043 Evas_Object *ic = it->itc->func.icon_get
2044 ((void *)it->base.data, it->base.widget, l->data);
2048 it->icon_objs = eina_list_append(it->icon_objs, ic);
2049 edje_object_part_swallow(it->base.view, key, ic);
2050 evas_object_show(ic);
2051 elm_widget_sub_object_add(it->base.widget, ic);
2052 evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it);
2056 if (it->itc->func.state_get)
2062 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2064 EINA_LIST_FOREACH(it->states, l, key)
2066 Eina_Bool on = it->itc->func.state_get
2067 ((void *)it->base.data, it->base.widget, l->data);
2071 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2072 edje_object_signal_emit(it->base.view, buf, "elm");
2076 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2077 edje_object_signal_emit(it->base.view, buf, "elm");
2082 _create_sweep_objs(it);
2085 Evas_Coord mw = -1, mh = -1;
2087 if (it->wd->height_for_width) mw = it->wd->w;
2089 if (!it->display_only)
2090 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2091 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2092 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2094 if (!it->display_only)
2095 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2096 it->w = it->minw = mw;
2097 it->h = it->minh = mh;
2098 it->mincalcd = EINA_TRUE;
2100 if ((!it->wd->group_item_width) && (it->flags == ELM_GENLIST_ITEM_GROUP))
2102 it->wd->group_item_width = mw;
2103 it->wd->group_item_height = mh;
2105 else if ((!it->wd->item_width) && (it->flags == ELM_GENLIST_ITEM_NONE))
2107 it->wd->item_width = mw;
2108 it->wd->item_height = mh;
2111 if (!calc) evas_object_show(it->base.view);
2114 if (it->tooltip.content_cb)
2116 elm_widget_item_tooltip_content_cb_set(it,
2117 it->tooltip.content_cb,
2118 it->tooltip.data, NULL);
2119 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2122 if (it->mouse_cursor)
2123 elm_widget_item_cursor_set(it, it->mouse_cursor);
2125 it->realized = EINA_TRUE;
2126 it->want_unrealize = EINA_FALSE;
2128 if (itc) _item_cache_free(itc);
2129 evas_object_smart_callback_call(it->base.widget, "realized", it);
2130 if ((it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && ((!it->wd->select_all_item) || ((it->wd->select_all_item) && (it != it->wd->select_all_item))))
2132 _effect_item_realize(it, EINA_FALSE);
2133 edje_object_message_signal_process(it->edit_obj);
2138 _item_unrealize(Elm_Genlist_Item *it)
2142 if (!it->realized) return;
2143 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2144 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2147 ecore_timer_del(it->long_timer);
2148 it->long_timer = NULL;
2150 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2152 it->sweeped = EINA_FALSE;
2153 it->wassweeped = EINA_FALSE;
2154 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2155 _delete_sweep_objs(it);
2156 evas_object_del(it->base.view);
2157 it->base.view = NULL;
2158 evas_object_del(it->spacer);
2163 // TODO: uncomment this after upstream merge
2164 //edje_object_mirrored_set(it->base.view, elm_widget_mirrored_get(it->base.widget));
2165 _item_cache_add(it);
2167 elm_widget_stringlist_free(it->labels);
2169 elm_widget_stringlist_free(it->icons);
2171 elm_widget_stringlist_free(it->states);
2173 EINA_LIST_FREE(it->icon_objs, icon)
2174 evas_object_del(icon);
2177 it->realized = EINA_FALSE;
2178 it->want_unrealize = EINA_FALSE;
2179 if (it->wd->edit_field && it->renamed)
2180 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
2181 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2185 _item_block_recalc(Item_Block *itb,
2191 Elm_Genlist_Item *it;
2192 Evas_Coord minw = 0, minh = 0;
2193 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2197 EINA_LIST_FOREACH(itb->items, l, it)
2199 if (it->delete_me) continue;
2200 showme |= it->showme;
2205 if (!it->mincalcd) changed = EINA_TRUE;
2208 _item_realize(it, in, EINA_TRUE);
2209 _item_unrealize(it);
2214 _item_realize(it, in, EINA_TRUE);
2215 if (!it->wd->contracting) _item_unrealize(it);
2219 _item_realize(it, in, EINA_FALSE);
2221 if (minw < it->minw) minw = it->minw;
2229 itb->changed = EINA_FALSE;
2230 /* force an evas norender to garbage collect deleted objects */
2231 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2236 _item_block_realize(Item_Block *itb,
2241 Elm_Genlist_Item *it;
2243 if (itb->realized) return;
2244 EINA_LIST_FOREACH(itb->items, l, it)
2246 if (it->delete_me) continue;
2247 if (full) _item_realize(it, in, EINA_FALSE);
2250 itb->realized = EINA_TRUE;
2251 itb->want_unrealize = EINA_FALSE;
2255 _item_block_unrealize(Item_Block *itb)
2258 Elm_Genlist_Item *it;
2259 Eina_Bool dragging = EINA_FALSE;
2261 if (!itb->realized) return;
2262 EINA_LIST_FOREACH(itb->items, l, it)
2264 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2268 dragging = EINA_TRUE;
2269 it->want_unrealize = EINA_TRUE;
2272 if (!it->wd->contracting) _item_unrealize(it);
2277 itb->realized = EINA_FALSE;
2278 itb->want_unrealize = EINA_TRUE;
2281 itb->want_unrealize = EINA_FALSE;
2285 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2287 Evas_Coord rox, roy, row, roh;
2288 Eina_Bool top = EINA_FALSE;
2289 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2290 if (!reorder_it) return 0;
2292 Evas_Coord ox,oy,oh,ow;
2293 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2294 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2296 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2298 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2299 if (it->block->count == 1)
2300 it->wd->reorder_rel = it;
2302 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2304 it->block->reorder_offset = it->wd->reorder_it->h;
2307 it->block->reorder_offset = 0;
2309 it->scrl_y += it->block->reorder_offset;
2311 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2312 rox, roy+roh/2, row, 1));
2315 it->wd->reorder_rel = it;
2316 it->scrl_y+=it->wd->reorder_it->h;
2317 return it->wd->reorder_it->h;
2324 _reorder_item_moving_effect_timer_cb(void *data)
2326 Elm_Genlist_Item *it = data;
2327 Eina_Bool down = EINA_FALSE;
2328 double time = 0.4, t;
2330 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2333 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2337 if (it->old_scrl_y < it->scrl_y)
2339 it->old_scrl_y += y;
2342 else if (it->old_scrl_y > it->scrl_y)
2344 it->old_scrl_y -= y;
2348 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2350 _group_items_recalc(it->wd);
2351 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2353 it->old_scrl_y = it->scrl_y;
2354 it->move_effect_me = EINA_FALSE;
2355 it->wd->item_moving_effect_timer = NULL;
2356 return ECORE_CALLBACK_CANCEL;
2358 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2360 it->old_scrl_y = it->scrl_y;
2361 it->move_effect_me = EINA_FALSE;
2362 it->wd->item_moving_effect_timer = NULL;
2363 return ECORE_CALLBACK_CANCEL;
2365 return ECORE_CALLBACK_RENEW;
2369 _item_block_position(Item_Block *itb,
2373 Elm_Genlist_Item *it;
2374 Elm_Genlist_Item *git;
2375 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2378 Elm_Genlist_Item *select_all_item = NULL;
2380 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2381 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2384 if (itb->wd->select_all_item &&
2385 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2387 if (itb->wd->select_all_check)
2388 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
2390 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
2392 select_all_item = itb->wd->select_all_item;
2394 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2395 evas_object_move(select_all_item->base.view, ox, oy);
2396 evas_object_raise(select_all_item->base.view);
2398 y = select_all_item->h;
2399 sel_all_h = select_all_item->h;
2402 EINA_LIST_FOREACH(itb->items, l, it)
2404 if (it->delete_me) continue;
2405 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2410 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2411 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2413 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2414 cvx, cvy, cvw, cvh));
2415 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2417 if ((itb->realized) && (!it->realized))
2419 if (vis) _item_realize(it, in, EINA_FALSE);
2425 if(it->wd->reorder_mode)
2426 y += _get_space_for_reorder_item(it);
2427 git = it->group_item;
2430 git->scrl_x = it->scrl_x;
2431 if (git->scrl_y < oy + sel_all_h)
2432 git->scrl_y = oy + sel_all_h;
2433 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2434 git->scrl_y = (it->scrl_y + it->h) - git->h;
2435 git->want_realize = EINA_TRUE;
2437 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2439 if (!it->move_effect_me)
2441 it->move_effect_me = EINA_TRUE;
2442 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2446 if (!it->move_effect_me )
2447 if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item))
2449 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
2451 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2455 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2456 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2457 if((!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) && (it->old_scrl_y == it->scrl_y)))
2458 evas_object_show(it->base.view);
2460 evas_object_hide(it->base.view);
2462 it->old_scrl_x = it->scrl_x;
2463 it->old_scrl_y = it->scrl_y;
2468 if (!it->dragging) _item_unrealize(it);
2475 if (vis) it->want_realize = EINA_TRUE;
2482 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2484 Elm_Genlist_Item *it = data;
2486 it->mincalcd = EINA_FALSE;
2487 it->block->updateme = EINA_TRUE;
2488 if (it->wd->changed_job) ecore_job_del(it->wd->changed_job);
2489 it->wd->changed_job = ecore_job_add(_changed_job, it->wd);
2493 _group_items_recalc(void *data)
2495 Widget_Data *wd = data;
2497 Elm_Genlist_Item *git;
2499 EINA_LIST_FOREACH(wd->group_items, l, git)
2501 if (git->want_realize)
2504 _item_realize(git, 0, EINA_FALSE);
2505 evas_object_resize(git->base.view, wd->minw, git->h);
2506 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2507 evas_object_show(git->base.view);
2508 evas_object_raise(git->base.view);
2510 else if (!git->want_realize && git->realized)
2513 _item_unrealize(git);
2519 _must_recalc_idler(void *data)
2521 Widget_Data *wd = data;
2522 if (wd->calc_job) ecore_job_del(wd->calc_job);
2523 wd->calc_job = ecore_job_add(_calc_job, wd);
2524 wd->must_recalc_idler = NULL;
2525 return ECORE_CALLBACK_CANCEL;
2529 _calc_job(void *data)
2531 Widget_Data *wd = data;
2533 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2534 Item_Block *chb = NULL;
2535 int in = 0, minw_change = 0;
2536 Eina_Bool changed = EINA_FALSE;
2538 Eina_Bool did_must_recalc = EINA_FALSE;
2541 t0 = ecore_time_get();
2542 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2546 // if (wd->height_for_width) changed = EINA_TRUE;
2549 EINA_INLIST_FOREACH(wd->blocks, itb)
2551 Eina_Bool showme = EINA_FALSE;
2554 showme = itb->showme;
2555 itb->showme = EINA_FALSE;
2558 if (itb->realized) _item_block_unrealize(itb);
2560 if ((itb->changed) || (changed) ||
2561 ((itb->must_recalc) && (!did_must_recalc)))
2563 if ((changed) || (itb->must_recalc))
2566 Elm_Genlist_Item *it;
2567 EINA_LIST_FOREACH(itb->items, l, it)
2568 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2569 itb->changed = EINA_TRUE;
2570 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2571 itb->must_recalc = EINA_FALSE;
2573 if (itb->realized) _item_block_unrealize(itb);
2574 showme = _item_block_recalc(itb, in, 0, 1);
2580 if (minw == -1) minw = itb->minw;
2581 else if ((!itb->must_recalc) && (minw < itb->minw))
2590 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2592 wd->show_item->showme = EINA_FALSE;
2594 elm_smart_scroller_region_bring_in(wd->scr,
2596 wd->show_item->block->x,
2598 wd->show_item->block->y,
2599 wd->show_item->block->w,
2602 elm_smart_scroller_child_region_show(wd->scr,
2604 wd->show_item->block->x,
2606 wd->show_item->block->y,
2607 wd->show_item->block->w,
2609 wd->show_item = NULL;
2614 EINA_INLIST_FOREACH(wd->blocks, itb)
2620 if ((chb) && (EINA_INLIST_GET(chb)->next))
2622 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2624 if (itb->realized) _item_block_unrealize(itb);
2627 wd->realminw = minw;
2628 if (minw < wd->w) minw = wd->w;
2629 if ((minw != wd->minw) || (minh != wd->minh) || (wd->select_all_item))
2633 if (wd->select_all_item)
2634 wd->minh += wd->select_all_item->h;
2635 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2636 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2637 _sizing_eval(wd->obj);
2639 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2641 Elm_Genlist_Item *it;
2644 it = wd->anchor_item;
2645 it_y = wd->anchor_y;
2646 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2647 it->block->y + it->y + it_y);
2648 wd->anchor_item = it;
2649 wd->anchor_y = it_y;
2653 t = ecore_time_get();
2654 if (did_must_recalc)
2656 if (!wd->must_recalc_idler)
2657 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2659 wd->calc_job = NULL;
2660 evas_object_smart_changed(wd->pan_smart);
2664 _update_job(void *data)
2666 Widget_Data *wd = data;
2669 int num, num0, position = 0, recalc = 0;
2671 wd->update_job = NULL;
2673 EINA_INLIST_FOREACH(wd->blocks, itb)
2675 Evas_Coord itminw, itminh;
2676 Elm_Genlist_Item *it;
2682 _item_block_position(itb, num);
2687 EINA_LIST_FOREACH(itb->items, l2, it)
2694 it->updateme = EINA_FALSE;
2697 _item_unrealize(it);
2698 _item_realize(it, num, 0);
2703 _item_realize(it, num, 1);
2704 _item_unrealize(it);
2706 if ((it->minw != itminw) || (it->minh != itminh))
2711 itb->updateme = EINA_FALSE;
2715 itb->changed = EINA_TRUE;
2716 _item_block_recalc(itb, num0, 0, 1);
2717 _item_block_position(itb, num0);
2722 if (wd->calc_job) ecore_job_del(wd->calc_job);
2723 wd->calc_job = ecore_job_add(_calc_job, wd);
2728 _changed_job(void *data)
2730 Widget_Data *wd = data; Eina_List *l2;
2732 int num, num0, position = 0, recalc = 0;
2734 wd->changed_job = NULL;
2736 EINA_INLIST_FOREACH(wd->blocks, itb)
2738 Evas_Coord itminw, itminh;
2739 Elm_Genlist_Item *it;
2745 _item_block_position(itb, num);
2750 EINA_LIST_FOREACH(itb->items, l2, it)
2754 Evas_Coord mw = -1, mh = -1;
2758 if (it->wd->height_for_width) mw = it->wd->w;
2759 if (!it->display_only)
2760 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2761 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2762 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
2763 if (!it->display_only)
2764 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2765 it->w = it->minw = mw;
2766 it->h = it->minh = mh;
2767 it->mincalcd = EINA_TRUE;
2769 //if ((it->minw != itminw) || (it->minh != itminh))
2770 if ((it->minh != itminh))
2775 itb->updateme = EINA_FALSE;
2779 itb->changed = EINA_TRUE;
2780 _item_block_recalc(itb, num0, 0, 1);
2781 _item_block_position(itb, num0);
2786 if (wd->calc_job) ecore_job_del(wd->calc_job);
2787 wd->calc_job = ecore_job_add(_calc_job, wd);
2792 _pan_set(Evas_Object *obj,
2796 Pan *sd = evas_object_smart_data_get(obj);
2799 // Evas_Coord ow, oh;
2800 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2801 // ow = sd->wd->minw - ow;
2802 // if (ow < 0) ow = 0;
2803 // oh = sd->wd->minh - oh;
2804 // if (oh < 0) oh = 0;
2805 // if (x < 0) x = 0;
2806 // if (y < 0) y = 0;
2807 // if (x > ow) x = ow;
2808 // if (y > oh) y = oh;
2809 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2814 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2816 if ((itb->y + itb->h) > y)
2818 Elm_Genlist_Item *it;
2821 EINA_LIST_FOREACH(itb->items, l2, it)
2823 if ((itb->y + it->y) >= y)
2825 sd->wd->anchor_item = it;
2826 sd->wd->anchor_y = -(itb->y + it->y - y);
2834 if(!sd->wd->item_moving_effect_timer) evas_object_smart_changed(obj);
2838 _pan_get(Evas_Object *obj,
2842 Pan *sd = evas_object_smart_data_get(obj);
2844 if (x) *x = sd->wd->pan_x;
2845 if (y) *y = sd->wd->pan_y;
2849 _pan_max_get(Evas_Object *obj,
2853 Pan *sd = evas_object_smart_data_get(obj);
2856 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2857 ow = sd->wd->minw - ow;
2859 oh = sd->wd->minh - oh;
2866 _pan_min_get(Evas_Object *obj __UNUSED__,
2875 _pan_child_size_get(Evas_Object *obj,
2879 Pan *sd = evas_object_smart_data_get(obj);
2881 if (w) *w = sd->wd->minw;
2882 if (h) *h = sd->wd->minh;
2886 _pan_add(Evas_Object *obj)
2889 Evas_Object_Smart_Clipped_Data *cd;
2892 cd = evas_object_smart_data_get(obj);
2895 sd->__clipped_data = *cd;
2897 evas_object_smart_data_set(obj, sd);
2901 _pan_del(Evas_Object *obj)
2903 Pan *sd = evas_object_smart_data_get(obj);
2908 ecore_job_del(sd->resize_job);
2909 sd->resize_job = NULL;
2915 _pan_resize_job(void *data)
2918 _sizing_eval(sd->wd->obj);
2919 sd->resize_job = NULL;
2923 _pan_resize(Evas_Object *obj,
2927 Pan *sd = evas_object_smart_data_get(obj);
2930 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2931 if ((ow == w) && (oh == h)) return;
2932 if ((sd->wd->height_for_width) && (ow != w))
2934 if (sd->resize_job) ecore_job_del(sd->resize_job);
2935 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2937 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2938 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2942 _pan_calculate(Evas_Object *obj)
2944 Pan *sd = evas_object_smart_data_get(obj);
2946 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2947 static Evas_Coord old_pan_y = 0;
2949 Elm_Genlist_Item *git;
2952 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2953 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2954 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2956 git->want_realize = EINA_FALSE;
2958 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2960 itb->w = sd->wd->minw;
2961 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2962 itb->y - sd->wd->pan_y + oy,
2964 cvx, cvy, cvw, cvh))
2966 if ((!itb->realized) || (itb->changed))
2967 _item_block_realize(itb, in, 0);
2968 _item_block_position(itb, in);
2972 if (itb->realized) _item_block_unrealize(itb);
2976 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2977 _group_items_recalc(sd->wd);
2979 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2981 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2982 else sd->wd->reorder_pan_move = EINA_FALSE;
2983 evas_object_raise(sd->wd->reorder_it->edit_obj);
2984 old_pan_y = sd->wd->pan_y;
2987 if (sd->wd->effect_mode &&
2988 ((sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND) ||
2989 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT) ||
2990 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)))
2992 if (!sd->wd->item_moving_effect_timer)
2994 if (sd->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
2995 _item_flip_effect_show(sd->wd->expand_item);
2997 evas_object_raise(sd->wd->alpha_bg);
2998 evas_object_show(sd->wd->alpha_bg);
2999 elm_smart_scroller_bounce_animator_disabled_set(sd->wd->scr, EINA_TRUE);
3000 sd->wd->start_time = current_time_get();
3001 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
3004 else _item_auto_scroll(sd->wd);
3005 if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view);
3006 sd->wd->contracting = EINA_FALSE;
3010 _pan_move(Evas_Object *obj,
3011 Evas_Coord x __UNUSED__,
3012 Evas_Coord y __UNUSED__)
3014 Pan *sd = evas_object_smart_data_get(obj);
3016 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
3017 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
3021 _hold_on(void *data __UNUSED__,
3023 void *event_info __UNUSED__)
3025 Widget_Data *wd = elm_widget_data_get(obj);
3027 elm_smart_scroller_hold_set(wd->scr, 1);
3031 _hold_off(void *data __UNUSED__,
3033 void *event_info __UNUSED__)
3035 Widget_Data *wd = elm_widget_data_get(obj);
3037 elm_smart_scroller_hold_set(wd->scr, 0);
3041 _freeze_on(void *data __UNUSED__,
3043 void *event_info __UNUSED__)
3045 Widget_Data *wd = elm_widget_data_get(obj);
3047 elm_smart_scroller_freeze_set(wd->scr, 1);
3051 _freeze_off(void *data __UNUSED__,
3053 void *event_info __UNUSED__)
3055 Widget_Data *wd = elm_widget_data_get(obj);
3057 elm_smart_scroller_freeze_set(wd->scr, 0);
3061 _scroll_edge_left(void *data,
3062 Evas_Object *scr __UNUSED__,
3063 void *event_info __UNUSED__)
3065 Evas_Object *obj = data;
3066 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
3070 _scroll_edge_right(void *data,
3071 Evas_Object *scr __UNUSED__,
3072 void *event_info __UNUSED__)
3074 Evas_Object *obj = data;
3075 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
3079 _scroll_edge_top(void *data,
3080 Evas_Object *scr __UNUSED__,
3081 void *event_info __UNUSED__)
3083 Evas_Object *obj = data;
3084 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
3088 _scroll_edge_bottom(void *data,
3089 Evas_Object *scr __UNUSED__,
3090 void *event_info __UNUSED__)
3092 Evas_Object *obj = data;
3093 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
3097 * Add a new Genlist object
3099 * @param parent The parent object
3100 * @return The new object or NULL if it cannot be created
3105 elm_genlist_add(Evas_Object *parent)
3110 Evas_Coord minw, minh;
3111 static Evas_Smart *smart = NULL;
3113 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3117 static Evas_Smart_Class sc;
3119 evas_object_smart_clipped_smart_set(&_pan_sc);
3121 sc.name = "elm_genlist_pan";
3122 sc.version = EVAS_SMART_CLASS_VERSION;
3125 sc.resize = _pan_resize;
3126 sc.move = _pan_move;
3127 sc.calculate = _pan_calculate;
3128 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3130 wd = ELM_NEW(Widget_Data);
3131 e = evas_object_evas_get(parent);
3132 if (!e) return NULL;
3133 obj = elm_widget_add(e);
3134 ELM_SET_WIDTYPE(widtype, "genlist");
3135 elm_widget_type_set(obj, "genlist");
3136 elm_widget_sub_object_add(parent, obj);
3137 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3138 elm_widget_data_set(obj, wd);
3139 elm_widget_del_hook_set(obj, _del_hook);
3140 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3141 elm_widget_theme_hook_set(obj, _theme_hook);
3142 elm_widget_can_focus_set(obj, EINA_TRUE);
3143 elm_widget_event_hook_set(obj, _event_hook);
3144 elm_widget_on_show_region_hook_set(obj, _show_region_hook, obj);
3146 wd->scr = elm_smart_scroller_add(e);
3147 elm_smart_scroller_widget_set(wd->scr, obj);
3148 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3149 elm_widget_style_get(obj));
3150 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3151 _elm_config->thumbscroll_bounce_enable);
3152 elm_widget_resize_object_set(obj, wd->scr);
3154 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3155 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3157 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3158 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3162 wd->mode = ELM_LIST_SCROLL;
3163 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3164 wd->item_cache_max = wd->max_items_per_block * 2;
3165 wd->longpress_timeout = _elm_config->longpress_timeout;
3166 //wd->effect_mode = _elm_config->effect_enable;
3167 // wd->effect_mode = EINA_TRUE;
3169 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3170 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3171 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3172 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3174 wd->pan_smart = evas_object_smart_add(e, smart);
3175 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3178 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3179 _pan_set, _pan_get, _pan_max_get,
3180 _pan_min_get, _pan_child_size_get);
3182 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3184 evas_object_size_hint_min_set(obj, minw, minh);
3186 // TODO: uncomment this after upstream merge
3187 //_mirrored_set(obj, elm_widget_mirrored_get(obj));
3192 static Elm_Genlist_Item *
3193 _item_new(Widget_Data *wd,
3194 const Elm_Genlist_Item_Class *itc,
3196 Elm_Genlist_Item *parent,
3197 Elm_Genlist_Item_Flags flags,
3199 const void *func_data)
3201 Elm_Genlist_Item *it;
3203 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3204 if (!it) return NULL;
3207 it->base.data = data;
3208 it->parent = parent;
3210 it->func.func = func;
3211 it->func.data = func_data;
3212 it->mouse_cursor = NULL;
3213 it->expanded_depth = 0;
3214 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3215 if ((!it->parent) && (it->wd->select_all_item))
3216 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE);
3217 it->num = ++wd->total_num; // todo : remov
3222 _item_block_add(Widget_Data *wd,
3223 Elm_Genlist_Item *it)
3225 Item_Block *itb = NULL;
3232 itb = calloc(1, sizeof(Item_Block));
3235 if (!it->rel->block)
3238 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3239 itb->items = eina_list_append(itb->items, it);
3245 wd->blocks = eina_inlist_prepend_relative
3246 (wd->blocks, EINA_INLIST_GET(itb),
3247 EINA_INLIST_GET(it->rel->block));
3249 eina_list_prepend_relative(itb->items, it, it->rel);
3253 wd->blocks = eina_inlist_append_relative
3254 (wd->blocks, EINA_INLIST_GET(itb),
3255 EINA_INLIST_GET(it->rel->block));
3257 eina_list_append_relative(itb->items, it, it->rel);
3267 itb = (Item_Block *)(wd->blocks);
3268 if (itb->count >= wd->max_items_per_block)
3270 itb = calloc(1, sizeof(Item_Block));
3274 eina_inlist_prepend(wd->blocks,
3275 EINA_INLIST_GET(itb));
3280 itb = calloc(1, sizeof(Item_Block));
3284 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3286 itb->items = eina_list_prepend(itb->items, it);
3292 itb = (Item_Block *)(wd->blocks->last);
3293 if (itb->count >= wd->max_items_per_block)
3295 itb = calloc(1, sizeof(Item_Block));
3299 eina_inlist_append(wd->blocks,
3300 EINA_INLIST_GET(itb));
3305 itb = calloc(1, sizeof(Item_Block));
3309 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3311 itb->items = eina_list_append(itb->items, it);
3317 itb = it->rel->block;
3318 if (!itb) goto newblock;
3320 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3322 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3325 itb->changed = EINA_TRUE;
3327 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3328 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3331 it->rel->relcount--;
3332 if ((it->rel->delete_me) && (!it->rel->relcount))
3336 if (itb->count > itb->wd->max_items_per_block)
3340 Elm_Genlist_Item *it2;
3342 newc = itb->count / 2;
3343 itb2 = calloc(1, sizeof(Item_Block));
3347 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3348 EINA_INLIST_GET(itb));
3349 itb2->changed = EINA_TRUE;
3350 while ((itb->count > newc) && (itb->items))
3354 l = eina_list_last(itb->items);
3356 itb->items = eina_list_remove_list(itb->items, l);
3359 itb2->items = eina_list_prepend(itb2->items, it2);
3367 _queue_process(Widget_Data *wd,
3371 Eina_Bool showme = EINA_FALSE;
3374 t0 = ecore_time_get();
3375 for (n = 0; (wd->queue) && (n < 128); n++)
3377 Elm_Genlist_Item *it;
3379 it = wd->queue->data;
3380 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3381 it->queued = EINA_FALSE;
3382 _item_block_add(wd, it);
3383 t = ecore_time_get();
3384 if (it->block->changed)
3386 showme = _item_block_recalc(it->block, it->block->num, 1,
3388 it->block->changed = 0;
3390 if (showme) it->block->showme = EINA_TRUE;
3391 if (eina_inlist_count(wd->blocks) > 1)
3393 if ((t - t0) > (ecore_animator_frametime_get())) break;
3400 _item_idler(void *data)
3402 Widget_Data *wd = data;
3405 //static double q_start = 0.0;
3406 //if (q_start == 0.0) q_start = ecore_time_get();
3409 if (_queue_process(wd, 1) > 0)
3411 if (wd->calc_job) ecore_job_del(wd->calc_job);
3412 wd->calc_job = ecore_job_add(_calc_job, wd);
3417 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3419 wd->queue_idler = NULL;
3420 return ECORE_CALLBACK_CANCEL;
3422 return ECORE_CALLBACK_RENEW;
3426 _item_queue(Widget_Data *wd,
3427 Elm_Genlist_Item *it)
3429 if (it->queued) return;
3430 it->queued = EINA_TRUE;
3431 wd->queue = eina_list_append(wd->queue, it);
3432 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3434 if (wd->queue_idler)
3436 ecore_idler_del(wd->queue_idler);
3437 wd->queue_idler = NULL;
3439 _queue_process(wd, 0);
3441 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3445 * Append item to the end of the genlist
3447 * This appends the given item to the end of the list or the end of
3448 * the children if the parent is given.
3450 * @param obj The genlist object
3451 * @param itc The item class for the item
3452 * @param data The item data
3453 * @param parent The parent item, or NULL if none
3454 * @param flags Item flags
3455 * @param func Convenience function called when item selected
3456 * @param func_data Data passed to @p func above.
3457 * @return A handle to the item added or NULL if not possible
3461 EAPI Elm_Genlist_Item *
3462 elm_genlist_item_append(Evas_Object *obj,
3463 const Elm_Genlist_Item_Class *itc,
3465 Elm_Genlist_Item *parent,
3466 Elm_Genlist_Item_Flags flags,
3468 const void *func_data)
3470 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3471 Widget_Data *wd = elm_widget_data_get(obj);
3472 if (!wd) return NULL;
3473 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3475 if (!it) return NULL;
3478 if (flags & ELM_GENLIST_ITEM_GROUP)
3479 wd->group_items = eina_list_append(wd->group_items, it);
3480 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3485 Elm_Genlist_Item *it2 = NULL;
3486 Eina_List *ll = eina_list_last(it->parent->items);
3487 if (ll) it2 = ll->data;
3488 it->parent->items = eina_list_append(it->parent->items, it);
3489 if (!it2) it2 = it->parent;
3491 it2 = elm_genlist_item_prev_get(it2);
3493 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3494 EINA_INLIST_GET(it2));
3496 it->rel->relcount++;
3498 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3499 it->group_item = parent;
3500 else if (it->parent->group_item)
3501 it->group_item = it->parent->group_item;
3503 it->before = EINA_FALSE;
3504 _item_queue(wd, it);
3509 * Prepend item at start of the genlist
3511 * This adds an item to the beginning of the list or beginning of the
3512 * children of the parent if given.
3514 * @param obj The genlist object
3515 * @param itc The item class for the item
3516 * @param data The item data
3517 * @param parent The parent item, or NULL if none
3518 * @param flags Item flags
3519 * @param func Convenience function called when item selected
3520 * @param func_data Data passed to @p func above.
3521 * @return A handle to the item added or NULL if not possible
3525 EAPI Elm_Genlist_Item *
3526 elm_genlist_item_prepend(Evas_Object *obj,
3527 const Elm_Genlist_Item_Class *itc,
3529 Elm_Genlist_Item *parent,
3530 Elm_Genlist_Item_Flags flags,
3532 const void *func_data)
3534 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3535 Widget_Data *wd = elm_widget_data_get(obj);
3536 if (!wd) return NULL;
3537 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3539 if (!it) return NULL;
3542 if (flags & ELM_GENLIST_ITEM_GROUP)
3543 wd->group_items = eina_list_prepend(wd->group_items, it);
3544 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3549 Elm_Genlist_Item *it2 = NULL;
3550 Eina_List *ll = it->parent->items;
3551 if (ll) it2 = ll->data;
3552 it->parent->items = eina_list_prepend(it->parent->items, it);
3553 if (!it2) it2 = it->parent;
3555 it2 = elm_genlist_item_next_get(it2);
3557 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3558 EINA_INLIST_GET(it2));
3560 it->rel->relcount++;
3562 it->before = EINA_TRUE;
3563 _item_queue(wd, it);
3568 * Insert item before another in the genlist
3570 * This inserts an item before another in the list. It will be in the
3571 * same tree level or group as the item it is inseted before.
3573 * @param obj The genlist object
3574 * @param itc The item class for the item
3575 * @param data The item data
3576 * @param before The item to insert before
3577 * @param flags Item flags
3578 * @param func Convenience function called when item selected
3579 * @param func_data Data passed to @p func above.
3580 * @return A handle to the item added or NULL if not possible
3584 EAPI Elm_Genlist_Item *
3585 elm_genlist_item_insert_before(Evas_Object *obj,
3586 const Elm_Genlist_Item_Class *itc,
3588 Elm_Genlist_Item *parent,
3589 Elm_Genlist_Item *before,
3590 Elm_Genlist_Item_Flags flags,
3592 const void *func_data)
3594 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3595 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3596 Widget_Data *wd = elm_widget_data_get(obj);
3597 if (!wd) return NULL;
3598 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3600 if (!it) return NULL;
3603 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3606 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3607 EINA_INLIST_GET(before));
3609 it->rel->relcount++;
3610 it->before = EINA_TRUE;
3611 _item_queue(wd, it);
3616 * Insert an item after another in the genlst
3618 * This inserts an item after another in the list. It will be in the
3619 * same tree level or group as the item it is inseted after.
3621 * @param obj The genlist object
3622 * @param itc The item class for the item
3623 * @param data The item data
3624 * @param after The item to insert after
3625 * @param flags Item flags
3626 * @param func Convenience function called when item selected
3627 * @param func_data Data passed to @p func above.
3628 * @return A handle to the item added or NULL if not possible
3632 EAPI Elm_Genlist_Item *
3633 elm_genlist_item_insert_after(Evas_Object *obj,
3634 const Elm_Genlist_Item_Class *itc,
3636 Elm_Genlist_Item *parent,
3637 Elm_Genlist_Item *after,
3638 Elm_Genlist_Item_Flags flags,
3640 const void *func_data)
3642 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3643 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3644 Widget_Data *wd = elm_widget_data_get(obj);
3645 if (!wd) return NULL;
3646 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3648 if (!it) return NULL;
3649 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3650 EINA_INLIST_GET(after));
3653 it->parent->items = eina_list_append_relative(it->parent->items, it,
3657 it->rel->relcount++;
3658 it->before = EINA_FALSE;
3659 _item_queue(wd, it);
3666 * This clears all items in the list, leaving it empty.
3668 * @param obj The genlist object
3673 elm_genlist_clear(Evas_Object *obj)
3675 ELM_CHECK_WIDTYPE(obj, widtype);
3676 Widget_Data *wd = elm_widget_data_get(obj);
3678 if (wd->walking > 0)
3680 Elm_Genlist_Item *it;
3682 wd->clear_me = EINA_TRUE;
3683 EINA_INLIST_FOREACH(wd->items, it)
3685 it->delete_me = EINA_TRUE;
3691 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3692 it->nocache = EINA_TRUE;
3693 it->highlighted = EINA_FALSE;
3695 if (wd->anchor_item == it)
3697 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3698 if (!wd->anchor_item)
3700 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3703 wd->items = eina_inlist_remove(wd->items, wd->items);
3704 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3705 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3706 elm_widget_item_pre_notify_del(it);
3707 if (it->effect_item_realized) _effect_item_unrealize(it);
3708 if (it->realized) _item_unrealize(it);
3709 if (((wd->clear_me) || (!it->delete_me)) && (it->itc->func.del))
3710 it->itc->func.del((void *)it->base.data, it->base.widget);
3711 if (it->long_timer) ecore_timer_del(it->long_timer);
3712 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3713 elm_widget_item_del(it);
3715 wd->clear_me = EINA_FALSE;
3716 wd->anchor_item = NULL;
3719 Item_Block *itb = (Item_Block *)(wd->blocks);
3721 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3722 if (itb->items) eina_list_free(itb->items);
3727 ecore_job_del(wd->calc_job);
3728 wd->calc_job = NULL;
3730 if (wd->queue_idler)
3732 ecore_idler_del(wd->queue_idler);
3733 wd->queue_idler = NULL;
3735 if (wd->must_recalc_idler)
3737 ecore_idler_del(wd->must_recalc_idler);
3738 wd->must_recalc_idler = NULL;
3742 eina_list_free(wd->queue);
3747 eina_list_free(wd->selected);
3748 wd->selected = NULL;
3752 Evas_Object *editfield;
3753 EINA_LIST_FREE(wd->edit_field, editfield)
3754 evas_object_del(editfield);
3755 wd->edit_field = NULL;
3757 if (wd->item_moving_effect_timer)
3759 ecore_animator_del(wd->item_moving_effect_timer);
3760 wd->item_moving_effect_timer = NULL;
3762 wd->show_item = NULL;
3769 evas_object_del(wd->alpha_bg);
3770 wd->alpha_bg = NULL;
3774 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3775 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3781 * Enable or disable multi-select in the genlist
3783 * This enables (EINA_TRUE) or disables (EINA_FALSE) multi-select in
3784 * the list. This allows more than 1 item to be selected.
3786 * @param obj The genlist object
3787 * @param multi Multi-select enable/disable
3792 elm_genlist_multi_select_set(Evas_Object *obj,
3795 ELM_CHECK_WIDTYPE(obj, widtype);
3796 Widget_Data *wd = elm_widget_data_get(obj);
3802 * Gets if multi-select in genlist is enable or disable
3804 * @param obj The genlist object
3805 * @return Multi-select enable/disable
3806 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3811 elm_genlist_multi_select_get(const Evas_Object *obj)
3813 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3814 Widget_Data *wd = elm_widget_data_get(obj);
3815 if (!wd) return EINA_FALSE;
3820 * Get the selectd item in the genlist
3822 * This gets the selected item in the list (if multi-select is enabled
3823 * only the first item in the list is selected - which is not very
3824 * useful, so see elm_genlist_selected_items_get() for when
3825 * multi-select is used).
3827 * If no item is selected, NULL is returned.
3829 * @param obj The genlist object
3830 * @return The selected item, or NULL if none.
3834 EAPI Elm_Genlist_Item *
3835 elm_genlist_selected_item_get(const Evas_Object *obj)
3837 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3838 Widget_Data *wd = elm_widget_data_get(obj);
3839 if (!wd) return NULL;
3840 if (wd->selected) return wd->selected->data;
3845 * Get a list of selected items in the genlist
3847 * This returns a list of the selected items. This list pointer is
3848 * only valid so long as no items are selected or unselected (or
3849 * unselected implicitly by deletion). The list contains
3850 * Elm_Genlist_Item pointers.
3852 * @param obj The genlist object
3853 * @return The list of selected items, nor NULL if none are selected.
3857 EAPI const Eina_List *
3858 elm_genlist_selected_items_get(const Evas_Object *obj)
3860 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3861 Widget_Data *wd = elm_widget_data_get(obj);
3862 if (!wd) return NULL;
3863 return wd->selected;
3867 * Get a list of realized items in genlist
3869 * This returns a list of the realized items in the genlist. The list
3870 * contains Elm_Genlist_Item pointers. The list must be freed by the
3871 * caller when done with eina_list_free(). The item pointers in the
3872 * list are only valid so long as those items are not deleted or the
3873 * genlist is not deleted.
3875 * @param obj The genlist object
3876 * @return The list of realized items, nor NULL if none are realized.
3881 elm_genlist_realized_items_get(const Evas_Object *obj)
3883 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3884 Widget_Data *wd = elm_widget_data_get(obj);
3885 Eina_List *list = NULL;
3887 Eina_Bool done = EINA_FALSE;
3888 if (!wd) return NULL;
3889 EINA_INLIST_FOREACH(wd->blocks, itb)
3894 Elm_Genlist_Item *it;
3897 EINA_LIST_FOREACH(itb->items, l, it)
3899 if (it->realized) list = eina_list_append(list, it);
3911 * Get the item that is at the x, y canvas coords
3913 * This returns the item at the given coordinates (which are canvas
3914 * relative not object-relative). If an item is at that coordinate,
3915 * that item handle is returned, and if @p posret is not NULL, the
3916 * integer pointed to is set to a value of -1, 0 or 1, depending if
3917 * the coordinate is on the upper portion of that item (-1), on the
3918 * middle section (0) or on the lower part (1). If NULL is returned as
3919 * an item (no item found there), then posret may indicate -1 or 1
3920 * based if the coordinate is above or below all items respectively in
3923 * @param it The item
3924 * @param x The input x coordinate
3925 * @param y The input y coordinate
3926 * @param posret The position relative to the item returned here
3927 * @return The item at the coordinates or NULL if none
3931 EAPI Elm_Genlist_Item *
3932 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3937 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3938 Widget_Data *wd = elm_widget_data_get(obj);
3939 Evas_Coord ox, oy, ow, oh;
3940 Evas_Coord head_y = 0;
3943 if (!wd) return NULL;
3944 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3947 if (wd->select_all_item) head_y = wd->select_all_item->h;
3948 EINA_INLIST_FOREACH(wd->blocks, itb)
3951 Elm_Genlist_Item *it;
3953 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3954 oy + itb->y + head_y - itb->wd->pan_y,
3955 itb->w, itb->h, x, y, 1, 1))
3957 EINA_LIST_FOREACH(itb->items, l, it)
3959 Evas_Coord itx, ity;
3961 itx = ox + itb->x + it->x - itb->wd->pan_x;
3962 ity = oy + itb->y + it->y - itb->wd->pan_y;
3963 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3967 if (y <= (ity + (it->h / 4))) *posret = -1;
3968 else if (y >= (ity + it->h - (it->h / 4)))
3974 lasty = ity + it->h;
3979 if (y > lasty) *posret = 1;
3986 * Get the first item in the genlist
3988 * This returns the first item in the list.
3990 * @param obj The genlist object
3991 * @return The first item, or NULL if none
3995 EAPI Elm_Genlist_Item *
3996 elm_genlist_first_item_get(const Evas_Object *obj)
3998 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3999 Widget_Data *wd = elm_widget_data_get(obj);
4000 if (!wd) return NULL;
4001 if (!wd->items) return NULL;
4002 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
4003 while ((it) && (it->delete_me))
4004 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4009 * Get the last item in the genlist
4011 * This returns the last item in the list.
4013 * @return The last item, or NULL if none
4017 EAPI Elm_Genlist_Item *
4018 elm_genlist_last_item_get(const Evas_Object *obj)
4020 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
4021 Widget_Data *wd = elm_widget_data_get(obj);
4022 if (!wd) return NULL;
4023 if (!wd->items) return NULL;
4024 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
4025 while ((it) && (it->delete_me))
4026 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4031 * Get the next item in the genlist
4033 * This returns the item after the item @p it.
4035 * @param it The item
4036 * @return The item after @p it, or NULL if none
4040 EAPI Elm_Genlist_Item *
4041 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
4043 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4046 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
4047 if ((it) && (!it->delete_me)) break;
4049 return (Elm_Genlist_Item *)it;
4053 * Get the previous item in the genlist
4055 * This returns the item before the item @p it.
4057 * @param it The item
4058 * @return The item before @p it, or NULL if none
4062 EAPI Elm_Genlist_Item *
4063 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
4065 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4068 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
4069 if ((it) && (!it->delete_me)) break;
4071 return (Elm_Genlist_Item *)it;
4075 * Get the genlist object from an item
4077 * This returns the genlist object itself that an item belongs to.
4079 * @param it The item
4080 * @return The genlist object
4085 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
4087 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4088 return it->base.widget;
4092 * Get the parent item of the given item
4094 * This returns the parent item of the item @p it given.
4096 * @param it The item
4097 * @return The parent of the item or NULL if none
4101 EAPI Elm_Genlist_Item *
4102 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
4104 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4109 * Clear all sub-items (children) of the given item
4111 * This clears all items that are children (or their descendants) of the
4114 * @param it The item
4119 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
4121 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4122 Elm_Genlist_Item *it2;
4125 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
4126 _item_subitems_clear(it);
4129 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP) &&
4130 it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE )
4132 it->wd->expand_item = it;
4133 _item_flip_effect_show(it);
4134 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4135 it->wd->expand_item_end = y + h;
4139 it2 = elm_genlist_item_next_get(it2);
4141 } while (it2->expanded_depth > it->expanded_depth);
4143 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4145 it->wd->expand_item_gap = 0;
4147 evas_object_raise(it->wd->alpha_bg);
4148 evas_object_show(it->wd->alpha_bg);
4150 it->wd->start_time = current_time_get();
4151 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4154 _item_subitems_clear(it);
4159 * Set the selected state of an item
4161 * This sets the selected state (1 selected, 0 not selected) of the given
4164 * @param it The item
4165 * @param selected The selected state
4170 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4173 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4174 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4176 if (it->delete_me) return;
4177 selected = !!selected;
4178 if (it->selected == selected) return;
4184 while (wd->selected)
4185 _item_unselect(wd->selected->data);
4187 _item_highlight(it);
4195 * Get the selected state of an item
4197 * This gets the selected state of an item (1 selected, 0 not selected).
4199 * @param it The item
4200 * @return The selected state
4205 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4207 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4208 return it->selected;
4212 * Sets the expanded state of an item (if it's a parent)
4214 * This expands or contracts a parent item (thus showing or hiding the
4217 * @param it The item
4218 * @param expanded The expanded state (1 expanded, 0 not expanded).
4223 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4226 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4227 if (it->expanded == expanded) return;
4228 it->expanded = expanded;
4229 it->wd->expand_item = it;
4231 if(it->wd->effect_mode && !it->wd->alpha_bg)
4232 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4236 it->wd->auto_scrolled = EINA_FALSE;
4237 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4239 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4240 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4244 it->wd->contracting = EINA_TRUE;
4245 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4247 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4248 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4253 * Get the expanded state of an item
4255 * This gets the expanded state of an item
4257 * @param it The item
4258 * @return Thre expanded state
4263 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4265 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4266 return it->expanded;
4270 * Get the depth of expanded item
4272 * @param it The genlist item object
4273 * @return The depth of expanded item
4278 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4280 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4281 return it->expanded_depth;
4285 * Sets the disabled state of an item.
4287 * A disabled item cannot be selected or unselected. It will also
4288 * change appearance to appear disabled. This sets the disabled state
4289 * (1 disabled, 0 not disabled).
4291 * @param it The item
4292 * @param disabled The disabled state
4297 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4301 if (it->disabled == disabled) return;
4302 if (it->delete_me) return;
4303 it->disabled = disabled;
4307 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4309 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4314 * Get the disabled state of an item
4316 * This gets the disabled state of the given item.
4318 * @param it The item
4319 * @return The disabled state
4324 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4326 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4327 if (it->delete_me) return EINA_FALSE;
4328 return it->disabled;
4332 * Sets the display only state of an item.
4334 * A display only item cannot be selected or unselected. It is for
4335 * display only and not selecting or otherwise clicking, dragging
4336 * etc. by the user, thus finger size rules will not be applied to
4339 * @param it The item
4340 * @param display_only The display only state
4345 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4346 Eina_Bool display_only)
4348 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4349 if (it->display_only == display_only) return;
4350 if (it->delete_me) return;
4351 it->display_only = display_only;
4352 it->mincalcd = EINA_FALSE;
4353 it->updateme = EINA_TRUE;
4354 if (it->block) it->block->updateme = EINA_TRUE;
4355 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4356 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4360 * Get the display only state of an item
4362 * This gets the display only state of the given item.
4364 * @param it The item
4365 * @return The display only state
4370 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4372 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4373 if (it->delete_me) return EINA_FALSE;
4374 return it->display_only;
4378 * Show the given item
4380 * This causes genlist to jump to the given item @p it and show it (by
4381 * scrolling), if it is not fully visible.
4383 * @param it The item
4388 elm_genlist_item_show(Elm_Genlist_Item *it)
4390 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4391 Evas_Coord gith = 0;
4392 if (it->delete_me) return;
4393 if ((it->queued) || (!it->mincalcd))
4395 it->wd->show_item = it;
4396 it->wd->bring_in = EINA_TRUE;
4397 it->showme = EINA_TRUE;
4400 if (it->wd->show_item)
4402 it->wd->show_item->showme = EINA_FALSE;
4403 it->wd->show_item = NULL;
4405 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4406 gith = it->group_item->h;
4407 elm_smart_scroller_child_region_show(it->wd->scr,
4408 it->x + it->block->x,
4409 it->y + it->block->y - gith,
4410 it->block->w, it->h);
4414 * Bring in the given item
4416 * This causes genlist to jump to the given item @p it and show it (by
4417 * scrolling), if it is not fully visible. This may use animation to
4418 * do so and take a period of time
4420 * @param it The item
4425 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4427 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4428 Evas_Coord gith = 0;
4429 if (it->delete_me) return;
4430 if ((it->queued) || (!it->mincalcd))
4432 it->wd->show_item = it;
4433 it->wd->bring_in = EINA_TRUE;
4434 it->showme = EINA_TRUE;
4437 if (it->wd->show_item)
4439 it->wd->show_item->showme = EINA_FALSE;
4440 it->wd->show_item = NULL;
4442 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4443 gith = it->group_item->h;
4444 elm_smart_scroller_region_bring_in(it->wd->scr,
4445 it->x + it->block->x,
4446 it->y + it->block->y - gith,
4447 it->block->w, it->h);
4451 * Show the given item at the top
4453 * This causes genlist to jump to the given item @p it and show it (by
4454 * scrolling), if it is not fully visible.
4456 * @param it The item
4461 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4463 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4465 Evas_Coord gith = 0;
4467 if (it->delete_me) return;
4468 if ((it->queued) || (!it->mincalcd))
4470 it->wd->show_item = it;
4471 it->wd->bring_in = EINA_TRUE;
4472 it->showme = EINA_TRUE;
4475 if (it->wd->show_item)
4477 it->wd->show_item->showme = EINA_FALSE;
4478 it->wd->show_item = NULL;
4480 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4481 if (it->group_item) gith = it->group_item->h;
4482 elm_smart_scroller_child_region_show(it->wd->scr,
4483 it->x + it->block->x,
4484 it->y + it->block->y - gith,
4489 * Bring in the given item at the top
4491 * This causes genlist to jump to the given item @p it and show it (by
4492 * scrolling), if it is not fully visible. This may use animation to
4493 * do so and take a period of time
4495 * @param it The item
4500 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4502 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4504 Evas_Coord gith = 0;
4506 if (it->delete_me) return;
4507 if ((it->queued) || (!it->mincalcd))
4509 it->wd->show_item = it;
4510 it->wd->bring_in = EINA_TRUE;
4511 it->showme = EINA_TRUE;
4514 if (it->wd->show_item)
4516 it->wd->show_item->showme = EINA_FALSE;
4517 it->wd->show_item = NULL;
4519 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4520 if (it->group_item) gith = it->group_item->h;
4521 elm_smart_scroller_region_bring_in(it->wd->scr,
4522 it->x + it->block->x,
4523 it->y + it->block->y - gith,
4528 * Show the given item at the middle
4530 * This causes genlist to jump to the given item @p it and show it (by
4531 * scrolling), if it is not fully visible.
4533 * @param it The item
4538 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4540 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4543 if (it->delete_me) return;
4544 if ((it->queued) || (!it->mincalcd))
4546 it->wd->show_item = it;
4547 it->wd->bring_in = EINA_TRUE;
4548 it->showme = EINA_TRUE;
4551 if (it->wd->show_item)
4553 it->wd->show_item->showme = EINA_FALSE;
4554 it->wd->show_item = NULL;
4556 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4557 elm_smart_scroller_child_region_show(it->wd->scr,
4558 it->x + it->block->x,
4559 it->y + it->block->y - oh / 2 +
4560 it->h / 2, it->block->w, oh);
4564 * Bring in the given item at the middle
4566 * This causes genlist to jump to the given item @p it and show it (by
4567 * scrolling), if it is not fully visible. This may use animation to
4568 * do so and take a period of time
4570 * @param it The item
4575 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4577 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4580 if (it->delete_me) return;
4581 if ((it->queued) || (!it->mincalcd))
4583 it->wd->show_item = it;
4584 it->wd->bring_in = EINA_TRUE;
4585 it->showme = EINA_TRUE;
4588 if (it->wd->show_item)
4590 it->wd->show_item->showme = EINA_FALSE;
4591 it->wd->show_item = NULL;
4593 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4594 elm_smart_scroller_region_bring_in(it->wd->scr,
4595 it->x + it->block->x,
4596 it->y + it->block->y - oh / 2 + it->h / 2,
4601 * Delete a given item
4603 * This deletes the item from genlist and calls the genlist item del
4604 * class callback defined in the item class, if it is set. This clears all
4605 * subitems if it is a tree.
4607 * @param it The item
4612 elm_genlist_item_del(Elm_Genlist_Item *it)
4614 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4615 if ((it->relcount > 0) || (it->walking > 0))
4617 elm_widget_item_pre_notify_del(it);
4618 elm_genlist_item_subitems_clear(it);
4619 it->delete_me = EINA_TRUE;
4620 if (it->wd->show_item == it) it->wd->show_item = NULL;
4622 it->wd->selected = eina_list_remove(it->wd->selected,
4626 if (it->realized) _item_unrealize(it);
4627 if (it->effect_item_realized) _effect_item_unrealize(it);
4628 it->block->changed = EINA_TRUE;
4629 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4630 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4632 if (it->itc->func.del)
4633 it->itc->func.del((void *)it->base.data, it->base.widget);
4640 * Set the data item from the genlist item
4642 * This set the data value passed on the elm_genlist_item_append() and
4643 * related item addition calls. This function will also call
4644 * elm_genlist_item_update() so the item will be updated to reflect the
4647 * @param it The item
4648 * @param data The new data pointer to set
4653 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4656 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4657 elm_widget_item_data_set(it, data);
4658 elm_genlist_item_update(it);
4662 * Get the data item from the genlist item
4664 * This returns the data value passed on the elm_genlist_item_append()
4665 * and related item addition calls and elm_genlist_item_data_set().
4667 * @param it The item
4668 * @return The data pointer provided when created
4673 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4675 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4676 return elm_widget_item_data_get(it);
4680 * Tells genlist to "orphan" icons fetchs by the item class
4682 * This instructs genlist to release references to icons in the item,
4683 * meaning that they will no longer be managed by genlist and are
4684 * floating "orphans" that can be re-used elsewhere if the user wants
4687 * @param it The item
4692 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4695 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4696 EINA_LIST_FREE(it->icon_objs, icon)
4698 elm_widget_sub_object_del(it->base.widget, icon);
4699 evas_object_smart_member_del(icon);
4700 evas_object_hide(icon);
4705 * Get the real evas object of the genlist item
4707 * This returns the actual evas object used for the specified genlist
4708 * item. This may be NULL as it may not be created, and may be deleted
4709 * at any time by genlist. Do not modify this object (move, resize,
4710 * show, hide etc.) as genlist is controlling it. This function is for
4711 * querying, emitting custom signals or hooking lower level callbacks
4712 * for events. Do not delete this object under any circumstances.
4714 * @param it The item
4715 * @return The object pointer
4719 EAPI const Evas_Object *
4720 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4722 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4723 return it->base.view;
4727 * Update the contents of an item
4729 * This updates an item by calling all the item class functions again
4730 * to get the icons, labels and states. Use this when the original
4731 * item data has changed and the changes are desired to be reflected.
4733 * @param it The item
4738 elm_genlist_item_update(Elm_Genlist_Item *it)
4740 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4741 if (!it->block) return;
4742 if (it->delete_me) return;
4743 it->mincalcd = EINA_FALSE;
4744 it->updateme = EINA_TRUE;
4745 it->block->updateme = EINA_TRUE;
4746 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4747 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4751 * Update the item class of an item
4753 * @param it The item
4754 * @parem itc The item class for the item
4759 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4760 const Elm_Genlist_Item_Class *itc)
4762 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4763 if (!it->block) return;
4764 EINA_SAFETY_ON_NULL_RETURN(itc);
4765 if (it->delete_me) return;
4767 it->nocache = EINA_TRUE;
4768 elm_genlist_item_update(it);
4771 static Evas_Object *
4772 _elm_genlist_item_label_create(void *data,
4774 void *item __UNUSED__)
4776 Evas_Object *label = elm_label_add(obj);
4779 elm_object_style_set(label, "tooltip");
4780 elm_label_label_set(label, data);
4785 _elm_genlist_item_label_del_cb(void *data,
4786 Evas_Object *obj __UNUSED__,
4787 void *event_info __UNUSED__)
4789 eina_stringshare_del(data);
4793 * Set the text to be shown in the genlist item.
4795 * @param item Target item
4796 * @param text The text to set in the content
4798 * Setup the text as tooltip to object. The item can have only one
4799 * tooltip, so any previous tooltip data is removed.
4804 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4807 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4808 text = eina_stringshare_add(text);
4809 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4811 _elm_genlist_item_label_del_cb);
4815 * Set the content to be shown in the tooltip item
4817 * Setup the tooltip to item. The item can have only one tooltip, so
4818 * any previous tooltip data is removed. @p func(with @p data) will be
4819 * called every time that need to show the tooltip and it should return a
4820 * valid Evas_Object. This object is then managed fully by tooltip
4821 * system and is deleted when the tooltip is gone.
4823 * @param item the genlist item being attached by a tooltip.
4824 * @param func the function used to create the tooltip contents.
4825 * @param data what to provide to @a func as callback data/context.
4826 * @param del_cb called when data is not needed anymore, either when
4827 * another callback replaces @func, the tooltip is unset with
4828 * elm_genlist_item_tooltip_unset() or the owner @a item
4829 * dies. This callback receives as the first parameter the
4830 * given @a data, and @c event_info is the item.
4835 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4836 Elm_Tooltip_Item_Content_Cb func,
4838 Evas_Smart_Cb del_cb)
4840 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4842 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4845 if (item->tooltip.del_cb)
4846 item->tooltip.del_cb((void *)item->tooltip.data,
4847 item->base.widget, item);
4849 item->tooltip.content_cb = func;
4850 item->tooltip.data = data;
4851 item->tooltip.del_cb = del_cb;
4853 if (item->base.view)
4855 elm_widget_item_tooltip_content_cb_set(item,
4856 item->tooltip.content_cb,
4857 item->tooltip.data, NULL);
4858 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4864 if (del_cb) del_cb((void *)data, NULL, NULL);
4868 * Unset tooltip from item
4870 * @param item genlist item to remove previously set tooltip.
4872 * Remove tooltip from item. The callback provided as del_cb to
4873 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4874 * it is not used anymore.
4876 * @see elm_genlist_item_tooltip_content_cb_set()
4881 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4883 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4884 if ((item->base.view) && (item->tooltip.content_cb))
4885 elm_widget_item_tooltip_unset(item);
4887 if (item->tooltip.del_cb)
4888 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4889 item->tooltip.del_cb = NULL;
4890 item->tooltip.content_cb = NULL;
4891 item->tooltip.data = NULL;
4892 if (item->tooltip.style)
4893 elm_genlist_item_tooltip_style_set(item, NULL);
4897 * Sets a different style for this item tooltip.
4899 * @note before you set a style you should define a tooltip with
4900 * elm_genlist_item_tooltip_content_cb_set() or
4901 * elm_genlist_item_tooltip_text_set()
4903 * @param item genlist item with tooltip already set.
4904 * @param style the theme style to use (default, transparent, ...)
4909 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4912 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4913 eina_stringshare_replace(&item->tooltip.style, style);
4914 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4918 * Get the style for this item tooltip.
4920 * @param item genlist item with tooltip already set.
4921 * @return style the theme style in use, defaults to "default". If the
4922 * object does not have a tooltip set, then NULL is returned.
4927 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4929 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4930 return item->tooltip.style;
4934 * Set the cursor to be shown when mouse is over the genlist item
4936 * @param item Target item
4937 * @param cursor the cursor name to be used.
4939 * @see elm_object_cursor_set()
4943 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4946 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4947 eina_stringshare_replace(&item->mouse_cursor, cursor);
4948 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4952 * Get the cursor to be shown when mouse is over the genlist item
4954 * @param item genlist item with cursor already set.
4955 * @return the cursor name.
4960 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4962 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4963 return elm_widget_item_cursor_get(item);
4967 * Unset the cursor to be shown when mouse is over the genlist item
4969 * @param item Target item
4971 * @see elm_object_cursor_unset()
4975 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4977 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4978 if (!item->mouse_cursor)
4981 if (item->base.view)
4982 elm_widget_item_cursor_unset(item);
4984 eina_stringshare_del(item->mouse_cursor);
4985 item->mouse_cursor = NULL;
4989 * Sets a different style for this item cursor.
4991 * @note before you set a style you should define a cursor with
4992 * elm_genlist_item_cursor_set()
4994 * @param item genlist item with cursor already set.
4995 * @param style the theme style to use (default, transparent, ...)
5000 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
5003 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5004 elm_widget_item_cursor_style_set(item, style);
5008 * Get the style for this item cursor.
5010 * @param item genlist item with cursor already set.
5011 * @return style the theme style in use, defaults to "default". If the
5012 * object does not have a cursor set, then NULL is returned.
5017 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
5019 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
5020 return elm_widget_item_cursor_style_get(item);
5024 * Set if the cursor set should be searched on the theme or should use
5025 * the provided by the engine, only.
5027 * @note before you set if should look on theme you should define a
5028 * cursor with elm_object_cursor_set(). By default it will only look
5029 * for cursors provided by the engine.
5031 * @param item widget item with cursor already set.
5032 * @param engine_only boolean to define it cursors should be looked
5033 * only between the provided by the engine or searched on widget's
5039 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
5040 Eina_Bool engine_only)
5042 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
5043 elm_widget_item_cursor_engine_only_set(item, engine_only);
5047 * Get the cursor engine only usage for this item cursor.
5049 * @param item widget item with cursor already set.
5050 * @return engine_only boolean to define it cursors should be looked
5051 * only between the provided by the engine or searched on widget's
5052 * theme as well. If the object does not have a cursor set, then
5053 * EINA_FALSE is returned.
5058 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
5060 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
5061 return elm_widget_item_cursor_engine_only_get(item);
5065 * This sets the horizontal stretching mode
5067 * This sets the mode used for sizing items horizontally. Valid modes
5068 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
5069 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
5070 * the scroller will scroll horizontally. Otherwise items are expanded
5071 * to fill the width of the viewport of the scroller. If it is
5072 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
5073 * limited to that size.
5075 * @param obj The genlist object
5076 * @param mode The mode to use
5081 elm_genlist_horizontal_mode_set(Evas_Object *obj,
5084 ELM_CHECK_WIDTYPE(obj, widtype);
5085 Widget_Data *wd = elm_widget_data_get(obj);
5087 if (wd->mode == mode) return;
5093 * Gets the horizontal stretching mode
5095 * @param obj The genlist object
5096 * @return The mode to use
5097 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
5102 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
5104 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
5105 Widget_Data *wd = elm_widget_data_get(obj);
5106 if (!wd) return ELM_LIST_LAST;
5111 * Set the always select mode.
5113 * Items will only call their selection func and callback when first
5114 * becoming selected. Any further clicks will do nothing, unless you
5115 * enable always select with elm_genlist_always_select_mode_set().
5116 * This means even if selected, every click will make the selected
5117 * callbacks be called.
5119 * @param obj The genlist object
5120 * @param always_select The always select mode
5121 * (EINA_TRUE = on, EINA_FALSE = off)
5126 elm_genlist_always_select_mode_set(Evas_Object *obj,
5127 Eina_Bool always_select)
5129 ELM_CHECK_WIDTYPE(obj, widtype);
5130 Widget_Data *wd = elm_widget_data_get(obj);
5132 wd->always_select = always_select;
5136 * Get the always select mode.
5138 * @param obj The genlist object
5139 * @return The always select mode
5140 * (EINA_TRUE = on, EINA_FALSE = off)
5145 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5147 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5148 Widget_Data *wd = elm_widget_data_get(obj);
5149 if (!wd) return EINA_FALSE;
5150 return wd->always_select;
5154 * Set no select mode
5156 * This will turn off the ability to select items entirely and they
5157 * will neither appear selected nor call selected callback functions.
5159 * @param obj The genlist object
5160 * @param no_select The no select mode
5161 * (EINA_TRUE = on, EINA_FALSE = off)
5166 elm_genlist_no_select_mode_set(Evas_Object *obj,
5167 Eina_Bool no_select)
5169 ELM_CHECK_WIDTYPE(obj, widtype);
5170 Widget_Data *wd = elm_widget_data_get(obj);
5172 wd->no_select = no_select;
5176 * Gets no select mode
5178 * @param obj The genlist object
5179 * @return The no select mode
5180 * (EINA_TRUE = on, EINA_FALSE = off)
5185 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5187 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5188 Widget_Data *wd = elm_widget_data_get(obj);
5189 if (!wd) return EINA_FALSE;
5190 return wd->no_select;
5196 * This will enable the compress mode where items are "compressed"
5197 * horizontally to fit the genlist scrollable viewport width. This is
5198 * special for genlist. Do not rely on
5199 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5200 * work as genlist needs to handle it specially.
5202 * @param obj The genlist object
5203 * @param compress The compress mode
5204 * (EINA_TRUE = on, EINA_FALSE = off)
5209 elm_genlist_compress_mode_set(Evas_Object *obj,
5212 ELM_CHECK_WIDTYPE(obj, widtype);
5213 Widget_Data *wd = elm_widget_data_get(obj);
5215 wd->compress = compress;
5219 * Get the compress mode
5221 * @param obj The genlist object
5222 * @return The compress mode
5223 * (EINA_TRUE = on, EINA_FALSE = off)
5228 elm_genlist_compress_mode_get(const Evas_Object *obj)
5230 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5231 Widget_Data *wd = elm_widget_data_get(obj);
5232 if (!wd) return EINA_FALSE;
5233 return wd->compress;
5237 * Set height-for-width mode
5239 * With height-for-width mode the item width will be fixed (restricted
5240 * to a minimum of) to the list width when calculating its size in
5241 * order to allow the height to be calculated based on it. This allows,
5242 * for instance, text block to wrap lines if the Edje part is
5243 * configured with "text.min: 0 1".
5245 * @note This mode will make list resize slower as it will have to
5246 * recalculate every item height again whenever the list width
5249 * @note When height-for-width mode is enabled, it also enables
5250 * compress mode (see elm_genlist_compress_mode_set()) and
5251 * disables homogeneous (see elm_genlist_homogeneous_set()).
5253 * @param obj The genlist object
5254 * @param setting The height-for-width mode (EINA_TRUE = on,
5260 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5261 Eina_Bool height_for_width)
5263 ELM_CHECK_WIDTYPE(obj, widtype);
5264 Widget_Data *wd = elm_widget_data_get(obj);
5266 wd->height_for_width = !!height_for_width;
5267 if (wd->height_for_width)
5269 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5270 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5275 * Get the height-for-width mode
5277 * @param obj The genlist object
5278 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5284 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5286 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5287 Widget_Data *wd = elm_widget_data_get(obj);
5288 if (!wd) return EINA_FALSE;
5289 return wd->height_for_width;
5295 * This will enable or disable the scroller bounce mode for the
5296 * genlist. See elm_scroller_bounce_set() for details
5298 * @param obj The genlist object
5299 * @param h_bounce Allow bounce horizontally
5300 * @param v_bounce Allow bounce vertically
5305 elm_genlist_bounce_set(Evas_Object *obj,
5309 ELM_CHECK_WIDTYPE(obj, widtype);
5310 Widget_Data *wd = elm_widget_data_get(obj);
5312 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5316 * Get the bounce mode
5318 * @param obj The genlist object
5319 * @param h_bounce Allow bounce horizontally
5320 * @param v_bounce Allow bounce vertically
5325 elm_genlist_bounce_get(const Evas_Object *obj,
5326 Eina_Bool *h_bounce,
5327 Eina_Bool *v_bounce)
5329 ELM_CHECK_WIDTYPE(obj, widtype);
5330 Widget_Data *wd = elm_widget_data_get(obj);
5332 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5336 * Set homogenous mode
5338 * This will enable the homogeneous mode where items are of the same
5339 * height and width so that genlist may do the lazy-loading at its
5340 * maximum. This implies 'compressed' mode.
5342 * @param obj The genlist object
5343 * @param homogeneous Assume the items within the genlist are of the
5344 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5349 elm_genlist_homogeneous_set(Evas_Object *obj,
5350 Eina_Bool homogeneous)
5352 ELM_CHECK_WIDTYPE(obj, widtype);
5353 Widget_Data *wd = elm_widget_data_get(obj);
5355 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5356 wd->homogeneous = homogeneous;
5360 * Get the homogenous mode
5362 * @param obj The genlist object
5363 * @return Assume the items within the genlist are of the same height
5364 * and width (EINA_TRUE = on, EINA_FALSE = off)
5369 elm_genlist_homogeneous_get(const Evas_Object *obj)
5371 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5372 Widget_Data *wd = elm_widget_data_get(obj);
5373 if (!wd) return EINA_FALSE;
5374 return wd->homogeneous;
5378 * Set the maximum number of items within an item block
5380 * This will configure the block count to tune to the target with
5381 * particular performance matrix.
5383 * @param obj The genlist object
5384 * @param n Maximum number of items within an item block
5389 elm_genlist_block_count_set(Evas_Object *obj,
5392 ELM_CHECK_WIDTYPE(obj, widtype);
5393 Widget_Data *wd = elm_widget_data_get(obj);
5395 wd->max_items_per_block = n;
5396 wd->item_cache_max = wd->max_items_per_block * 2;
5397 _item_cache_clean(wd);
5401 * Get the maximum number of items within an item block
5403 * @param obj The genlist object
5404 * @return Maximum number of items within an item block
5409 elm_genlist_block_count_get(const Evas_Object *obj)
5411 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5412 Widget_Data *wd = elm_widget_data_get(obj);
5414 return wd->max_items_per_block;
5418 * Set the timeout in seconds for the longpress event
5420 * @param obj The genlist object
5421 * @param timeout timeout in seconds
5426 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5429 ELM_CHECK_WIDTYPE(obj, widtype);
5430 Widget_Data *wd = elm_widget_data_get(obj);
5432 wd->longpress_timeout = timeout;
5436 * Get the timeout in seconds for the longpress event
5438 * @param obj The genlist object
5439 * @return timeout in seconds
5444 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5446 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5447 Widget_Data *wd = elm_widget_data_get(obj);
5449 return wd->longpress_timeout;
5453 * Set the scrollbar policy
5455 * This sets the scrollbar visibility policy for the given genlist
5456 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5457 * made visible if it is needed, and otherwise kept hidden.
5458 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5459 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5460 * respectively for the horizontal and vertical scrollbars.
5462 * @param obj The genlist object
5463 * @param policy_h Horizontal scrollbar policy
5464 * @param policy_v Vertical scrollbar policy
5469 elm_genlist_scroller_policy_set(Evas_Object *obj,
5470 Elm_Scroller_Policy policy_h,
5471 Elm_Scroller_Policy policy_v)
5473 ELM_CHECK_WIDTYPE(obj, widtype);
5474 Widget_Data *wd = elm_widget_data_get(obj);
5476 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5477 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5480 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5484 * Get the scrollbar policy
5486 * @param obj The genlist object
5487 * @param policy_h Horizontal scrollbar policy
5488 * @param policy_v Vertical scrollbar policy
5493 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5494 Elm_Scroller_Policy *policy_h,
5495 Elm_Scroller_Policy *policy_v)
5497 ELM_CHECK_WIDTYPE(obj, widtype);
5498 Widget_Data *wd = elm_widget_data_get(obj);
5499 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5500 if ((!wd) || (!wd->scr)) return;
5501 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5502 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5503 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5506 /****************************************************************************/
5511 * @param obj The genlist object
5512 * @param reorder_mode The reorder mode
5513 * (EINA_TRUE = on, EINA_FALSE = off)
5518 elm_genlist_reorder_mode_set(Evas_Object *obj,
5519 Eina_Bool reorder_mode)
5521 ELM_CHECK_WIDTYPE(obj, widtype);
5522 Widget_Data *wd = elm_widget_data_get(obj);
5524 wd->reorder_mode = reorder_mode;
5528 * Get the reorder mode
5530 * @param obj The genlist object
5531 * @return The reorder mode
5532 * (EINA_TRUE = on, EINA_FALSE = off)
5537 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5539 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5540 Widget_Data *wd = elm_widget_data_get(obj);
5541 if (!wd) return EINA_FALSE;
5542 return wd->reorder_mode;
5546 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5552 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5558 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5563 if (it->wd->ed->ec->move)
5564 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5566 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5567 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5568 it->wd->reorder_deleted = EINA_TRUE;
5569 _item_block_del(it);
5571 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5573 it->rel->relcount++;
5574 it->before = EINA_FALSE;
5575 _item_queue(it->wd, it);
5579 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5582 if (!before) return;
5584 if (it->wd->ed->ec->move)
5585 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5587 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5588 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5589 it->wd->reorder_deleted = EINA_TRUE;
5590 _item_block_del(it);
5591 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5593 it->rel->relcount++;
5594 it->before = EINA_TRUE;
5595 _item_queue(it->wd, it);
5599 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5601 ELM_CHECK_WIDTYPE(obj, widtype);
5602 Widget_Data *wd = elm_widget_data_get(obj);
5604 wd->effect_mode = emode;
5605 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5606 // evas_object_resize(wd->point_rect, 10, 25);
5607 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5608 // evas_object_show(wd->point_rect);
5609 // evas_object_hide(wd->point_rect);
5613 _create_tray_alpha_bg(const Evas_Object *obj)
5615 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5616 Widget_Data *wd = elm_widget_data_get(obj);
5617 if (!wd) return NULL;
5619 Evas_Object *bg = NULL;
5620 Evas_Coord ox, oy, ow, oh;
5622 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5623 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5624 evas_object_color_set(bg,0,0,0,0);
5625 evas_object_resize(bg , ow, oh);
5626 evas_object_move(bg , ox, oy);
5627 evas_object_show(bg);
5628 evas_object_hide(bg);
5635 struct timeval timev;
5637 gettimeofday(&timev, NULL);
5638 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5641 // added for item moving animation.
5643 _item_moving_effect_timer_cb(void *data)
5645 Widget_Data *wd = data;
5646 if (!wd) return EINA_FALSE;
5648 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5649 Elm_Genlist_Item *it, *it2;
5651 double time = 0.4, t;
5653 Eina_Bool check, end = EINA_FALSE;
5654 // static Eina_Bool first = EINA_TRUE;
5657 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5659 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5660 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5661 if (t > time) end = EINA_TRUE;
5662 EINA_INLIST_FOREACH(wd->blocks, itb)
5665 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5666 itb->y - wd->pan_y + oy,
5668 cvx, cvy, cvw, cvh))
5670 EINA_LIST_FOREACH(itb->items, l, it)
5672 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5677 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5683 //printf(" s: %d %d ", oy, oh);
5684 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5685 dy = it->scrl_y - it->old_scrl_y;
5686 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5688 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5689 if(wd->expand_item_end < it->old_scrl_y)
5690 dy = wd->expand_item_gap;
5692 else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
5694 if (wd->expand_item_end < it->old_scrl_y)
5695 dy = wd->expand_item_gap;
5698 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5705 if (!it->old_scrl_y)
5706 it->old_scrl_y = it->scrl_y;
5709 if (it->old_scrl_y + y < oy + oh)
5711 if (!it->realized) _item_realize(it, in, 0);
5713 if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y < it->scrl_y)
5714 it->old_scrl_y = it->scrl_y - y;
5717 if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE ||
5718 (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE && it->old_scrl_y + y >= it->scrl_y))
5720 if (wd->edit_mode) _effect_item_controls(it, it->scrl_x, it->old_scrl_y + y);
5723 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5724 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5725 evas_object_show(it->base.view);
5726 evas_object_raise(it->base.view);
5729 if(wd->select_all_item) evas_object_raise(wd->select_all_item->base.view);
5730 if (it->group_item) evas_object_raise(it->group_item->base.view);
5733 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5735 it2 = elm_genlist_item_prev_get(it);
5738 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5740 if(!it2->effect_done)
5742 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5743 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5744 evas_object_show(it2->base.view);
5745 it2->effect_done = EINA_TRUE;
5749 it2 = elm_genlist_item_prev_get(it2);
5752 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5754 it2 = elm_genlist_item_prev_get(it);
5757 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5759 if(!it2->effect_done)
5761 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5762 it2->effect_done = EINA_TRUE;
5767 it2 = elm_genlist_item_prev_get(it2);
5773 // first = EINA_FALSE;
5777 if (wd->item_moving_effect_timer)
5779 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5780 _item_subitems_clear(wd->expand_item);
5781 EINA_INLIST_FOREACH(wd->blocks, itb)
5783 EINA_LIST_FOREACH(itb->items, l, it)
5785 it->effect_done = EINA_TRUE;
5786 it->list_expanded = 0;
5787 it->old_scrl_y = it->scrl_y;
5791 //evas_render(evas_object_evas_get(wd->obj));
5792 wd->item_moving_effect_timer = NULL;
5793 // first = EINA_TRUE;
5795 _item_auto_scroll(wd);
5796 evas_object_lower(wd->alpha_bg);
5797 evas_object_hide(wd->alpha_bg);
5798 if (wd->calc_job) ecore_job_del(wd->calc_job);
5799 wd->calc_job = ecore_job_add(_calc_job, wd);
5800 elm_smart_scroller_bounce_animator_disabled_set(wd->scr, EINA_FALSE);
5801 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5803 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
5804 evas_object_smart_callback_call(wd->obj, "effect_done", NULL);
5805 return ECORE_CALLBACK_CANCEL;
5807 return ECORE_CALLBACK_RENEW;
5811 _emit_contract(Elm_Genlist_Item *it)
5813 Elm_Genlist_Item *it2;
5816 // printf("%p is emited contract\n", it);
5817 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5818 it->effect_done = EINA_FALSE;
5820 EINA_LIST_FOREACH(it->items, l, it2)
5822 _emit_contract(it2);
5825 // added for item moving animation.
5827 _item_flip_effect_show(Elm_Genlist_Item *it)
5829 Elm_Genlist_Item *it2;
5831 Widget_Data *wd = it->wd;
5832 Eina_Bool check = EINA_FALSE;
5834 it2 = elm_genlist_item_next_get(it);
5837 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5838 it2 = elm_genlist_item_next_get(it2);
5840 EINA_LIST_FOREACH(it->items, l, it2)
5842 if (it2->parent && it == it2->parent)
5844 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5846 edje_object_signal_emit(it2->base.view, "flip_item", "");
5848 evas_object_move(it2->base.view, -9999, -9999);
5850 evas_object_show(it2->base.view);
5852 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5853 _emit_contract(it2);
5857 return ECORE_CALLBACK_CANCEL;
5862 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5864 printf("!!! NOW FIXING \n");
5869 * Set pinch zoom mode
5871 * @param obj The genlist object
5873 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5878 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5880 printf("!!! NOW FIXING \n");
5884 * Get pinch zoom mode
5886 * @param obj The genlist object
5887 * @return The pinch mode
5888 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5893 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5895 printf("!!! NOW FIXING \n");
5900 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5902 printf("!!! NOW FIXING \n");
5906 ////////////////////////////////////////////////////////////////////////
5908 ////////////////////////////////////////////////////////////////////////
5910 _effect_item_update(Elm_Genlist_Item *it)
5912 if (it->edit_select_check)
5914 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5918 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5923 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5926 if (edit_select_check_state)
5928 it->edit_select_check = EINA_TRUE;
5929 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
5933 it->edit_select_check = EINA_FALSE;
5934 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
5936 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5937 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5941 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5944 Eina_List *tl = NULL, *l;
5945 Elm_Genlist_Item *it2;
5947 EINA_LIST_FOREACH(it->items, l, it2)
5948 tl = eina_list_append(tl, it2);
5949 EINA_LIST_FREE(tl, it2)
5950 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5954 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5957 Elm_Genlist_Item *tmp_it;
5958 Eina_Bool parent_check = EINA_TRUE;
5960 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5962 if (tmp_it->parent && it->parent)
5963 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5967 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5968 else it->parent->edit_select_check = EINA_FALSE;
5973 _effect_item_update(it->parent);
5974 return _edit_parent_items_checkbox_set(it->parent);
5979 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items)
5981 if (!select_all_it || !select_all_it->wd) return;
5983 Eina_Bool old_check_state;
5984 Elm_Genlist_Item *it;
5985 Widget_Data *wd = select_all_it->wd;
5987 wd->select_all_check = checked;
5988 if (wd->select_all_check)
5989 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_check", "elm");
5991 edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_uncheck", "elm");
5995 EINA_INLIST_FOREACH(wd->items, it)
5997 old_check_state = it->edit_select_check;
5998 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5999 else it->edit_select_check = EINA_FALSE;
6001 // TODO : check this
6002 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
6003 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
6007 if (wd->ed->ec->item_selected)
6008 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
6010 if (wd->calc_job) ecore_job_del(wd->calc_job);
6011 wd->calc_job = ecore_job_add(_calc_job, wd);
6015 _checkbox_item_select_process(Elm_Genlist_Item *it)
6017 Elm_Genlist_Item *tmp_it;
6018 Eina_Bool old_check_state;
6019 int check_cnt = 0, total_cnt = 0;
6022 _edit_item_checkbox_set(it, it->edit_select_check);
6023 _edit_subitems_checkbox_set(it);
6024 _edit_parent_items_checkbox_set(it);
6026 if (it->wd->ed) it->wd->ed->del_item = it;
6028 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
6030 if (tmp_it->edit_select_check) check_cnt++;
6034 if (it->wd->select_all_item)
6036 old_check_state = it->wd->select_all_check;
6037 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
6038 else it->wd->select_all_check = EINA_FALSE;
6040 if (check_cnt == total_cnt)
6042 it->wd->select_all_check = EINA_TRUE;
6043 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_check", "elm");
6047 it->wd->select_all_check = EINA_FALSE;
6048 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm");
6054 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
6056 Elm_Genlist_Item *it = data;
6058 it->edit_select_check = !it->edit_select_check;
6059 _checkbox_item_select_process(it);
6063 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
6065 Elm_Genlist_Item *select_all_it = data;
6066 Widget_Data *wd = select_all_it->wd;
6069 _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE);
6074 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
6076 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6078 evas_object_resize(it->edit_obj,it->w, it->h);
6079 evas_object_move(it->edit_obj, itx, ity);
6081 if (it->wd->select_all_check)
6082 it->edit_select_check = EINA_TRUE;
6085 if (it->edit_select_check)
6087 edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm");
6091 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6097 _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on)
6099 if ((it->effect_item_realized) || (it->delete_me)) return;
6100 int itmode = 0, pad = 0;
6101 const char *pad_str;
6103 it->pad_left = it->pad_right = 0;
6105 if (it->itc->func.editmode_get)
6106 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
6107 itmode &= it->wd->edit_mode;
6109 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6110 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
6112 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
6113 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
6114 _elm_config->scale);
6115 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
6116 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
6118 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
6119 else strncpy(buf, "item", sizeof(buf));
6120 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
6122 strncat(buf, "/", sizeof(buf) - strlen(buf));
6124 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
6126 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
6127 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
6131 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6134 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6135 if (pad_str) pad = atoi(pad_str);
6137 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6139 if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable_effect", "elm");
6140 else edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6142 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6143 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6144 "elm", _checkbox_item_select_cb);
6146 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,select",
6147 "elm", _checkbox_item_select_cb, it);
6148 it->pad_left += pad * _elm_config->scale;
6152 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6154 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select",
6155 "elm", _checkbox_item_select_cb);
6158 if (effect_on && itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6160 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm");
6161 edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm");
6163 else if (itmode & ELM_GENLIST_EDIT_MODE_REORDER)
6164 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm");
6166 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6168 if (it->itc->func.icon_get)
6173 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6174 EINA_LIST_FOREACH(it->icons, l, key)
6176 Evas_Object *ic = it->itc->func.icon_get
6177 (it->base.data, it->base.widget, l->data);
6181 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6182 edje_object_part_swallow(it->edit_obj, key, ic);
6183 evas_object_show(ic);
6184 elm_widget_sub_object_add(it->base.widget, ic);
6189 edje_object_part_swallow(it->edit_obj, "original_edc", it->base.view);
6190 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6191 evas_object_show(it->edit_obj);
6193 it->effect_item_realized = EINA_TRUE;
6194 it->want_unrealize = EINA_FALSE;
6198 _effect_item_unrealize(Elm_Genlist_Item *it)
6202 if (!it->effect_item_realized) return;
6203 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6205 it->pad_left = it->pad_right = 0;
6206 edje_object_signal_emit(it->edit_obj, "elm,state,reorder_disable_effect", "elm");
6207 edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm");
6208 edje_object_message_signal_process(it->edit_obj);
6209 edje_object_part_unswallow(it->edit_obj, it->base.view);
6210 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
6211 elm_widget_sub_object_add(it->base.widget, it->base.view);
6212 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6213 // _item_cache_add(it);
6214 evas_object_del(it->edit_obj);
6215 it->edit_obj = NULL;
6216 EINA_LIST_FREE(it->edit_icon_objs, icon)
6217 evas_object_del(icon);
6219 // edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6220 it->effect_item_realized = EINA_FALSE;
6224 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6226 fprintf(stderr, "=================> Caution!!! <========================\n");
6227 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6228 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6229 fprintf(stderr, "=======================================================\n");
6231 elm_genlist_edit_mode_set(obj, emode, edit_class);
6235 * Get Genlist edit mode
6237 * @param obj The genlist object
6238 * @return The edit mode status
6239 * (EINA_TRUE = edit mode, EINA_FALSE = normal mode
6244 elm_genlist_edit_mode_get(const Evas_Object *obj)
6246 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
6247 Widget_Data *wd = elm_widget_data_get(obj);
6248 if (!wd) return EINA_FALSE;
6250 if (wd->edit_mode) return EINA_TRUE;
6251 else return EINA_FALSE;
6255 * Set Genlist edit mode
6257 * This sets Genlist edit mode.
6259 * @param obj The Genlist object
6260 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6261 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6266 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6268 ELM_CHECK_WIDTYPE(obj, widtype);
6271 Eina_Bool done = EINA_FALSE;
6272 static Elm_Genlist_Item_Class itc;
6274 Elm_Genlist_Item *it;
6275 int check_cnt = 0, total_cnt = 0;
6277 Widget_Data *wd = elm_widget_data_get(obj);
6279 if (wd->edit_mode == emode) return;
6281 wd->edit_mode = emode;
6283 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6284 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6287 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6289 EINA_INLIST_FOREACH(wd->blocks, itb)
6294 EINA_LIST_FOREACH(itb->items, l, it)
6296 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6298 it->pad_left = it->pad_right = 0;
6299 _effect_item_unrealize(it);
6309 EINA_INLIST_FOREACH(wd->items, it)
6311 it->edit_select_check = EINA_FALSE;
6313 if (wd->ed) free (wd->ed);
6315 wd->reorder_mode = EINA_FALSE;
6316 if (wd->select_all_item)
6318 wd->select_all_check = EINA_FALSE;
6319 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down);
6320 elm_widget_item_pre_notify_del(wd->select_all_item);
6321 _item_unrealize(wd->select_all_item);
6322 elm_widget_item_del(wd->select_all_item);
6324 wd->select_all_item = NULL;
6327 Evas_Object *editfield;
6328 EINA_LIST_FREE(wd->edit_field, editfield)
6329 evas_object_del(editfield);
6330 wd->edit_field = NULL;
6332 _item_cache_zero(wd);
6336 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6337 wd->reorder_mode = EINA_TRUE;
6340 wd->ed = calloc(1, sizeof(Edit_Data));
6342 wd->ed->ec = edit_class;
6344 EINA_INLIST_FOREACH(wd->blocks, itb)
6349 EINA_LIST_FOREACH(itb->items, l, it)
6351 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6353 if(it->selected) _item_unselect(it);
6354 _effect_item_realize(it, EINA_TRUE);
6364 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6366 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6367 itc.item_style = edit_class->select_all_item_style;
6369 itc.item_style = "select_all";
6370 itc.func.label_get = NULL;
6371 itc.func.icon_get = NULL;
6372 itc.func.del = NULL;
6373 itc.func.editmode_get = NULL;
6374 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6377 if (!wd->select_all_item) return;
6379 _item_realize(wd->select_all_item, 0, 0);
6380 edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down, wd->select_all_item);
6382 wd->select_all_item->rel = NULL;
6383 wd->select_all_item->block = NULL;
6385 EINA_INLIST_FOREACH(wd->items, it)
6387 if (it->edit_select_check) check_cnt++;
6390 if (check_cnt == total_cnt) wd->select_all_check = EINA_TRUE;
6391 else wd->select_all_check = EINA_FALSE;
6395 if (wd->calc_job) ecore_job_del(wd->calc_job);
6396 wd->calc_job = ecore_job_add(_calc_job, wd);
6400 * Delete selected items in genlist edit mode.
6402 * @param obj The genlist object
6407 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6409 ELM_CHECK_WIDTYPE(obj, widtype);
6410 Widget_Data *wd = elm_widget_data_get(obj);
6412 if (!wd->blocks) return;
6413 Elm_Genlist_Item *it;
6414 Eina_List *edit_selected_list, *l;
6418 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
6421 if (wd->edit_field) return;
6422 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
6423 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy,&cvw, &cvh);
6424 EINA_INLIST_FOREACH(wd->blocks, itb)
6426 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
6427 itb->y - wd->pan_y + oy,
6429 cvx, cvy, cvw, cvh))
6430 EINA_LIST_FOREACH(itb->items, l, it)
6432 it->old_scrl_y =itb->y + it->y - it->wd->pan_y + oy;
6435 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6436 cnt = eina_list_count(edit_selected_list);
6437 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6439 wd->expand_item_gap = wd->expand_item_end = 0;
6440 EINA_LIST_FOREACH(edit_selected_list, l, it)
6442 if (it->flags != ELM_GENLIST_ITEM_GROUP)
6444 it->wd->expand_item_gap += it->h * -1;
6445 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
6446 cvx, cvy, cvw, cvh));
6447 if (!it->wd->expand_item_end && vis ) it->wd->expand_item_end = it->old_scrl_y;
6448 it->wd->expand_item = elm_genlist_item_prev_get(it);
6449 elm_genlist_item_del(it);
6452 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE;
6453 eina_list_free(edit_selected_list);
6455 evas_render(evas_object_evas_get(wd->obj));
6456 if (wd->calc_job) ecore_job_del(wd->calc_job);
6457 wd->calc_job = ecore_job_add(_calc_job, wd);
6461 elm_genlist_selected_items_del(Evas_Object *obj)
6463 fprintf(stderr, "=================> Caution!!! <========================\n");
6464 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6465 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6466 fprintf(stderr, "=======================================================\n");
6467 elm_genlist_edit_selected_items_del(obj);
6471 * Get a list of selected items in genlist
6473 * This returns a list of the selected items in the genlist. The list
6474 * contains Elm_Genlist_Item pointers. The list must be freed by the
6475 * caller when done with eina_list_free(). The item pointers in the list
6476 * are only vallid so long as those items are not deleted or the genlist is
6479 * @param obj The genlist object
6480 * @return The list of selected items, nor NULL if none are selected.
6485 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6487 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6488 Widget_Data *wd = elm_widget_data_get(obj);
6489 Eina_List *list = NULL;
6490 Elm_Genlist_Item *it;
6491 if (!wd) return NULL;
6493 EINA_INLIST_FOREACH(wd->items, it)
6495 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6501 // TODO : add comment
6503 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6506 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6507 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6509 selected = !!selected;
6510 if (it->edit_select_check == selected) return;
6512 it->edit_select_check = selected;
6513 _checkbox_item_select_process(it);
6516 // TODO : add comment
6518 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6520 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6521 return it->edit_select_check;
6525 * Set a given item's rename mode
6527 * This renames the item's label from genlist
6529 * @param it The item
6530 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6535 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6537 if (!it) return NULL;
6538 if (it->wd->queue_idler) return NULL;
6540 const Eina_List *l, *list, *l2;
6541 const char *label, *rename_swallow_part;
6543 Eina_Bool done = EINA_FALSE;
6544 int label_cnt = 0 , swallow_part_cnt = 0;
6547 Evas_Object *editfield;
6548 Evas_Object *entry = NULL;
6549 int edit_field_cnt = 0;
6551 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6556 Elm_Genlist_Item *it;
6558 EINA_LIST_FOREACH(itb->items, l, it)
6562 it->renamed = EINA_FALSE;
6563 if (it->selected) _item_unselect(it);
6564 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6566 entry = elm_editfield_entry_get(editfield);
6567 const char *text = elm_entry_entry_get(entry);
6568 if (it->itc->func.label_changed)
6569 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6571 EINA_LIST_FREE(it->wd->edit_field, editfield)
6572 evas_object_del(editfield);
6573 it->wd->edit_field = NULL;
6575 if (it->wd->edit_mode)
6577 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6578 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6579 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6580 edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm");
6583 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6596 it->renamed = EINA_TRUE;
6597 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6599 it->wd->edit_mode = 0xF0;
6600 _effect_item_realize(it, EINA_TRUE);
6601 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6604 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6605 EINA_LIST_FOREACH(it->labels, list, label)
6607 if (it->itc->func.label_get)
6609 swallow_part_cnt = 0;
6611 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6612 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6614 if (label_cnt == swallow_part_cnt)
6616 editfield = elm_editfield_add(it->base.widget);
6617 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6619 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6620 elm_editfield_eraser_set(editfield, EINA_TRUE);
6621 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6622 elm_widget_sub_object_add(it->edit_obj, editfield);
6624 evas_object_show(editfield);
6626 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6629 entry = elm_editfield_entry_get(editfield);
6630 elm_entry_entry_set(entry,s);
6631 elm_entry_cursor_end_set(entry);
6635 elm_editfield_guide_text_set(editfield, "Text Input");
6642 elm_widget_focused_object_clear(elm_widget_focused_object_get(it->wd->obj));
6643 elm_widget_focus_set(editfield, EINA_TRUE);
6649 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6651 Elm_Genlist_Item *it = data;
6653 _delete_sweep_objs(it);
6657 _scr_hold_timer_cb(void *data)
6659 Elm_Genlist_Item *it = data;
6660 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6661 it->wd->scr_hold_timer = NULL;
6662 return ECORE_CALLBACK_CANCEL;
6666 _delete_sweep_objs(Elm_Genlist_Item *it)
6670 elm_widget_stringlist_free(it->sweep_labels);
6671 it->sweep_labels = NULL;
6672 elm_widget_stringlist_free(it->sweep_icons);
6673 it->sweep_icons = NULL;
6674 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6675 evas_object_del(ic);
6679 _create_sweep_objs(Elm_Genlist_Item *it)
6685 if (it->itc->func.label_get)
6688 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6690 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6692 char *s = it->itc->func.label_get
6693 ((void *)it->base.data, it->base.widget, l->data);
6697 edje_object_part_text_set(it->base.view, l->data, s);
6702 if (it->itc->func.icon_get)
6705 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6707 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6709 ic = it->itc->func.icon_get
6710 ((void *)it->base.data, it->base.widget, l->data);
6714 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6715 edje_object_part_swallow(it->base.view, key, ic);
6716 evas_object_show(ic);
6717 elm_widget_sub_object_add(it->base.widget, ic);
6724 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6727 Elm_Genlist_Item *it2;
6728 const char *allow_slide;
6730 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6731 if ((!allow_slide) || (atoi(allow_slide) != 1))
6736 if (it->sweeped) return;
6737 if (it->wd->scr_hold_timer)
6739 ecore_timer_del(it->wd->scr_hold_timer);
6740 it->wd->scr_hold_timer = NULL;
6742 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6743 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6745 _delete_sweep_objs(it);
6746 _create_sweep_objs(it);
6747 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6748 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6749 it->wassweeped = EINA_TRUE;
6750 it->sweeped = EINA_TRUE;
6752 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6756 it2->sweeped = EINA_FALSE;
6757 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6758 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6759 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6765 if (!it->sweeped) return;
6766 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6767 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6768 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6769 it->sweeped = EINA_FALSE;
6774 _item_auto_scroll(void *data)
6776 Widget_Data *wd = data;
6779 if ((wd->expand_item) && (!wd->auto_scrolled))
6781 Elm_Genlist_Item *it;
6783 Evas_Coord ox, oy, ow, oh;
6784 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6786 wd->auto_scrolled = EINA_TRUE;
6787 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6789 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6791 elm_genlist_item_bring_in(it);