1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
7 #define LONGPRESS_TIMEOUT 0.2
10 * @defgroup Genlist Genlist
12 * The aim was to have more expansive list than the simple list in
13 * Elementary that could have more flexible items and allow many more entries
14 * while still being fast and low on memory usage. At the same time it was
15 * also made to be able to do tree structures. But the price to pay is more
16 * complex when it comes to usage. If all you want is a simple list with
17 * icons and a single label, use the normal List object.
19 * Signals that you can add callbacks for are:
21 * clicked - This is called when a user has double-clicked an item. The
22 * event_info parameter is the genlist item that was double-clicked.
24 * selected - This is called when a user has made an item selected. The
25 * event_info parameter is the genlist item that was selected.
27 * unselected - This is called when a user has made an item unselected. The
28 * event_info parameter is the genlist item that was unselected.
30 * expanded - This is called when elm_genlist_item_expanded_set() is called
31 * and the item is now meant to be expanded. The event_info parameter is the
32 * genlist item that was indicated to expand. It is the job of this callback
33 * to then fill in the child items.
35 * contracted - This is called when elm_genlist_item_expanded_set() is called
36 * and the item is now meant to be contracted. The event_info parameter is
37 * the genlist item that was indicated to contract. It is the job of this
38 * callback to then delete the child items.
40 * expand,request - This is called when a user has indicated they want to
41 * expand a tree branch item. The callback should decide if the item can
42 * expand (has any children) and then call elm_genlist_item_expanded_set()
43 * appropriately to set the state. The event_info parameter is the genlist
44 * item that was indicated to expand.
46 * contract,request - This is called when a user has indicated they want to
47 * contract a tree branch item. The callback should decide if the item can
48 * contract (has any children) and then call elm_genlist_item_expanded_set()
49 * appropriately to set the state. The event_info parameter is the genlist
50 * item that was indicated to contract.
52 * realized - This is called when the item in the list is created as a real
53 * evas object. event_info parameter is the genlist item that was created.
54 * The object may be deleted at any time, so it is up to the caller to
55 * not use the object pointer from elm_genlist_item_object_get() in a way
56 * where it may point to freed objects.
58 * unrealized - This is called just before an item is unrealized. After
59 * this call icon objects provided will be deleted and the item object
60 * itself delete or be put into a floating cache.
62 * drag,start,up - This is called when the item in the list has been dragged
65 * drag,start,down - This is called when the item in the list has been dragged
66 * (not scrolled) down.
68 * drag,start,left - This is called when the item in the list has been dragged
69 * (not scrolled) left.
71 * drag,start,right - This is called when the item in the list has been dragged
72 * (not scrolled) right.
74 * drag,stop - This is called when the item in the list has stopped being
77 * drag - This is called when the item in the list is being dragged.
79 * longpressed - This is called when the item is pressed for a certain amount
80 * of time. By default it's 1 second.
82 * scroll,edge,top - This is called when the genlist is scrolled until the top
85 * scroll,edge,bottom - This is called when the genlist is scrolled until the
88 * scroll,edge,left - This is called when the genlist is scrolled until the
91 * scroll,edge,right - This is called when the genlist is scrolled until the
94 * multi,swipe,left - This is called when the genlist is multi-touch swiped
97 * multi,swipe,right - This is called when the genlist is multi-touch swiped
100 * multi,swipe,up - This is called when the genlist is multi-touch swiped
103 * multi,swipe,down - This is called when the genlist is multi-touch swiped
106 * multi,pinch,out - This is called when the genlist is multi-touch pinched
109 * multi,pinch,in - This is called when the genlist is multi-touch pinched
112 * Genlist has a fairly large API, mostly because it's relatively complex,
113 * trying to be both expansive, powerful and efficient. First we will begin
114 * an overview on the theory behind genlist.
116 * Evas tracks every object you create. Every time it processes an event
117 * (mouse move, down, up etc.) it needs to walk through objects and find out
118 * what event that affects. Even worse every time it renders display updates,
119 * in order to just calculate what to re-draw, it needs to walk through many
120 * many many objects. Thus, the more objects you keep active, the more
121 * overhead Evas has in just doing its work. It is advisable to keep your
122 * active objects to the minimum working set you need. Also remember that
123 * object creation and deletion carries an overhead, so there is a
124 * middle-ground, which is not easily determined. But don't keep massive lists
125 * of objects you can't see or use. Genlist does this with list objects. It
126 * creates and destroys them dynamically as you scroll around. It groups them
127 * into blocks so it can determine the visibility etc. of a whole block at
128 * once as opposed to having to walk the whole list. This 2-level list allows
129 * for very large numbers of items to be in the list (tests have used up to
130 * 2,000,000 items). Also genlist employs a queue for adding items. As items
131 * may be different sizes, every item added needs to be calculated as to its
132 * size and thus this presents a lot of overhead on populating the list, this
133 * genlist employs a queue. Any item added is queued and spooled off over
134 * time, actually appearing some time later, so if your list has many members
135 * you may find it takes a while for them to all appear, with your process
136 * consuming a lot of CPU while it is busy spooling.
138 * Genlist also implements a tree structure, but it does so with callbacks to
139 * the application, with the application filling in tree structures when
140 * requested (allowing for efficient building of a very deep tree that could
141 * even be used for file-management). See the above smart signal callbacks for
144 * An item in the genlist world can have 0 or more text labels (they can be
145 * regular text or textblock ??that's up to the style to determine), 0 or
146 * more icons (which are simply objects swallowed into the genlist item) and
147 * 0 or more boolean states that can be used for check, radio or other
148 * indicators by the edje theme style. An item may be one of several styles
149 * (Elementary provides 4 by default - ?
\9cdefault?? ?
\9cdouble_label?? "group_index"
150 * and "icon_top_text_bottom", but this can be extended by system or
151 * application custom themes/overlays/extensions).
153 * In order to implement the ability to add and delete items on the fly,
154 * Genlist implements a class/callback system where the application provides
155 * a structure with information about that type of item (genlist may contain
156 * multiple different items with different classes, states and styles).
157 * Genlist will call the functions in this struct (methods) when an item is
158 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
159 * simply be deleted when no longer needed with evas_object_del(). The
160 * Elm_Genlist_Item_Class structure contains the following members:
162 * item_style - This is a constant string and simply defines the name of the
163 * item style. It must be specified and the default should be ?
\9cdefault??
165 * func.label_get - This function is called when an actual item object is
166 * created. The data parameter is the data parameter passed to
167 * elm_genlist_item_append() and related item creation functions. The obj
168 * parameter is the genlist object and the part parameter is the string name
169 * of the text part in the edje design that is listed as one of the possible
170 * labels that can be set. This function must return a strudup()'ed string as
171 * the caller will free() it when done.
173 * func.icon_get - This function is called when an actual item object is
174 * created. The data parameter is the data parameter passed to
175 * elm_genlist_item_append() and related item creation functions. The obj
176 * parameter is the genlist object and the part parameter is the string name
177 * of the icon part in the edje design that is listed as one of the possible
178 * icons that can be set. This must return NULL for no object or a valid
179 * object. The object will be deleted by genlist on shutdown or when the item
182 * func.state_get - This function is called when an actual item object is
183 * created. The data parameter is the data parameter passed to
184 * elm_genlist_item_append() and related item creation functions. The obj
185 * parameter is the genlist object and the part parameter is the string name
186 * of the state part in the edje design that is listed as one of the possible
187 * states that can be set. Return 0 for false or 1 for true. Genlist will
188 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
189 * true (the default is false), where XXX is the name of the part.
191 * func.del - This is called when elm_genlist_item_del() is called on an
192 * item, elm_genlist_clear() is called on the genlist, or
193 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
194 * intended for use when actual genlist items are deleted, so any backing
195 * data attached to the item (e.g. its data parameter on creation) can be
198 * Items can be added by several calls. All of them return a Elm_Genlist_Item
199 * handle that is an internal member inside the genlist. They all take a data
200 * parameter that is meant to be used for a handle to the applications
201 * internal data (eg the struct with the original item data). The parent
202 * parameter is the parent genlist item this belongs to if it is a tree or
203 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
204 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
205 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
206 * is displayed as an item that is able to expand and have child items.
207 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
208 * displayed at the top until the next group comes. The func parameter is a
209 * convenience callback that is called when the item is selected and the data
210 * parameter will be the func_data parameter, obj be the genlist object and
211 * event_info will be the genlist item.
213 * elm_genlist_item_append() appends an item to the end of the list, or if
214 * there is a parent, to the end of all the child items of the parent.
215 * elm_genlist_item_prepend() is the same but prepends to the beginning of
216 * the list or children list. elm_genlist_item_insert_before() inserts at
217 * item before another item and elm_genlist_item_insert_after() inserts after
218 * the indicated item.
220 * The application can clear the list with elm_genlist_clear() which deletes
221 * all the items in the list and elm_genlist_item_del() will delete a specific
222 * item. elm_genlist_item_subitems_clear() will clear all items that are
223 * children of the indicated parent item.
225 * If the application wants multiple items to be able to be selected,
226 * elm_genlist_multi_select_set() can enable this. If the list is
227 * single-selection only (the default), then elm_genlist_selected_item_get()
228 * will return the selected item, if any, or NULL I none is selected. If the
229 * list is multi-select then elm_genlist_selected_items_get() will return a
230 * list (that is only valid as long as no items are modified (added, deleted,
231 * selected or unselected)).
233 * To help inspect list items you can jump to the item at the top of the list
234 * with elm_genlist_first_item_get() which will return the item pointer, and
235 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
236 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
237 * and previous items respectively relative to the indicated item. Using
238 * these calls you can walk the entire item list/tree. Note that as a tree
239 * the items are flattened in the list, so elm_genlist_item_parent_get() will
240 * let you know which item is the parent (and thus know how to skip them if
243 * There are also convenience functions. elm_genlist_item_genlist_get() will
244 * return the genlist object the item belongs to. elm_genlist_item_show()
245 * will make the scroller scroll to show that specific item so its visible.
246 * elm_genlist_item_data_get() returns the data pointer set by the item
247 * creation functions.
249 * If an item changes (state of boolean changes, label or icons change),
250 * then use elm_genlist_item_update() to have genlist update the item with
251 * the new state. Genlist will re-realize the item thus call the functions
252 * in the _Elm_Genlist_Item_Class for that item.
254 * To programmatically (un)select an item use elm_genlist_item_selected_set().
255 * To get its selected state use elm_genlist_item_selected_get(). Similarly
256 * to expand/contract an item and get its expanded state, use
257 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
258 * again to make an item disabled (unable to be selected and appear
259 * differently) use elm_genlist_item_disabled_set() to set this and
260 * elm_genlist_item_disabled_get() to get the disabled state.
262 * In general to indicate how the genlist should expand items horizontally to
263 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
264 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
265 * mode means that if items are too wide to fit, the scroller will scroll
266 * horizontally. Otherwise items are expanded to fill the width of the
267 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
268 * to the viewport width and limited to that size. This can be combined with
269 * a different style that uses edjes' ellipsis feature (cutting text off like
270 * this: ?
\9ctex...??.
272 * Items will only call their selection func and callback when first becoming
273 * selected. Any further clicks will do nothing, unless you enable always
274 * select with elm_genlist_always_select_mode_set(). This means even if
275 * selected, every click will make the selected callbacks be called.
276 * elm_genlist_no_select_mode_set() will turn off the ability to select
277 * items entirely and they will neither appear selected nor call selected
278 * callback functions.
280 * Remember that you can create new styles and add your own theme augmentation
281 * per application with elm_theme_extension_add(). If you absolutely must
282 * have a specific style that overrides any theme the user or system sets up
283 * you can use elm_theme_overlay_add() to add such a file.
286 typedef struct _Widget_Data Widget_Data;
287 typedef struct _Item_Block Item_Block;
288 typedef struct _Pan Pan;
289 typedef struct _Item_Cache Item_Cache;
290 typedef struct _Edit_Data Edit_Data;
292 typedef enum _Elm_Genlist_Item_Move_effect_Mode
294 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
295 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
297 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
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;
315 Elm_Genlist_Item *reorder_it, *reorder_rel;
318 Ecore_Timer *multi_timer;
319 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
320 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
321 Evas_Coord reorder_start_y;
322 Eina_Bool mouse_down : 1;
323 Eina_Bool multi_down : 1;
324 Eina_Bool multi_timeout : 1;
325 Eina_Bool multitouched : 1;
326 Ecore_Animator *item_moving_effect_timer;
327 Evas_Object *alpha_bg;
328 Elm_Genlist_Item *expand_item;
329 Evas_Coord expand_item_end;
330 Evas_Coord expand_item_gap;
331 Eina_Bool on_hold : 1;
333 Eina_Bool always_select : 1;
334 Eina_Bool longpressed : 1;
335 Eina_Bool wasselected : 1;
336 Eina_Bool no_select : 1;
337 Eina_Bool bring_in : 1;
338 Eina_Bool compress : 1;
339 Eina_Bool height_for_width : 1;
340 Eina_Bool homogeneous : 1;
341 Eina_Bool clear_me : 1;
346 } history[SWIPE_MOVES];
348 int item_cache_count;
354 int max_items_per_block;
355 int move_effect_mode;
356 unsigned int start_time;
357 double longpress_timeout;
359 // TODO : refactoring
360 Eina_Bool reorder_mode : 1;
361 Eina_Bool reorder_pan_move : 1;
362 Eina_Bool effect_mode : 1;
363 Eina_Bool select_all_check : 1;
366 Eina_List *edit_field;
367 Elm_Genlist_Item *select_all_item;
368 Eina_List *sweeped_items;
369 Ecore_Timer *scr_hold_timer;
381 Evas_Coord x, y, w, h, minw, minh;
382 Eina_Bool want_unrealize : 1;
383 Eina_Bool realized : 1;
384 Eina_Bool changed : 1;
385 Eina_Bool updateme : 1;
386 Eina_Bool showme : 1;
387 Eina_Bool must_recalc : 1;
390 struct _Elm_Genlist_Item
392 Elm_Widget_Item base;
397 Evas_Coord x, y, w, h, minw, minh;
398 const Elm_Genlist_Item_Class *itc;
399 Elm_Genlist_Item *parent;
400 Elm_Genlist_Item *group_item;
401 Elm_Genlist_Item_Flags flags;
409 Eina_List *labels, *icons, *states, *icon_objs;
410 Ecore_Timer *long_timer;
411 Ecore_Timer *swipe_timer;
412 Ecore_Animator *item_moving_effect_timer;
414 Evas_Coord scrl_x, scrl_y;
415 Evas_Coord old_scrl_x, old_scrl_y;
416 Evas_Coord pad_left, pad_right;
418 Elm_Genlist_Item *rel;
423 Elm_Tooltip_Item_Content_Cb content_cb;
424 Evas_Smart_Cb del_cb;
428 const char *mouse_cursor;
436 Eina_Bool before : 1;
438 Eina_Bool want_unrealize : 1;
439 Eina_Bool want_realize : 1;
440 Eina_Bool realized : 1;
441 Eina_Bool selected : 1;
442 Eina_Bool hilighted : 1;
443 Eina_Bool expanded : 1;
444 Eina_Bool disabled : 1;
445 Eina_Bool display_only : 1;
446 Eina_Bool mincalcd : 1;
447 Eina_Bool queued : 1;
448 Eina_Bool showme : 1;
449 Eina_Bool delete_me : 1;
451 Eina_Bool dragging : 1;
452 Eina_Bool updateme : 1;
455 Eina_Bool move_effect_me : 1;
456 Eina_Bool effect_done : 1;
457 Eina_List *edit_icon_objs;
458 Evas_Object *edit_obj;
459 Eina_Bool reordering : 1;
460 Eina_Bool edit_select_check: 1;
461 Eina_Bool renamed : 1;
462 Eina_Bool effect_item_realized : 1;
463 Eina_Bool sweeped : 1;
464 Eina_Bool wassweeped : 1;
465 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
473 Evas_Object *base_view, *spacer;
475 const char *item_style; // it->itc->item_style
476 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
477 Eina_Bool compress : 1; // it->wd->compress
478 Eina_Bool odd : 1; // in & 0x1
480 Eina_Bool selected : 1; // it->selected
481 Eina_Bool disabled : 1; // it->disabled
482 Eina_Bool expanded : 1; // it->expanded
487 Elm_Genlist_Edit_Class *ec;
488 Elm_Genlist_Item *del_item;
489 Elm_Genlist_Item *reorder_item;
490 Elm_Genlist_Item *reorder_rel;
491 Evas_Object *del_confirm;
494 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
495 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
499 Evas_Object_Smart_Clipped_Data __clipped_data;
501 Ecore_Job *resize_job;
504 static const char *widtype = NULL;
505 static void _item_cache_zero(Widget_Data *wd);
506 static void _del_hook(Evas_Object *obj);
507 static void _theme_hook(Evas_Object *obj);
508 //static void _show_region_hook(void *data, Evas_Object *obj);
509 static void _sizing_eval(Evas_Object *obj);
510 static void _item_unrealize(Elm_Genlist_Item *it);
511 static void _item_block_unrealize(Item_Block *itb);
512 static void _calc_job(void *data);
513 static void _on_focus_hook(void *data,
515 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
516 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
517 static Eina_Bool _item_single_select_up(Widget_Data *wd);
518 static Eina_Bool _item_single_select_down(Widget_Data *wd);
519 static Eina_Bool _event_hook(Evas_Object *obj,
521 Evas_Callback_Type type,
523 static Eina_Bool _deselect_all_items(Widget_Data *wd);
524 static void _pan_calculate(Evas_Object *obj);
525 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
526 static unsigned int current_time_get();
527 static Eina_Bool _item_moving_effect_timer_cb(void *data);
528 static int _item_flip_effect_show(Elm_Genlist_Item *it);
529 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
530 static void _effect_item_realize(Elm_Genlist_Item *it);
531 static void _effect_item_unrealize(Elm_Genlist_Item *it);
533 // TODO : refactoring
534 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
535 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
536 static void _create_sweep_objs(Elm_Genlist_Item *it);
537 static void _delete_sweep_objs(Elm_Genlist_Item *it);
539 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
542 _event_hook(Evas_Object *obj,
543 Evas_Object *src __UNUSED__,
544 Evas_Callback_Type type,
547 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
548 Evas_Event_Key_Down *ev = event_info;
549 Widget_Data *wd = elm_widget_data_get(obj);
550 if (!wd) return EINA_FALSE;
551 if (!wd->items) return EINA_FALSE;
552 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
553 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
555 Elm_Genlist_Item *it = NULL;
558 Evas_Coord step_x = 0;
559 Evas_Coord step_y = 0;
562 Evas_Coord page_x = 0;
563 Evas_Coord page_y = 0;
565 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
566 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
567 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
568 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
570 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
574 else if ((!strcmp(ev->keyname, "Right")) ||
575 (!strcmp(ev->keyname, "KP_Right")))
579 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
581 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
582 (_item_multi_select_up(wd)))
583 || (_item_single_select_up(wd)))
585 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
591 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
593 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
594 (_item_multi_select_down(wd)))
595 || (_item_single_select_down(wd)))
597 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
603 else if ((!strcmp(ev->keyname, "Home")) ||
604 (!strcmp(ev->keyname, "KP_Home")))
606 it = elm_genlist_first_item_get(obj);
607 elm_genlist_item_bring_in(it);
608 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
611 else if ((!strcmp(ev->keyname, "End")) ||
612 (!strcmp(ev->keyname, "KP_End")))
614 it = elm_genlist_last_item_get(obj);
615 elm_genlist_item_bring_in(it);
616 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
619 else if ((!strcmp(ev->keyname, "Prior")) ||
620 (!strcmp(ev->keyname, "KP_Prior")))
623 y -= -(page_y * v_h) / 100;
627 else if ((!strcmp(ev->keyname, "Next")) ||
628 (!strcmp(ev->keyname, "KP_Next")))
631 y += -(page_y * v_h) / 100;
635 else if(((!strcmp(ev->keyname, "Return")) ||
636 (!strcmp(ev->keyname, "KP_Enter")) ||
637 (!strcmp(ev->keyname, "space")))
638 && (!wd->multi) && (wd->selected))
640 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
641 elm_genlist_item_expanded_set(it,
642 !elm_genlist_item_expanded_get(it));
644 else if (!strcmp(ev->keyname, "Escape"))
646 if (!_deselect_all_items(wd)) return EINA_FALSE;
647 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
650 else return EINA_FALSE;
652 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
653 elm_smart_scroller_child_pos_set(wd->scr, x, y);
658 _deselect_all_items(Widget_Data *wd)
660 if (!wd->selected) return EINA_FALSE;
662 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
668 _item_multi_select_up(Widget_Data *wd)
670 if (!wd->selected) return EINA_FALSE;
671 if (!wd->multi) return EINA_FALSE;
673 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
674 if (!prev) return EINA_TRUE;
676 if (elm_genlist_item_selected_get(prev))
678 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
679 wd->last_selected_item = prev;
680 elm_genlist_item_show(wd->last_selected_item);
684 elm_genlist_item_selected_set(prev, EINA_TRUE);
685 elm_genlist_item_show(prev);
691 _item_multi_select_down(Widget_Data *wd)
693 if (!wd->selected) return EINA_FALSE;
694 if (!wd->multi) return EINA_FALSE;
696 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
697 if (!next) return EINA_TRUE;
699 if (elm_genlist_item_selected_get(next))
701 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
702 wd->last_selected_item = next;
703 elm_genlist_item_show(wd->last_selected_item);
707 elm_genlist_item_selected_set(next, EINA_TRUE);
708 elm_genlist_item_show(next);
714 _item_single_select_up(Widget_Data *wd)
716 Elm_Genlist_Item *prev;
719 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
720 while ((prev) && (prev->delete_me))
721 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
723 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
725 if (!prev) return EINA_FALSE;
727 _deselect_all_items(wd);
729 elm_genlist_item_selected_set(prev, EINA_TRUE);
730 elm_genlist_item_show(prev);
735 _item_single_select_down(Widget_Data *wd)
737 Elm_Genlist_Item *next;
740 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
741 while ((next) && (next->delete_me))
742 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
744 else next = elm_genlist_item_next_get(wd->last_selected_item);
746 if (!next) return EINA_FALSE;
748 _deselect_all_items(wd);
750 elm_genlist_item_selected_set(next, EINA_TRUE);
751 elm_genlist_item_show(next);
756 _on_focus_hook(void *data __UNUSED__,
759 Widget_Data *wd = elm_widget_data_get(obj);
761 if (elm_widget_focus_get(obj))
763 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
764 evas_object_focus_set(wd->obj, EINA_TRUE);
765 if ((wd->selected) && (!wd->last_selected_item))
766 wd->last_selected_item = eina_list_data_get(wd->selected);
770 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
771 evas_object_focus_set(wd->obj, EINA_FALSE);
776 _del_hook(Evas_Object *obj)
778 Widget_Data *wd = elm_widget_data_get(obj);
780 _item_cache_zero(wd);
781 if (wd->calc_job) ecore_job_del(wd->calc_job);
782 if (wd->update_job) ecore_job_del(wd->update_job);
783 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
784 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
785 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
790 _del_pre_hook(Evas_Object *obj)
792 Widget_Data *wd = elm_widget_data_get(obj);
794 evas_object_del(wd->pan_smart);
795 wd->pan_smart = NULL;
796 elm_genlist_clear(obj);
800 _theme_hook(Evas_Object *obj)
802 Widget_Data *wd = elm_widget_data_get(obj);
805 _item_cache_zero(wd);
806 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
807 elm_widget_style_get(obj));
808 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
809 wd->item_width = wd->item_height = 0;
810 wd->minw = wd->minh = wd->realminw = 0;
811 EINA_INLIST_FOREACH(wd->blocks, itb)
814 Elm_Genlist_Item *it;
816 if (itb->realized) _item_block_unrealize(itb);
817 EINA_LIST_FOREACH(itb->items, l, it)
818 it->mincalcd = EINA_FALSE;
820 itb->changed = EINA_TRUE;
822 if (wd->calc_job) ecore_job_del(wd->calc_job);
823 wd->calc_job = ecore_job_add(_calc_job, wd);
829 _show_region_hook(void *data, Evas_Object *obj)
831 Widget_Data *wd = elm_widget_data_get(data);
832 Evas_Coord x, y, w, h;
834 elm_widget_show_region_get(obj, &x, &y, &w, &h);
835 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
840 _sizing_eval(Evas_Object *obj)
842 Widget_Data *wd = elm_widget_data_get(obj);
843 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
845 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
846 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
848 if (wd->height_for_width)
852 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
853 if ((vw != 0) && (vw != wd->prev_viewport_w))
857 wd->prev_viewport_w = vw;
858 EINA_INLIST_FOREACH(wd->blocks, itb)
860 itb->must_recalc = EINA_TRUE;
862 if (wd->calc_job) ecore_job_del(wd->calc_job);
863 wd->calc_job = ecore_job_add(_calc_job, wd);
866 if (wd->mode == ELM_LIST_LIMIT)
868 Evas_Coord vmw, vmh, vw, vh;
872 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
873 if ((minw > 0) && (vw < minw)) vw = minw;
874 else if ((maxw > 0) && (vw > maxw))
876 edje_object_size_min_calc
877 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
884 edje_object_size_min_calc
885 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
889 evas_object_size_hint_min_set(obj, minw, minh);
890 evas_object_size_hint_max_set(obj, maxw, maxh);
894 _item_hilight(Elm_Genlist_Item *it)
896 const char *selectraise;
897 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
898 (it->disabled)) return;
900 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
901 selectraise = edje_object_data_get(it->base.view, "selectraise");
902 if ((selectraise) && (!strcmp(selectraise, "on")))
904 evas_object_raise(it->base.view);
905 if ((it->group_item) && (it->group_item->realized))
906 evas_object_raise(it->group_item->base.view);
908 it->hilighted = EINA_TRUE;
912 _item_block_del(Elm_Genlist_Item *it)
915 Item_Block *itb = it->block;
917 itb->items = eina_list_remove(itb->items, it);
919 itb->changed = EINA_TRUE;
920 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
921 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
924 il = EINA_INLIST_GET(itb);
925 Item_Block *itbn = (Item_Block *)(il->next);
927 it->parent->items = eina_list_remove(it->parent->items, it);
929 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
931 if (itbn) itbn->changed = EINA_TRUE;
935 if (itb->count < itb->wd->max_items_per_block/2)
937 il = EINA_INLIST_GET(itb);
938 Item_Block *itbp = (Item_Block *)(il->prev);
939 Item_Block *itbn = (Item_Block *)(il->next);
940 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
942 Elm_Genlist_Item *it2;
944 EINA_LIST_FREE(itb->items, it2)
947 itbp->items = eina_list_append(itbp->items, it2);
949 itbp->changed = EINA_TRUE;
951 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
952 EINA_INLIST_GET(itb));
955 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
959 Eina_List *last = eina_list_last(itb->items);
960 Elm_Genlist_Item *it2 = last->data;
963 itb->items = eina_list_remove_list(itb->items, last);
964 itbn->items = eina_list_prepend(itbn->items, it2);
966 itbn->changed = EINA_TRUE;
969 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
977 _item_subitems_clear(Elm_Genlist_Item *it)
980 Eina_List *tl = NULL, *l;
981 Elm_Genlist_Item *it2;
983 EINA_LIST_FOREACH(it->items, l, it2)
984 tl = eina_list_append(tl, it2);
986 EINA_LIST_FREE(tl, it2)
987 elm_genlist_item_del(it2);
991 _item_del(Elm_Genlist_Item *it)
993 elm_widget_item_pre_notify_del(it);
994 elm_genlist_item_subitems_clear(it);
995 it->wd->walking -= it->walking;
996 if (it->wd->show_item == it) it->wd->show_item = NULL;
997 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
998 if (it->realized) _item_unrealize(it);
999 if (it->effect_item_realized) _effect_item_unrealize(it);
1000 if (it->block) _item_block_del(it);
1001 if ((!it->delete_me) && (it->itc->func.del))
1002 it->itc->func.del((void *)it->base.data, it->base.widget);
1003 it->delete_me = EINA_TRUE;
1005 it->wd->queue = eina_list_remove(it->wd->queue, it);
1006 if (it->wd->anchor_item == it)
1008 it->wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
1009 if (!it->wd->anchor_item)
1010 it->wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
1012 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1014 it->parent->items = eina_list_remove(it->parent->items, it);
1015 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1016 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1017 if (it->long_timer) ecore_timer_del(it->long_timer);
1018 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1020 if (it->tooltip.del_cb)
1021 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1023 elm_widget_item_del(it);
1024 it->wd->total_num--; // todo : remove
1028 _item_select(Elm_Genlist_Item *it)
1030 if ((it->wd->no_select) || (it->delete_me)) return;
1033 if (it->wd->always_select) goto call;
1036 it->selected = EINA_TRUE;
1037 it->wd->selected = eina_list_append(it->wd->selected, it);
1041 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1043 evas_object_smart_callback_call(it->base.widget, "selected", it);
1046 if ((it->wd->clear_me) && (!it->wd->walking))
1047 elm_genlist_clear(it->base.widget);
1050 if ((!it->walking) && (it->delete_me))
1052 if (!it->relcount) _item_del(it);
1055 it->wd->last_selected_item = it;
1059 _item_unselect(Elm_Genlist_Item *it)
1061 const char *stacking, *selectraise;
1063 if ((it->delete_me) || (!it->hilighted)) return;
1065 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1066 stacking = edje_object_data_get(it->base.view, "stacking");
1067 selectraise = edje_object_data_get(it->base.view, "selectraise");
1068 if ((selectraise) && (!strcmp(selectraise, "on")))
1070 if ((stacking) && (!strcmp(stacking, "below")))
1071 evas_object_lower(it->base.view);
1073 it->hilighted = EINA_FALSE;
1076 it->selected = EINA_FALSE;
1077 it->wd->selected = eina_list_remove(it->wd->selected, it);
1078 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1083 _mouse_move(void *data,
1084 Evas *evas __UNUSED__,
1088 Elm_Genlist_Item *it = data;
1089 Evas_Event_Mouse_Move *ev = event_info;
1090 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1092 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1094 if (!it->wd->on_hold)
1096 it->wd->on_hold = EINA_TRUE;
1097 if (!it->wd->wasselected)
1101 if (it->wd->multitouched)
1103 it->wd->cur_x = ev->cur.canvas.x;
1104 it->wd->cur_y = ev->cur.canvas.y;
1107 if ((it->dragging) && (it->down))
1109 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1112 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1113 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1114 if (abs((it->wd->history[it->wd->movements].x -
1115 it->wd->history[0].x)) > 40)
1116 it->wd->swipe = EINA_TRUE;
1118 it->wd->movements++;
1122 ecore_timer_del(it->long_timer);
1123 it->long_timer = NULL;
1125 evas_object_smart_callback_call(it->base.widget, "drag", it);
1128 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1132 ecore_timer_del(it->long_timer);
1133 it->long_timer = NULL;
1135 if (it->wd->reorder_mode && it->wd->reorder_it)
1137 Evas_Coord ox,oy,oh,ow;
1138 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1139 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1140 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1142 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1145 evas_object_move(it->base.view, it->scrl_x+it->pad_left,oy);
1146 _effect_item_controls(it, it->scrl_x, oy);
1148 else if (it_y + it->wd->reorder_it->h > oy+oh)
1150 evas_object_move(it->base.view, it->scrl_x+it->pad_left, oy + oh - it->wd->reorder_it->h);
1151 _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1155 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it_y);
1156 _effect_item_controls(it, it->scrl_x, it_y);
1161 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1162 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1166 if (!it->display_only)
1167 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1168 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1169 x = ev->cur.canvas.x - x;
1170 y = ev->cur.canvas.y - y;
1173 if (adx < 0) adx = -dx;
1176 if (ady < 0) ady = -dy;
1179 if ((adx > minw) || (ady > minh))
1181 it->dragging = EINA_TRUE;
1184 ecore_timer_del(it->long_timer);
1185 it->long_timer = NULL;
1187 if (!it->wd->wasselected)
1192 evas_object_smart_callback_call(it->base.widget,
1193 "drag,start,up", it);
1198 evas_object_smart_callback_call(it->base.widget,
1199 "drag,start,left", it);
1200 _item_slide(it, EINA_FALSE);
1204 evas_object_smart_callback_call(it->base.widget,
1205 "drag,start,right", it);
1206 _item_slide(it, EINA_TRUE);
1213 evas_object_smart_callback_call(it->base.widget,
1214 "drag,start,down", it);
1219 evas_object_smart_callback_call(it->base.widget,
1220 "drag,start,left", it);
1221 _item_slide(it, EINA_FALSE);
1225 evas_object_smart_callback_call(it->base.widget,
1226 "drag,start,right", it);
1227 _item_slide(it, EINA_TRUE);
1235 _long_press(void *data)
1237 Elm_Genlist_Item *it = data , *it_tmp;
1238 static Eina_Bool done = EINA_FALSE;
1239 //static Eina_Bool contracted = EINA_FALSE;
1243 it->long_timer = NULL;
1244 if ((it->disabled) || (it->dragging) || (it->display_only))
1245 return ECORE_CALLBACK_CANCEL;
1246 it->wd->longpressed = EINA_TRUE;
1247 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1248 if (it->wd->reorder_mode)
1250 it->wd->reorder_it = it;
1251 it->wd->reorder_start_y = 0;
1252 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1253 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1255 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1260 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1262 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1264 _item_unselect(it_tmp);
1276 EINA_LIST_FOREACH(it->items, l, it_tmp)
1278 if (elm_genlist_item_expanded_get(it_tmp))
1280 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1281 // contracted = EINA_TRUE;
1282 return ECORE_CALLBACK_RENEW;
1286 if (elm_genlist_item_expanded_get(it)) {
1287 elm_genlist_item_expanded_set(it, EINA_FALSE);
1288 return ECORE_CALLBACK_RENEW;
1292 return ECORE_CALLBACK_CANCEL;
1296 _swipe(Elm_Genlist_Item *it)
1301 it->wd->swipe = EINA_FALSE;
1302 for (i = 0; i < it->wd->movements; i++)
1304 sum += it->wd->history[i].x;
1305 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1308 sum /= it->wd->movements;
1309 if (abs(sum - it->wd->history[0].x) <= 10) return;
1310 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1314 _swipe_cancel(void *data)
1316 Elm_Genlist_Item *it = data;
1318 if (!it) return ECORE_CALLBACK_CANCEL;
1319 it->wd->swipe = EINA_FALSE;
1320 it->wd->movements = 0;
1321 return ECORE_CALLBACK_RENEW;
1325 _multi_cancel(void *data)
1327 Widget_Data *wd = data;
1329 if (!wd) return ECORE_CALLBACK_CANCEL;
1330 wd->multi_timeout = EINA_TRUE;
1331 return ECORE_CALLBACK_RENEW;
1335 _multi_touch_gesture_eval(void *data)
1337 Elm_Genlist_Item *it = data;
1339 it->wd->multitouched = EINA_FALSE;
1340 if (it->wd->multi_timer)
1342 ecore_timer_del(it->wd->multi_timer);
1343 it->wd->multi_timer = NULL;
1345 if (it->wd->multi_timeout)
1347 it->wd->multi_timeout = EINA_FALSE;
1351 Evas_Coord minw = 0, minh = 0;
1352 Evas_Coord off_x, off_y, off_mx, off_my;
1354 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1355 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1356 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1357 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1358 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1360 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1362 if ((off_x + off_mx) > (off_y + off_my))
1364 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1365 evas_object_smart_callback_call(it->base.widget,
1366 "multi,swipe,right", it);
1367 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1368 evas_object_smart_callback_call(it->base.widget,
1369 "multi,swipe,left", it);
1370 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1371 evas_object_smart_callback_call(it->base.widget,
1372 "multi,pinch,out", it);
1374 evas_object_smart_callback_call(it->base.widget,
1375 "multi,pinch,in", it);
1379 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1380 evas_object_smart_callback_call(it->base.widget,
1381 "multi,swipe,down", it);
1382 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1383 evas_object_smart_callback_call(it->base.widget,
1384 "multi,swipe,up", it);
1385 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1386 evas_object_smart_callback_call(it->base.widget,
1387 "multi,pinch,out", it);
1389 evas_object_smart_callback_call(it->base.widget,
1390 "multi,pinch,in", it);
1393 it->wd->multi_timeout = EINA_FALSE;
1397 _multi_down(void *data,
1398 Evas *evas __UNUSED__,
1399 Evas_Object *obj __UNUSED__,
1402 Elm_Genlist_Item *it = data;
1403 Evas_Event_Multi_Down *ev = event_info;
1405 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1406 it->wd->multi_device = ev->device;
1407 it->wd->multi_down = EINA_TRUE;
1408 it->wd->multitouched = EINA_TRUE;
1409 it->wd->prev_mx = ev->canvas.x;
1410 it->wd->prev_my = ev->canvas.y;
1411 if (!it->wd->wasselected) _item_unselect(it);
1412 it->wd->wasselected = EINA_FALSE;
1413 it->wd->longpressed = EINA_FALSE;
1416 ecore_timer_del(it->long_timer);
1417 it->long_timer = NULL;
1421 it->dragging = EINA_FALSE;
1422 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1424 if (it->swipe_timer)
1426 ecore_timer_del(it->swipe_timer);
1427 it->swipe_timer = NULL;
1429 if (it->wd->on_hold)
1431 it->wd->swipe = EINA_FALSE;
1432 it->wd->movements = 0;
1433 it->wd->on_hold = EINA_FALSE;
1438 _multi_up(void *data,
1439 Evas *evas __UNUSED__,
1440 Evas_Object *obj __UNUSED__,
1443 Elm_Genlist_Item *it = data;
1444 Evas_Event_Multi_Up *ev = event_info;
1446 if (it->wd->multi_device != ev->device) return;
1447 it->wd->multi_device = 0;
1448 it->wd->multi_down = EINA_FALSE;
1449 if (it->wd->mouse_down) return;
1450 _multi_touch_gesture_eval(data);
1454 _multi_move(void *data,
1455 Evas *evas __UNUSED__,
1456 Evas_Object *obj __UNUSED__,
1459 Elm_Genlist_Item *it = data;
1460 Evas_Event_Multi_Move *ev = event_info;
1462 if (it->wd->multi_device != ev->device) return;
1463 it->wd->cur_mx = ev->cur.canvas.x;
1464 it->wd->cur_my = ev->cur.canvas.y;
1468 _mouse_down(void *data,
1469 Evas *evas __UNUSED__,
1473 Elm_Genlist_Item *it = data;
1474 Evas_Event_Mouse_Down *ev = event_info;
1477 if (ev->button != 1) return;
1478 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1480 it->wd->on_hold = EINA_TRUE;
1483 if (it->wd->edit_field && !it->renamed)
1484 elm_genlist_item_rename_mode_set(it, 0);
1485 it->down = EINA_TRUE;
1486 it->dragging = EINA_FALSE;
1487 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1488 it->dx = ev->canvas.x - x;
1489 it->dy = ev->canvas.y - y;
1490 it->wd->mouse_down = EINA_TRUE;
1491 if (!it->wd->multitouched)
1493 it->wd->prev_x = ev->canvas.x;
1494 it->wd->prev_y = ev->canvas.y;
1495 it->wd->multi_timeout = EINA_FALSE;
1496 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1497 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1499 it->wd->longpressed = EINA_FALSE;
1500 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1501 else it->wd->on_hold = EINA_FALSE;
1502 if (it->wd->on_hold) return;
1503 it->wd->wasselected = it->selected;
1505 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1506 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1507 if (it->long_timer) ecore_timer_del(it->long_timer);
1508 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1509 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1511 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1514 it->long_timer = NULL;
1515 it->wd->swipe = EINA_FALSE;
1516 it->wd->movements = 0;
1520 _mouse_up(void *data,
1521 Evas *evas __UNUSED__,
1522 Evas_Object *obj __UNUSED__,
1525 Elm_Genlist_Item *it = data;
1526 Evas_Event_Mouse_Up *ev = event_info;
1527 Eina_Bool dragged = EINA_FALSE;
1529 if (ev->button != 1) return;
1530 it->down = EINA_FALSE;
1531 it->wd->mouse_down = EINA_FALSE;
1532 if (it->wd->multitouched)
1534 if (it->wd->multi_down) return;
1535 _multi_touch_gesture_eval(data);
1538 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1539 else it->wd->on_hold = EINA_FALSE;
1542 ecore_timer_del(it->long_timer);
1543 it->long_timer = NULL;
1547 it->dragging = EINA_FALSE;
1548 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1551 if (it->swipe_timer)
1553 ecore_timer_del(it->swipe_timer);
1554 it->swipe_timer = NULL;
1556 if (it->wd->multi_timer)
1558 ecore_timer_del(it->wd->multi_timer);
1559 it->wd->multi_timer = NULL;
1560 it->wd->multi_timeout = EINA_FALSE;
1562 if (it->wd->on_hold)
1564 if (it->wd->swipe) _swipe(data);
1565 it->wd->longpressed = EINA_FALSE;
1566 it->wd->on_hold = EINA_FALSE;
1569 if (it->wd->reorder_mode)
1571 Evas_Coord rox, roy, row, roh;
1572 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1575 Evas_Coord ox,oy,oh,ow;
1576 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1577 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1578 if (it->wd->reorder_rel)
1580 if (roy + oy < it->wd->reorder_rel->scrl_y)
1581 elm_genlist_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1583 elm_genlist_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1585 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1586 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1587 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1589 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1590 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1593 if (it->wd->longpressed)
1595 it->wd->longpressed = EINA_FALSE;
1596 if (!it->wd->wasselected)
1598 it->wd->wasselected = EINA_FALSE;
1603 if (it->want_unrealize)
1605 _item_unrealize(it);
1606 if (it->block->want_unrealize)
1607 _item_block_unrealize(it->block);
1610 if ((it->disabled) || (dragged) || (it->display_only)) return;
1611 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1614 if ((!it->selected) && (!it->sweeped))
1619 else _item_unselect(it);
1625 Widget_Data *wd = it->wd;
1628 while (wd->selected) _item_unselect(wd->selected->data);
1633 const Eina_List *l, *l_next;
1634 Elm_Genlist_Item *it2;
1636 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1637 if (it2 != it) _item_unselect(it2);
1638 //_item_hilight(it);
1650 _signal_expand_toggle(void *data,
1651 Evas_Object *obj __UNUSED__,
1652 const char *emission __UNUSED__,
1653 const char *source __UNUSED__)
1655 Elm_Genlist_Item *it = data;
1658 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1660 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1664 _signal_expand(void *data,
1665 Evas_Object *obj __UNUSED__,
1666 const char *emission __UNUSED__,
1667 const char *source __UNUSED__)
1669 Elm_Genlist_Item *it = data;
1672 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1676 _signal_contract(void *data,
1677 Evas_Object *obj __UNUSED__,
1678 const char *emission __UNUSED__,
1679 const char *source __UNUSED__)
1681 Elm_Genlist_Item *it = data;
1684 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1688 _item_cache_clean(Widget_Data *wd)
1690 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1694 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1695 wd->item_cache = eina_inlist_remove(wd->item_cache,
1696 wd->item_cache->last);
1697 wd->item_cache_count--;
1698 if (itc->spacer) evas_object_del(itc->spacer);
1699 if (itc->base_view) evas_object_del(itc->base_view);
1700 if (itc->item_style) eina_stringshare_del(itc->item_style);
1706 _item_cache_zero(Widget_Data *wd)
1708 int pmax = wd->item_cache_max;
1709 wd->item_cache_max = 0;
1710 _item_cache_clean(wd);
1711 wd->item_cache_max = pmax;
1715 _item_cache_add(Elm_Genlist_Item *it)
1719 if (it->wd->item_cache_max <= 0)
1721 evas_object_del(it->base.view);
1722 it->base.view = NULL;
1723 evas_object_del(it->spacer);
1728 it->wd->item_cache_count++;
1729 itc = calloc(1, sizeof(Item_Cache));
1730 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1731 EINA_INLIST_GET(itc));
1732 itc->spacer = it->spacer;
1734 itc->base_view = it->base.view;
1735 it->base.view = NULL;
1736 evas_object_hide(itc->base_view);
1737 evas_object_move(itc->base_view, -9999, -9999);
1738 itc->item_style = eina_stringshare_add(it->itc->item_style);
1739 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1740 itc->compress = (it->wd->compress);
1741 itc->odd = (it->order_num_in & 0x1);
1742 itc->selected = it->selected;
1743 itc->disabled = it->disabled;
1744 itc->expanded = it->expanded;
1747 ecore_timer_del(it->long_timer);
1748 it->long_timer = NULL;
1750 if (it->swipe_timer)
1752 ecore_timer_del(it->swipe_timer);
1753 it->swipe_timer = NULL;
1755 // FIXME: other callbacks?
1756 edje_object_signal_callback_del_full(itc->base_view,
1757 "elm,action,expand,toggle",
1758 "elm", _signal_expand_toggle, it);
1759 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1761 _signal_expand, it);
1762 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1763 "elm", _signal_contract, it);
1764 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1766 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1768 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1770 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1772 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1774 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1776 _item_cache_clean(it->wd);
1780 _item_cache_find(Elm_Genlist_Item *it)
1783 Eina_Bool tree = 0, odd;
1785 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1786 odd = (it->order_num_in & 0x1);
1787 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1789 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1791 if ((itc->tree == tree) &&
1792 (itc->odd == odd) &&
1793 (itc->compress == it->wd->compress) &&
1794 (!strcmp(it->itc->item_style, itc->item_style)))
1796 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1797 EINA_INLIST_GET(itc));
1798 it->wd->item_cache_count--;
1806 _item_cache_free(Item_Cache *itc)
1808 if (itc->spacer) evas_object_del(itc->spacer);
1809 if (itc->base_view) evas_object_del(itc->base_view);
1810 if (itc->item_style) eina_stringshare_del(itc->item_style);
1815 _item_realize(Elm_Genlist_Item *it,
1819 if ((it->realized) || (it->delete_me)) return;
1821 Elm_Genlist_Item *it2;
1822 const char *stacking;
1823 const char *treesize;
1825 int depth, tsize = 20;
1828 it->order_num_in = in;
1830 itc = _item_cache_find(it);
1831 if (!it->wd->effect_mode && itc)
1833 it->base.view = itc->base_view;
1834 itc->base_view = NULL;
1835 it->spacer = itc->spacer;
1840 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1841 edje_object_scale_set(it->base.view,
1842 elm_widget_scale_get(it->base.widget) *
1843 _elm_config->scale);
1844 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1845 elm_widget_sub_object_add(it->base.widget, it->base.view);
1847 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1848 strncpy(buf, "tree", sizeof(buf));
1849 else strncpy(buf, "item", sizeof(buf));
1850 if (it->wd->compress)
1851 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1853 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1854 strncat(buf, "/", sizeof(buf) - strlen(buf));
1855 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1857 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1858 elm_widget_style_get(it->base.widget));
1860 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1861 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1862 elm_widget_sub_object_add(it->base.widget, it->spacer);
1864 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1866 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1868 it->expanded_depth = depth;
1869 treesize = edje_object_data_get(it->base.view, "treesize");
1870 if (treesize) tsize = atoi(treesize);
1871 evas_object_size_hint_min_set(it->spacer,
1872 (depth * tsize) * _elm_config->scale, 1);
1873 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1876 edje_object_signal_callback_add(it->base.view,
1877 "elm,action,expand,toggle",
1878 "elm", _signal_expand_toggle, it);
1879 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1880 "elm", _signal_expand, it);
1881 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1882 "elm", _signal_contract, it);
1883 stacking = edje_object_data_get(it->base.view, "stacking");
1886 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1887 else if (!strcmp(stacking, "above"))
1888 evas_object_raise(it->base.view);
1890 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1892 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1894 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1896 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1898 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1900 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1904 if (it->selected != itc->selected)
1906 if ((it->selected) && (!it->sweeped))
1907 edje_object_signal_emit(it->base.view,
1908 "elm,state,selected", "elm");
1910 if (it->disabled != itc->disabled)
1913 edje_object_signal_emit(it->base.view,
1914 "elm,state,disabled", "elm");
1916 if (it->expanded != itc->expanded)
1919 edje_object_signal_emit(it->base.view,
1920 "elm,state,expanded", "elm");
1925 if ((it->selected) && (!it->sweeped))
1926 edje_object_signal_emit(it->base.view,
1927 "elm,state,selected", "elm");
1929 edje_object_signal_emit(it->base.view,
1930 "elm,state,disabled", "elm");
1932 edje_object_signal_emit(it->base.view,
1933 "elm,state,expanded", "elm");
1937 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width))
1939 /* homogenous genlist shortcut */
1942 it->w = it->minw = it->wd->item_width;
1943 it->h = it->minh = it->wd->item_height;
1944 it->mincalcd = EINA_TRUE;
1949 if (it->itc->func.label_get)
1955 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1957 EINA_LIST_FOREACH(it->labels, l, key)
1959 char *s = it->itc->func.label_get
1960 ((void *)it->base.data, it->base.widget, l->data);
1964 edje_object_part_text_set(it->base.view, l->data, s);
1968 edje_object_part_text_set(it->base.view, l->data, "");
1971 if (it->itc->func.icon_get)
1977 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1979 EINA_LIST_FOREACH(it->icons, l, key)
1981 Evas_Object *ic = it->itc->func.icon_get
1982 ((void *)it->base.data, it->base.widget, l->data);
1986 it->icon_objs = eina_list_append(it->icon_objs, ic);
1987 edje_object_part_swallow(it->base.view, key, ic);
1988 evas_object_show(ic);
1989 elm_widget_sub_object_add(it->base.widget, ic);
1993 if (it->itc->func.state_get)
1999 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2001 EINA_LIST_FOREACH(it->states, l, key)
2003 Eina_Bool on = it->itc->func.state_get
2004 ((void *)it->base.data, it->base.widget, l->data);
2008 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2009 edje_object_signal_emit(it->base.view, buf, "elm");
2013 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2014 edje_object_signal_emit(it->base.view, buf, "elm");
2020 _create_sweep_objs(it);
2024 Evas_Coord mw = -1, mh = -1;
2026 if (it->wd->height_for_width) mw = it->wd->w;
2028 if (!it->display_only)
2029 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2030 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2031 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2033 if (!it->display_only)
2034 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2035 it->w = it->minw = mw;
2036 it->h = it->minh = mh;
2037 it->mincalcd = EINA_TRUE;
2039 if ((!in) && (it->wd->homogeneous))
2041 it->wd->item_width = mw;
2042 it->wd->item_height = mh;
2045 if (!calc) evas_object_show(it->base.view);
2048 if (it->tooltip.content_cb)
2050 elm_widget_item_tooltip_content_cb_set(it,
2051 it->tooltip.content_cb,
2052 it->tooltip.data, NULL);
2053 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2056 if (it->mouse_cursor)
2057 elm_widget_item_cursor_set(it, it->mouse_cursor);
2059 it->realized = EINA_TRUE;
2060 it->want_unrealize = EINA_FALSE;
2062 if (itc) _item_cache_free(itc);
2063 evas_object_smart_callback_call(it->base.widget, "realized", it);
2065 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_realize(it);
2069 _item_unrealize(Elm_Genlist_Item *it)
2073 if (!it->realized) return;
2074 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2076 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2079 ecore_timer_del(it->long_timer);
2080 it->long_timer = NULL;
2082 if (it->sweeped || it->wassweeped)
2084 it->sweeped = EINA_FALSE;
2085 it->wassweeped = EINA_FALSE;
2086 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2087 _delete_sweep_objs(it);
2088 evas_object_del(it->base.view);
2089 it->base.view = NULL;
2090 evas_object_del(it->spacer);
2094 _item_cache_add(it);
2095 elm_widget_stringlist_free(it->labels);
2097 elm_widget_stringlist_free(it->icons);
2099 elm_widget_stringlist_free(it->states);
2101 EINA_LIST_FREE(it->icon_objs, icon)
2102 evas_object_del(icon);
2105 it->realized = EINA_FALSE;
2106 it->want_unrealize = EINA_FALSE;
2108 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2112 _item_block_recalc(Item_Block *itb,
2118 Elm_Genlist_Item *it;
2119 Evas_Coord minw = 0, minh = 0;
2120 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2124 EINA_LIST_FOREACH(itb->items, l, it)
2126 if (it->delete_me) continue;
2127 showme |= it->showme;
2132 if (!it->mincalcd) changed = EINA_TRUE;
2135 _item_realize(it, in, 1);
2136 _item_unrealize(it);
2141 _item_realize(it, in, 1);
2142 _item_unrealize(it);
2146 _item_realize(it, in, 0);
2148 if (minw < it->minw) minw = it->minw;
2156 itb->changed = EINA_FALSE;
2157 /* force an evas norender to garbage collect deleted objects */
2158 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2163 _item_block_realize(Item_Block *itb,
2168 Elm_Genlist_Item *it;
2170 if (itb->realized) return;
2171 EINA_LIST_FOREACH(itb->items, l, it)
2173 if (it->delete_me) continue;
2174 if (full) _item_realize(it, in, 0);
2177 itb->realized = EINA_TRUE;
2178 itb->want_unrealize = EINA_FALSE;
2182 _item_block_unrealize(Item_Block *itb)
2185 Elm_Genlist_Item *it;
2186 Eina_Bool dragging = EINA_FALSE;
2188 if (!itb->realized) return;
2189 EINA_LIST_FOREACH(itb->items, l, it)
2191 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2195 dragging = EINA_TRUE;
2196 it->want_unrealize = EINA_TRUE;
2199 _item_unrealize(it);
2204 itb->realized = EINA_FALSE;
2205 itb->want_unrealize = EINA_TRUE;
2208 itb->want_unrealize = EINA_FALSE;
2212 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2214 Evas_Coord rox, roy, row, roh;
2215 Eina_Bool top = EINA_FALSE;
2216 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2217 if (!reorder_it) return 0;
2219 Evas_Coord ox,oy,oh,ow;
2220 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2221 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2223 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2225 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2226 if (it->block->count == 1)
2227 it->wd->reorder_rel = it;
2229 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2231 it->block->reorder_offset = it->wd->reorder_it->h;
2234 it->block->reorder_offset = 0;
2236 it->scrl_y += it->block->reorder_offset;
2238 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2239 rox, roy+roh/2, row, 1));
2242 it->wd->reorder_rel = it;
2243 it->scrl_y+=it->wd->reorder_it->h;
2244 return it->wd->reorder_it->h;
2251 _item_moving_effect_timer_cb2(void *data)
2253 Elm_Genlist_Item *it = data;
2254 Eina_Bool down = EINA_FALSE;
2256 if (it->old_scrl_y < it->scrl_y)
2258 it->old_scrl_y += 4;
2261 else if (it->old_scrl_y > it->scrl_y)
2263 it->old_scrl_y -= 4;
2267 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2268 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y);
2269 evas_object_show(it->base.view);
2271 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2273 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2275 it->old_scrl_y = it->scrl_y;
2276 it->move_effect_me = EINA_FALSE;
2277 return ECORE_CALLBACK_CANCEL;
2279 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2281 it->old_scrl_y = it->scrl_y;
2282 it->move_effect_me = EINA_FALSE;
2283 return ECORE_CALLBACK_CANCEL;
2285 return ECORE_CALLBACK_RENEW;
2289 _item_block_position(Item_Block *itb,
2293 Elm_Genlist_Item *it;
2294 Elm_Genlist_Item *git;
2295 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2297 Elm_Genlist_Item *select_all_item = NULL;
2299 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2300 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2303 if (itb->wd->select_all_item &&
2304 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2306 select_all_item = itb->wd->select_all_item;
2308 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2309 evas_object_move(select_all_item->base.view, ox, oy);
2310 evas_object_raise(select_all_item->base.view);
2312 if (itb->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
2313 evas_object_show(select_all_item->base.view);
2315 evas_object_hide(select_all_item->base.view);
2316 y = select_all_item->h;
2319 EINA_LIST_FOREACH(itb->items, l, it)
2321 if (it->delete_me) continue;
2322 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2327 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2328 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2330 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2331 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2332 cvx, cvy, cvw, cvh));
2333 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2335 if ((itb->realized) && (!it->realized))
2337 if (vis) _item_realize(it, in, 0);
2343 if(it->wd->reorder_mode)
2344 y += _get_space_for_reorder_item(it);
2345 git = it->group_item;
2348 if (git->scrl_y < oy)
2350 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2351 git->scrl_y = (it->scrl_y + it->h) - git->h;
2352 git->want_realize = EINA_TRUE;
2354 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2356 if (!it->move_effect_me)
2358 it->move_effect_me = EINA_TRUE;
2359 it->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb2, it);
2363 if (!it->move_effect_me )
2364 if (!it->wd->effect_mode || (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || (it->parent == it->wd->expand_item))
2366 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2367 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2368 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2369 if(!it->wd->effect_mode || (it->expanded_depth == 0) || (it->parent != it->wd->expand_item) || it->effect_done)
2370 evas_object_show(it->base.view);
2372 evas_object_hide(it->base.view);
2373 it->old_scrl_x = it->scrl_x;
2374 it->old_scrl_y = it->scrl_y;
2379 if (!it->dragging) _item_unrealize(it);
2386 if (vis) it->want_realize = EINA_TRUE;
2391 if (itb->wd->select_all_item &&
2392 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2393 evas_object_raise(select_all_item->base.view);
2397 _group_items_recalc(void *data)
2399 Widget_Data *wd = data;
2401 Elm_Genlist_Item *git;
2403 EINA_LIST_FOREACH(wd->group_items, l, git)
2405 if (git->want_realize)
2408 _item_realize(git, 0, 0);
2409 evas_object_resize(git->base.view, wd->minw, git->h);
2410 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2411 evas_object_show(git->base.view);
2412 evas_object_raise(git->base.view);
2414 else if (!git->want_realize && git->realized)
2417 _item_unrealize(git);
2423 _must_recalc_idler(void *data)
2425 Widget_Data *wd = data;
2426 if (wd->calc_job) ecore_job_del(wd->calc_job);
2427 wd->calc_job = ecore_job_add(_calc_job, wd);
2428 wd->must_recalc_idler = NULL;
2429 return ECORE_CALLBACK_CANCEL;
2433 _calc_job(void *data)
2435 Widget_Data *wd = data;
2437 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2438 Item_Block *chb = NULL;
2439 int in = 0, minw_change = 0;
2440 Eina_Bool changed = EINA_FALSE;
2442 Eina_Bool did_must_recalc = EINA_FALSE;
2445 t0 = ecore_time_get();
2446 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2450 // if (wd->height_for_width) changed = EINA_TRUE;
2453 EINA_INLIST_FOREACH(wd->blocks, itb)
2455 Eina_Bool showme = EINA_FALSE;
2458 showme = itb->showme;
2459 itb->showme = EINA_FALSE;
2462 if (itb->realized) _item_block_unrealize(itb);
2464 if ((itb->changed) || (changed) ||
2465 ((itb->must_recalc) && (!did_must_recalc)))
2467 if ((changed) || (itb->must_recalc))
2470 Elm_Genlist_Item *it;
2471 EINA_LIST_FOREACH(itb->items, l, it)
2472 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2473 itb->changed = EINA_TRUE;
2474 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2475 itb->must_recalc = EINA_FALSE;
2477 if (itb->realized) _item_block_unrealize(itb);
2478 showme = _item_block_recalc(itb, in, 0, 1);
2484 if (minw == -1) minw = itb->minw;
2485 else if ((!itb->must_recalc) && (minw < itb->minw))
2494 if ((showme) && (wd->show_item))
2496 wd->show_item->showme = EINA_FALSE;
2498 elm_smart_scroller_region_bring_in(wd->scr,
2500 wd->show_item->block->x,
2502 wd->show_item->block->y,
2503 wd->show_item->block->w,
2506 elm_smart_scroller_child_region_show(wd->scr,
2508 wd->show_item->block->x,
2510 wd->show_item->block->y,
2511 wd->show_item->block->w,
2513 wd->show_item = NULL;
2518 EINA_INLIST_FOREACH(wd->blocks, itb)
2524 if ((chb) && (EINA_INLIST_GET(chb)->next))
2526 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2528 if (itb->realized) _item_block_unrealize(itb);
2531 wd->realminw = minw;
2532 if (minw < wd->w) minw = wd->w;
2533 if ((minw != wd->minw) || (minh != wd->minh))
2537 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2538 _sizing_eval(wd->obj);
2539 if ((wd->anchor_item) && (wd->anchor_item->block))
2541 Elm_Genlist_Item *it;
2544 it = wd->anchor_item;
2545 it_y = wd->anchor_y;
2546 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2547 it->block->y + it->y + it_y);
2548 wd->anchor_item = it;
2549 wd->anchor_y = it_y;
2552 t = ecore_time_get();
2553 if (did_must_recalc)
2555 if (!wd->must_recalc_idler)
2556 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2558 wd->calc_job = NULL;
2559 evas_object_smart_changed(wd->pan_smart);
2563 _update_job(void *data)
2565 Widget_Data *wd = data;
2568 int num, num0, position = 0, recalc = 0;
2570 wd->update_job = NULL;
2572 EINA_INLIST_FOREACH(wd->blocks, itb)
2574 Evas_Coord itminw, itminh;
2575 Elm_Genlist_Item *it;
2581 _item_block_position(itb, num);
2586 EINA_LIST_FOREACH(itb->items, l2, it)
2593 it->updateme = EINA_FALSE;
2596 _item_unrealize(it);
2597 _item_realize(it, num, 0);
2602 _item_realize(it, num, 1);
2603 _item_unrealize(it);
2605 if ((it->minw != itminw) || (it->minh != itminh))
2610 itb->updateme = EINA_FALSE;
2614 itb->changed = EINA_TRUE;
2615 _item_block_recalc(itb, num0, 0, 1);
2616 _item_block_position(itb, num0);
2621 if (wd->calc_job) ecore_job_del(wd->calc_job);
2622 wd->calc_job = ecore_job_add(_calc_job, wd);
2627 _pan_set(Evas_Object *obj,
2631 Pan *sd = evas_object_smart_data_get(obj);
2634 // Evas_Coord ow, oh;
2635 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2636 // ow = sd->wd->minw - ow;
2637 // if (ow < 0) ow = 0;
2638 // oh = sd->wd->minh - oh;
2639 // if (oh < 0) oh = 0;
2640 // if (x < 0) x = 0;
2641 // if (y < 0) y = 0;
2642 // if (x > ow) x = ow;
2643 // if (y > oh) y = oh;
2644 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2648 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2650 if ((itb->y + itb->h) > y)
2652 Elm_Genlist_Item *it;
2655 EINA_LIST_FOREACH(itb->items, l2, it)
2657 if ((itb->y + it->y) >= y)
2659 sd->wd->anchor_item = it;
2660 sd->wd->anchor_y = -(itb->y + it->y - y);
2667 evas_object_smart_changed(obj);
2671 _pan_get(Evas_Object *obj,
2675 Pan *sd = evas_object_smart_data_get(obj);
2677 if (x) *x = sd->wd->pan_x;
2678 if (y) *y = sd->wd->pan_y;
2682 _pan_max_get(Evas_Object *obj,
2686 Pan *sd = evas_object_smart_data_get(obj);
2689 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2690 ow = sd->wd->minw - ow;
2692 oh = sd->wd->minh - oh;
2699 _pan_min_get(Evas_Object *obj __UNUSED__,
2708 _pan_child_size_get(Evas_Object *obj,
2712 Pan *sd = evas_object_smart_data_get(obj);
2714 if (w) *w = sd->wd->minw;
2715 if (h) *h = sd->wd->minh;
2719 _pan_add(Evas_Object *obj)
2722 Evas_Object_Smart_Clipped_Data *cd;
2725 cd = evas_object_smart_data_get(obj);
2728 sd->__clipped_data = *cd;
2730 evas_object_smart_data_set(obj, sd);
2734 _pan_del(Evas_Object *obj)
2736 Pan *sd = evas_object_smart_data_get(obj);
2741 ecore_job_del(sd->resize_job);
2742 sd->resize_job = NULL;
2748 _pan_resize_job(void *data)
2751 _sizing_eval(sd->wd->obj);
2752 sd->resize_job = NULL;
2756 _pan_resize(Evas_Object *obj,
2760 Pan *sd = evas_object_smart_data_get(obj);
2763 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2764 if ((ow == w) && (oh == h)) return;
2765 if ((sd->wd->height_for_width) && (ow != w))
2767 if (sd->resize_job) ecore_job_del(sd->resize_job);
2768 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2770 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2771 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2775 _pan_calculate(Evas_Object *obj)
2777 Pan *sd = evas_object_smart_data_get(obj);
2779 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2780 static Evas_Coord old_pan_y = 0;
2782 Elm_Genlist_Item *git;
2785 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2786 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2787 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2789 git->want_realize = EINA_FALSE;
2791 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2793 itb->w = sd->wd->minw;
2794 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2795 itb->y - sd->wd->pan_y + oy,
2797 cvx, cvy, cvw, cvh))
2799 if ((!itb->realized) || (itb->changed))
2800 _item_block_realize(itb, in, 0);
2801 _item_block_position(itb, in);
2805 if (itb->realized) _item_block_unrealize(itb);
2809 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2810 _group_items_recalc(sd->wd);
2812 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2814 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2815 else sd->wd->reorder_pan_move = EINA_FALSE;
2816 evas_object_raise(sd->wd->reorder_it->base.view);
2817 old_pan_y = sd->wd->pan_y;
2820 if (sd->wd->effect_mode &&
2821 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2823 _item_flip_effect_show(sd->wd->expand_item);
2824 evas_object_raise(sd->wd->alpha_bg);
2825 evas_object_show(sd->wd->alpha_bg);
2826 sd->wd->start_time = current_time_get();
2827 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2829 if (sd->wd->select_all_item)
2830 evas_object_raise(sd->wd->select_all_item->base.view);
2834 _pan_move(Evas_Object *obj,
2835 Evas_Coord x __UNUSED__,
2836 Evas_Coord y __UNUSED__)
2838 Pan *sd = evas_object_smart_data_get(obj);
2840 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2841 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2845 _hold_on(void *data __UNUSED__,
2847 void *event_info __UNUSED__)
2849 Widget_Data *wd = elm_widget_data_get(obj);
2851 elm_smart_scroller_hold_set(wd->scr, 1);
2855 _hold_off(void *data __UNUSED__,
2857 void *event_info __UNUSED__)
2859 Widget_Data *wd = elm_widget_data_get(obj);
2861 elm_smart_scroller_hold_set(wd->scr, 0);
2865 _freeze_on(void *data __UNUSED__,
2867 void *event_info __UNUSED__)
2869 Widget_Data *wd = elm_widget_data_get(obj);
2871 elm_smart_scroller_freeze_set(wd->scr, 1);
2875 _freeze_off(void *data __UNUSED__,
2877 void *event_info __UNUSED__)
2879 Widget_Data *wd = elm_widget_data_get(obj);
2881 elm_smart_scroller_freeze_set(wd->scr, 0);
2885 _scroll_edge_left(void *data,
2886 Evas_Object *scr __UNUSED__,
2887 void *event_info __UNUSED__)
2889 Evas_Object *obj = data;
2890 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2894 _scroll_edge_right(void *data,
2895 Evas_Object *scr __UNUSED__,
2896 void *event_info __UNUSED__)
2898 Evas_Object *obj = data;
2899 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2903 _scroll_edge_top(void *data,
2904 Evas_Object *scr __UNUSED__,
2905 void *event_info __UNUSED__)
2907 Evas_Object *obj = data;
2908 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2912 _scroll_edge_bottom(void *data,
2913 Evas_Object *scr __UNUSED__,
2914 void *event_info __UNUSED__)
2916 Evas_Object *obj = data;
2917 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2921 * Add a new Genlist object
2923 * @param parent The parent object
2924 * @return The new object or NULL if it cannot be created
2929 elm_genlist_add(Evas_Object *parent)
2934 Evas_Coord minw, minh;
2935 static Evas_Smart *smart = NULL;
2937 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2941 static Evas_Smart_Class sc;
2943 evas_object_smart_clipped_smart_set(&_pan_sc);
2945 sc.name = "elm_genlist_pan";
2946 sc.version = EVAS_SMART_CLASS_VERSION;
2949 sc.resize = _pan_resize;
2950 sc.move = _pan_move;
2951 sc.calculate = _pan_calculate;
2952 if (!(smart = evas_smart_class_new(&sc))) return NULL;
2954 wd = ELM_NEW(Widget_Data);
2955 e = evas_object_evas_get(parent);
2956 if (!e) return NULL;
2957 obj = elm_widget_add(e);
2958 ELM_SET_WIDTYPE(widtype, "genlist");
2959 elm_widget_type_set(obj, "genlist");
2960 elm_widget_sub_object_add(parent, obj);
2961 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
2962 elm_widget_data_set(obj, wd);
2963 elm_widget_del_hook_set(obj, _del_hook);
2964 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
2965 elm_widget_theme_hook_set(obj, _theme_hook);
2966 elm_widget_can_focus_set(obj, EINA_TRUE);
2967 elm_widget_event_hook_set(obj, _event_hook);
2969 wd->scr = elm_smart_scroller_add(e);
2970 elm_smart_scroller_widget_set(wd->scr, obj);
2971 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
2972 elm_widget_style_get(obj));
2973 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
2974 _elm_config->thumbscroll_bounce_enable);
2975 elm_widget_resize_object_set(obj, wd->scr);
2977 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
2978 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
2980 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
2981 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
2985 wd->mode = ELM_LIST_SCROLL;
2986 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
2987 wd->item_cache_max = wd->max_items_per_block * 2;
2988 wd->longpress_timeout = _elm_config->longpress_timeout;
2989 //wd->effect_mode = _elm_config->effect_enable;
2990 //wd->effect_mode = EINA_TRUE;
2992 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
2993 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
2994 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
2995 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
2997 wd->pan_smart = evas_object_smart_add(e, smart);
2998 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3001 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3002 _pan_set, _pan_get, _pan_max_get,
3003 _pan_min_get, _pan_child_size_get);
3005 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3007 evas_object_size_hint_min_set(obj, minw, minh);
3013 static Elm_Genlist_Item *
3014 _item_new(Widget_Data *wd,
3015 const Elm_Genlist_Item_Class *itc,
3017 Elm_Genlist_Item *parent,
3018 Elm_Genlist_Item_Flags flags,
3020 const void *func_data)
3022 Elm_Genlist_Item *it;
3024 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3025 if (!it) return NULL;
3028 it->base.data = data;
3029 it->parent = parent;
3031 it->func.func = func;
3032 it->func.data = func_data;
3033 it->mouse_cursor = NULL;
3034 it->expanded_depth = 0;
3035 if (it->parent && it->parent->edit_select_check) it->edit_select_check = EINA_TRUE;
3041 _item_block_add(Widget_Data *wd,
3042 Elm_Genlist_Item *it)
3044 Item_Block *itb = NULL;
3051 itb = calloc(1, sizeof(Item_Block));
3054 if (!it->rel->block)
3057 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3058 itb->items = eina_list_append(itb->items, it);
3064 wd->blocks = eina_inlist_prepend_relative
3065 (wd->blocks, EINA_INLIST_GET(itb),
3066 EINA_INLIST_GET(it->rel->block));
3068 eina_list_prepend_relative(itb->items, it, it->rel);
3072 wd->blocks = eina_inlist_append_relative
3073 (wd->blocks, EINA_INLIST_GET(itb),
3074 EINA_INLIST_GET(it->rel->block));
3076 eina_list_append_relative(itb->items, it, it->rel);
3086 itb = (Item_Block *)(wd->blocks);
3087 if (itb->count >= wd->max_items_per_block)
3089 itb = calloc(1, sizeof(Item_Block));
3093 eina_inlist_prepend(wd->blocks,
3094 EINA_INLIST_GET(itb));
3099 itb = calloc(1, sizeof(Item_Block));
3103 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3105 itb->items = eina_list_prepend(itb->items, it);
3111 itb = (Item_Block *)(wd->blocks->last);
3112 if (itb->count >= wd->max_items_per_block)
3114 itb = calloc(1, sizeof(Item_Block));
3118 eina_inlist_append(wd->blocks,
3119 EINA_INLIST_GET(itb));
3124 itb = calloc(1, sizeof(Item_Block));
3128 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3130 itb->items = eina_list_append(itb->items, it);
3136 itb = it->rel->block;
3137 if (!itb) goto newblock;
3139 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3141 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3144 itb->changed = EINA_TRUE;
3146 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3147 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3150 it->rel->relcount--;
3151 if ((it->rel->delete_me) && (!it->rel->relcount))
3155 if (itb->count > itb->wd->max_items_per_block)
3159 Elm_Genlist_Item *it2;
3161 newc = itb->count / 2;
3162 itb2 = calloc(1, sizeof(Item_Block));
3166 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3167 EINA_INLIST_GET(itb));
3168 itb2->changed = EINA_TRUE;
3169 while ((itb->count > newc) && (itb->items))
3173 l = eina_list_last(itb->items);
3175 itb->items = eina_list_remove_list(itb->items, l);
3178 itb2->items = eina_list_prepend(itb2->items, it2);
3186 _queue_proecess(Widget_Data *wd,
3190 Eina_Bool showme = EINA_FALSE;
3193 t0 = ecore_time_get();
3194 for (n = 0; (wd->queue) && (n < 128); n++)
3196 Elm_Genlist_Item *it;
3198 it = wd->queue->data;
3199 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3200 it->queued = EINA_FALSE;
3201 it->num = ++wd->total_num; // todo : remov
3202 _item_block_add(wd, it);
3203 t = ecore_time_get();
3204 if (it->block->changed)
3206 showme = _item_block_recalc(it->block, it->block->num, 1,
3208 it->block->changed = 0;
3210 if (showme) it->block->showme = EINA_TRUE;
3211 if (eina_inlist_count(wd->blocks) > 1)
3213 if ((t - t0) > (ecore_animator_frametime_get())) break;
3220 _item_idler(void *data)
3222 Widget_Data *wd = data;
3225 //static double q_start = 0.0;
3226 //if (q_start == 0.0) q_start = ecore_time_get();
3229 if (_queue_proecess(wd, 1) > 0)
3231 if (wd->calc_job) ecore_job_del(wd->calc_job);
3232 wd->calc_job = ecore_job_add(_calc_job, wd);
3237 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3239 wd->queue_idler = NULL;
3240 return ECORE_CALLBACK_CANCEL;
3242 return ECORE_CALLBACK_RENEW;
3246 _item_queue(Widget_Data *wd,
3247 Elm_Genlist_Item *it)
3249 if (it->queued) return;
3250 it->queued = EINA_TRUE;
3251 wd->queue = eina_list_append(wd->queue, it);
3252 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3254 if (wd->queue_idler)
3256 ecore_idler_del(wd->queue_idler);
3257 wd->queue_idler = NULL;
3259 _queue_proecess(wd, 0);
3261 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3265 * Append item to the end of the genlist
3267 * This appends the given item to the end of the list or the end of
3268 * the children if the parent is given.
3270 * @param obj The genlist object
3271 * @param itc The item class for the item
3272 * @param data The item data
3273 * @param parent The parent item, or NULL if none
3274 * @param flags Item flags
3275 * @param func Convenience function called when item selected
3276 * @param func_data Data passed to @p func above.
3277 * @return A handle to the item added or NULL if not possible
3281 EAPI Elm_Genlist_Item *
3282 elm_genlist_item_append(Evas_Object *obj,
3283 const Elm_Genlist_Item_Class *itc,
3285 Elm_Genlist_Item *parent,
3286 Elm_Genlist_Item_Flags flags,
3288 const void *func_data)
3290 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3291 Widget_Data *wd = elm_widget_data_get(obj);
3292 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3294 if (!wd) return NULL;
3295 if (!it) return NULL;
3298 if (flags & ELM_GENLIST_ITEM_GROUP)
3299 wd->group_items = eina_list_append(wd->group_items, it);
3300 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3305 Elm_Genlist_Item *it2 = NULL;
3306 Eina_List *ll = eina_list_last(it->parent->items);
3307 if (ll) it2 = ll->data;
3308 it->parent->items = eina_list_append(it->parent->items, it);
3309 if (!it2) it2 = it->parent;
3311 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3312 EINA_INLIST_GET(it2));
3314 it->rel->relcount++;
3316 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3317 it->group_item = parent;
3318 else if (it->parent->group_item)
3319 it->group_item = it->parent->group_item;
3321 it->before = EINA_FALSE;
3322 _item_queue(wd, it);
3327 * Prepend item at start of the genlist
3329 * This adds an item to the beginning of the list or beginning of the
3330 * children of the parent if given.
3332 * @param obj The genlist object
3333 * @param itc The item class for the item
3334 * @param data The item data
3335 * @param parent The parent item, or NULL if none
3336 * @param flags Item flags
3337 * @param func Convenience function called when item selected
3338 * @param func_data Data passed to @p func above.
3339 * @return A handle to the item added or NULL if not possible
3343 EAPI Elm_Genlist_Item *
3344 elm_genlist_item_prepend(Evas_Object *obj,
3345 const Elm_Genlist_Item_Class *itc,
3347 Elm_Genlist_Item *parent,
3348 Elm_Genlist_Item_Flags flags,
3350 const void *func_data)
3352 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3353 Widget_Data *wd = elm_widget_data_get(obj);
3354 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3356 if (!wd) return NULL;
3357 if (!it) return NULL;
3360 if (flags & ELM_GENLIST_ITEM_GROUP)
3361 wd->group_items = eina_list_prepend(wd->group_items, it);
3362 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3367 Elm_Genlist_Item *it2 = NULL;
3368 Eina_List *ll = it->parent->items;
3369 if (ll) it2 = ll->data;
3370 it->parent->items = eina_list_prepend(it->parent->items, it);
3371 if (!it2) it2 = it->parent;
3373 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3374 EINA_INLIST_GET(it2));
3376 it->rel->relcount++;
3378 it->before = EINA_TRUE;
3379 _item_queue(wd, it);
3384 * Insert item before another in the genlist
3386 * This inserts an item before another in the list. It will be in the
3387 * same tree level or group as the item it is inseted before.
3389 * @param obj The genlist object
3390 * @param itc The item class for the item
3391 * @param data The item data
3392 * @param before The item to insert before
3393 * @param flags Item flags
3394 * @param func Convenience function called when item selected
3395 * @param func_data Data passed to @p func above.
3396 * @return A handle to the item added or NULL if not possible
3400 EAPI Elm_Genlist_Item *
3401 elm_genlist_item_insert_before(Evas_Object *obj,
3402 const Elm_Genlist_Item_Class *itc,
3404 Elm_Genlist_Item *parent,
3405 Elm_Genlist_Item *before,
3406 Elm_Genlist_Item_Flags flags,
3408 const void *func_data)
3410 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3411 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3412 Widget_Data *wd = elm_widget_data_get(obj);
3413 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3415 if (!wd) return NULL;
3416 if (!it) return NULL;
3419 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3422 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3423 EINA_INLIST_GET(before));
3425 it->rel->relcount++;
3426 it->before = EINA_TRUE;
3427 _item_queue(wd, it);
3432 * Insert an item after another in the genlst
3434 * This inserts an item after another in the list. It will be in the
3435 * same tree level or group as the item it is inseted after.
3437 * @param obj The genlist object
3438 * @param itc The item class for the item
3439 * @param data The item data
3440 * @param after The item to insert after
3441 * @param flags Item flags
3442 * @param func Convenience function called when item selected
3443 * @param func_data Data passed to @p func above.
3444 * @return A handle to the item added or NULL if not possible
3448 EAPI Elm_Genlist_Item *
3449 elm_genlist_item_insert_after(Evas_Object *obj,
3450 const Elm_Genlist_Item_Class *itc,
3452 Elm_Genlist_Item *parent,
3453 Elm_Genlist_Item *after,
3454 Elm_Genlist_Item_Flags flags,
3456 const void *func_data)
3458 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3459 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3460 Widget_Data *wd = elm_widget_data_get(obj);
3461 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3463 if (!wd) return NULL;
3464 if (!it) return NULL;
3465 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3466 EINA_INLIST_GET(after));
3469 it->parent->items = eina_list_append_relative(it->parent->items, it,
3473 it->rel->relcount++;
3474 it->before = EINA_FALSE;
3475 _item_queue(wd, it);
3482 * This clears all items in the list, leaving it empty.
3484 * @param obj The genlist object
3489 elm_genlist_clear(Evas_Object *obj)
3491 ELM_CHECK_WIDTYPE(obj, widtype);
3492 Widget_Data *wd = elm_widget_data_get(obj);
3494 if (wd->walking > 0)
3496 Elm_Genlist_Item *it;
3498 wd->clear_me = EINA_TRUE;
3499 EINA_INLIST_FOREACH(wd->items, it)
3501 it->delete_me = EINA_TRUE;
3505 wd->clear_me = EINA_FALSE;
3508 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3510 if (wd->anchor_item == it)
3512 wd->anchor_item = (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->next);
3513 if (!wd->anchor_item)
3515 (Elm_Genlist_Item *)(EINA_INLIST_GET(it)->prev);
3517 wd->items = eina_inlist_remove(wd->items, wd->items);
3518 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3519 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3520 elm_widget_item_pre_notify_del(it);
3521 if (it->realized) _item_unrealize(it);
3522 if (it->itc->func.del)
3523 it->itc->func.del((void *)it->base.data, it->base.widget);
3524 if (it->long_timer) ecore_timer_del(it->long_timer);
3525 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3526 elm_widget_item_del(it);
3528 wd->anchor_item = NULL;
3531 Item_Block *itb = (Item_Block *)(wd->blocks);
3533 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3534 if (itb->items) eina_list_free(itb->items);
3539 ecore_job_del(wd->calc_job);
3540 wd->calc_job = NULL;
3542 if (wd->queue_idler)
3544 ecore_idler_del(wd->queue_idler);
3545 wd->queue_idler = NULL;
3547 if (wd->must_recalc_idler)
3549 ecore_idler_del(wd->must_recalc_idler);
3550 wd->must_recalc_idler = NULL;
3554 eina_list_free(wd->queue);
3559 eina_list_free(wd->selected);
3560 wd->selected = NULL;
3562 wd->show_item = NULL;
3569 evas_object_del(wd->alpha_bg);
3570 wd->alpha_bg = NULL;
3574 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3575 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3581 * Enable or disable multi-select in the genlist
3583 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3584 * the list. This allows more than 1 item to be selected.
3586 * @param obj The genlist object
3587 * @param multi Multi-select enable/disable
3592 elm_genlist_multi_select_set(Evas_Object *obj,
3595 ELM_CHECK_WIDTYPE(obj, widtype);
3596 Widget_Data *wd = elm_widget_data_get(obj);
3602 * Gets if multi-select in genlist is enable or disable
3604 * @param obj The genlist object
3605 * @return Multi-select enable/disable
3606 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3611 elm_genlist_multi_select_get(const Evas_Object *obj)
3613 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3614 Widget_Data *wd = elm_widget_data_get(obj);
3615 if (!wd) return EINA_FALSE;
3620 * Get the selectd item in the genlist
3622 * This gets the selected item in the list (if multi-select is enabled
3623 * only the first item in the list is selected - which is not very
3624 * useful, so see elm_genlist_selected_items_get() for when
3625 * multi-select is used).
3627 * If no item is selected, NULL is returned.
3629 * @param obj The genlist object
3630 * @return The selected item, or NULL if none.
3634 EAPI Elm_Genlist_Item *
3635 elm_genlist_selected_item_get(const Evas_Object *obj)
3637 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3638 Widget_Data *wd = elm_widget_data_get(obj);
3639 if (!wd) return NULL;
3640 if (wd->selected) return wd->selected->data;
3645 * Get a list of selected items in the genlist
3647 * This returns a list of the selected items. This list pointer is
3648 * only valid so long as no items are selected or unselected (or
3649 * unselected implicitly by deletion). The list contains
3650 * Elm_Genlist_Item pointers.
3652 * @param obj The genlist object
3653 * @return The list of selected items, nor NULL if none are selected.
3657 EAPI const Eina_List *
3658 elm_genlist_selected_items_get(const Evas_Object *obj)
3660 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3661 Widget_Data *wd = elm_widget_data_get(obj);
3662 if (!wd) return NULL;
3663 return wd->selected;
3667 * Get a list of realized items in genlist
3669 * This returns a list of the realized items in the genlist. The list
3670 * contains Elm_Genlist_Item pointers. The list must be freed by the
3671 * caller when done with eina_list_free(). The item pointers in the
3672 * list are only valid so long as those items are not deleted or the
3673 * genlist is not deleted.
3675 * @param obj The genlist object
3676 * @return The list of realized items, nor NULL if none are realized.
3681 elm_genlist_realized_items_get(const Evas_Object *obj)
3683 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3684 Widget_Data *wd = elm_widget_data_get(obj);
3685 Eina_List *list = NULL;
3687 Eina_Bool done = EINA_FALSE;
3688 if (!wd) return NULL;
3689 EINA_INLIST_FOREACH(wd->blocks, itb)
3694 Elm_Genlist_Item *it;
3697 EINA_LIST_FOREACH(itb->items, l, it)
3699 if (it->realized) list = eina_list_append(list, it);
3711 * Get the item that is at the x, y canvas coords
3713 * This returns the item at the given coordinates (which are canvas
3714 * relative not object-relative). If an item is at that coordinate,
3715 * that item handle is returned, and if @p posret is not NULL, the
3716 * integer pointed to is set to a value of -1, 0 or 1, depending if
3717 * the coordinate is on the upper portion of that item (-1), on the
3718 * middle section (0) or on the lower part (1). If NULL is returned as
3719 * an item (no item found there), then posret may indicate -1 or 1
3720 * based if the coordinate is above or below all items respectively in
3723 * @param it The item
3724 * @param x The input x coordinate
3725 * @param y The input y coordinate
3726 * @param posret The position relative to the item returned here
3727 * @return The item at the coordinates or NULL if none
3731 EAPI Elm_Genlist_Item *
3732 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3737 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3738 Widget_Data *wd = elm_widget_data_get(obj);
3739 Evas_Coord ox, oy, ow, oh;
3742 if (!wd) return NULL;
3743 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3745 EINA_INLIST_FOREACH(wd->blocks, itb)
3748 Elm_Genlist_Item *it;
3750 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3751 oy + itb->y - itb->wd->pan_y,
3752 itb->w, itb->h, x, y, 1, 1))
3754 EINA_LIST_FOREACH(itb->items, l, it)
3756 Evas_Coord itx, ity;
3758 itx = ox + itb->x + it->x - itb->wd->pan_x;
3759 ity = oy + itb->y + it->y - itb->wd->pan_y;
3760 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3764 if (y <= (ity + (it->h / 4))) *posret = -1;
3765 else if (y >= (ity + it->h - (it->h / 4)))
3771 lasty = ity + it->h;
3776 if (y > lasty) *posret = 1;
3783 * Get the first item in the genlist
3785 * This returns the first item in the list.
3787 * @param obj The genlist object
3788 * @return The first item, or NULL if none
3792 EAPI Elm_Genlist_Item *
3793 elm_genlist_first_item_get(const Evas_Object *obj)
3795 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3796 Widget_Data *wd = elm_widget_data_get(obj);
3797 if (!wd) return NULL;
3798 if (!wd->items) return NULL;
3799 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3800 while ((it) && (it->delete_me))
3801 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3806 * Get the last item in the genlist
3808 * This returns the last item in the list.
3810 * @return The last item, or NULL if none
3814 EAPI Elm_Genlist_Item *
3815 elm_genlist_last_item_get(const Evas_Object *obj)
3817 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3818 Widget_Data *wd = elm_widget_data_get(obj);
3819 if (!wd) return NULL;
3820 if (!wd->items) return NULL;
3821 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3822 while ((it) && (it->delete_me))
3823 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3828 * Get the next item in the genlist
3830 * This returns the item after the item @p it.
3832 * @param it The item
3833 * @return The item after @p it, or NULL if none
3837 EAPI Elm_Genlist_Item *
3838 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3840 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3843 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3844 if ((it) && (!it->delete_me)) break;
3846 return (Elm_Genlist_Item *)it;
3850 * Get the previous item in the genlist
3852 * This returns the item before the item @p it.
3854 * @param it The item
3855 * @return The item before @p it, or NULL if none
3859 EAPI Elm_Genlist_Item *
3860 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3862 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3865 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3866 if ((it) && (!it->delete_me)) break;
3868 return (Elm_Genlist_Item *)it;
3872 * Get the genlist object from an item
3874 * This returns the genlist object itself that an item belongs to.
3876 * @param it The item
3877 * @return The genlist object
3882 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3884 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3885 return it->base.widget;
3889 * Get the parent item of the given item
3891 * This returns the parent item of the item @p it given.
3893 * @param it The item
3894 * @return The parent of the item or NULL if none
3898 EAPI Elm_Genlist_Item *
3899 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3901 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3906 * Clear all sub-items (children) of the given item
3908 * This clears all items that are children (or their descendants) of the
3911 * @param it The item
3916 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3918 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3919 Elm_Genlist_Item *it2;
3922 if(!it->wd->effect_mode)
3923 _item_subitems_clear(it);
3926 if(!it->wd->item_moving_effect_timer)
3928 it->wd->expand_item = it;
3929 _item_flip_effect_show(it);
3930 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
3931 it->wd->expand_item_end = y + h;
3935 it2 = elm_genlist_item_next_get(it2);
3937 } while (it2->expanded_depth > it->expanded_depth);
3939 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
3941 it->wd->expand_item_gap = 0;
3943 evas_object_raise(it->wd->alpha_bg);
3944 evas_object_show(it->wd->alpha_bg);
3946 it->wd->start_time = current_time_get();
3947 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
3950 _item_subitems_clear(it);
3955 * Set the selected state of an item
3957 * This sets the selected state (1 selected, 0 not selected) of the given
3960 * @param it The item
3961 * @param selected The selected state
3966 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
3969 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3970 Widget_Data *wd = elm_widget_data_get(it->base.widget);
3972 if (it->delete_me) return;
3973 selected = !!selected;
3974 if (it->selected == selected) return;
3980 while (wd->selected)
3981 _item_unselect(wd->selected->data);
3991 * Get the selected state of an item
3993 * This gets the selected state of an item (1 selected, 0 not selected).
3995 * @param it The item
3996 * @return The selected state
4001 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4003 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4004 return it->selected;
4008 * Sets the expanded state of an item (if it's a parent)
4010 * This expands or contracts a parent item (thus showing or hiding the
4013 * @param it The item
4014 * @param expanded The expanded state (1 expanded, 0 not expanded).
4019 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4022 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4023 if (it->expanded == expanded) return;
4024 it->expanded = expanded;
4025 it->wd->expand_item = it;
4027 if(it->wd->effect_mode && !it->wd->alpha_bg)
4028 it->wd->alpha_bg = _create_tray_alpha_bg(it->wd->obj);
4032 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4034 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4035 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4039 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4041 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4042 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4047 * Get the expanded state of an item
4049 * This gets the expanded state of an item
4051 * @param it The item
4052 * @return Thre expanded state
4057 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4059 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4060 return it->expanded;
4064 * Get the depth of expanded item
4066 * @param it The genlist item object
4067 * @return The depth of expanded item
4072 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4074 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4075 return it->expanded_depth;
4079 * Sets the disabled state of an item.
4081 * A disabled item cannot be selected or unselected. It will also
4082 * change appearance to appear disabled. This sets the disabled state
4083 * (1 disabled, 0 not disabled).
4085 * @param it The item
4086 * @param disabled The disabled state
4091 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4094 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4095 if (it->disabled == disabled) return;
4096 if (it->delete_me) return;
4097 it->disabled = disabled;
4101 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4103 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4108 * Get the disabled state of an item
4110 * This gets the disabled state of the given item.
4112 * @param it The item
4113 * @return The disabled state
4118 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4120 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4121 if (it->delete_me) return EINA_FALSE;
4122 return it->disabled;
4126 * Sets the display only state of an item.
4128 * A display only item cannot be selected or unselected. It is for
4129 * display only and not selecting or otherwise clicking, dragging
4130 * etc. by the user, thus finger size rules will not be applied to
4133 * @param it The item
4134 * @param display_only The display only state
4139 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4140 Eina_Bool display_only)
4142 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4143 if (!it->block) return;
4144 if (it->display_only == display_only) return;
4145 if (it->delete_me) return;
4146 it->display_only = display_only;
4147 it->mincalcd = EINA_FALSE;
4148 it->updateme = EINA_TRUE;
4149 it->block->updateme = EINA_TRUE;
4150 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4151 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4155 * Get the display only state of an item
4157 * This gets the display only state of the given item.
4159 * @param it The item
4160 * @return The display only state
4165 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4167 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4168 if (it->delete_me) return EINA_FALSE;
4169 return it->display_only;
4173 * Show the given item
4175 * This causes genlist to jump to the given item @p it and show it (by
4176 * scrolling), if it is not fully visible.
4178 * @param it The item
4183 elm_genlist_item_show(Elm_Genlist_Item *it)
4185 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4186 Evas_Coord gith = 0;
4187 if (it->delete_me) return;
4188 if ((it->queued) || (!it->mincalcd))
4190 it->wd->show_item = it;
4191 it->wd->bring_in = EINA_TRUE;
4192 it->showme = EINA_TRUE;
4195 if (it->wd->show_item)
4197 it->wd->show_item->showme = EINA_FALSE;
4198 it->wd->show_item = NULL;
4200 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4201 gith = it->group_item->h;
4202 elm_smart_scroller_child_region_show(it->wd->scr,
4203 it->x + it->block->x,
4204 it->y + it->block->y - gith,
4205 it->block->w, it->h);
4209 * Bring in the given item
4211 * This causes genlist to jump to the given item @p it and show it (by
4212 * scrolling), if it is not fully visible. This may use animation to
4213 * do so and take a period of time
4215 * @param it The item
4220 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4222 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4223 Evas_Coord gith = 0;
4224 if (it->delete_me) return;
4225 if ((it->queued) || (!it->mincalcd))
4227 it->wd->show_item = it;
4228 it->wd->bring_in = EINA_TRUE;
4229 it->showme = EINA_TRUE;
4232 if (it->wd->show_item)
4234 it->wd->show_item->showme = EINA_FALSE;
4235 it->wd->show_item = NULL;
4237 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4238 gith = it->group_item->h;
4239 elm_smart_scroller_region_bring_in(it->wd->scr,
4240 it->x + it->block->x,
4241 it->y + it->block->y - gith,
4242 it->block->w, it->h);
4246 * Show the given item at the top
4248 * This causes genlist to jump to the given item @p it and show it (by
4249 * scrolling), if it is not fully visible.
4251 * @param it The item
4256 elm_genlist_item_top_show(Elm_Genlist_Item *it)
4258 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4260 Evas_Coord gith = 0;
4262 if (it->delete_me) return;
4263 if ((it->queued) || (!it->mincalcd))
4265 it->wd->show_item = it;
4266 it->wd->bring_in = EINA_TRUE;
4267 it->showme = EINA_TRUE;
4270 if (it->wd->show_item)
4272 it->wd->show_item->showme = EINA_FALSE;
4273 it->wd->show_item = NULL;
4275 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4276 if (it->group_item) gith = it->group_item->h;
4277 elm_smart_scroller_child_region_show(it->wd->scr,
4278 it->x + it->block->x,
4279 it->y + it->block->y - gith,
4284 * Bring in the given item at the top
4286 * This causes genlist to jump to the given item @p it and show it (by
4287 * scrolling), if it is not fully visible. This may use animation to
4288 * do so and take a period of time
4290 * @param it The item
4295 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4297 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4299 Evas_Coord gith = 0;
4301 if (it->delete_me) return;
4302 if ((it->queued) || (!it->mincalcd))
4304 it->wd->show_item = it;
4305 it->wd->bring_in = EINA_TRUE;
4306 it->showme = EINA_TRUE;
4309 if (it->wd->show_item)
4311 it->wd->show_item->showme = EINA_FALSE;
4312 it->wd->show_item = NULL;
4314 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4315 if (it->group_item) gith = it->group_item->h;
4316 elm_smart_scroller_region_bring_in(it->wd->scr,
4317 it->x + it->block->x,
4318 it->y + it->block->y - gith,
4323 * Show the given item at the middle
4325 * This causes genlist to jump to the given item @p it and show it (by
4326 * scrolling), if it is not fully visible.
4328 * @param it The item
4333 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4338 if (it->delete_me) return;
4339 if ((it->queued) || (!it->mincalcd))
4341 it->wd->show_item = it;
4342 it->wd->bring_in = EINA_TRUE;
4343 it->showme = EINA_TRUE;
4346 if (it->wd->show_item)
4348 it->wd->show_item->showme = EINA_FALSE;
4349 it->wd->show_item = NULL;
4351 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4352 elm_smart_scroller_child_region_show(it->wd->scr,
4353 it->x + it->block->x,
4354 it->y + it->block->y - oh / 2 +
4355 it->h / 2, it->block->w, oh);
4359 * Bring in the given item at the middle
4361 * This causes genlist to jump to the given item @p it and show it (by
4362 * scrolling), if it is not fully visible. This may use animation to
4363 * do so and take a period of time
4365 * @param it The item
4370 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4372 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4375 if (it->delete_me) return;
4376 if ((it->queued) || (!it->mincalcd))
4378 it->wd->show_item = it;
4379 it->wd->bring_in = EINA_TRUE;
4380 it->showme = EINA_TRUE;
4383 if (it->wd->show_item)
4385 it->wd->show_item->showme = EINA_FALSE;
4386 it->wd->show_item = NULL;
4388 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4389 elm_smart_scroller_region_bring_in(it->wd->scr,
4390 it->x + it->block->x,
4391 it->y + it->block->y - oh / 2 + it->h / 2,
4396 * Delete a given item
4398 * This deletes the item from genlist and calls the genlist item del
4399 * class callback defined in the item class, if it is set. This clears all
4400 * subitems if it is a tree.
4402 * @param it The item
4407 elm_genlist_item_del(Elm_Genlist_Item *it)
4409 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4410 if ((it->relcount > 0) || (it->walking > 0))
4412 elm_widget_item_pre_notify_del(it);
4413 elm_genlist_item_subitems_clear(it);
4414 it->delete_me = EINA_TRUE;
4415 if (it->wd->show_item == it) it->wd->show_item = NULL;
4417 it->wd->selected = eina_list_remove(it->wd->selected,
4421 if (it->realized) _item_unrealize(it);
4422 if (it->effect_item_realized) _effect_item_unrealize(it);
4423 it->block->changed = EINA_TRUE;
4424 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4425 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4427 if (it->itc->func.del)
4428 it->itc->func.del((void *)it->base.data, it->base.widget);
4435 * Set the data item from the genlist item
4437 * This set the data value passed on the elm_genlist_item_append() and
4438 * related item addition calls. This function will also call
4439 * elm_genlist_item_update() so the item will be updated to reflect the
4442 * @param it The item
4443 * @param data The new data pointer to set
4448 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4451 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4452 elm_widget_item_data_set(it, data);
4453 elm_genlist_item_update(it);
4457 * Get the data item from the genlist item
4459 * This returns the data value passed on the elm_genlist_item_append()
4460 * and related item addition calls and elm_genlist_item_data_set().
4462 * @param it The item
4463 * @return The data pointer provided when created
4468 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4470 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4471 return elm_widget_item_data_get(it);
4475 * Tells genlist to "orphan" icons fetchs by the item class
4477 * This instructs genlist to release references to icons in the item,
4478 * meaning that they will no longer be managed by genlist and are
4479 * floating "orphans" that can be re-used elsewhere if the user wants
4482 * @param it The item
4487 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4490 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4491 EINA_LIST_FREE(it->icon_objs, icon)
4493 elm_widget_sub_object_del(it->base.widget, icon);
4494 evas_object_smart_member_del(icon);
4495 evas_object_hide(icon);
4500 * Get the real evas object of the genlist item
4502 * This returns the actual evas object used for the specified genlist
4503 * item. This may be NULL as it may not be created, and may be deleted
4504 * at any time by genlist. Do not modify this object (move, resize,
4505 * show, hide etc.) as genlist is controlling it. This function is for
4506 * querying, emitting custom signals or hooking lower level callbacks
4507 * for events. Do not delete this object under any circumstances.
4509 * @param it The item
4510 * @return The object pointer
4514 EAPI const Evas_Object *
4515 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4517 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4518 return it->base.view;
4522 * Update the contents of an item
4524 * This updates an item by calling all the item class functions again
4525 * to get the icons, labels and states. Use this when the original
4526 * item data has changed and the changes are desired to be reflected.
4528 * @param it The item
4533 elm_genlist_item_update(Elm_Genlist_Item *it)
4535 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4536 if (!it->block) return;
4537 if (it->delete_me) return;
4538 it->mincalcd = EINA_FALSE;
4539 it->updateme = EINA_TRUE;
4540 it->block->updateme = EINA_TRUE;
4541 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4542 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4546 * Update the item class of an item
4548 * @param it The item
4549 * @parem itc The item class for the item
4554 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4555 const Elm_Genlist_Item_Class *itc)
4557 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4558 if (!it->block) return;
4559 EINA_SAFETY_ON_NULL_RETURN(itc);
4560 if (it->delete_me) return;
4562 elm_genlist_item_update(it);
4565 static Evas_Object *
4566 _elm_genlist_item_label_create(void *data,
4568 void *item __UNUSED__)
4570 Evas_Object *label = elm_label_add(obj);
4573 elm_object_style_set(label, "tooltip");
4574 elm_label_label_set(label, data);
4579 _elm_genlist_item_label_del_cb(void *data,
4580 Evas_Object *obj __UNUSED__,
4581 void *event_info __UNUSED__)
4583 eina_stringshare_del(data);
4587 * Set the text to be shown in the genlist item.
4589 * @param item Target item
4590 * @param text The text to set in the content
4592 * Setup the text as tooltip to object. The item can have only one
4593 * tooltip, so any previous tooltip data is removed.
4598 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4601 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4602 text = eina_stringshare_add(text);
4603 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4605 _elm_genlist_item_label_del_cb);
4609 * Set the content to be shown in the tooltip item
4611 * Setup the tooltip to item. The item can have only one tooltip, so
4612 * any previous tooltip data is removed. @p func(with @p data) will be
4613 * called every time that need to show the tooltip and it should return a
4614 * valid Evas_Object. This object is then managed fully by tooltip
4615 * system and is deleted when the tooltip is gone.
4617 * @param item the genlist item being attached by a tooltip.
4618 * @param func the function used to create the tooltip contents.
4619 * @param data what to provide to @a func as callback data/context.
4620 * @param del_cb called when data is not needed anymore, either when
4621 * another callback replaces @func, the tooltip is unset with
4622 * elm_genlist_item_tooltip_unset() or the owner @a item
4623 * dies. This callback receives as the first parameter the
4624 * given @a data, and @c event_info is the item.
4629 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4630 Elm_Tooltip_Item_Content_Cb func,
4632 Evas_Smart_Cb del_cb)
4634 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4636 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4639 if (item->tooltip.del_cb)
4640 item->tooltip.del_cb((void *)item->tooltip.data,
4641 item->base.widget, item);
4643 item->tooltip.content_cb = func;
4644 item->tooltip.data = data;
4645 item->tooltip.del_cb = del_cb;
4647 if (item->base.view)
4649 elm_widget_item_tooltip_content_cb_set(item,
4650 item->tooltip.content_cb,
4651 item->tooltip.data, NULL);
4652 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4658 if (del_cb) del_cb((void *)data, NULL, NULL);
4662 * Unset tooltip from item
4664 * @param item genlist item to remove previously set tooltip.
4666 * Remove tooltip from item. The callback provided as del_cb to
4667 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4668 * it is not used anymore.
4670 * @see elm_genlist_item_tooltip_content_cb_set()
4675 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4677 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4678 if ((item->base.view) && (item->tooltip.content_cb))
4679 elm_widget_item_tooltip_unset(item);
4681 if (item->tooltip.del_cb)
4682 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4683 item->tooltip.del_cb = NULL;
4684 item->tooltip.content_cb = NULL;
4685 item->tooltip.data = NULL;
4686 if (item->tooltip.style)
4687 elm_genlist_item_tooltip_style_set(item, NULL);
4691 * Sets a different style for this item tooltip.
4693 * @note before you set a style you should define a tooltip with
4694 * elm_genlist_item_tooltip_content_cb_set() or
4695 * elm_genlist_item_tooltip_text_set()
4697 * @param item genlist item with tooltip already set.
4698 * @param style the theme style to use (default, transparent, ...)
4703 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4706 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4707 eina_stringshare_replace(&item->tooltip.style, style);
4708 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4712 * Get the style for this item tooltip.
4714 * @param item genlist item with tooltip already set.
4715 * @return style the theme style in use, defaults to "default". If the
4716 * object does not have a tooltip set, then NULL is returned.
4721 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4723 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4724 return item->tooltip.style;
4728 * Set the cursor to be shown when mouse is over the genlist item
4730 * @param item Target item
4731 * @param cursor the cursor name to be used.
4733 * @see elm_object_cursor_set()
4737 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4740 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4741 eina_stringshare_replace(&item->mouse_cursor, cursor);
4742 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4746 * Get the cursor to be shown when mouse is over the genlist item
4748 * @param item genlist item with cursor already set.
4749 * @return the cursor name.
4754 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4756 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4757 return elm_widget_item_cursor_get(item);
4761 * Unset the cursor to be shown when mouse is over the genlist item
4763 * @param item Target item
4765 * @see elm_object_cursor_unset()
4769 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4771 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4772 if (!item->mouse_cursor)
4775 if (item->base.view)
4776 elm_widget_item_cursor_unset(item);
4778 eina_stringshare_del(item->mouse_cursor);
4779 item->mouse_cursor = NULL;
4783 * Sets a different style for this item cursor.
4785 * @note before you set a style you should define a cursor with
4786 * elm_genlist_item_cursor_set()
4788 * @param item genlist item with cursor already set.
4789 * @param style the theme style to use (default, transparent, ...)
4794 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4797 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4798 elm_widget_item_cursor_style_set(item, style);
4802 * Get the style for this item cursor.
4804 * @param item genlist item with cursor already set.
4805 * @return style the theme style in use, defaults to "default". If the
4806 * object does not have a cursor set, then NULL is returned.
4811 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4813 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4814 return elm_widget_item_cursor_style_get(item);
4818 * Set if the cursor set should be searched on the theme or should use
4819 * the provided by the engine, only.
4821 * @note before you set if should look on theme you should define a
4822 * cursor with elm_object_cursor_set(). By default it will only look
4823 * for cursors provided by the engine.
4825 * @param item widget item with cursor already set.
4826 * @param engine_only boolean to define it cursors should be looked
4827 * only between the provided by the engine or searched on widget's
4833 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4834 Eina_Bool engine_only)
4836 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4837 elm_widget_item_cursor_engine_only_set(item, engine_only);
4841 * Get the cursor engine only usage for this item cursor.
4843 * @param item widget item with cursor already set.
4844 * @return engine_only boolean to define it cursors should be looked
4845 * only between the provided by the engine or searched on widget's
4846 * theme as well. If the object does not have a cursor set, then
4847 * EINA_FALSE is returned.
4852 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4854 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4855 return elm_widget_item_cursor_engine_only_get(item);
4859 * This sets the horizontal stretching mode
4861 * This sets the mode used for sizing items horizontally. Valid modes
4862 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4863 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4864 * the scroller will scroll horizontally. Otherwise items are expanded
4865 * to fill the width of the viewport of the scroller. If it is
4866 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4867 * limited to that size.
4869 * @param obj The genlist object
4870 * @param mode The mode to use
4875 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4878 ELM_CHECK_WIDTYPE(obj, widtype);
4879 Widget_Data *wd = elm_widget_data_get(obj);
4881 if (wd->mode == mode) return;
4887 * Gets the horizontal stretching mode
4889 * @param obj The genlist object
4890 * @return The mode to use
4891 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4896 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4898 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4899 Widget_Data *wd = elm_widget_data_get(obj);
4900 if (!wd) return ELM_LIST_LAST;
4905 * Set the always select mode.
4907 * Items will only call their selection func and callback when first
4908 * becoming selected. Any further clicks will do nothing, unless you
4909 * enable always select with elm_genlist_always_select_mode_set().
4910 * This means even if selected, every click will make the selected
4911 * callbacks be called.
4913 * @param obj The genlist object
4914 * @param always_select The always select mode
4915 * (EINA_TRUE = on, EINA_FALSE = off)
4920 elm_genlist_always_select_mode_set(Evas_Object *obj,
4921 Eina_Bool always_select)
4923 ELM_CHECK_WIDTYPE(obj, widtype);
4924 Widget_Data *wd = elm_widget_data_get(obj);
4926 wd->always_select = always_select;
4930 * Get the always select mode.
4932 * @param obj The genlist object
4933 * @return The always select mode
4934 * (EINA_TRUE = on, EINA_FALSE = off)
4939 elm_genlist_always_select_mode_get(const Evas_Object *obj)
4941 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4942 Widget_Data *wd = elm_widget_data_get(obj);
4943 if (!wd) return EINA_FALSE;
4944 return wd->always_select;
4948 * Set no select mode
4950 * This will turn off the ability to select items entirely and they
4951 * will neither appear selected nor call selected callback functions.
4953 * @param obj The genlist object
4954 * @param no_select The no select mode
4955 * (EINA_TRUE = on, EINA_FALSE = off)
4960 elm_genlist_no_select_mode_set(Evas_Object *obj,
4961 Eina_Bool no_select)
4963 ELM_CHECK_WIDTYPE(obj, widtype);
4964 Widget_Data *wd = elm_widget_data_get(obj);
4966 wd->no_select = no_select;
4970 * Gets no select mode
4972 * @param obj The genlist object
4973 * @return The no select mode
4974 * (EINA_TRUE = on, EINA_FALSE = off)
4979 elm_genlist_no_select_mode_get(const Evas_Object *obj)
4981 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
4982 Widget_Data *wd = elm_widget_data_get(obj);
4983 if (!wd) return EINA_FALSE;
4984 return wd->no_select;
4990 * This will enable the compress mode where items are "compressed"
4991 * horizontally to fit the genlist scrollable viewport width. This is
4992 * special for genlist. Do not rely on
4993 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
4994 * work as genlist needs to handle it specially.
4996 * @param obj The genlist object
4997 * @param compress The compress mode
4998 * (EINA_TRUE = on, EINA_FALSE = off)
5003 elm_genlist_compress_mode_set(Evas_Object *obj,
5006 ELM_CHECK_WIDTYPE(obj, widtype);
5007 Widget_Data *wd = elm_widget_data_get(obj);
5009 wd->compress = compress;
5013 * Get the compress mode
5015 * @param obj The genlist object
5016 * @return The compress mode
5017 * (EINA_TRUE = on, EINA_FALSE = off)
5022 elm_genlist_compress_mode_get(const Evas_Object *obj)
5024 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5025 Widget_Data *wd = elm_widget_data_get(obj);
5026 if (!wd) return EINA_FALSE;
5027 return wd->compress;
5031 * Set height-for-width mode
5033 * With height-for-width mode the item width will be fixed (restricted
5034 * to a minimum of) to the list width when calculating its size in
5035 * order to allow the height to be calculated based on it. This allows,
5036 * for instance, text block to wrap lines if the Edje part is
5037 * configured with "text.min: 0 1".
5039 * @note This mode will make list resize slower as it will have to
5040 * recalculate every item height again whenever the list width
5043 * @note When height-for-width mode is enabled, it also enables
5044 * compress mode (see elm_genlist_compress_mode_set()) and
5045 * disables homogeneous (see elm_genlist_homogeneous_set()).
5047 * @param obj The genlist object
5048 * @param setting The height-for-width mode (EINA_TRUE = on,
5054 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5055 Eina_Bool height_for_width)
5057 ELM_CHECK_WIDTYPE(obj, widtype);
5058 Widget_Data *wd = elm_widget_data_get(obj);
5060 wd->height_for_width = !!height_for_width;
5061 if (wd->height_for_width)
5063 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5064 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5069 * Get the height-for-width mode
5071 * @param obj The genlist object
5072 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5078 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5080 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5081 Widget_Data *wd = elm_widget_data_get(obj);
5082 if (!wd) return EINA_FALSE;
5083 return wd->height_for_width;
5089 * This will enable or disable the scroller bounce mode for the
5090 * genlist. See elm_scroller_bounce_set() for details
5092 * @param obj The genlist object
5093 * @param h_bounce Allow bounce horizontally
5094 * @param v_bounce Allow bounce vertically
5099 elm_genlist_bounce_set(Evas_Object *obj,
5103 ELM_CHECK_WIDTYPE(obj, widtype);
5104 Widget_Data *wd = elm_widget_data_get(obj);
5106 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5110 * Get the bounce mode
5112 * @param obj The genlist object
5113 * @param h_bounce Allow bounce horizontally
5114 * @param v_bounce Allow bounce vertically
5119 elm_genlist_bounce_get(const Evas_Object *obj,
5120 Eina_Bool *h_bounce,
5121 Eina_Bool *v_bounce)
5123 ELM_CHECK_WIDTYPE(obj, widtype);
5124 Widget_Data *wd = elm_widget_data_get(obj);
5126 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5130 * Set homogenous mode
5132 * This will enable the homogeneous mode where items are of the same
5133 * height and width so that genlist may do the lazy-loading at its
5134 * maximum. This implies 'compressed' mode.
5136 * @param obj The genlist object
5137 * @param homogeneous Assume the items within the genlist are of the
5138 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5143 elm_genlist_homogeneous_set(Evas_Object *obj,
5144 Eina_Bool homogeneous)
5146 ELM_CHECK_WIDTYPE(obj, widtype);
5147 Widget_Data *wd = elm_widget_data_get(obj);
5149 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5150 wd->homogeneous = homogeneous;
5154 * Get the homogenous mode
5156 * @param obj The genlist object
5157 * @return Assume the items within the genlist are of the same height
5158 * and width (EINA_TRUE = on, EINA_FALSE = off)
5163 elm_genlist_homogeneous_get(const Evas_Object *obj)
5165 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5166 Widget_Data *wd = elm_widget_data_get(obj);
5167 if (!wd) return EINA_FALSE;
5168 return wd->homogeneous;
5172 * Set the maximum number of items within an item block
5174 * This will configure the block count to tune to the target with
5175 * particular performance matrix.
5177 * @param obj The genlist object
5178 * @param n Maximum number of items within an item block
5183 elm_genlist_block_count_set(Evas_Object *obj,
5186 ELM_CHECK_WIDTYPE(obj, widtype);
5187 Widget_Data *wd = elm_widget_data_get(obj);
5189 wd->max_items_per_block = n;
5190 wd->item_cache_max = wd->max_items_per_block * 2;
5191 _item_cache_clean(wd);
5195 * Get the maximum number of items within an item block
5197 * @param obj The genlist object
5198 * @return Maximum number of items within an item block
5203 elm_genlist_block_count_get(const Evas_Object *obj)
5205 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5206 Widget_Data *wd = elm_widget_data_get(obj);
5208 return wd->max_items_per_block;
5212 * Set the timeout in seconds for the longpress event
5214 * @param obj The genlist object
5215 * @param timeout timeout in seconds
5220 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5223 ELM_CHECK_WIDTYPE(obj, widtype);
5224 Widget_Data *wd = elm_widget_data_get(obj);
5226 wd->longpress_timeout = timeout;
5230 * Get the timeout in seconds for the longpress event
5232 * @param obj The genlist object
5233 * @return timeout in seconds
5238 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5240 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5241 Widget_Data *wd = elm_widget_data_get(obj);
5243 return wd->longpress_timeout;
5247 * Set the scrollbar policy
5249 * This sets the scrollbar visibility policy for the given genlist
5250 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5251 * made visible if it is needed, and otherwise kept hidden.
5252 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5253 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5254 * respectively for the horizontal and vertical scrollbars.
5256 * @param obj The genlist object
5257 * @param policy_h Horizontal scrollbar policy
5258 * @param policy_v Vertical scrollbar policy
5263 elm_genlist_scroller_policy_set(Evas_Object *obj,
5264 Elm_Scroller_Policy policy_h,
5265 Elm_Scroller_Policy policy_v)
5267 ELM_CHECK_WIDTYPE(obj, widtype);
5268 Widget_Data *wd = elm_widget_data_get(obj);
5270 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5271 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5274 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5278 * Get the scrollbar policy
5280 * @param obj The genlist object
5281 * @param policy_h Horizontal scrollbar policy
5282 * @param policy_v Vertical scrollbar policy
5287 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5288 Elm_Scroller_Policy *policy_h,
5289 Elm_Scroller_Policy *policy_v)
5291 ELM_CHECK_WIDTYPE(obj, widtype);
5292 Widget_Data *wd = elm_widget_data_get(obj);
5293 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5294 if ((!wd) || (!wd->scr)) return;
5295 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5296 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5297 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5300 /****************************************************************************/
5305 * @param obj The genlist object
5306 * @param reorder_mode The reorder mode
5307 * (EINA_TRUE = on, EINA_FALSE = off)
5312 elm_genlist_reorder_mode_set(Evas_Object *obj,
5313 Eina_Bool reorder_mode)
5315 ELM_CHECK_WIDTYPE(obj, widtype);
5316 Widget_Data *wd = elm_widget_data_get(obj);
5318 wd->reorder_mode = reorder_mode;
5322 * Get the reorder mode
5324 * @param obj The genlist object
5325 * @return The reorder mode
5326 * (EINA_TRUE = on, EINA_FALSE = off)
5331 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5333 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5334 Widget_Data *wd = elm_widget_data_get(obj);
5335 if (!wd) return EINA_FALSE;
5336 return wd->reorder_mode;
5340 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5345 printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5346 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5347 _item_block_del(it);
5349 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5351 it->rel->relcount++;
5352 it->before = EINA_FALSE;
5353 _item_queue(it->wd, it);
5357 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5360 if (!before) return;
5362 printf("MOVE AFTER : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5363 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5364 _item_block_del(it);
5365 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5367 it->rel->relcount++;
5368 it->before = EINA_TRUE;
5369 _item_queue(it->wd, it);
5373 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5375 ELM_CHECK_WIDTYPE(obj, widtype);
5376 Widget_Data *wd = elm_widget_data_get(obj);
5378 wd->effect_mode = emode;
5379 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5380 // evas_object_resize(wd->point_rect, 10, 25);
5381 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5382 // evas_object_show(wd->point_rect);
5383 // evas_object_hide(wd->point_rect);
5387 _create_tray_alpha_bg(const Evas_Object *obj)
5389 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5390 Widget_Data *wd = elm_widget_data_get(obj);
5391 if (!wd) return NULL;
5393 Evas_Object *bg = NULL;
5394 Evas_Coord ox, oy, ow, oh;
5396 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5397 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5398 evas_object_color_set(bg,0,0,0,0);
5399 evas_object_resize(bg , ow, oh);
5400 evas_object_move(bg , ox, oy);
5401 evas_object_show(bg);
5402 evas_object_hide(bg);
5409 struct timeval timev;
5411 gettimeofday(&timev, NULL);
5412 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5415 // added for item moving animation.
5417 _item_moving_effect_timer_cb(void *data)
5419 Widget_Data *wd = data;
5420 if (!wd) return EINA_FALSE;
5422 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5423 Elm_Genlist_Item *it, *it2;
5425 double time = 0.4, t;
5427 Eina_Bool check, end = EINA_FALSE;
5428 // static Eina_Bool first = EINA_TRUE;
5431 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5433 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5434 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5436 EINA_INLIST_FOREACH(wd->blocks, itb)
5439 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5440 itb->y - wd->pan_y + oy,
5442 cvx, cvy, cvw, cvh))
5444 EINA_LIST_FOREACH(itb->items, l, it)
5449 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5454 // printf("item : %p - ", it);
5457 //printf(" s: %d %d ", oy, oh);
5458 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5459 dy = it->scrl_y - it->old_scrl_y;
5460 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5462 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5463 if(wd->expand_item_end < it->old_scrl_y)
5464 dy = wd->expand_item_gap;
5466 // printf(" dy - %d -", dy);
5468 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5474 //printf("s : %d os : %d y : %d t : %2.2f time : %2.2f dy : %d\n", it->scrl_y, it->old_scrl_y, y, t, time, dy);
5476 if (!it->old_scrl_y)
5477 it->old_scrl_y = it->scrl_y;
5480 //printf(" %d | ", it->old_scrl_y + y);
5481 if (it->old_scrl_y + y < oy + oh)
5483 // printf("%p in pan | ", it);
5484 //if (!it->realized) printf("%p is not realized %d :: \n", it, it->old_scrl_y + y);
5486 if (!it->realized) _item_realize(it, in, 0);
5488 /* else if(first && wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5490 printf("1 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5491 it->old_scrl_y = it->old_scrl_y - ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5492 wd->expand_item_gap = wd->expand_item_gap + ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5493 printf("2 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5497 // printf("%p :: %d\n", it, it->old_scrl_y + y);
5498 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5499 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5500 evas_object_show(it->base.view);
5501 evas_object_raise(it->base.view);
5503 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5505 it2 = elm_genlist_item_prev_get(it);
5508 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5510 if(!it2->effect_done)
5512 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5513 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5514 evas_object_show(it2->base.view);
5515 it2->effect_done = EINA_TRUE;
5519 it2 = elm_genlist_item_prev_get(it2);
5522 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5524 it2 = elm_genlist_item_prev_get(it);
5527 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5529 if(!it2->effect_done)
5531 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5532 it2->effect_done = EINA_TRUE;
5537 it2 = elm_genlist_item_prev_get(it2);
5543 // first = EINA_FALSE;
5547 if (wd->item_moving_effect_timer)
5549 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5550 _item_subitems_clear(wd->expand_item);
5551 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5552 EINA_INLIST_FOREACH(wd->blocks, itb)
5554 EINA_LIST_FOREACH(itb->items, l, it)
5556 it->effect_done = EINA_TRUE;
5557 it->list_expanded = 0;
5558 it->old_scrl_y = it->scrl_y;
5562 //evas_render(evas_object_evas_get(wd->obj));
5563 wd->item_moving_effect_timer = NULL;
5564 // first = EINA_TRUE;
5566 evas_object_lower(wd->alpha_bg);
5567 evas_object_hide(wd->alpha_bg);
5569 return ECORE_CALLBACK_CANCEL;
5571 return ECORE_CALLBACK_RENEW;
5575 _emit_contract(Elm_Genlist_Item *it)
5577 Elm_Genlist_Item *it2;
5580 // printf("%p is emited contract\n", it);
5581 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5582 it->effect_done = EINA_FALSE;
5584 EINA_LIST_FOREACH(it->items, l, it2)
5586 _emit_contract(it2);
5589 // added for item moving animation.
5591 _item_flip_effect_show(Elm_Genlist_Item *it)
5593 Elm_Genlist_Item *it2;
5595 Widget_Data *wd = it->wd;
5596 Eina_Bool check = EINA_FALSE;
5598 it2 = elm_genlist_item_next_get(it);
5601 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5602 it2 = elm_genlist_item_next_get(it2);
5604 EINA_LIST_FOREACH(it->items, l, it2)
5606 if (it2->parent && it == it2->parent)
5608 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5610 // edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5611 edje_object_signal_emit(it2->base.view, "flip_item", "");
5613 evas_object_move(it2->base.view, -9999, -9999);
5615 evas_object_show(it2->base.view);
5617 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5618 _emit_contract(it2);
5622 return ECORE_CALLBACK_CANCEL;
5626 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5628 printf("!!! NOW FIXING \n");
5632 * Set pinch zoom mode
5634 * @param obj The genlist object
5636 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5641 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5643 printf("!!! NOW FIXING \n");
5647 * Get pinch zoom mode
5649 * @param obj The genlist object
5650 * @return The pinch mode
5651 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5656 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5658 printf("!!! NOW FIXING \n");
5663 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5665 printf("!!! NOW FIXING \n");
5669 ////////////////////////////////////////////////////////////////////////
5671 ////////////////////////////////////////////////////////////////////////
5673 _effect_item_update(Elm_Genlist_Item *it)
5675 if (it->edit_select_check)
5677 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5681 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5686 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5689 if (edit_select_check_state)
5691 it->edit_select_check = EINA_TRUE;
5692 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5696 it->edit_select_check = EINA_FALSE;
5697 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5700 if (it->wd->ed->ec->item_selected)
5701 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5705 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5708 Eina_List *tl = NULL, *l;
5709 Elm_Genlist_Item *it2;
5711 EINA_LIST_FOREACH(it->items, l, it2)
5712 tl = eina_list_append(tl, it2);
5713 EINA_LIST_FREE(tl, it2)
5714 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5718 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5721 Elm_Genlist_Item *tmp_it;
5722 Eina_Bool parent_check = EINA_TRUE;
5724 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5726 if (tmp_it->parent && it->parent)
5727 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5731 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5732 else it->parent->edit_select_check = EINA_FALSE;
5737 _effect_item_update(it->parent);
5738 return _edit_parent_items_checkbox_set(it->parent);
5743 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5745 Elm_Genlist_Item *it = data, *tmp_it;
5746 Eina_Bool parent_check = EINA_TRUE, old_check_state;
5747 int check_cnt = 0, total_cnt = 0;
5750 _edit_item_checkbox_set(it, !it->edit_select_check);
5751 _edit_subitems_checkbox_set(it);
5752 _edit_parent_items_checkbox_set(it);
5754 it->wd->ed->del_item = it;
5756 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5758 if (tmp_it->edit_select_check) check_cnt++;
5762 if (it->wd->select_all_item)
5764 old_check_state = it->wd->select_all_check;
5765 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
5766 else it->wd->select_all_check = EINA_FALSE;
5768 if (check_cnt == total_cnt)
5770 it->wd->select_all_check = EINA_TRUE;
5771 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del_confirm", "elm");
5775 it->wd->select_all_check = EINA_FALSE;
5776 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del,animated,enable", "elm");
5778 if (old_check_state != it->wd->select_all_check && it->wd->ed->ec->item_selected)
5779 it->wd->ed->ec->item_selected(it->wd->select_all_item->base.data, it->wd->select_all_item, it->wd->select_all_check);
5784 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5786 Elm_Genlist_Item *select_all_it = data, *it;
5787 Eina_Bool old_check_state;
5788 Widget_Data *wd = select_all_it->wd;
5791 wd->select_all_check = !wd->select_all_check;
5792 if (wd->select_all_check)
5793 edje_object_signal_emit(select_all_it->base.view, "elm,state,del_confirm", "elm");
5795 edje_object_signal_emit(select_all_it->base.view, "elm,state,del,animated,enable", "elm");
5797 EINA_INLIST_FOREACH(wd->items, it)
5799 old_check_state = it->edit_select_check;
5800 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5801 else it->edit_select_check = EINA_FALSE;
5803 // TODO : check this
5804 if (old_check_state != it->edit_select_check && it->wd->ed->ec->item_selected)
5805 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5808 if (wd->ed->ec->item_selected)
5809 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
5811 if (wd->calc_job) ecore_job_del(wd->calc_job);
5812 wd->calc_job = ecore_job_add(_calc_job, wd);
5817 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5819 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5821 evas_object_resize(it->edit_obj,it->w, it->h);
5822 evas_object_move(it->edit_obj, itx, ity);
5823 evas_object_raise(it->edit_obj);
5825 if (it->wd->select_all_check)
5826 it->edit_select_check = EINA_TRUE;
5827 if (it->edit_select_check) edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5829 edje_object_signal_emit(it->edit_obj, "elm,state,del,animated,enable", "elm");
5833 _effect_item_realize(Elm_Genlist_Item *it)
5835 if ((it->effect_item_realized) || (it->delete_me)) return;
5836 int itmode = 0, pad = 0;
5837 const char *pad_str;
5839 it->pad_left = it->pad_right = 0;
5841 if (it->itc->func.editmode_get)
5842 itmode = it->itc->func.editmode_get((void *)it->base.data, it->base.widget, it->wd->edit_mode);
5843 itmode &= it->wd->edit_mode;
5845 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5846 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5848 it->edit_obj = edje_object_add(evas_object_evas_get(it->wd->obj));
5849 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->wd->obj) *
5850 _elm_config->scale);
5851 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5852 elm_widget_sub_object_add(it->wd->obj, it->edit_obj);
5854 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5855 else strncpy(buf, "item", sizeof(buf));
5856 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5858 strncat(buf, "/", sizeof(buf) - strlen(buf));
5860 if (it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5862 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5863 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", buf, elm_widget_style_get(it->wd->obj));
5867 _elm_theme_object_set(it->wd->obj, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->wd->obj));
5870 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
5871 if (pad_str) pad = atoi(pad_str);
5873 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
5875 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5877 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5878 "elm", _checkbox_item_select_cb);
5880 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
5881 "elm", _checkbox_item_select_cb, it);
5882 it->pad_left += pad * _elm_config->scale;
5886 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
5888 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
5889 "elm", _checkbox_item_select_cb);
5892 if (it->wd->edit_mode != 0xF0) {
5893 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE)
5895 if (it->itc->func.icon_get)
5897 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
5902 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
5903 EINA_LIST_FOREACH(it->icons, l, key)
5905 Evas_Object *ic = it->itc->func.icon_get
5906 (it->base.data, it->base.widget, l->data);
5910 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
5911 edje_object_part_swallow(it->edit_obj, key, ic);
5912 evas_object_show(ic);
5913 elm_widget_sub_object_add(it->wd->obj, ic);
5920 _effect_item_controls(it,it->scrl_x, it->scrl_y);
5921 evas_object_show(it->edit_obj);
5923 it->effect_item_realized = EINA_TRUE;
5924 it->want_unrealize = EINA_FALSE;
5928 _effect_item_unrealize(Elm_Genlist_Item *it)
5930 Evas_Object *icon, *editfield;
5932 if (!it->effect_item_realized) return;
5933 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
5935 it->pad_left = it->pad_right = 0;
5936 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
5937 // _item_cache_add(it);
5938 evas_object_del(it->edit_obj);
5939 it->edit_obj = NULL;
5940 EINA_LIST_FREE(it->edit_icon_objs, icon)
5941 evas_object_del(icon);
5943 EINA_LIST_FREE(it->wd->edit_field, editfield)
5944 evas_object_del(editfield);
5946 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
5947 it->effect_item_realized = EINA_FALSE;
5951 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5953 fprintf(stderr, "=================> Caution!!! <========================\n");
5954 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
5955 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
5956 fprintf(stderr, "=======================================================\n");
5958 elm_genlist_edit_mode_set(obj, emode, edit_class);
5962 * Set Genlist edit mode
5964 * This sets Genlist edit mode.
5966 * @param obj The Genlist object
5967 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
5968 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
5973 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
5975 ELM_CHECK_WIDTYPE(obj, widtype);
5978 Eina_Bool done = EINA_FALSE;
5979 static Elm_Genlist_Item_Class itc;
5981 Widget_Data *wd = elm_widget_data_get(obj);
5983 if (wd->edit_mode == emode) return;
5985 wd->edit_mode = emode;
5987 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5988 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
5991 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5993 EINA_INLIST_FOREACH(wd->blocks, itb)
5998 Elm_Genlist_Item *it;
6001 EINA_LIST_FOREACH(itb->items, l, it)
6003 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6005 it->pad_left = it->pad_right = 0;
6006 _effect_item_unrealize(it);
6015 if (wd->ed) free (wd->ed);
6017 wd->reorder_mode = EINA_FALSE;
6018 if (wd->select_all_item)
6020 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
6021 free(wd->select_all_item);
6023 wd->select_all_item = NULL;
6027 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6028 wd->reorder_mode = EINA_TRUE;
6031 wd->ed = calloc(1, sizeof(Edit_Data));
6033 wd->ed->ec = edit_class;
6035 EINA_INLIST_FOREACH(wd->blocks, itb)
6040 Elm_Genlist_Item *it;
6043 EINA_LIST_FOREACH(itb->items, l, it)
6045 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6048 _effect_item_realize(it);
6058 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6060 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6061 itc.item_style = edit_class->select_all_item_style;
6063 itc.item_style = "select_all";
6064 itc.func.label_get = NULL;
6065 itc.func.icon_get = NULL;
6066 itc.func.del = NULL;
6067 itc.func.editmode_get = NULL;
6068 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6071 if (!wd->select_all_item) return;
6073 _item_realize(wd->select_all_item, 0, 0);
6074 edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
6076 wd->select_all_item->rel = NULL;
6077 wd->select_all_item->block = NULL;
6079 else if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE)
6081 if (wd->select_all_item)
6083 if (wd->select_all_item->realized) _item_unrealize(wd->select_all_item);
6084 free(wd->select_all_item);
6086 wd->select_all_item = NULL;
6090 if (wd->calc_job) ecore_job_del(wd->calc_job);
6091 wd->calc_job = ecore_job_add(_calc_job, wd);
6095 * Delete selected items in genlist edit mode.
6097 * @param obj The genlist object
6102 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6104 ELM_CHECK_WIDTYPE(obj, widtype);
6105 Widget_Data *wd = elm_widget_data_get(obj);
6107 if (!wd->blocks) return;
6108 Elm_Genlist_Item *it;
6109 Eina_List *edit_selected_list, *l;
6112 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6113 cnt = eina_list_count(edit_selected_list);
6114 printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6116 wd->anchor_item = NULL;
6117 EINA_LIST_FOREACH(edit_selected_list, l, it)
6119 elm_genlist_item_del(it);
6121 eina_list_free(edit_selected_list);
6123 evas_render(evas_object_evas_get(wd->obj));
6124 if (wd->calc_job) ecore_job_del(wd->calc_job);
6125 wd->calc_job = ecore_job_add(_calc_job, wd);
6129 elm_genlist_selected_items_del(Evas_Object *obj)
6131 fprintf(stderr, "=================> Caution!!! <========================\n");
6132 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6133 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6134 fprintf(stderr, "=======================================================\n");
6135 elm_genlist_edit_selected_items_del(obj);
6139 * Get a list of selected items in genlist
6141 * This returns a list of the selected items in the genlist. The list
6142 * contains Elm_Genlist_Item pointers. The list must be freed by the
6143 * caller when done with eina_list_free(). The item pointers in the list
6144 * are only vallid so long as those items are not deleted or the genlist is
6147 * @param obj The genlist object
6148 * @return The list of selected items, nor NULL if none are selected.
6153 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6155 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6156 Widget_Data *wd = elm_widget_data_get(obj);
6157 Eina_List *list = NULL;
6158 Elm_Genlist_Item *it;
6159 if (!wd) return NULL;
6161 EINA_INLIST_FOREACH(wd->items, it)
6163 if (it->edit_select_check) list = eina_list_append(list, it);
6169 // TODO : add cooment
6171 elm_genlist_edit_item_select_set(Elm_Genlist_Item *it,
6174 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6175 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6177 selected = !!selected;
6178 if (it->edit_select_check == selected) return;
6180 it->edit_select_check = selected;
6181 _edit_item_checkbox_set(it, it->edit_select_check);
6182 _edit_subitems_checkbox_set(it);
6183 _edit_parent_items_checkbox_set(it);
6186 // TODO : add cooment
6188 elm_genlist_edit_item_select_get(const Elm_Genlist_Item *it)
6190 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6191 return it->edit_select_check;
6195 * Set a given item's rename mode
6197 * This renames the item's label from genlist
6199 * @param it The item
6200 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6205 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6209 const Eina_List *l, *list, *l2;
6210 const char *label, *rename_swallow_part;
6212 Eina_Bool done = EINA_FALSE;
6213 int label_cnt = 0 , swallow_part_cnt = 0;
6216 Evas_Object *editfield;
6217 Evas_Object *entry = NULL;
6218 int edit_field_cnt = 0;
6221 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6223 it->wd->edit_mode = 0xF0;
6224 _effect_item_realize(it);
6227 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6232 Elm_Genlist_Item *it;
6235 EINA_LIST_FOREACH(itb->items, l, it)
6239 it->renamed = EINA_FALSE;
6241 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6243 entry = elm_editfield_entry_get(editfield);
6244 const char *text = elm_entry_entry_get(entry);
6246 if (it->itc->func.label_changed)
6247 it->itc->func.label_changed(it->base.view, it, text, edit_field_cnt++);
6249 Ecore_IMF_Context *imf = elm_entry_imf_context_get(entry);
6250 ecore_imf_context_input_panel_hide(imf);
6252 Evas_Object *editfield;
6253 EINA_LIST_FREE(it->wd->edit_field, editfield)
6254 evas_object_del(editfield);
6256 if (it->wd->edit_mode)
6258 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_INSERT))
6259 edje_object_signal_emit(it->edit_obj, "elm,state,ins,enable", "elm");
6261 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_DELETE) || (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT))
6262 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6264 if ((it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER))
6265 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6269 evas_object_del(it->edit_obj);
6270 it->edit_obj = NULL;
6272 EINA_LIST_FREE(it->edit_icon_objs, icon)
6273 evas_object_del(icon);
6283 // if (emode != ELM_GENLIST_RENAME_MODE_NONE)
6286 it->renamed = EINA_TRUE;
6288 it->labels = elm_widget_stringlist_get(edje_object_data_get(it->base.view, "labels"));
6289 EINA_LIST_FOREACH(it->labels, list, label)
6291 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6292 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6293 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6294 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6296 if (it->itc->func.label_get)
6298 it->renamed = EINA_TRUE;
6299 swallow_part_cnt = 0;
6301 EINA_LIST_FREE(it->edit_icon_objs, icon)
6302 evas_object_del(icon);
6303 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6304 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6306 if (label_cnt == swallow_part_cnt)
6308 editfield = elm_editfield_add(it->wd->obj);
6309 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6311 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6312 elm_editfield_eraser_set(editfield, EINA_TRUE);
6313 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6314 elm_widget_sub_object_add(it->edit_obj, editfield);
6316 evas_object_show(editfield);
6318 s = it->itc->func.label_get(it->base.view, it->wd->obj, list->data);
6322 Evas_Object *entry = elm_editfield_entry_get(editfield);
6323 elm_entry_entry_set(entry,s);
6328 elm_editfield_guide_text_set(editfield, "Text Input");
6337 if (it->wd->edit_mode == 0xF0)
6339 it->wd->edit_mode = 0;
6343 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6345 Elm_Genlist_Item *it = data;
6347 _delete_sweep_objs(it);
6351 _scr_hold_timer_cb(void *data)
6353 Elm_Genlist_Item *it = data;
6354 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6355 it->wd->scr_hold_timer = NULL;
6356 return ECORE_CALLBACK_CANCEL;
6360 _delete_sweep_objs(Elm_Genlist_Item *it)
6364 elm_widget_stringlist_free(it->sweep_labels);
6365 it->sweep_labels = NULL;
6366 elm_widget_stringlist_free(it->sweep_icons);
6367 it->sweep_icons = NULL;
6368 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6369 evas_object_del(ic);
6373 _create_sweep_objs(Elm_Genlist_Item *it)
6379 if (it->itc->func.label_get)
6382 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6384 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6386 char *s = it->itc->func.label_get
6387 ((void *)it->base.data, it->base.widget, l->data);
6391 edje_object_part_text_set(it->base.view, l->data, s);
6396 if (it->itc->func.icon_get)
6399 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6401 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6403 ic = it->itc->func.icon_get
6404 ((void *)it->base.data, it->base.widget, l->data);
6408 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6409 edje_object_part_swallow(it->base.view, key, ic);
6410 evas_object_show(ic);
6411 elm_widget_sub_object_add(it->base.widget, ic);
6418 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6421 Elm_Genlist_Item *it2;
6422 const char *allow_slide;
6424 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6425 if ((!allow_slide) || (atoi(allow_slide) != 1))
6430 if (it->sweeped) return;
6431 if (it->wd->scr_hold_timer)
6433 ecore_timer_del(it->wd->scr_hold_timer);
6434 it->wd->scr_hold_timer = NULL;
6436 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6437 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6439 _delete_sweep_objs(it);
6440 _create_sweep_objs(it);
6441 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6442 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6443 it->wassweeped = EINA_TRUE;
6444 it->sweeped = EINA_TRUE;
6446 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6450 it2->sweeped = EINA_FALSE;
6451 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6452 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6453 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6459 if (!it->sweeped) return;
6460 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6461 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6462 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6463 it->sweeped = EINA_FALSE;