1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
6 #define MAX_ITEMS_PER_BLOCK 32
9 * @defgroup Genlist Genlist
11 * The aim was to have more expansive list than the simple list in
12 * Elementary that could have more flexible items and allow many more entries
13 * while still being fast and low on memory usage. At the same time it was
14 * also made to be able to do tree structures. But the price to pay is more
15 * complex when it comes to usage. If all you want is a simple list with
16 * icons and a single label, use the normal List object.
18 * Signals that you can add callbacks for are:
20 * clicked - This is called when a user has double-clicked an item. The
21 * event_info parameter is the genlist item that was double-clicked.
23 * selected - This is called when a user has made an item selected. The
24 * event_info parameter is the genlist item that was selected.
26 * unselected - This is called when a user has made an item unselected. The
27 * event_info parameter is the genlist item that was unselected.
29 * expanded - This is called when elm_genlist_item_expanded_set() is called
30 * and the item is now meant to be expanded. The event_info parameter is the
31 * genlist item that was indicated to expand. It is the job of this callback
32 * to then fill in the child items.
34 * contracted - This is called when elm_genlist_item_expanded_set() is called
35 * and the item is now meant to be contracted. The event_info parameter is
36 * the genlist item that was indicated to contract. It is the job of this
37 * callback to then delete the child items.
39 * expand,request - This is called when a user has indicated they want to
40 * expand a tree branch item. The callback should decide if the item can
41 * expand (has any children) and then call elm_genlist_item_expanded_set()
42 * appropriately to set the state. The event_info parameter is the genlist
43 * item that was indicated to expand.
45 * contract,request - This is called when a user has indicated they want to
46 * contract a tree branch item. The callback should decide if the item can
47 * contract (has any children) and then call elm_genlist_item_expanded_set()
48 * appropriately to set the state. The event_info parameter is the genlist
49 * item that was indicated to contract.
51 * realized - This is called when the item in the list is created as a real
52 * evas object. event_info parameter is the genlist item that was created.
53 * The object may be deleted at any time, so it is up to the caller to
54 * not use the object pointer from elm_genlist_item_object_get() in a way
55 * where it may point to freed objects.
57 * unrealized - This is called just before an item is unrealized. After
58 * this call icon objects provided will be deleted and the item object
59 * itself delete or be put into a floating cache.
61 * drag,start,up - This is called when the item in the list has been dragged
64 * drag,start,down - This is called when the item in the list has been dragged
65 * (not scrolled) down.
67 * drag,start,left - This is called when the item in the list has been dragged
68 * (not scrolled) left.
70 * drag,start,right - This is called when the item in the list has been dragged
71 * (not scrolled) right.
73 * drag,stop - This is called when the item in the list has stopped being
76 * drag - This is called when the item in the list is being dragged.
78 * longpressed - This is called when the item is pressed for a certain amount
79 * of time. By default it's 1 second.
81 * scroll,edge,top - This is called when the genlist is scrolled until the top
84 * scroll,edge,bottom - This is called when the genlist is scrolled until the
87 * scroll,edge,left - This is called when the genlist is scrolled until the
90 * scroll,edge,right - This is called when the genlist is scrolled until the
93 * multi,swipe,left - This is called when the genlist is multi-touch swiped
96 * multi,swipe,right - This is called when the genlist is multi-touch swiped
99 * multi,swipe,up - This is called when the genlist is multi-touch swiped
102 * multi,swipe,down - This is called when the genlist is multi-touch swiped
105 * multi,pinch,out - This is called when the genlist is multi-touch pinched
108 * multi,pinch,in - This is called when the genlist is multi-touch pinched
111 * Genlist has a fairly large API, mostly because it's relatively complex,
112 * trying to be both expansive, powerful and efficient. First we will begin
113 * an overview on the theory behind genlist.
115 * Evas tracks every object you create. Every time it processes an event
116 * (mouse move, down, up etc.) it needs to walk through objects and find out
117 * what event that affects. Even worse every time it renders display updates,
118 * in order to just calculate what to re-draw, it needs to walk through many
119 * many many objects. Thus, the more objects you keep active, the more
120 * overhead Evas has in just doing its work. It is advisable to keep your
121 * active objects to the minimum working set you need. Also remember that
122 * object creation and deletion carries an overhead, so there is a
123 * middle-ground, which is not easily determined. But don't keep massive lists
124 * of objects you can't see or use. Genlist does this with list objects. It
125 * creates and destroys them dynamically as you scroll around. It groups them
126 * into blocks so it can determine the visibility etc. of a whole block at
127 * once as opposed to having to walk the whole list. This 2-level list allows
128 * for very large numbers of items to be in the list (tests have used up to
129 * 2,000,000 items). Also genlist employs a queue for adding items. As items
130 * may be different sizes, every item added needs to be calculated as to its
131 * size and thus this presents a lot of overhead on populating the list, this
132 * genlist employs a queue. Any item added is queued and spooled off over
133 * time, actually appearing some time later, so if your list has many members
134 * you may find it takes a while for them to all appear, with your process
135 * consuming a lot of CPU while it is busy spooling.
137 * Genlist also implements a tree structure, but it does so with callbacks to
138 * the application, with the application filling in tree structures when
139 * requested (allowing for efficient building of a very deep tree that could
140 * even be used for file-management). See the above smart signal callbacks for
143 * An item in the genlist world can have 0 or more text labels (they can be
144 * regular text or textblock ??that's up to the style to determine), 0 or
145 * more icons (which are simply objects swallowed into the genlist item) and
146 * 0 or more boolean states that can be used for check, radio or other
147 * indicators by the edje theme style. An item may be one of several styles
148 * (Elementary provides 4 by default - ?
\9cdefault?? ?
\9cdouble_label?? "group_index"
149 * and "icon_top_text_bottom", but this can be extended by system or
150 * application custom themes/overlays/extensions).
152 * In order to implement the ability to add and delete items on the fly,
153 * Genlist implements a class/callback system where the application provides
154 * a structure with information about that type of item (genlist may contain
155 * multiple different items with different classes, states and styles).
156 * Genlist will call the functions in this struct (methods) when an item is
157 * ?
\9crealized??(that is created dynamically while scrolling). All objects will
158 * simply be deleted when no longer needed with evas_object_del(). The
159 * Elm_Genlist_Item_Class structure contains the following members:
161 * item_style - This is a constant string and simply defines the name of the
162 * item style. It must be specified and the default should be ?
\9cdefault??
164 * func.label_get - This function is called when an actual item object is
165 * created. The data parameter is the data parameter passed to
166 * elm_genlist_item_append() and related item creation functions. The obj
167 * parameter is the genlist object and the part parameter is the string name
168 * of the text part in the edje design that is listed as one of the possible
169 * labels that can be set. This function must return a strudup()'ed string as
170 * the caller will free() it when done.
172 * func.icon_get - This function is called when an actual item object is
173 * created. The data parameter is the data parameter passed to
174 * elm_genlist_item_append() and related item creation functions. The obj
175 * parameter is the genlist object and the part parameter is the string name
176 * of the icon part in the edje design that is listed as one of the possible
177 * icons that can be set. This must return NULL for no object or a valid
178 * object. The object will be deleted by genlist on shutdown or when the item
181 * func.state_get - This function is called when an actual item object is
182 * created. The data parameter is the data parameter passed to
183 * elm_genlist_item_append() and related item creation functions. The obj
184 * parameter is the genlist object and the part parameter is the string name
185 * of the state part in the edje design that is listed as one of the possible
186 * states that can be set. Return 0 for false or 1 for true. Genlist will
187 * emit a signal to the edje object with ?
\9celm,state,XXX,active???
\9celm??when
188 * true (the default is false), where XXX is the name of the part.
190 * func.del - This is called when elm_genlist_item_del() is called on an
191 * item, elm_genlist_clear() is called on the genlist, or
192 * elm_genlist_item_subitems_clear() is called to clear sub-items. This is
193 * intended for use when actual genlist items are deleted, so any backing
194 * data attached to the item (e.g. its data parameter on creation) can be
197 * Items can be added by several calls. All of them return a Elm_Genlist_Item
198 * handle that is an internal member inside the genlist. They all take a data
199 * parameter that is meant to be used for a handle to the applications
200 * internal data (eg the struct with the original item data). The parent
201 * parameter is the parent genlist item this belongs to if it is a tree or
202 * an indexed group, and NULL if there is no parent. The flags can be a bitmask
203 * of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_SUBITEMS and
204 * ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_SUBITEMS is set then this item
205 * is displayed as an item that is able to expand and have child items.
206 * If ELM_GENLIST_ITEM_GROUP is set then this item is group idex item that is
207 * displayed at the top until the next group comes. The func parameter is a
208 * convenience callback that is called when the item is selected and the data
209 * parameter will be the func_data parameter, obj be the genlist object and
210 * event_info will be the genlist item.
212 * elm_genlist_item_append() appends an item to the end of the list, or if
213 * there is a parent, to the end of all the child items of the parent.
214 * elm_genlist_item_prepend() is the same but prepends to the beginning of
215 * the list or children list. elm_genlist_item_insert_before() inserts at
216 * item before another item and elm_genlist_item_insert_after() inserts after
217 * the indicated item.
219 * The application can clear the list with elm_genlist_clear() which deletes
220 * all the items in the list and elm_genlist_item_del() will delete a specific
221 * item. elm_genlist_item_subitems_clear() will clear all items that are
222 * children of the indicated parent item.
224 * If the application wants multiple items to be able to be selected,
225 * elm_genlist_multi_select_set() can enable this. If the list is
226 * single-selection only (the default), then elm_genlist_selected_item_get()
227 * will return the selected item, if any, or NULL I none is selected. If the
228 * list is multi-select then elm_genlist_selected_items_get() will return a
229 * list (that is only valid as long as no items are modified (added, deleted,
230 * selected or unselected)).
232 * To help inspect list items you can jump to the item at the top of the list
233 * with elm_genlist_first_item_get() which will return the item pointer, and
234 * similarly elm_genlist_last_item_get() gets the item at the end of the list.
235 * elm_genlist_item_next_get() and elm_genlist_item_prev_get() get the next
236 * and previous items respectively relative to the indicated item. Using
237 * these calls you can walk the entire item list/tree. Note that as a tree
238 * the items are flattened in the list, so elm_genlist_item_parent_get() will
239 * let you know which item is the parent (and thus know how to skip them if
242 * There are also convenience functions. elm_genlist_item_genlist_get() will
243 * return the genlist object the item belongs to. elm_genlist_item_show()
244 * will make the scroller scroll to show that specific item so its visible.
245 * elm_genlist_item_data_get() returns the data pointer set by the item
246 * creation functions.
248 * If an item changes (state of boolean changes, label or icons change),
249 * then use elm_genlist_item_update() to have genlist update the item with
250 * the new state. Genlist will re-realize the item thus call the functions
251 * in the _Elm_Genlist_Item_Class for that item.
253 * To programmatically (un)select an item use elm_genlist_item_selected_set().
254 * To get its selected state use elm_genlist_item_selected_get(). Similarly
255 * to expand/contract an item and get its expanded state, use
256 * elm_genlist_item_expanded_set() and elm_genlist_item_expanded_get(). And
257 * again to make an item disabled (unable to be selected and appear
258 * differently) use elm_genlist_item_disabled_set() to set this and
259 * elm_genlist_item_disabled_get() to get the disabled state.
261 * In general to indicate how the genlist should expand items horizontally to
262 * fill the list area, use elm_genlist_horizontal_mode_set(). Valid modes are
263 * ELM_LIST_LIMIT and ELM_LIST_SCROLL . The default is ELM_LIST_SCROLL. This
264 * mode means that if items are too wide to fit, the scroller will scroll
265 * horizontally. Otherwise items are expanded to fill the width of the
266 * viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded
267 * to the viewport width and limited to that size. This can be combined with
268 * a different style that uses edjes' ellipsis feature (cutting text off like
269 * this: ?
\9ctex...??.
271 * Items will only call their selection func and callback when first becoming
272 * selected. Any further clicks will do nothing, unless you enable always
273 * select with elm_genlist_always_select_mode_set(). This means even if
274 * selected, every click will make the selected callbacks be called.
275 * elm_genlist_no_select_mode_set() will turn off the ability to select
276 * items entirely and they will neither appear selected nor call selected
277 * callback functions.
279 * Remember that you can create new styles and add your own theme augmentation
280 * per application with elm_theme_extension_add(). If you absolutely must
281 * have a specific style that overrides any theme the user or system sets up
282 * you can use elm_theme_overlay_add() to add such a file.
285 typedef struct _Widget_Data Widget_Data;
286 typedef struct _Item_Block Item_Block;
287 typedef struct _Pan Pan;
288 typedef struct _Item_Cache Item_Cache;
289 typedef struct _Edit_Data Edit_Data;
291 typedef enum _Elm_Genlist_Item_Move_effect_Mode
293 ELM_GENLIST_ITEM_MOVE_EFFECT_NONE = 0,
294 ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND = (1 << 0),
295 ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT = (1 << 1),
296 ELM_GENLIST_ITEM_MOVE_EFFECT_EDIT_MODE = (1 << 2),
297 } Elm_Genlist_Item_Move_effect_Mode;
301 Evas_Object *obj, *scr, *pan_smart;
302 Eina_Inlist *items, *blocks;
303 Eina_List *group_items;
305 Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w;
306 Ecore_Job *calc_job, *update_job;
307 Ecore_Idler *queue_idler;
308 Ecore_Idler *must_recalc_idler;
309 Eina_List *queue, *selected;
310 Elm_Genlist_Item *show_item;
311 Elm_Genlist_Item *last_selected_item;
312 Eina_Inlist *item_cache;
313 Elm_Genlist_Item *anchor_item;
316 Ecore_Timer *multi_timer;
317 Evas_Coord prev_x, prev_y, prev_mx, prev_my;
318 Evas_Coord cur_x, cur_y, cur_mx, cur_my;
319 Eina_Bool mouse_down : 1;
320 Eina_Bool multi_down : 1;
321 Eina_Bool multi_timeout : 1;
322 Eina_Bool multitouched : 1;
323 Eina_Bool on_hold : 1;
325 Eina_Bool always_select : 1;
326 Eina_Bool longpressed : 1;
327 Eina_Bool wasselected : 1;
328 Eina_Bool no_select : 1;
329 Eina_Bool bring_in : 1;
330 Eina_Bool compress : 1;
331 Eina_Bool height_for_width : 1;
332 Eina_Bool homogeneous : 1;
333 Eina_Bool clear_me : 1;
338 } history[SWIPE_MOVES];
340 int item_cache_count;
346 int max_items_per_block;
347 double longpress_timeout;
349 // TODO : refactoring
350 Eina_Bool reorder_mode : 1;
351 Eina_Bool reorder_pan_move : 1;
352 Eina_Bool effect_mode : 1;
353 Eina_Bool select_all_check : 1;
354 Eina_Bool auto_scrolled : 1;
357 Eina_List *edit_field;
358 Elm_Genlist_Item *select_all_item;
359 Eina_List *sweeped_items;
360 Ecore_Timer *scr_hold_timer;
362 int group_item_width;
363 int group_item_height;
364 Elm_Genlist_Item *reorder_it, *reorder_rel;
365 Evas_Coord reorder_start_y;
366 Ecore_Animator *item_moving_effect_timer;
367 Evas_Object *alpha_bg;
368 Elm_Genlist_Item *expand_item;
369 Evas_Coord expand_item_end;
370 Evas_Coord expand_item_gap;
371 int move_effect_mode;
372 unsigned int start_time;
382 Evas_Coord x, y, w, h, minw, minh;
383 Eina_Bool want_unrealize : 1;
384 Eina_Bool realized : 1;
385 Eina_Bool changed : 1;
386 Eina_Bool updateme : 1;
387 Eina_Bool showme : 1;
388 Eina_Bool must_recalc : 1;
392 struct _Elm_Genlist_Item
394 Elm_Widget_Item base;
399 Evas_Coord x, y, w, h, minw, minh;
400 const Elm_Genlist_Item_Class *itc;
401 Elm_Genlist_Item *parent;
402 Elm_Genlist_Item *group_item;
403 Elm_Genlist_Item_Flags flags;
411 Eina_List *labels, *icons, *states, *icon_objs;
412 Ecore_Timer *long_timer;
413 Ecore_Timer *swipe_timer;
415 Evas_Coord scrl_x, scrl_y;
417 Elm_Genlist_Item *rel;
422 Elm_Tooltip_Item_Content_Cb content_cb;
423 Evas_Smart_Cb del_cb;
427 const char *mouse_cursor;
434 Eina_Bool before : 1;
436 Eina_Bool want_unrealize : 1;
437 Eina_Bool want_realize : 1;
438 Eina_Bool realized : 1;
439 Eina_Bool selected : 1;
440 Eina_Bool hilighted : 1;
441 Eina_Bool expanded : 1;
442 Eina_Bool disabled : 1;
443 Eina_Bool display_only : 1;
444 Eina_Bool mincalcd : 1;
445 Eina_Bool queued : 1;
446 Eina_Bool showme : 1;
447 Eina_Bool delete_me : 1;
449 Eina_Bool dragging : 1;
450 Eina_Bool updateme : 1;
451 Eina_Bool nocache : 1;
454 Eina_Bool move_effect_me : 1;
455 Eina_Bool effect_done : 1;
456 Eina_Bool reordering : 1;
457 Eina_Bool edit_select_check: 1;
458 Eina_Bool renamed : 1;
459 Eina_Bool effect_item_realized : 1;
460 Eina_Bool sweeped : 1;
461 Eina_Bool wassweeped : 1;
462 Eina_List *edit_icon_objs;
463 Evas_Object *edit_obj;
464 Eina_List *sweep_labels, *sweep_icons, *sweep_icon_objs;
466 Ecore_Animator *item_moving_effect_timer;
467 Evas_Coord old_scrl_x, old_scrl_y;
468 Evas_Coord pad_left, pad_right;
476 Evas_Object *base_view, *spacer;
478 const char *item_style; // it->itc->item_style
479 Eina_Bool tree : 1; // it->flags & ELM_GENLIST_ITEM_SUBITEMS
480 Eina_Bool compress : 1; // it->wd->compress
481 Eina_Bool odd : 1; // in & 0x1
483 Eina_Bool selected : 1; // it->selected
484 Eina_Bool disabled : 1; // it->disabled
485 Eina_Bool expanded : 1; // it->expanded
490 Elm_Genlist_Edit_Class *ec;
491 Elm_Genlist_Item *del_item;
492 Elm_Genlist_Item *reorder_item;
493 Elm_Genlist_Item *reorder_rel;
494 Evas_Object *del_confirm;
497 #define ELM_GENLIST_ITEM_FROM_INLIST(item) \
498 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL)
502 Evas_Object_Smart_Clipped_Data __clipped_data;
504 Ecore_Job *resize_job;
507 static const char *widtype = NULL;
508 static void _item_cache_zero(Widget_Data *wd);
509 static void _del_hook(Evas_Object *obj);
510 static void _theme_hook(Evas_Object *obj);
511 //static void _show_region_hook(void *data, Evas_Object *obj);
512 static void _sizing_eval(Evas_Object *obj);
513 static void _item_unrealize(Elm_Genlist_Item *it);
514 static void _item_block_unrealize(Item_Block *itb);
515 static void _calc_job(void *data);
516 static void _on_focus_hook(void *data,
518 static Eina_Bool _item_multi_select_up(Widget_Data *wd);
519 static Eina_Bool _item_multi_select_down(Widget_Data *wd);
520 static Eina_Bool _item_single_select_up(Widget_Data *wd);
521 static Eina_Bool _item_single_select_down(Widget_Data *wd);
522 static Eina_Bool _event_hook(Evas_Object *obj,
524 Evas_Callback_Type type,
526 static Eina_Bool _deselect_all_items(Widget_Data *wd);
527 static void _pan_calculate(Evas_Object *obj);
528 // TODO : refactoring
529 static Evas_Object* _create_tray_alpha_bg(const Evas_Object *obj);
530 static unsigned int current_time_get();
531 static Eina_Bool _item_moving_effect_timer_cb(void *data);
532 static int _item_flip_effect_show(Elm_Genlist_Item *it);
533 static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity);
534 static void _effect_item_realize(Elm_Genlist_Item *it);
535 static void _effect_item_unrealize(Elm_Genlist_Item *it);
536 static void _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right);
537 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source);
538 static void _create_sweep_objs(Elm_Genlist_Item *it);
539 static void _delete_sweep_objs(Elm_Genlist_Item *it);
540 static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after);
541 static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before);
542 static void _group_items_recalc(void *data);
543 static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items);
544 static void _checkbox_item_select_process(Elm_Genlist_Item *it);
545 static void _item_auto_scroll(void *data);
547 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION;
550 _event_hook(Evas_Object *obj,
551 Evas_Object *src __UNUSED__,
552 Evas_Callback_Type type,
555 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
556 Evas_Event_Key_Down *ev = event_info;
557 Widget_Data *wd = elm_widget_data_get(obj);
558 if (!wd) return EINA_FALSE;
559 if (!wd->items) return EINA_FALSE;
560 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
561 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
563 Elm_Genlist_Item *it = NULL;
566 Evas_Coord step_x = 0;
567 Evas_Coord step_y = 0;
570 Evas_Coord page_x = 0;
571 Evas_Coord page_y = 0;
573 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
574 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
575 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
576 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
578 if ((!strcmp(ev->keyname, "Left")) || (!strcmp(ev->keyname, "KP_Left")))
582 else if ((!strcmp(ev->keyname, "Right")) ||
583 (!strcmp(ev->keyname, "KP_Right")))
587 else if ((!strcmp(ev->keyname, "Up")) || (!strcmp(ev->keyname, "KP_Up")))
589 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
590 (_item_multi_select_up(wd)))
591 || (_item_single_select_up(wd)))
593 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
599 else if ((!strcmp(ev->keyname, "Down")) || (!strcmp(ev->keyname, "KP_Down")))
601 if (((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
602 (_item_multi_select_down(wd)))
603 || (_item_single_select_down(wd)))
605 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
611 else if ((!strcmp(ev->keyname, "Home")) ||
612 (!strcmp(ev->keyname, "KP_Home")))
614 it = elm_genlist_first_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, "End")) ||
620 (!strcmp(ev->keyname, "KP_End")))
622 it = elm_genlist_last_item_get(obj);
623 elm_genlist_item_bring_in(it);
624 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
627 else if ((!strcmp(ev->keyname, "Prior")) ||
628 (!strcmp(ev->keyname, "KP_Prior")))
631 y -= -(page_y * v_h) / 100;
635 else if ((!strcmp(ev->keyname, "Next")) ||
636 (!strcmp(ev->keyname, "KP_Next")))
639 y += -(page_y * v_h) / 100;
643 else if(((!strcmp(ev->keyname, "Return")) ||
644 (!strcmp(ev->keyname, "KP_Enter")) ||
645 (!strcmp(ev->keyname, "space")))
646 && (!wd->multi) && (wd->selected))
648 Elm_Genlist_Item *it = elm_genlist_selected_item_get(obj);
649 elm_genlist_item_expanded_set(it,
650 !elm_genlist_item_expanded_get(it));
652 else if (!strcmp(ev->keyname, "Escape"))
654 if (!_deselect_all_items(wd)) return EINA_FALSE;
655 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
658 else return EINA_FALSE;
660 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
661 elm_smart_scroller_child_pos_set(wd->scr, x, y);
666 _deselect_all_items(Widget_Data *wd)
668 if (!wd->selected) return EINA_FALSE;
670 elm_genlist_item_selected_set(wd->selected->data, EINA_FALSE);
676 _item_multi_select_up(Widget_Data *wd)
678 if (!wd->selected) return EINA_FALSE;
679 if (!wd->multi) return EINA_FALSE;
681 Elm_Genlist_Item *prev = elm_genlist_item_prev_get(wd->last_selected_item);
682 if (!prev) return EINA_TRUE;
684 if (elm_genlist_item_selected_get(prev))
686 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
687 wd->last_selected_item = prev;
688 elm_genlist_item_show(wd->last_selected_item);
692 elm_genlist_item_selected_set(prev, EINA_TRUE);
693 elm_genlist_item_show(prev);
699 _item_multi_select_down(Widget_Data *wd)
701 if (!wd->selected) return EINA_FALSE;
702 if (!wd->multi) return EINA_FALSE;
704 Elm_Genlist_Item *next = elm_genlist_item_next_get(wd->last_selected_item);
705 if (!next) return EINA_TRUE;
707 if (elm_genlist_item_selected_get(next))
709 elm_genlist_item_selected_set(wd->last_selected_item, EINA_FALSE);
710 wd->last_selected_item = next;
711 elm_genlist_item_show(wd->last_selected_item);
715 elm_genlist_item_selected_set(next, EINA_TRUE);
716 elm_genlist_item_show(next);
722 _item_single_select_up(Widget_Data *wd)
724 Elm_Genlist_Item *prev;
727 prev = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
728 while ((prev) && (prev->delete_me))
729 prev = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
731 else prev = elm_genlist_item_prev_get(wd->last_selected_item);
733 if (!prev) return EINA_FALSE;
735 _deselect_all_items(wd);
737 elm_genlist_item_selected_set(prev, EINA_TRUE);
738 elm_genlist_item_show(prev);
743 _item_single_select_down(Widget_Data *wd)
745 Elm_Genlist_Item *next;
748 next = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
749 while ((next) && (next->delete_me))
750 next = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
752 else next = elm_genlist_item_next_get(wd->last_selected_item);
754 if (!next) return EINA_FALSE;
756 _deselect_all_items(wd);
758 elm_genlist_item_selected_set(next, EINA_TRUE);
759 elm_genlist_item_show(next);
764 _on_focus_hook(void *data __UNUSED__,
767 Widget_Data *wd = elm_widget_data_get(obj);
769 if (elm_widget_focus_get(obj))
771 edje_object_signal_emit(wd->obj, "elm,action,focus", "elm");
772 evas_object_focus_set(wd->obj, EINA_TRUE);
773 if ((wd->selected) && (!wd->last_selected_item))
774 wd->last_selected_item = eina_list_data_get(wd->selected);
778 edje_object_signal_emit(wd->obj, "elm,action,unfocus", "elm");
779 evas_object_focus_set(wd->obj, EINA_FALSE);
784 _del_hook(Evas_Object *obj)
786 Widget_Data *wd = elm_widget_data_get(obj);
788 _item_cache_zero(wd);
789 if (wd->calc_job) ecore_job_del(wd->calc_job);
790 if (wd->update_job) ecore_job_del(wd->update_job);
791 if (wd->must_recalc_idler) ecore_idler_del(wd->must_recalc_idler);
792 if (wd->multi_timer) ecore_timer_del(wd->multi_timer);
793 if (wd->scr_hold_timer) ecore_timer_del(wd->scr_hold_timer);
798 _del_pre_hook(Evas_Object *obj)
800 Widget_Data *wd = elm_widget_data_get(obj);
802 evas_object_del(wd->pan_smart);
803 wd->pan_smart = NULL;
804 elm_genlist_clear(obj);
808 _theme_hook(Evas_Object *obj)
810 Widget_Data *wd = elm_widget_data_get(obj);
813 _item_cache_zero(wd);
814 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
815 elm_widget_style_get(obj));
816 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
817 wd->item_width = wd->item_height = 0;
818 wd->minw = wd->minh = wd->realminw = 0;
819 EINA_INLIST_FOREACH(wd->blocks, itb)
822 Elm_Genlist_Item *it;
824 if (itb->realized) _item_block_unrealize(itb);
825 EINA_LIST_FOREACH(itb->items, l, it)
826 it->mincalcd = EINA_FALSE;
828 itb->changed = EINA_TRUE;
830 if (wd->calc_job) ecore_job_del(wd->calc_job);
831 wd->calc_job = ecore_job_add(_calc_job, wd);
837 _show_region_hook(void *data, Evas_Object *obj)
839 Widget_Data *wd = elm_widget_data_get(data);
840 Evas_Coord x, y, w, h;
842 elm_widget_show_region_get(obj, &x, &y, &w, &h);
843 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
848 _sizing_eval(Evas_Object *obj)
850 Widget_Data *wd = elm_widget_data_get(obj);
851 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
853 evas_object_size_hint_min_get(wd->scr, &minw, &minh);
854 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
856 if (wd->height_for_width)
860 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
861 if ((vw != 0) && (vw != wd->prev_viewport_w))
865 wd->prev_viewport_w = vw;
866 EINA_INLIST_FOREACH(wd->blocks, itb)
868 itb->must_recalc = EINA_TRUE;
870 if (wd->calc_job) ecore_job_del(wd->calc_job);
871 wd->calc_job = ecore_job_add(_calc_job, wd);
874 if (wd->mode == ELM_LIST_LIMIT)
876 Evas_Coord vmw, vmh, vw, vh;
880 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
881 if ((minw > 0) && (vw < minw)) vw = minw;
882 else if ((maxw > 0) && (vw > maxw))
884 edje_object_size_min_calc
885 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
892 edje_object_size_min_calc
893 (elm_smart_scroller_edje_object_get(wd->scr), &vmw, &vmh);
897 evas_object_size_hint_min_set(obj, minw, minh);
898 evas_object_size_hint_max_set(obj, maxw, maxh);
902 _item_hilight(Elm_Genlist_Item *it)
904 const char *selectraise;
905 if ((it->wd->no_select) || (it->delete_me) || (it->hilighted) ||
906 (it->disabled)) return;
907 if ((!it->sweeped) && (!it->wd->edit_mode))
908 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
909 selectraise = edje_object_data_get(it->base.view, "selectraise");
910 if ((selectraise) && (!strcmp(selectraise, "on")))
912 if (!it->wd->edit_mode) evas_object_raise(it->base.view);
913 if ((it->group_item) && (it->group_item->realized))
914 evas_object_raise(it->group_item->base.view);
916 it->hilighted = EINA_TRUE;
917 if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view);
921 _item_block_del(Elm_Genlist_Item *it)
924 Item_Block *itb = it->block;
926 itb->items = eina_list_remove(itb->items, it);
928 itb->changed = EINA_TRUE;
929 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
930 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
933 il = EINA_INLIST_GET(itb);
934 Item_Block *itbn = (Item_Block *)(il->next);
936 it->parent->items = eina_list_remove(it->parent->items, it);
938 it->wd->blocks = eina_inlist_remove(it->wd->blocks, il);
940 if (itbn) itbn->changed = EINA_TRUE;
944 if (itb->count < itb->wd->max_items_per_block/2)
946 il = EINA_INLIST_GET(itb);
947 Item_Block *itbp = (Item_Block *)(il->prev);
948 Item_Block *itbn = (Item_Block *)(il->next);
949 if ((itbp) && ((itbp->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
951 Elm_Genlist_Item *it2;
953 EINA_LIST_FREE(itb->items, it2)
956 itbp->items = eina_list_append(itbp->items, it2);
958 itbp->changed = EINA_TRUE;
960 it->wd->blocks = eina_inlist_remove(it->wd->blocks,
961 EINA_INLIST_GET(itb));
964 else if ((itbn) && ((itbn->count + itb->count) < itb->wd->max_items_per_block + itb->wd->max_items_per_block/2))
968 Eina_List *last = eina_list_last(itb->items);
969 Elm_Genlist_Item *it2 = last->data;
972 itb->items = eina_list_remove_list(itb->items, last);
973 itbn->items = eina_list_prepend(itbn->items, it2);
975 itbn->changed = EINA_TRUE;
978 eina_inlist_remove(it->wd->blocks, EINA_INLIST_GET(itb));
986 _item_subitems_clear(Elm_Genlist_Item *it)
989 Eina_List *tl = NULL, *l;
990 Elm_Genlist_Item *it2;
992 EINA_LIST_FOREACH(it->items, l, it2)
993 tl = eina_list_append(tl, it2);
995 EINA_LIST_FREE(tl, it2)
996 elm_genlist_item_del(it2);
1000 _item_del(Elm_Genlist_Item *it)
1002 elm_widget_item_pre_notify_del(it);
1003 elm_genlist_item_subitems_clear(it);
1004 it->wd->walking -= it->walking;
1005 if (it->wd->show_item == it) it->wd->show_item = NULL;
1006 if (it->selected) it->wd->selected = eina_list_remove(it->wd->selected, it);
1007 if (it->realized) _item_unrealize(it);
1008 if (it->effect_item_realized) _effect_item_unrealize(it);
1009 if (it->block) _item_block_del(it);
1010 if ((!it->delete_me) && (it->itc->func.del))
1011 it->itc->func.del((void *)it->base.data, it->base.widget);
1012 it->delete_me = EINA_TRUE;
1014 it->wd->queue = eina_list_remove(it->wd->queue, it);
1016 if (it->wd->anchor_item == it)
1018 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
1019 if (!it->wd->anchor_item)
1020 it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
1023 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
1025 it->parent->items = eina_list_remove(it->parent->items, it);
1026 if (it->flags & ELM_GENLIST_ITEM_GROUP)
1027 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
1028 if (it->long_timer) ecore_timer_del(it->long_timer);
1029 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1031 if (it->tooltip.del_cb)
1032 it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it);
1034 elm_widget_item_del(it);
1035 it->wd->total_num--; // todo : remove
1039 _item_select(Elm_Genlist_Item *it)
1041 if ((it->wd->no_select) || (it->delete_me)) return;
1042 if (it == it->wd->select_all_item)
1044 if(it->wd->select_all_check)
1045 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE);
1047 _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE);
1052 if (it->wd->always_select) goto call;
1055 it->selected = EINA_TRUE;
1056 it->wd->selected = eina_list_append(it->wd->selected, it);
1060 if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
1062 evas_object_smart_callback_call(it->base.widget, "selected", it);
1065 if ((it->wd->clear_me) && (!it->wd->walking))
1066 elm_genlist_clear(it->base.widget);
1069 if ((!it->walking) && (it->delete_me))
1071 if (!it->relcount) _item_del(it);
1074 it->wd->last_selected_item = it;
1078 _item_unselect(Elm_Genlist_Item *it)
1080 const char *stacking, *selectraise;
1082 if (it == it->wd->select_all_item) return;
1083 if ((it->delete_me) || (!it->hilighted)) return;
1085 edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm");
1086 stacking = edje_object_data_get(it->base.view, "stacking");
1087 selectraise = edje_object_data_get(it->base.view, "selectraise");
1088 if ((selectraise) && (!strcmp(selectraise, "on")))
1090 if ((stacking) && (!strcmp(stacking, "below")))
1091 evas_object_lower(it->base.view);
1093 it->hilighted = EINA_FALSE;
1096 it->selected = EINA_FALSE;
1097 it->wd->selected = eina_list_remove(it->wd->selected, it);
1098 evas_object_smart_callback_call(it->base.widget, "unselected", it);
1103 _mouse_move(void *data,
1104 Evas *evas __UNUSED__,
1108 Elm_Genlist_Item *it = data;
1109 Evas_Event_Mouse_Move *ev = event_info;
1110 Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady;
1112 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1114 if (!it->wd->on_hold)
1116 it->wd->on_hold = EINA_TRUE;
1117 if (!it->wd->wasselected)
1121 if (it->wd->multitouched)
1123 it->wd->cur_x = ev->cur.canvas.x;
1124 it->wd->cur_y = ev->cur.canvas.y;
1127 if ((it->dragging) && (it->down))
1129 if (it->wd->movements == SWIPE_MOVES) it->wd->swipe = EINA_TRUE;
1132 it->wd->history[it->wd->movements].x = ev->cur.canvas.x;
1133 it->wd->history[it->wd->movements].y = ev->cur.canvas.y;
1134 if (abs((it->wd->history[it->wd->movements].x -
1135 it->wd->history[0].x)) > 40)
1136 it->wd->swipe = EINA_TRUE;
1138 it->wd->movements++;
1142 ecore_timer_del(it->long_timer);
1143 it->long_timer = NULL;
1145 evas_object_smart_callback_call(it->base.widget, "drag", it);
1148 if ((!it->down) /* || (it->wd->on_hold)*/ || (it->wd->longpressed))
1152 ecore_timer_del(it->long_timer);
1153 it->long_timer = NULL;
1155 if (it->wd->reorder_mode && it->wd->reorder_it)
1157 Evas_Coord ox,oy,oh,ow, sel_all_h = 0;
1158 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1159 int it_y = ev->cur.canvas.y - it->wd->reorder_it->dy;
1160 if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y;
1162 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
1163 if (it->wd->select_all_item)
1164 sel_all_h = it->wd->select_all_item->h;
1165 if (it_y < oy + sel_all_h)
1167 evas_object_move(it->base.view, it->scrl_x+it->pad_left,oy + sel_all_h);
1168 _effect_item_controls(it, it->scrl_x, oy + sel_all_h);
1170 else if (it_y + it->wd->reorder_it->h > oy+oh)
1172 evas_object_move(it->base.view, it->scrl_x+it->pad_left, oy + oh - it->wd->reorder_it->h);
1173 _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h);
1177 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it_y);
1178 _effect_item_controls(it, it->scrl_x, it_y);
1180 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1181 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1185 if (!it->display_only)
1186 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1187 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1188 x = ev->cur.canvas.x - x;
1189 y = ev->cur.canvas.y - y;
1192 if (adx < 0) adx = -dx;
1195 if (ady < 0) ady = -dy;
1198 if ((adx > minw) || (ady > minh))
1200 it->dragging = EINA_TRUE;
1203 ecore_timer_del(it->long_timer);
1204 it->long_timer = NULL;
1206 if (!it->wd->wasselected)
1211 evas_object_smart_callback_call(it->base.widget,
1212 "drag,start,up", it);
1217 evas_object_smart_callback_call(it->base.widget,
1218 "drag,start,left", it);
1219 _item_slide(it, EINA_FALSE);
1223 evas_object_smart_callback_call(it->base.widget,
1224 "drag,start,right", it);
1225 _item_slide(it, EINA_TRUE);
1232 evas_object_smart_callback_call(it->base.widget,
1233 "drag,start,down", it);
1238 evas_object_smart_callback_call(it->base.widget,
1239 "drag,start,left", it);
1240 _item_slide(it, EINA_FALSE);
1244 evas_object_smart_callback_call(it->base.widget,
1245 "drag,start,right", it);
1246 _item_slide(it, EINA_TRUE);
1254 _long_press(void *data)
1256 Elm_Genlist_Item *it = data;
1257 Elm_Genlist_Item *it_tmp;
1258 static Eina_Bool done = EINA_FALSE;
1259 //static Eina_Bool contracted = EINA_FALSE;
1263 it->long_timer = NULL;
1264 if ((it->disabled) || (it->dragging) || (it->display_only))
1265 return ECORE_CALLBACK_CANCEL;
1266 it->wd->longpressed = EINA_TRUE;
1267 evas_object_smart_callback_call(it->base.widget, "longpressed", it);
1268 if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP))
1270 it->wd->reorder_it = it;
1271 it->wd->reorder_start_y = 0;
1272 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
1273 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_start", "elm");
1275 EINA_INLIST_FOREACH(it->wd->blocks, itb)
1280 EINA_LIST_FOREACH(itb->items, l, it_tmp)
1282 if (it_tmp->flags != ELM_GENLIST_ITEM_GROUP && it_tmp->realized)
1284 _item_unselect(it_tmp);
1296 EINA_LIST_FOREACH(it->items, l, it_tmp)
1298 if (elm_genlist_item_expanded_get(it_tmp))
1300 elm_genlist_item_expanded_set(it_tmp, EINA_FALSE);
1301 return ECORE_CALLBACK_RENEW;
1305 if (elm_genlist_item_expanded_get(it)) {
1306 elm_genlist_item_expanded_set(it, EINA_FALSE);
1307 return ECORE_CALLBACK_RENEW;
1309 if (it->wd->edit_field && it->renamed)
1310 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1313 return ECORE_CALLBACK_CANCEL;
1317 _swipe(Elm_Genlist_Item *it)
1322 it->wd->swipe = EINA_FALSE;
1323 for (i = 0; i < it->wd->movements; i++)
1325 sum += it->wd->history[i].x;
1326 if (abs(it->wd->history[0].y - it->wd->history[i].y) > 10) return;
1329 sum /= it->wd->movements;
1330 if (abs(sum - it->wd->history[0].x) <= 10) return;
1331 evas_object_smart_callback_call(it->base.widget, "swipe", it);
1335 _swipe_cancel(void *data)
1337 Elm_Genlist_Item *it = data;
1339 if (!it) return ECORE_CALLBACK_CANCEL;
1340 it->wd->swipe = EINA_FALSE;
1341 it->wd->movements = 0;
1342 return ECORE_CALLBACK_RENEW;
1346 _multi_cancel(void *data)
1348 Widget_Data *wd = data;
1350 if (!wd) return ECORE_CALLBACK_CANCEL;
1351 wd->multi_timeout = EINA_TRUE;
1352 return ECORE_CALLBACK_RENEW;
1356 _multi_touch_gesture_eval(void *data)
1358 Elm_Genlist_Item *it = data;
1360 it->wd->multitouched = EINA_FALSE;
1361 if (it->wd->multi_timer)
1363 ecore_timer_del(it->wd->multi_timer);
1364 it->wd->multi_timer = NULL;
1366 if (it->wd->multi_timeout)
1368 it->wd->multi_timeout = EINA_FALSE;
1372 Evas_Coord minw = 0, minh = 0;
1373 Evas_Coord off_x, off_y, off_mx, off_my;
1375 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
1376 off_x = abs(it->wd->cur_x - it->wd->prev_x);
1377 off_y = abs(it->wd->cur_y - it->wd->prev_y);
1378 off_mx = abs(it->wd->cur_mx - it->wd->prev_mx);
1379 off_my = abs(it->wd->cur_my - it->wd->prev_my);
1381 if (((off_x > minw) || (off_y > minh)) && ((off_mx > minw) || (off_my > minh)))
1383 if ((off_x + off_mx) > (off_y + off_my))
1385 if ((it->wd->cur_x > it->wd->prev_x) && (it->wd->cur_mx > it->wd->prev_mx))
1386 evas_object_smart_callback_call(it->base.widget,
1387 "multi,swipe,right", it);
1388 else if ((it->wd->cur_x < it->wd->prev_x) && (it->wd->cur_mx < it->wd->prev_mx))
1389 evas_object_smart_callback_call(it->base.widget,
1390 "multi,swipe,left", it);
1391 else if (abs(it->wd->cur_x - it->wd->cur_mx) > abs(it->wd->prev_x - it->wd->prev_mx))
1392 evas_object_smart_callback_call(it->base.widget,
1393 "multi,pinch,out", it);
1395 evas_object_smart_callback_call(it->base.widget,
1396 "multi,pinch,in", it);
1400 if ((it->wd->cur_y > it->wd->prev_y) && (it->wd->cur_my > it->wd->prev_my))
1401 evas_object_smart_callback_call(it->base.widget,
1402 "multi,swipe,down", it);
1403 else if ((it->wd->cur_y < it->wd->prev_y) && (it->wd->cur_my < it->wd->prev_my))
1404 evas_object_smart_callback_call(it->base.widget,
1405 "multi,swipe,up", it);
1406 else if (abs(it->wd->cur_y - it->wd->cur_my) > abs(it->wd->prev_y - it->wd->prev_my))
1407 evas_object_smart_callback_call(it->base.widget,
1408 "multi,pinch,out", it);
1410 evas_object_smart_callback_call(it->base.widget,
1411 "multi,pinch,in", it);
1414 it->wd->multi_timeout = EINA_FALSE;
1418 _multi_down(void *data,
1419 Evas *evas __UNUSED__,
1420 Evas_Object *obj __UNUSED__,
1423 Elm_Genlist_Item *it = data;
1424 Evas_Event_Multi_Down *ev = event_info;
1426 if ((it->wd->multi_device != 0) || (it->wd->multitouched) || (it->wd->multi_timeout)) return;
1427 it->wd->multi_device = ev->device;
1428 it->wd->multi_down = EINA_TRUE;
1429 it->wd->multitouched = EINA_TRUE;
1430 it->wd->prev_mx = ev->canvas.x;
1431 it->wd->prev_my = ev->canvas.y;
1432 if (!it->wd->wasselected) _item_unselect(it);
1433 it->wd->wasselected = EINA_FALSE;
1434 it->wd->longpressed = EINA_FALSE;
1437 ecore_timer_del(it->long_timer);
1438 it->long_timer = NULL;
1442 it->dragging = EINA_FALSE;
1443 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1445 if (it->swipe_timer)
1447 ecore_timer_del(it->swipe_timer);
1448 it->swipe_timer = NULL;
1450 if (it->wd->on_hold)
1452 it->wd->swipe = EINA_FALSE;
1453 it->wd->movements = 0;
1454 it->wd->on_hold = EINA_FALSE;
1459 _multi_up(void *data,
1460 Evas *evas __UNUSED__,
1461 Evas_Object *obj __UNUSED__,
1464 Elm_Genlist_Item *it = data;
1465 Evas_Event_Multi_Up *ev = event_info;
1467 if (it->wd->multi_device != ev->device) return;
1468 it->wd->multi_device = 0;
1469 it->wd->multi_down = EINA_FALSE;
1470 if (it->wd->mouse_down) return;
1471 _multi_touch_gesture_eval(data);
1475 _multi_move(void *data,
1476 Evas *evas __UNUSED__,
1477 Evas_Object *obj __UNUSED__,
1480 Elm_Genlist_Item *it = data;
1481 Evas_Event_Multi_Move *ev = event_info;
1483 if (it->wd->multi_device != ev->device) return;
1484 it->wd->cur_mx = ev->cur.canvas.x;
1485 it->wd->cur_my = ev->cur.canvas.y;
1489 _mouse_down(void *data,
1490 Evas *evas __UNUSED__,
1494 Elm_Genlist_Item *it = data;
1495 Evas_Event_Mouse_Down *ev = event_info;
1498 if (ev->button != 1) return;
1499 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1501 it->wd->on_hold = EINA_TRUE;
1504 if (it->wd->edit_field && !it->renamed)
1505 elm_genlist_item_rename_mode_set(it, EINA_FALSE);
1506 it->down = EINA_TRUE;
1507 it->dragging = EINA_FALSE;
1508 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
1509 it->dx = ev->canvas.x - x;
1510 it->dy = ev->canvas.y - y;
1511 it->wd->mouse_down = EINA_TRUE;
1512 if (!it->wd->multitouched)
1514 it->wd->prev_x = ev->canvas.x;
1515 it->wd->prev_y = ev->canvas.y;
1516 it->wd->multi_timeout = EINA_FALSE;
1517 if (it->wd->multi_timer) ecore_timer_del(it->wd->multi_timer);
1518 it->wd->multi_timer = ecore_timer_add(1, _multi_cancel, it->wd);
1520 it->wd->longpressed = EINA_FALSE;
1521 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1522 else it->wd->on_hold = EINA_FALSE;
1523 if (it->wd->on_hold) return;
1524 it->wd->wasselected = it->selected;
1526 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1527 evas_object_smart_callback_call(it->base.widget, "clicked", it);
1528 if (it->long_timer) ecore_timer_del(it->long_timer);
1529 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
1530 it->swipe_timer = ecore_timer_add(0.4, _swipe_cancel, it);
1532 it->long_timer = ecore_timer_add(it->wd->longpress_timeout, _long_press,
1535 it->long_timer = NULL;
1536 it->wd->swipe = EINA_FALSE;
1537 it->wd->movements = 0;
1541 _mouse_up(void *data,
1542 Evas *evas __UNUSED__,
1543 Evas_Object *obj __UNUSED__,
1546 Elm_Genlist_Item *it = data;
1547 Evas_Event_Mouse_Up *ev = event_info;
1548 Eina_Bool dragged = EINA_FALSE;
1550 if (ev->button != 1) return;
1551 it->down = EINA_FALSE;
1552 it->wd->mouse_down = EINA_FALSE;
1553 if (it->wd->multitouched)
1555 if (it->wd->multi_down) return;
1556 _multi_touch_gesture_eval(data);
1559 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) it->wd->on_hold = EINA_TRUE;
1560 else it->wd->on_hold = EINA_FALSE;
1563 ecore_timer_del(it->long_timer);
1564 it->long_timer = NULL;
1568 it->dragging = EINA_FALSE;
1569 evas_object_smart_callback_call(it->base.widget, "drag,stop", it);
1572 if (it->swipe_timer)
1574 ecore_timer_del(it->swipe_timer);
1575 it->swipe_timer = NULL;
1577 if (it->wd->multi_timer)
1579 ecore_timer_del(it->wd->multi_timer);
1580 it->wd->multi_timer = NULL;
1581 it->wd->multi_timeout = EINA_FALSE;
1583 if (it->wd->on_hold)
1585 if (it->wd->swipe) _swipe(data);
1586 it->wd->longpressed = EINA_FALSE;
1587 it->wd->on_hold = EINA_FALSE;
1590 if (it->wd->reorder_mode)
1592 Evas_Coord rox, roy, row, roh, sel_all_h = 0;
1593 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
1596 Evas_Coord ox,oy,oh,ow;
1597 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
1598 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
1599 if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h;
1600 if (it->wd->reorder_rel)
1602 if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring
1604 if (roy + oy - sel_all_h <= it->wd->reorder_rel->scrl_y)
1605 _effect_item_move_before(it->wd->reorder_it, it->wd->reorder_rel);
1607 _effect_item_move_after(it->wd->reorder_it, it->wd->reorder_rel);
1610 it->wd->reorder_it = it->wd->reorder_rel = NULL;
1611 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
1612 edje_object_signal_emit(it->edit_obj, "elm,action,item,reorder_end", "elm");
1614 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
1615 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
1618 if (it->wd->longpressed)
1620 it->wd->longpressed = EINA_FALSE;
1621 if (!it->wd->wasselected)
1623 it->wd->wasselected = EINA_FALSE;
1628 if (it->want_unrealize)
1630 _item_unrealize(it);
1631 if (it->block->want_unrealize)
1632 _item_block_unrealize(it->block);
1635 if ((it->disabled) || (dragged) || (it->display_only)) return;
1636 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1639 if ((!it->selected) && (!it->sweeped))
1644 else _item_unselect(it);
1650 Widget_Data *wd = it->wd;
1653 while (wd->selected) _item_unselect(wd->selected->data);
1658 const Eina_List *l, *l_next;
1659 Elm_Genlist_Item *it2;
1661 EINA_LIST_FOREACH_SAFE(it->wd->selected, l, l_next, it2)
1662 if (it2 != it) _item_unselect(it2);
1663 //_item_hilight(it);
1675 _signal_expand_toggle(void *data,
1676 Evas_Object *obj __UNUSED__,
1677 const char *emission __UNUSED__,
1678 const char *source __UNUSED__)
1680 Elm_Genlist_Item *it = data;
1683 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1685 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1689 _signal_expand(void *data,
1690 Evas_Object *obj __UNUSED__,
1691 const char *emission __UNUSED__,
1692 const char *source __UNUSED__)
1694 Elm_Genlist_Item *it = data;
1697 evas_object_smart_callback_call(it->base.widget, "expand,request", it);
1701 _signal_contract(void *data,
1702 Evas_Object *obj __UNUSED__,
1703 const char *emission __UNUSED__,
1704 const char *source __UNUSED__)
1706 Elm_Genlist_Item *it = data;
1709 evas_object_smart_callback_call(it->base.widget, "contract,request", it);
1713 _item_cache_clean(Widget_Data *wd)
1715 while ((wd->item_cache) && (wd->item_cache_count > wd->item_cache_max))
1719 itc = EINA_INLIST_CONTAINER_GET(wd->item_cache->last, Item_Cache);
1720 wd->item_cache = eina_inlist_remove(wd->item_cache,
1721 wd->item_cache->last);
1722 wd->item_cache_count--;
1723 if (itc->spacer) evas_object_del(itc->spacer);
1724 if (itc->base_view) evas_object_del(itc->base_view);
1725 if (itc->item_style) eina_stringshare_del(itc->item_style);
1731 _item_cache_zero(Widget_Data *wd)
1733 int pmax = wd->item_cache_max;
1734 wd->item_cache_max = 0;
1735 _item_cache_clean(wd);
1736 wd->item_cache_max = pmax;
1740 _item_cache_add(Elm_Genlist_Item *it)
1744 if (it->wd->item_cache_max <= 0)
1746 evas_object_del(it->base.view);
1747 it->base.view = NULL;
1748 evas_object_del(it->spacer);
1753 it->wd->item_cache_count++;
1754 itc = calloc(1, sizeof(Item_Cache));
1756 it->wd->item_cache = eina_inlist_prepend(it->wd->item_cache,
1757 EINA_INLIST_GET(itc));
1758 itc->spacer = it->spacer;
1760 itc->base_view = it->base.view;
1761 it->base.view = NULL;
1762 evas_object_hide(itc->base_view);
1763 evas_object_move(itc->base_view, -9999, -9999);
1764 itc->item_style = eina_stringshare_add(it->itc->item_style);
1765 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) itc->tree = 1;
1766 itc->compress = (it->wd->compress);
1767 itc->odd = (it->order_num_in & 0x1);
1768 itc->selected = it->selected;
1769 itc->disabled = it->disabled;
1770 itc->expanded = it->expanded;
1773 ecore_timer_del(it->long_timer);
1774 it->long_timer = NULL;
1776 if (it->swipe_timer)
1778 ecore_timer_del(it->swipe_timer);
1779 it->swipe_timer = NULL;
1781 // FIXME: other callbacks?
1782 edje_object_signal_callback_del_full(itc->base_view,
1783 "elm,action,expand,toggle",
1784 "elm", _signal_expand_toggle, it);
1785 edje_object_signal_callback_del_full(itc->base_view, "elm,action,expand",
1787 _signal_expand, it);
1788 edje_object_signal_callback_del_full(itc->base_view, "elm,action,contract",
1789 "elm", _signal_contract, it);
1790 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_DOWN,
1792 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_UP,
1794 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MOUSE_MOVE,
1796 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_DOWN,
1798 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_UP,
1800 evas_object_event_callback_del_full(itc->base_view, EVAS_CALLBACK_MULTI_MOVE,
1802 _item_cache_clean(it->wd);
1806 _item_cache_find(Elm_Genlist_Item *it)
1809 Eina_Bool tree = 0, odd;
1811 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) tree = 1;
1812 odd = (it->order_num_in & 0x1);
1813 EINA_INLIST_FOREACH(it->wd->item_cache, itc)
1815 if ((itc->selected) || (itc->disabled) || (itc->expanded))
1817 if ((itc->tree == tree) &&
1818 (itc->odd == odd) &&
1819 (itc->compress == it->wd->compress) &&
1820 (!strcmp(it->itc->item_style, itc->item_style)))
1822 it->wd->item_cache = eina_inlist_remove(it->wd->item_cache,
1823 EINA_INLIST_GET(itc));
1824 it->wd->item_cache_count--;
1832 _item_cache_free(Item_Cache *itc)
1834 if (itc->spacer) evas_object_del(itc->spacer);
1835 if (itc->base_view) evas_object_del(itc->base_view);
1836 if (itc->item_style) eina_stringshare_del(itc->item_style);
1841 _item_realize(Elm_Genlist_Item *it,
1845 Elm_Genlist_Item *it2;
1846 const char *stacking;
1847 const char *treesize;
1849 int depth, tsize = 20;
1850 Item_Cache *itc = NULL;
1852 if ((it->realized) || (it->delete_me)) return;
1853 it->order_num_in = in;
1856 it->nocache = EINA_FALSE;
1858 itc = _item_cache_find(it);
1859 if ((!it->wd->effect_mode) && (itc))
1861 it->base.view = itc->base_view;
1862 itc->base_view = NULL;
1863 it->spacer = itc->spacer;
1868 it->base.view = edje_object_add(evas_object_evas_get(it->base.widget));
1869 edje_object_scale_set(it->base.view,
1870 elm_widget_scale_get(it->base.widget) *
1871 _elm_config->scale);
1872 evas_object_smart_member_add(it->base.view, it->wd->pan_smart);
1873 elm_widget_sub_object_add(it->base.widget, it->base.view);
1875 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS)
1876 strncpy(buf, "tree", sizeof(buf));
1877 else strncpy(buf, "item", sizeof(buf));
1878 if (it->wd->compress)
1879 strncat(buf, "_compress", sizeof(buf) - strlen(buf));
1881 if (in & 0x1) strncat(buf, "_odd", sizeof(buf) - strlen(buf));
1882 strncat(buf, "/", sizeof(buf) - strlen(buf));
1883 strncat(buf, it->itc->item_style, sizeof(buf) - strlen(buf));
1885 _elm_theme_object_set(it->base.widget, it->base.view, "genlist", buf,
1886 elm_widget_style_get(it->base.widget));
1888 evas_object_rectangle_add(evas_object_evas_get(it->base.widget));
1889 evas_object_color_set(it->spacer, 0, 0, 0, 0);
1890 elm_widget_sub_object_add(it->base.widget, it->spacer);
1892 for (it2 = it, depth = 0; it2->parent; it2 = it2->parent)
1894 if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1;
1896 it->expanded_depth = depth;
1897 treesize = edje_object_data_get(it->base.view, "treesize");
1898 if (treesize) tsize = atoi(treesize);
1899 evas_object_size_hint_min_set(it->spacer,
1900 (depth * tsize) * _elm_config->scale, 1);
1901 edje_object_part_swallow(it->base.view, "elm.swallow.pad", it->spacer);
1904 edje_object_signal_callback_add(it->base.view,
1905 "elm,action,expand,toggle",
1906 "elm", _signal_expand_toggle, it);
1907 edje_object_signal_callback_add(it->base.view, "elm,action,expand",
1908 "elm", _signal_expand, it);
1909 edje_object_signal_callback_add(it->base.view, "elm,action,contract",
1910 "elm", _signal_contract, it);
1911 stacking = edje_object_data_get(it->base.view, "stacking");
1914 if (!strcmp(stacking, "below")) evas_object_lower(it->base.view);
1915 else if (!strcmp(stacking, "above"))
1916 evas_object_raise(it->base.view);
1918 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_DOWN,
1920 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_UP,
1922 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOUSE_MOVE,
1924 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_DOWN,
1926 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_UP,
1928 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MULTI_MOVE,
1932 if (it->selected != itc->selected)
1934 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1935 edje_object_signal_emit(it->base.view,
1936 "elm,state,selected", "elm");
1938 if (it->disabled != itc->disabled)
1941 edje_object_signal_emit(it->base.view,
1942 "elm,state,disabled", "elm");
1944 if (it->expanded != itc->expanded)
1947 edje_object_signal_emit(it->base.view,
1948 "elm,state,expanded", "elm");
1953 if ((it->selected) && (!it->sweeped) && (!it->wd->edit_mode))
1954 edje_object_signal_emit(it->base.view,
1955 "elm,state,selected", "elm");
1957 edje_object_signal_emit(it->base.view,
1958 "elm,state,disabled", "elm");
1960 edje_object_signal_emit(it->base.view,
1961 "elm,state,expanded", "elm");
1965 if ((calc) && (it->wd->homogeneous) && (it->wd->item_width) && it->wd->group_item_width )
1967 /* homogenous genlist shortcut */
1968 if ((it->flags & ELM_GENLIST_ITEM_GROUP) && (!it->mincalcd))
1970 it->w = it->minw = it->wd->group_item_width;
1971 it->h = it->minh = it->wd->group_item_height;
1972 it->mincalcd = EINA_TRUE;
1974 else if (!it->mincalcd)
1976 it->w = it->minw = it->wd->item_width;
1977 it->h = it->minh = it->wd->item_height;
1978 it->mincalcd = EINA_TRUE;
1983 if (it->itc->func.label_get)
1989 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
1991 EINA_LIST_FOREACH(it->labels, l, key)
1993 char *s = it->itc->func.label_get
1994 ((void *)it->base.data, it->base.widget, l->data);
1998 edje_object_part_text_set(it->base.view, l->data, s);
2002 edje_object_part_text_set(it->base.view, l->data, "");
2005 if (it->itc->func.icon_get)
2011 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2013 EINA_LIST_FOREACH(it->icons, l, key)
2015 Evas_Object *ic = it->itc->func.icon_get
2016 ((void *)it->base.data, it->base.widget, l->data);
2020 it->icon_objs = eina_list_append(it->icon_objs, ic);
2021 edje_object_part_swallow(it->base.view, key, ic);
2022 evas_object_show(ic);
2023 elm_widget_sub_object_add(it->base.widget, ic);
2027 if (it->itc->func.state_get)
2033 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
2035 EINA_LIST_FOREACH(it->states, l, key)
2037 Eina_Bool on = it->itc->func.state_get
2038 ((void *)it->base.data, it->base.widget, l->data);
2042 snprintf(buf, sizeof(buf), "elm,state,%s,active", key);
2043 edje_object_signal_emit(it->base.view, buf, "elm");
2047 snprintf(buf, sizeof(buf), "elm,state,%s,passive", key);
2048 edje_object_signal_emit(it->base.view, buf, "elm");
2053 _create_sweep_objs(it);
2056 Evas_Coord mw = -1, mh = -1;
2058 if (it->wd->height_for_width) mw = it->wd->w;
2060 if (!it->display_only)
2061 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2062 if (it->wd->height_for_width) mw = it->wd->prev_viewport_w;
2063 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw,
2065 if (!it->display_only)
2066 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2067 it->w = it->minw = mw;
2068 it->h = it->minh = mh;
2069 it->mincalcd = EINA_TRUE;
2071 if ((it->wd->homogeneous) && (it->flags & ELM_GENLIST_ITEM_GROUP))
2073 it->wd->group_item_width = mw;
2074 it->wd->group_item_height = mh;
2076 else if ((it->wd->homogeneous))
2077 // if ((!in) && (it->wd->homogeneous))
2079 it->wd->item_width = mw;
2080 it->wd->item_height = mh;
2082 if ((!in) && (it->wd->homogeneous) && (!it->wd->group_item_width))
2084 if (it->flags & ELM_GENLIST_ITEM_GROUP)
2086 it->wd->group_item_width = mw;
2087 it->wd->group_item_height = mh;
2091 if (!calc) evas_object_show(it->base.view);
2094 if (it->tooltip.content_cb)
2096 elm_widget_item_tooltip_content_cb_set(it,
2097 it->tooltip.content_cb,
2098 it->tooltip.data, NULL);
2099 elm_widget_item_tooltip_style_set(it, it->tooltip.style);
2102 if (it->mouse_cursor)
2103 elm_widget_item_cursor_set(it, it->mouse_cursor);
2105 it->realized = EINA_TRUE;
2106 it->want_unrealize = EINA_FALSE;
2108 if (itc) _item_cache_free(itc);
2109 evas_object_smart_callback_call(it->base.widget, "realized", it);
2110 if ((it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && (!calc)) _effect_item_realize(it);
2114 _item_unrealize(Elm_Genlist_Item *it)
2118 if (!it->realized) return;
2119 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
2120 evas_object_smart_callback_call(it->base.widget, "unrealized", it);
2123 ecore_timer_del(it->long_timer);
2124 it->long_timer = NULL;
2126 if ((it->sweeped) || (it->wassweeped) || (it->nocache))
2128 it->sweeped = EINA_FALSE;
2129 it->wassweeped = EINA_FALSE;
2130 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
2131 _delete_sweep_objs(it);
2132 evas_object_del(it->base.view);
2133 it->base.view = NULL;
2134 evas_object_del(it->spacer);
2138 _item_cache_add(it);
2139 elm_widget_stringlist_free(it->labels);
2141 elm_widget_stringlist_free(it->icons);
2143 elm_widget_stringlist_free(it->states);
2145 EINA_LIST_FREE(it->icon_objs, icon)
2146 evas_object_del(icon);
2149 it->realized = EINA_FALSE;
2150 it->want_unrealize = EINA_FALSE;
2151 if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it);
2155 _item_block_recalc(Item_Block *itb,
2161 Elm_Genlist_Item *it;
2162 Evas_Coord minw = 0, minh = 0;
2163 Eina_Bool showme = EINA_FALSE, changed = EINA_FALSE;
2167 EINA_LIST_FOREACH(itb->items, l, it)
2169 if (it->delete_me) continue;
2170 showme |= it->showme;
2175 if (!it->mincalcd) changed = EINA_TRUE;
2178 _item_realize(it, in, 1);
2179 _item_unrealize(it);
2184 _item_realize(it, in, 1);
2185 _item_unrealize(it);
2189 _item_realize(it, in, 0);
2191 if (minw < it->minw) minw = it->minw;
2199 itb->changed = EINA_FALSE;
2200 /* force an evas norender to garbage collect deleted objects */
2201 if (norender) evas_norender(evas_object_evas_get(itb->wd->obj));
2206 _item_block_realize(Item_Block *itb,
2211 Elm_Genlist_Item *it;
2213 if (itb->realized) return;
2214 EINA_LIST_FOREACH(itb->items, l, it)
2216 if (it->delete_me) continue;
2217 if (full) _item_realize(it, in, 0);
2220 itb->realized = EINA_TRUE;
2221 itb->want_unrealize = EINA_FALSE;
2225 _item_block_unrealize(Item_Block *itb)
2228 Elm_Genlist_Item *it;
2229 Eina_Bool dragging = EINA_FALSE;
2231 if (!itb->realized) return;
2232 EINA_LIST_FOREACH(itb->items, l, it)
2234 if (it->flags != ELM_GENLIST_ITEM_GROUP)
2238 dragging = EINA_TRUE;
2239 it->want_unrealize = EINA_TRUE;
2242 _item_unrealize(it);
2247 itb->realized = EINA_FALSE;
2248 itb->want_unrealize = EINA_TRUE;
2251 itb->want_unrealize = EINA_FALSE;
2255 _get_space_for_reorder_item(Elm_Genlist_Item *it)
2257 Evas_Coord rox, roy, row, roh;
2258 Eina_Bool top = EINA_FALSE;
2259 Elm_Genlist_Item *reorder_it = it->wd->reorder_it;
2260 if (!reorder_it) return 0;
2262 Evas_Coord ox,oy,oh,ow;
2263 evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh);
2264 evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh);
2266 if ((it->wd->reorder_start_y < it->block->y) && (roy - oy + roh/2 >= it->block->y - it->wd->pan_y))
2268 it->block->reorder_offset = it->wd->reorder_it->h * -1;
2269 if (it->block->count == 1)
2270 it->wd->reorder_rel = it;
2272 else if ((it->wd->reorder_start_y >= it->block->y) && (roy - oy + roh/2 <= it->block->y - it->wd->pan_y))
2274 it->block->reorder_offset = it->wd->reorder_it->h;
2277 it->block->reorder_offset = 0;
2279 it->scrl_y += it->block->reorder_offset;
2281 top = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2282 rox, roy+roh/2, row, 1));
2285 it->wd->reorder_rel = it;
2286 it->scrl_y+=it->wd->reorder_it->h;
2287 return it->wd->reorder_it->h;
2294 _reorder_item_moving_effect_timer_cb(void *data)
2296 Elm_Genlist_Item *it = data;
2297 Eina_Bool down = EINA_FALSE;
2298 double time = 0.4, t;
2300 t = ((0.0 > (t = current_time_get() - it->wd->start_time)) ? 0.0 : t) / 1000;
2303 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
2307 if (it->old_scrl_y < it->scrl_y)
2309 it->old_scrl_y += y;
2312 else if (it->old_scrl_y > it->scrl_y)
2314 it->old_scrl_y -= y;
2318 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2319 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y);
2320 evas_object_show(it->base.view);
2322 _effect_item_controls(it, it->scrl_x, it->old_scrl_y);
2324 _group_items_recalc(it->wd);
2325 if (!it->wd->reorder_it || it->wd->reorder_pan_move)
2327 it->old_scrl_y = it->scrl_y;
2328 it->move_effect_me = EINA_FALSE;
2329 return ECORE_CALLBACK_CANCEL;
2331 if ((down && it->old_scrl_y >= it->scrl_y) || (!down && it->old_scrl_y <= it->scrl_y))
2333 it->old_scrl_y = it->scrl_y;
2334 it->move_effect_me = EINA_FALSE;
2335 return ECORE_CALLBACK_CANCEL;
2337 return ECORE_CALLBACK_RENEW;
2341 _item_block_position(Item_Block *itb,
2345 Elm_Genlist_Item *it;
2346 Elm_Genlist_Item *git;
2347 Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2350 Elm_Genlist_Item *select_all_item = NULL;
2352 evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh);
2353 evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy,
2356 if (itb->wd->select_all_item &&
2357 (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL))
2359 if (itb->wd->select_all_check)
2360 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,del_confirm", "elm");
2362 edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,del,animated,enable", "elm");
2364 select_all_item = itb->wd->select_all_item;
2366 evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h);
2367 evas_object_move(select_all_item->base.view, ox, oy);
2368 evas_object_raise(select_all_item->base.view);
2370 y = select_all_item->h;
2371 sel_all_h = select_all_item->h;
2374 EINA_LIST_FOREACH(itb->items, l, it)
2376 if (it->delete_me) continue;
2377 else if (it->wd->reorder_it && it->wd->reorder_it == it) continue;
2382 it->scrl_x = itb->x + it->x - it->wd->pan_x + ox;
2383 it->scrl_y = itb->y + it->y - it->wd->pan_y + oy;
2385 vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h,
2386 cvx, cvy, cvw, cvh));
2387 if (it->flags != ELM_GENLIST_ITEM_GROUP || (it->wd->reorder_it ))
2389 if ((itb->realized) && (!it->realized))
2391 if (vis) _item_realize(it, in, 0);
2397 if(it->wd->reorder_mode)
2398 y += _get_space_for_reorder_item(it);
2399 git = it->group_item;
2402 git->scrl_x = it->scrl_x;
2403 if (git->scrl_y < oy + sel_all_h)
2404 git->scrl_y = oy + sel_all_h;
2405 if ((git->scrl_y + git->h) > (it->scrl_y + it->h))
2406 git->scrl_y = (it->scrl_y + it->h) - git->h;
2407 git->want_realize = EINA_TRUE;
2409 if (it->wd->reorder_it && !it->wd->reorder_pan_move && it->old_scrl_y && it->old_scrl_y != it->scrl_y)
2411 if (!it->move_effect_me)
2413 it->move_effect_me = EINA_TRUE;
2414 it->item_moving_effect_timer = ecore_animator_add(_reorder_item_moving_effect_timer_cb, it);
2418 if (!it->move_effect_me )
2419 if (!it->wd->effect_mode || (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE) || (it->parent == it->wd->expand_item))
2421 _effect_item_controls(it, it->scrl_x, it->scrl_y);
2422 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
2423 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->scrl_y);
2424 if(!it->wd->effect_mode || (it->expanded_depth == 0) || (it->parent != it->wd->expand_item) || it->effect_done || (it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE))
2425 evas_object_show(it->base.view);
2427 evas_object_hide(it->base.view);
2428 it->old_scrl_x = it->scrl_x;
2429 it->old_scrl_y = it->scrl_y;
2434 if (!it->dragging) _item_unrealize(it);
2441 if (vis) it->want_realize = EINA_TRUE;
2448 _group_items_recalc(void *data)
2450 Widget_Data *wd = data;
2452 Elm_Genlist_Item *git;
2454 EINA_LIST_FOREACH(wd->group_items, l, git)
2456 if (git->want_realize)
2459 _item_realize(git, 0, 0);
2460 evas_object_resize(git->base.view, wd->minw, git->h);
2461 evas_object_move(git->base.view, git->scrl_x, git->scrl_y);
2462 evas_object_show(git->base.view);
2463 evas_object_raise(git->base.view);
2465 else if (!git->want_realize && git->realized)
2468 _item_unrealize(git);
2474 _must_recalc_idler(void *data)
2476 Widget_Data *wd = data;
2477 if (wd->calc_job) ecore_job_del(wd->calc_job);
2478 wd->calc_job = ecore_job_add(_calc_job, wd);
2479 wd->must_recalc_idler = NULL;
2480 return ECORE_CALLBACK_CANCEL;
2484 _calc_job(void *data)
2486 Widget_Data *wd = data;
2488 Evas_Coord minw = -1, minh = 0, y = 0, ow;
2489 Item_Block *chb = NULL;
2490 int in = 0, minw_change = 0;
2491 Eina_Bool changed = EINA_FALSE;
2493 Eina_Bool did_must_recalc = EINA_FALSE;
2496 t0 = ecore_time_get();
2497 evas_object_geometry_get(wd->pan_smart, NULL, NULL, &ow, &wd->h);
2501 // if (wd->height_for_width) changed = EINA_TRUE;
2504 EINA_INLIST_FOREACH(wd->blocks, itb)
2506 Eina_Bool showme = EINA_FALSE;
2509 showme = itb->showme;
2510 itb->showme = EINA_FALSE;
2513 if (itb->realized) _item_block_unrealize(itb);
2515 if ((itb->changed) || (changed) ||
2516 ((itb->must_recalc) && (!did_must_recalc)))
2518 if ((changed) || (itb->must_recalc))
2521 Elm_Genlist_Item *it;
2522 EINA_LIST_FOREACH(itb->items, l, it)
2523 if (it->mincalcd) it->mincalcd = EINA_FALSE;
2524 itb->changed = EINA_TRUE;
2525 if (itb->must_recalc) did_must_recalc = EINA_TRUE;
2526 itb->must_recalc = EINA_FALSE;
2528 if (itb->realized) _item_block_unrealize(itb);
2529 showme = _item_block_recalc(itb, in, 0, 1);
2535 if (minw == -1) minw = itb->minw;
2536 else if ((!itb->must_recalc) && (minw < itb->minw))
2545 if ((showme) && (wd->show_item) && (!wd->show_item->queued))
2547 wd->show_item->showme = EINA_FALSE;
2549 elm_smart_scroller_region_bring_in(wd->scr,
2551 wd->show_item->block->x,
2553 wd->show_item->block->y,
2554 wd->show_item->block->w,
2557 elm_smart_scroller_child_region_show(wd->scr,
2559 wd->show_item->block->x,
2561 wd->show_item->block->y,
2562 wd->show_item->block->w,
2564 wd->show_item = NULL;
2569 EINA_INLIST_FOREACH(wd->blocks, itb)
2575 if ((chb) && (EINA_INLIST_GET(chb)->next))
2577 EINA_INLIST_FOREACH(EINA_INLIST_GET(chb)->next, itb)
2579 if (itb->realized) _item_block_unrealize(itb);
2582 wd->realminw = minw;
2583 if (minw < wd->w) minw = wd->w;
2584 if ((minw != wd->minw) || (minh != wd->minh) || (wd->select_all_item))
2588 if (wd->select_all_item)
2589 wd->minh += wd->select_all_item->h;
2590 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
2591 _sizing_eval(wd->obj);
2593 if ((wd->anchor_item) && (wd->anchor_item->block) && (!wd->auto_scrolled))
2595 Elm_Genlist_Item *it;
2598 it = wd->anchor_item;
2599 it_y = wd->anchor_y;
2600 elm_smart_scroller_child_pos_set(wd->scr, wd->pan_x,
2601 it->block->y + it->y + it_y);
2602 wd->anchor_item = it;
2603 wd->anchor_y = it_y;
2607 t = ecore_time_get();
2608 if (did_must_recalc)
2610 if (!wd->must_recalc_idler)
2611 wd->must_recalc_idler = ecore_idler_add(_must_recalc_idler, wd);
2613 wd->calc_job = NULL;
2614 evas_object_smart_changed(wd->pan_smart);
2618 _update_job(void *data)
2620 Widget_Data *wd = data;
2623 int num, num0, position = 0, recalc = 0;
2625 wd->update_job = NULL;
2627 EINA_INLIST_FOREACH(wd->blocks, itb)
2629 Evas_Coord itminw, itminh;
2630 Elm_Genlist_Item *it;
2636 _item_block_position(itb, num);
2641 EINA_LIST_FOREACH(itb->items, l2, it)
2648 it->updateme = EINA_FALSE;
2651 _item_unrealize(it);
2652 _item_realize(it, num, 0);
2657 _item_realize(it, num, 1);
2658 _item_unrealize(it);
2660 if ((it->minw != itminw) || (it->minh != itminh))
2665 itb->updateme = EINA_FALSE;
2669 itb->changed = EINA_TRUE;
2670 _item_block_recalc(itb, num0, 0, 1);
2671 _item_block_position(itb, num0);
2676 if (wd->calc_job) ecore_job_del(wd->calc_job);
2677 wd->calc_job = ecore_job_add(_calc_job, wd);
2682 _pan_set(Evas_Object *obj,
2686 Pan *sd = evas_object_smart_data_get(obj);
2689 // Evas_Coord ow, oh;
2690 // evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2691 // ow = sd->wd->minw - ow;
2692 // if (ow < 0) ow = 0;
2693 // oh = sd->wd->minh - oh;
2694 // if (oh < 0) oh = 0;
2695 // if (x < 0) x = 0;
2696 // if (y < 0) y = 0;
2697 // if (x > ow) x = ow;
2698 // if (y > oh) y = oh;
2699 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
2704 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2706 if ((itb->y + itb->h) > y)
2708 Elm_Genlist_Item *it;
2711 EINA_LIST_FOREACH(itb->items, l2, it)
2713 if ((itb->y + it->y) >= y)
2715 sd->wd->anchor_item = it;
2716 sd->wd->anchor_y = -(itb->y + it->y - y);
2724 evas_object_smart_changed(obj);
2728 _pan_get(Evas_Object *obj,
2732 Pan *sd = evas_object_smart_data_get(obj);
2734 if (x) *x = sd->wd->pan_x;
2735 if (y) *y = sd->wd->pan_y;
2739 _pan_max_get(Evas_Object *obj,
2743 Pan *sd = evas_object_smart_data_get(obj);
2746 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2747 ow = sd->wd->minw - ow;
2749 oh = sd->wd->minh - oh;
2756 _pan_min_get(Evas_Object *obj __UNUSED__,
2765 _pan_child_size_get(Evas_Object *obj,
2769 Pan *sd = evas_object_smart_data_get(obj);
2771 if (w) *w = sd->wd->minw;
2772 if (h) *h = sd->wd->minh;
2776 _pan_add(Evas_Object *obj)
2779 Evas_Object_Smart_Clipped_Data *cd;
2782 cd = evas_object_smart_data_get(obj);
2785 sd->__clipped_data = *cd;
2787 evas_object_smart_data_set(obj, sd);
2791 _pan_del(Evas_Object *obj)
2793 Pan *sd = evas_object_smart_data_get(obj);
2798 ecore_job_del(sd->resize_job);
2799 sd->resize_job = NULL;
2805 _pan_resize_job(void *data)
2808 _sizing_eval(sd->wd->obj);
2809 sd->resize_job = NULL;
2813 _pan_resize(Evas_Object *obj,
2817 Pan *sd = evas_object_smart_data_get(obj);
2820 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
2821 if ((ow == w) && (oh == h)) return;
2822 if ((sd->wd->height_for_width) && (ow != w))
2824 if (sd->resize_job) ecore_job_del(sd->resize_job);
2825 sd->resize_job = ecore_job_add(_pan_resize_job, sd);
2827 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2828 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2832 _pan_calculate(Evas_Object *obj)
2834 Pan *sd = evas_object_smart_data_get(obj);
2836 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
2837 static Evas_Coord old_pan_y = 0;
2839 Elm_Genlist_Item *git;
2842 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
2843 evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
2844 EINA_LIST_FOREACH(sd->wd->group_items, l, git)
2846 git->want_realize = EINA_FALSE;
2848 EINA_INLIST_FOREACH(sd->wd->blocks, itb)
2850 itb->w = sd->wd->minw;
2851 if (ELM_RECTS_INTERSECT(itb->x - sd->wd->pan_x + ox,
2852 itb->y - sd->wd->pan_y + oy,
2854 cvx, cvy, cvw, cvh))
2856 if ((!itb->realized) || (itb->changed))
2857 _item_block_realize(itb, in, 0);
2858 _item_block_position(itb, in);
2862 if (itb->realized) _item_block_unrealize(itb);
2866 if (!sd->wd->reorder_it || sd->wd->reorder_pan_move)
2867 _group_items_recalc(sd->wd);
2869 if (sd->wd->reorder_mode && sd->wd->reorder_it)
2871 if (sd->wd->pan_y != old_pan_y) sd->wd->reorder_pan_move = EINA_TRUE;
2872 else sd->wd->reorder_pan_move = EINA_FALSE;
2873 evas_object_raise(sd->wd->reorder_it->base.view);
2874 old_pan_y = sd->wd->pan_y;
2877 if (sd->wd->effect_mode &&
2878 (sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND || sd->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT))
2880 if (!sd->wd->item_moving_effect_timer)
2882 _item_flip_effect_show(sd->wd->expand_item);
2883 evas_object_raise(sd->wd->alpha_bg);
2884 evas_object_show(sd->wd->alpha_bg);
2885 sd->wd->start_time = current_time_get();
2886 sd->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, sd->wd);
2889 else _item_auto_scroll(sd->wd);
2890 if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view);
2894 _pan_move(Evas_Object *obj,
2895 Evas_Coord x __UNUSED__,
2896 Evas_Coord y __UNUSED__)
2898 Pan *sd = evas_object_smart_data_get(obj);
2900 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
2901 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
2905 _hold_on(void *data __UNUSED__,
2907 void *event_info __UNUSED__)
2909 Widget_Data *wd = elm_widget_data_get(obj);
2911 elm_smart_scroller_hold_set(wd->scr, 1);
2915 _hold_off(void *data __UNUSED__,
2917 void *event_info __UNUSED__)
2919 Widget_Data *wd = elm_widget_data_get(obj);
2921 elm_smart_scroller_hold_set(wd->scr, 0);
2925 _freeze_on(void *data __UNUSED__,
2927 void *event_info __UNUSED__)
2929 Widget_Data *wd = elm_widget_data_get(obj);
2931 elm_smart_scroller_freeze_set(wd->scr, 1);
2935 _freeze_off(void *data __UNUSED__,
2937 void *event_info __UNUSED__)
2939 Widget_Data *wd = elm_widget_data_get(obj);
2941 elm_smart_scroller_freeze_set(wd->scr, 0);
2945 _scroll_edge_left(void *data,
2946 Evas_Object *scr __UNUSED__,
2947 void *event_info __UNUSED__)
2949 Evas_Object *obj = data;
2950 evas_object_smart_callback_call(obj, "scroll,edge,left", NULL);
2954 _scroll_edge_right(void *data,
2955 Evas_Object *scr __UNUSED__,
2956 void *event_info __UNUSED__)
2958 Evas_Object *obj = data;
2959 evas_object_smart_callback_call(obj, "scroll,edge,right", NULL);
2963 _scroll_edge_top(void *data,
2964 Evas_Object *scr __UNUSED__,
2965 void *event_info __UNUSED__)
2967 Evas_Object *obj = data;
2968 evas_object_smart_callback_call(obj, "scroll,edge,top", NULL);
2972 _scroll_edge_bottom(void *data,
2973 Evas_Object *scr __UNUSED__,
2974 void *event_info __UNUSED__)
2976 Evas_Object *obj = data;
2977 evas_object_smart_callback_call(obj, "scroll,edge,bottom", NULL);
2981 * Add a new Genlist object
2983 * @param parent The parent object
2984 * @return The new object or NULL if it cannot be created
2989 elm_genlist_add(Evas_Object *parent)
2994 Evas_Coord minw, minh;
2995 static Evas_Smart *smart = NULL;
2997 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
3001 static Evas_Smart_Class sc;
3003 evas_object_smart_clipped_smart_set(&_pan_sc);
3005 sc.name = "elm_genlist_pan";
3006 sc.version = EVAS_SMART_CLASS_VERSION;
3009 sc.resize = _pan_resize;
3010 sc.move = _pan_move;
3011 sc.calculate = _pan_calculate;
3012 if (!(smart = evas_smart_class_new(&sc))) return NULL;
3014 wd = ELM_NEW(Widget_Data);
3015 e = evas_object_evas_get(parent);
3016 if (!e) return NULL;
3017 obj = elm_widget_add(e);
3018 ELM_SET_WIDTYPE(widtype, "genlist");
3019 elm_widget_type_set(obj, "genlist");
3020 elm_widget_sub_object_add(parent, obj);
3021 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
3022 elm_widget_data_set(obj, wd);
3023 elm_widget_del_hook_set(obj, _del_hook);
3024 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
3025 elm_widget_theme_hook_set(obj, _theme_hook);
3026 elm_widget_can_focus_set(obj, EINA_TRUE);
3027 elm_widget_event_hook_set(obj, _event_hook);
3029 wd->scr = elm_smart_scroller_add(e);
3030 elm_smart_scroller_widget_set(wd->scr, obj);
3031 elm_smart_scroller_object_theme_set(obj, wd->scr, "genlist", "base",
3032 elm_widget_style_get(obj));
3033 elm_smart_scroller_bounce_allow_set(wd->scr, EINA_FALSE,
3034 _elm_config->thumbscroll_bounce_enable);
3035 elm_widget_resize_object_set(obj, wd->scr);
3037 evas_object_smart_callback_add(wd->scr, "edge,left", _scroll_edge_left, obj);
3038 evas_object_smart_callback_add(wd->scr, "edge,right", _scroll_edge_right,
3040 evas_object_smart_callback_add(wd->scr, "edge,top", _scroll_edge_top, obj);
3041 evas_object_smart_callback_add(wd->scr, "edge,bottom", _scroll_edge_bottom,
3045 wd->mode = ELM_LIST_SCROLL;
3046 wd->max_items_per_block = MAX_ITEMS_PER_BLOCK;
3047 wd->item_cache_max = wd->max_items_per_block * 2;
3048 wd->longpress_timeout = _elm_config->longpress_timeout;
3049 //wd->effect_mode = _elm_config->effect_enable;
3050 //wd->effect_mode = EINA_TRUE;
3052 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
3053 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
3054 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
3055 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
3057 wd->pan_smart = evas_object_smart_add(e, smart);
3058 wd->pan = evas_object_smart_data_get(wd->pan_smart);
3061 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
3062 _pan_set, _pan_get, _pan_max_get,
3063 _pan_min_get, _pan_child_size_get);
3065 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
3067 evas_object_size_hint_min_set(obj, minw, minh);
3073 static Elm_Genlist_Item *
3074 _item_new(Widget_Data *wd,
3075 const Elm_Genlist_Item_Class *itc,
3077 Elm_Genlist_Item *parent,
3078 Elm_Genlist_Item_Flags flags,
3080 const void *func_data)
3082 Elm_Genlist_Item *it;
3084 it = elm_widget_item_new(wd->obj, Elm_Genlist_Item);
3085 if (!it) return NULL;
3088 it->base.data = data;
3089 it->parent = parent;
3091 it->func.func = func;
3092 it->func.data = func_data;
3093 it->mouse_cursor = NULL;
3094 it->expanded_depth = 0;
3095 if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE;
3096 if ((!it->parent) && (it->wd->select_all_item))
3097 _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE);
3098 it->num = ++wd->total_num; // todo : remov
3103 _item_block_add(Widget_Data *wd,
3104 Elm_Genlist_Item *it)
3106 Item_Block *itb = NULL;
3113 itb = calloc(1, sizeof(Item_Block));
3116 if (!it->rel->block)
3119 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3120 itb->items = eina_list_append(itb->items, it);
3126 wd->blocks = eina_inlist_prepend_relative
3127 (wd->blocks, EINA_INLIST_GET(itb),
3128 EINA_INLIST_GET(it->rel->block));
3130 eina_list_prepend_relative(itb->items, it, it->rel);
3134 wd->blocks = eina_inlist_append_relative
3135 (wd->blocks, EINA_INLIST_GET(itb),
3136 EINA_INLIST_GET(it->rel->block));
3138 eina_list_append_relative(itb->items, it, it->rel);
3148 itb = (Item_Block *)(wd->blocks);
3149 if (itb->count >= wd->max_items_per_block)
3151 itb = calloc(1, sizeof(Item_Block));
3155 eina_inlist_prepend(wd->blocks,
3156 EINA_INLIST_GET(itb));
3161 itb = calloc(1, sizeof(Item_Block));
3165 eina_inlist_prepend(wd->blocks, EINA_INLIST_GET(itb));
3167 itb->items = eina_list_prepend(itb->items, it);
3173 itb = (Item_Block *)(wd->blocks->last);
3174 if (itb->count >= wd->max_items_per_block)
3176 itb = calloc(1, sizeof(Item_Block));
3180 eina_inlist_append(wd->blocks,
3181 EINA_INLIST_GET(itb));
3186 itb = calloc(1, sizeof(Item_Block));
3190 eina_inlist_append(wd->blocks, EINA_INLIST_GET(itb));
3192 itb->items = eina_list_append(itb->items, it);
3198 itb = it->rel->block;
3199 if (!itb) goto newblock;
3201 itb->items = eina_list_prepend_relative(itb->items, it, it->rel);
3203 itb->items = eina_list_append_relative(itb->items, it, it->rel);
3206 itb->changed = EINA_TRUE;
3208 if (itb->wd->calc_job) ecore_job_del(itb->wd->calc_job);
3209 itb->wd->calc_job = ecore_job_add(_calc_job, itb->wd);
3212 it->rel->relcount--;
3213 if ((it->rel->delete_me) && (!it->rel->relcount))
3217 if (itb->count > itb->wd->max_items_per_block)
3221 Elm_Genlist_Item *it2;
3223 newc = itb->count / 2;
3224 itb2 = calloc(1, sizeof(Item_Block));
3228 eina_inlist_append_relative(wd->blocks, EINA_INLIST_GET(itb2),
3229 EINA_INLIST_GET(itb));
3230 itb2->changed = EINA_TRUE;
3231 while ((itb->count > newc) && (itb->items))
3235 l = eina_list_last(itb->items);
3237 itb->items = eina_list_remove_list(itb->items, l);
3240 itb2->items = eina_list_prepend(itb2->items, it2);
3248 _queue_proecess(Widget_Data *wd,
3252 Eina_Bool showme = EINA_FALSE;
3255 t0 = ecore_time_get();
3256 for (n = 0; (wd->queue) && (n < 128); n++)
3258 Elm_Genlist_Item *it;
3260 it = wd->queue->data;
3261 wd->queue = eina_list_remove_list(wd->queue, wd->queue);
3262 it->queued = EINA_FALSE;
3263 _item_block_add(wd, it);
3264 t = ecore_time_get();
3265 if (it->block->changed)
3267 showme = _item_block_recalc(it->block, it->block->num, 1,
3269 it->block->changed = 0;
3271 if (showme) it->block->showme = EINA_TRUE;
3272 if (eina_inlist_count(wd->blocks) > 1)
3274 if ((t - t0) > (ecore_animator_frametime_get())) break;
3281 _item_idler(void *data)
3283 Widget_Data *wd = data;
3286 //static double q_start = 0.0;
3287 //if (q_start == 0.0) q_start = ecore_time_get();
3290 if (_queue_proecess(wd, 1) > 0)
3292 if (wd->calc_job) ecore_job_del(wd->calc_job);
3293 wd->calc_job = ecore_job_add(_calc_job, wd);
3298 //printf("PROCESS TIME: %3.3f\n", ecore_time_get() - q_start);
3300 wd->queue_idler = NULL;
3301 return ECORE_CALLBACK_CANCEL;
3303 return ECORE_CALLBACK_RENEW;
3307 _item_queue(Widget_Data *wd,
3308 Elm_Genlist_Item *it)
3310 if (it->queued) return;
3311 it->queued = EINA_TRUE;
3312 wd->queue = eina_list_append(wd->queue, it);
3313 while ((wd->queue) && ((!wd->blocks) || (!wd->blocks->next)))
3315 if (wd->queue_idler)
3317 ecore_idler_del(wd->queue_idler);
3318 wd->queue_idler = NULL;
3320 _queue_proecess(wd, 0);
3322 if (!wd->queue_idler) wd->queue_idler = ecore_idler_add(_item_idler, wd);
3326 * Append item to the end of the genlist
3328 * This appends the given item to the end of the list or the end of
3329 * the children if the parent is given.
3331 * @param obj The genlist object
3332 * @param itc The item class for the item
3333 * @param data The item data
3334 * @param parent The parent item, or NULL if none
3335 * @param flags Item flags
3336 * @param func Convenience function called when item selected
3337 * @param func_data Data passed to @p func above.
3338 * @return A handle to the item added or NULL if not possible
3342 EAPI Elm_Genlist_Item *
3343 elm_genlist_item_append(Evas_Object *obj,
3344 const Elm_Genlist_Item_Class *itc,
3346 Elm_Genlist_Item *parent,
3347 Elm_Genlist_Item_Flags flags,
3349 const void *func_data)
3351 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3352 Widget_Data *wd = elm_widget_data_get(obj);
3353 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3355 if (!wd) return NULL;
3356 if (!it) return NULL;
3359 if (flags & ELM_GENLIST_ITEM_GROUP)
3360 wd->group_items = eina_list_append(wd->group_items, it);
3361 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
3366 Elm_Genlist_Item *it2 = NULL;
3367 Eina_List *ll = eina_list_last(it->parent->items);
3368 if (ll) it2 = ll->data;
3369 it->parent->items = eina_list_append(it->parent->items, it);
3370 if (!it2) it2 = it->parent;
3372 eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3373 EINA_INLIST_GET(it2));
3375 it->rel->relcount++;
3377 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3378 it->group_item = parent;
3379 else if (it->parent->group_item)
3380 it->group_item = it->parent->group_item;
3382 it->before = EINA_FALSE;
3383 _item_queue(wd, it);
3388 * Prepend item at start of the genlist
3390 * This adds an item to the beginning of the list or beginning of the
3391 * children of the parent if given.
3393 * @param obj The genlist object
3394 * @param itc The item class for the item
3395 * @param data The item data
3396 * @param parent The parent item, or NULL if none
3397 * @param flags Item flags
3398 * @param func Convenience function called when item selected
3399 * @param func_data Data passed to @p func above.
3400 * @return A handle to the item added or NULL if not possible
3404 EAPI Elm_Genlist_Item *
3405 elm_genlist_item_prepend(Evas_Object *obj,
3406 const Elm_Genlist_Item_Class *itc,
3408 Elm_Genlist_Item *parent,
3409 Elm_Genlist_Item_Flags flags,
3411 const void *func_data)
3413 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3414 Widget_Data *wd = elm_widget_data_get(obj);
3415 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3417 if (!wd) return NULL;
3418 if (!it) return NULL;
3421 if (flags & ELM_GENLIST_ITEM_GROUP)
3422 wd->group_items = eina_list_prepend(wd->group_items, it);
3423 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
3428 Elm_Genlist_Item *it2 = NULL;
3429 Eina_List *ll = it->parent->items;
3430 if (ll) it2 = ll->data;
3431 it->parent->items = eina_list_prepend(it->parent->items, it);
3432 if (!it2) it2 = it->parent;
3434 eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3435 EINA_INLIST_GET(it2));
3437 it->rel->relcount++;
3439 it->before = EINA_TRUE;
3440 _item_queue(wd, it);
3445 * Insert item before another in the genlist
3447 * This inserts an item before another in the list. It will be in the
3448 * same tree level or group as the item it is inseted before.
3450 * @param obj The genlist object
3451 * @param itc The item class for the item
3452 * @param data The item data
3453 * @param before The item to insert before
3454 * @param flags Item flags
3455 * @param func Convenience function called when item selected
3456 * @param func_data Data passed to @p func above.
3457 * @return A handle to the item added or NULL if not possible
3461 EAPI Elm_Genlist_Item *
3462 elm_genlist_item_insert_before(Evas_Object *obj,
3463 const Elm_Genlist_Item_Class *itc,
3465 Elm_Genlist_Item *parent,
3466 Elm_Genlist_Item *before,
3467 Elm_Genlist_Item_Flags flags,
3469 const void *func_data)
3471 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3472 EINA_SAFETY_ON_NULL_RETURN_VAL(before, NULL);
3473 Widget_Data *wd = elm_widget_data_get(obj);
3474 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3476 if (!wd) return NULL;
3477 if (!it) return NULL;
3480 it->parent->items = eina_list_prepend_relative(it->parent->items, it,
3483 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
3484 EINA_INLIST_GET(before));
3486 it->rel->relcount++;
3487 it->before = EINA_TRUE;
3488 _item_queue(wd, it);
3493 * Insert an item after another in the genlst
3495 * This inserts an item after another in the list. It will be in the
3496 * same tree level or group as the item it is inseted after.
3498 * @param obj The genlist object
3499 * @param itc The item class for the item
3500 * @param data The item data
3501 * @param after The item to insert after
3502 * @param flags Item flags
3503 * @param func Convenience function called when item selected
3504 * @param func_data Data passed to @p func above.
3505 * @return A handle to the item added or NULL if not possible
3509 EAPI Elm_Genlist_Item *
3510 elm_genlist_item_insert_after(Evas_Object *obj,
3511 const Elm_Genlist_Item_Class *itc,
3513 Elm_Genlist_Item *parent,
3514 Elm_Genlist_Item *after,
3515 Elm_Genlist_Item_Flags flags,
3517 const void *func_data)
3519 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3520 EINA_SAFETY_ON_NULL_RETURN_VAL(after, NULL);
3521 Widget_Data *wd = elm_widget_data_get(obj);
3522 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3524 if (!wd) return NULL;
3525 if (!it) return NULL;
3526 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
3527 EINA_INLIST_GET(after));
3530 it->parent->items = eina_list_append_relative(it->parent->items, it,
3534 it->rel->relcount++;
3535 it->before = EINA_FALSE;
3536 _item_queue(wd, it);
3543 * This clears all items in the list, leaving it empty.
3545 * @param obj The genlist object
3550 elm_genlist_clear(Evas_Object *obj)
3552 ELM_CHECK_WIDTYPE(obj, widtype);
3553 Widget_Data *wd = elm_widget_data_get(obj);
3555 if (wd->walking > 0)
3557 Elm_Genlist_Item *it;
3559 wd->clear_me = EINA_TRUE;
3560 EINA_INLIST_FOREACH(wd->items, it)
3562 it->delete_me = EINA_TRUE;
3566 wd->clear_me = EINA_FALSE;
3569 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3570 it->nocache = EINA_TRUE;
3572 if (wd->anchor_item == it)
3574 wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3575 if (!wd->anchor_item)
3577 ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3580 wd->items = eina_inlist_remove(wd->items, wd->items);
3581 if (it->flags & ELM_GENLIST_ITEM_GROUP)
3582 it->wd->group_items = eina_list_remove(it->wd->group_items, it);
3583 elm_widget_item_pre_notify_del(it);
3584 if (it->effect_item_realized) _effect_item_unrealize(it);
3585 if (it->realized) _item_unrealize(it);
3586 if (it->itc->func.del)
3587 it->itc->func.del((void *)it->base.data, it->base.widget);
3588 if (it->long_timer) ecore_timer_del(it->long_timer);
3589 if (it->swipe_timer) ecore_timer_del(it->swipe_timer);
3590 elm_widget_item_del(it);
3592 wd->anchor_item = NULL;
3595 Item_Block *itb = (Item_Block *)(wd->blocks);
3597 wd->blocks = eina_inlist_remove(wd->blocks, wd->blocks);
3598 if (itb->items) eina_list_free(itb->items);
3603 ecore_job_del(wd->calc_job);
3604 wd->calc_job = NULL;
3606 if (wd->queue_idler)
3608 ecore_idler_del(wd->queue_idler);
3609 wd->queue_idler = NULL;
3611 if (wd->must_recalc_idler)
3613 ecore_idler_del(wd->must_recalc_idler);
3614 wd->must_recalc_idler = NULL;
3618 eina_list_free(wd->queue);
3623 eina_list_free(wd->selected);
3624 wd->selected = NULL;
3628 Evas_Object *editfield;
3629 EINA_LIST_FREE(wd->edit_field, editfield)
3630 evas_object_del(editfield);
3631 wd->edit_field = NULL;
3633 if (wd->item_moving_effect_timer)
3635 ecore_animator_del(wd->item_moving_effect_timer);
3636 wd->item_moving_effect_timer = NULL;
3638 wd->show_item = NULL;
3645 evas_object_del(wd->alpha_bg);
3646 wd->alpha_bg = NULL;
3650 evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
3651 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
3657 * Enable or disable multi-select in the genlist
3659 * This enables (EINA_TRUE) or disableds (EINA_FALSE) multi-select in
3660 * the list. This allows more than 1 item to be selected.
3662 * @param obj The genlist object
3663 * @param multi Multi-select enable/disable
3668 elm_genlist_multi_select_set(Evas_Object *obj,
3671 ELM_CHECK_WIDTYPE(obj, widtype);
3672 Widget_Data *wd = elm_widget_data_get(obj);
3678 * Gets if multi-select in genlist is enable or disable
3680 * @param obj The genlist object
3681 * @return Multi-select enable/disable
3682 * (EINA_TRUE = enabled/EINA_FALSE = disabled)
3687 elm_genlist_multi_select_get(const Evas_Object *obj)
3689 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3690 Widget_Data *wd = elm_widget_data_get(obj);
3691 if (!wd) return EINA_FALSE;
3696 * Get the selectd item in the genlist
3698 * This gets the selected item in the list (if multi-select is enabled
3699 * only the first item in the list is selected - which is not very
3700 * useful, so see elm_genlist_selected_items_get() for when
3701 * multi-select is used).
3703 * If no item is selected, NULL is returned.
3705 * @param obj The genlist object
3706 * @return The selected item, or NULL if none.
3710 EAPI Elm_Genlist_Item *
3711 elm_genlist_selected_item_get(const Evas_Object *obj)
3713 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3714 Widget_Data *wd = elm_widget_data_get(obj);
3715 if (!wd) return NULL;
3716 if (wd->selected) return wd->selected->data;
3721 * Get a list of selected items in the genlist
3723 * This returns a list of the selected items. This list pointer is
3724 * only valid so long as no items are selected or unselected (or
3725 * unselected implicitly by deletion). The list contains
3726 * Elm_Genlist_Item pointers.
3728 * @param obj The genlist object
3729 * @return The list of selected items, nor NULL if none are selected.
3733 EAPI const Eina_List *
3734 elm_genlist_selected_items_get(const Evas_Object *obj)
3736 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3737 Widget_Data *wd = elm_widget_data_get(obj);
3738 if (!wd) return NULL;
3739 return wd->selected;
3743 * Get a list of realized items in genlist
3745 * This returns a list of the realized items in the genlist. The list
3746 * contains Elm_Genlist_Item pointers. The list must be freed by the
3747 * caller when done with eina_list_free(). The item pointers in the
3748 * list are only valid so long as those items are not deleted or the
3749 * genlist is not deleted.
3751 * @param obj The genlist object
3752 * @return The list of realized items, nor NULL if none are realized.
3757 elm_genlist_realized_items_get(const Evas_Object *obj)
3759 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3760 Widget_Data *wd = elm_widget_data_get(obj);
3761 Eina_List *list = NULL;
3763 Eina_Bool done = EINA_FALSE;
3764 if (!wd) return NULL;
3765 EINA_INLIST_FOREACH(wd->blocks, itb)
3770 Elm_Genlist_Item *it;
3773 EINA_LIST_FOREACH(itb->items, l, it)
3775 if (it->realized) list = eina_list_append(list, it);
3787 * Get the item that is at the x, y canvas coords
3789 * This returns the item at the given coordinates (which are canvas
3790 * relative not object-relative). If an item is at that coordinate,
3791 * that item handle is returned, and if @p posret is not NULL, the
3792 * integer pointed to is set to a value of -1, 0 or 1, depending if
3793 * the coordinate is on the upper portion of that item (-1), on the
3794 * middle section (0) or on the lower part (1). If NULL is returned as
3795 * an item (no item found there), then posret may indicate -1 or 1
3796 * based if the coordinate is above or below all items respectively in
3799 * @param it The item
3800 * @param x The input x coordinate
3801 * @param y The input y coordinate
3802 * @param posret The position relative to the item returned here
3803 * @return The item at the coordinates or NULL if none
3807 EAPI Elm_Genlist_Item *
3808 elm_genlist_at_xy_item_get(const Evas_Object *obj,
3813 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3814 Widget_Data *wd = elm_widget_data_get(obj);
3815 Evas_Coord ox, oy, ow, oh;
3818 if (!wd) return NULL;
3819 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
3821 EINA_INLIST_FOREACH(wd->blocks, itb)
3824 Elm_Genlist_Item *it;
3826 if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x,
3827 oy + itb->y - itb->wd->pan_y,
3828 itb->w, itb->h, x, y, 1, 1))
3830 EINA_LIST_FOREACH(itb->items, l, it)
3832 Evas_Coord itx, ity;
3834 itx = ox + itb->x + it->x - itb->wd->pan_x;
3835 ity = oy + itb->y + it->y - itb->wd->pan_y;
3836 if (ELM_RECTS_INTERSECT(itx, ity, it->w, it->h, x, y, 1, 1))
3840 if (y <= (ity + (it->h / 4))) *posret = -1;
3841 else if (y >= (ity + it->h - (it->h / 4)))
3847 lasty = ity + it->h;
3852 if (y > lasty) *posret = 1;
3859 * Get the first item in the genlist
3861 * This returns the first item in the list.
3863 * @param obj The genlist object
3864 * @return The first item, or NULL if none
3868 EAPI Elm_Genlist_Item *
3869 elm_genlist_first_item_get(const Evas_Object *obj)
3871 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3872 Widget_Data *wd = elm_widget_data_get(obj);
3873 if (!wd) return NULL;
3874 if (!wd->items) return NULL;
3875 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items);
3876 while ((it) && (it->delete_me))
3877 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3882 * Get the last item in the genlist
3884 * This returns the last item in the list.
3886 * @return The last item, or NULL if none
3890 EAPI Elm_Genlist_Item *
3891 elm_genlist_last_item_get(const Evas_Object *obj)
3893 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3894 Widget_Data *wd = elm_widget_data_get(obj);
3895 if (!wd) return NULL;
3896 if (!wd->items) return NULL;
3897 Elm_Genlist_Item *it = ELM_GENLIST_ITEM_FROM_INLIST(wd->items->last);
3898 while ((it) && (it->delete_me))
3899 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3904 * Get the next item in the genlist
3906 * This returns the item after the item @p it.
3908 * @param it The item
3909 * @return The item after @p it, or NULL if none
3913 EAPI Elm_Genlist_Item *
3914 elm_genlist_item_next_get(const Elm_Genlist_Item *it)
3916 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3919 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3920 if ((it) && (!it->delete_me)) break;
3922 return (Elm_Genlist_Item *)it;
3926 * Get the previous item in the genlist
3928 * This returns the item before the item @p it.
3930 * @param it The item
3931 * @return The item before @p it, or NULL if none
3935 EAPI Elm_Genlist_Item *
3936 elm_genlist_item_prev_get(const Elm_Genlist_Item *it)
3938 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3941 it = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3942 if ((it) && (!it->delete_me)) break;
3944 return (Elm_Genlist_Item *)it;
3948 * Get the genlist object from an item
3950 * This returns the genlist object itself that an item belongs to.
3952 * @param it The item
3953 * @return The genlist object
3958 elm_genlist_item_genlist_get(const Elm_Genlist_Item *it)
3960 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3961 return it->base.widget;
3965 * Get the parent item of the given item
3967 * This returns the parent item of the item @p it given.
3969 * @param it The item
3970 * @return The parent of the item or NULL if none
3974 EAPI Elm_Genlist_Item *
3975 elm_genlist_item_parent_get(const Elm_Genlist_Item *it)
3977 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
3982 * Clear all sub-items (children) of the given item
3984 * This clears all items that are children (or their descendants) of the
3987 * @param it The item
3992 elm_genlist_item_subitems_clear(Elm_Genlist_Item *it)
3994 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
3995 Elm_Genlist_Item *it2;
3998 if(!it->wd->effect_mode || !it->wd->move_effect_mode)
3999 _item_subitems_clear(it);
4002 if((!it->wd->item_moving_effect_timer) && (it->flags != ELM_GENLIST_ITEM_GROUP))
4004 it->wd->expand_item = it;
4005 _item_flip_effect_show(it);
4006 evas_object_geometry_get(it->base.view, NULL, &y, NULL, &h);
4007 it->wd->expand_item_end = y + h;
4011 it2 = elm_genlist_item_next_get(it2);
4013 } while (it2->expanded_depth > it->expanded_depth);
4015 it->wd->expand_item_gap = it->wd->expand_item_end - it2->old_scrl_y;
4017 it->wd->expand_item_gap = 0;
4019 evas_object_raise(it->wd->alpha_bg);
4020 evas_object_show(it->wd->alpha_bg);
4022 it->wd->start_time = current_time_get();
4023 it->wd->item_moving_effect_timer = ecore_animator_add(_item_moving_effect_timer_cb, it->wd);
4026 _item_subitems_clear(it);
4031 * Set the selected state of an item
4033 * This sets the selected state (1 selected, 0 not selected) of the given
4036 * @param it The item
4037 * @param selected The selected state
4042 elm_genlist_item_selected_set(Elm_Genlist_Item *it,
4045 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4046 Widget_Data *wd = elm_widget_data_get(it->base.widget);
4048 if (it->delete_me) return;
4049 selected = !!selected;
4050 if (it->selected == selected) return;
4056 while (wd->selected)
4057 _item_unselect(wd->selected->data);
4067 * Get the selected state of an item
4069 * This gets the selected state of an item (1 selected, 0 not selected).
4071 * @param it The item
4072 * @return The selected state
4077 elm_genlist_item_selected_get(const Elm_Genlist_Item *it)
4079 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4080 return it->selected;
4084 * Sets the expanded state of an item (if it's a parent)
4086 * This expands or contracts a parent item (thus showing or hiding the
4089 * @param it The item
4090 * @param expanded The expanded state (1 expanded, 0 not expanded).
4095 elm_genlist_item_expanded_set(Elm_Genlist_Item *it,
4098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4099 if (it->expanded == expanded) return;
4100 it->expanded = expanded;
4101 it->wd->expand_item = it;
4103 if(it->wd->effect_mode && !it->wd->alpha_bg)
4104 it->wd->alpha_bg = _create_tray_alpha_bg(it->base.widget);
4108 it->wd->auto_scrolled = EINA_FALSE;
4109 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND;
4111 edje_object_signal_emit(it->base.view, "elm,state,expanded", "elm");
4112 evas_object_smart_callback_call(it->base.widget, "expanded", it);
4116 it->wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT;
4118 edje_object_signal_emit(it->base.view, "elm,state,contracted", "elm");
4119 evas_object_smart_callback_call(it->base.widget, "contracted", it);
4124 * Get the expanded state of an item
4126 * This gets the expanded state of an item
4128 * @param it The item
4129 * @return Thre expanded state
4134 elm_genlist_item_expanded_get(const Elm_Genlist_Item *it)
4136 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4137 return it->expanded;
4141 * Get the depth of expanded item
4143 * @param it The genlist item object
4144 * @return The depth of expanded item
4149 elm_genlist_item_expanded_depth_get(const Elm_Genlist_Item *it)
4151 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, 0);
4152 return it->expanded_depth;
4156 * Sets the disabled state of an item.
4158 * A disabled item cannot be selected or unselected. It will also
4159 * change appearance to appear disabled. This sets the disabled state
4160 * (1 disabled, 0 not disabled).
4162 * @param it The item
4163 * @param disabled The disabled state
4168 elm_genlist_item_disabled_set(Elm_Genlist_Item *it,
4171 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4172 if (it->disabled == disabled) return;
4173 if (it->delete_me) return;
4174 it->disabled = disabled;
4178 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
4180 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
4185 * Get the disabled state of an item
4187 * This gets the disabled state of the given item.
4189 * @param it The item
4190 * @return The disabled state
4195 elm_genlist_item_disabled_get(const Elm_Genlist_Item *it)
4197 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4198 if (it->delete_me) return EINA_FALSE;
4199 return it->disabled;
4203 * Sets the display only state of an item.
4205 * A display only item cannot be selected or unselected. It is for
4206 * display only and not selecting or otherwise clicking, dragging
4207 * etc. by the user, thus finger size rules will not be applied to
4210 * @param it The item
4211 * @param display_only The display only state
4216 elm_genlist_item_display_only_set(Elm_Genlist_Item *it,
4217 Eina_Bool display_only)
4219 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4220 if (!it->block) return;
4221 if (it->display_only == display_only) return;
4222 if (it->delete_me) return;
4223 it->display_only = display_only;
4224 it->mincalcd = EINA_FALSE;
4225 it->updateme = EINA_TRUE;
4226 it->block->updateme = EINA_TRUE;
4227 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4228 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4232 * Get the display only state of an item
4234 * This gets the display only state of the given item.
4236 * @param it The item
4237 * @return The display only state
4242 elm_genlist_item_display_only_get(const Elm_Genlist_Item *it)
4244 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
4245 if (it->delete_me) return EINA_FALSE;
4246 return it->display_only;
4250 * Show the given item
4252 * This causes genlist to jump to the given item @p it and show it (by
4253 * scrolling), if it is not fully visible.
4255 * @param it The item
4260 elm_genlist_item_show(Elm_Genlist_Item *it)
4262 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4263 Evas_Coord gith = 0;
4264 if (it->delete_me) return;
4265 if ((it->queued) || (!it->mincalcd))
4267 it->wd->show_item = it;
4268 it->wd->bring_in = EINA_TRUE;
4269 it->showme = EINA_TRUE;
4272 if (it->wd->show_item)
4274 it->wd->show_item->showme = EINA_FALSE;
4275 it->wd->show_item = NULL;
4277 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4278 gith = it->group_item->h;
4279 elm_smart_scroller_child_region_show(it->wd->scr,
4280 it->x + it->block->x,
4281 it->y + it->block->y - gith,
4282 it->block->w, it->h);
4286 * Bring in the given item
4288 * This causes genlist to jump to the given item @p it and show it (by
4289 * scrolling), if it is not fully visible. This may use animation to
4290 * do so and take a period of time
4292 * @param it The item
4297 elm_genlist_item_bring_in(Elm_Genlist_Item *it)
4299 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4300 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 if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y)))
4315 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,
4319 it->block->w, it->h);
4323 * Show the given item at the top
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_top_show(Elm_Genlist_Item *it)
4335 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4337 Evas_Coord gith = 0;
4339 if (it->delete_me) return;
4340 if ((it->queued) || (!it->mincalcd))
4342 it->wd->show_item = it;
4343 it->wd->bring_in = EINA_TRUE;
4344 it->showme = EINA_TRUE;
4347 if (it->wd->show_item)
4349 it->wd->show_item->showme = EINA_FALSE;
4350 it->wd->show_item = NULL;
4352 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4353 if (it->group_item) gith = it->group_item->h;
4354 elm_smart_scroller_child_region_show(it->wd->scr,
4355 it->x + it->block->x,
4356 it->y + it->block->y - gith,
4361 * Bring in the given item at the top
4363 * This causes genlist to jump to the given item @p it and show it (by
4364 * scrolling), if it is not fully visible. This may use animation to
4365 * do so and take a period of time
4367 * @param it The item
4372 elm_genlist_item_top_bring_in(Elm_Genlist_Item *it)
4374 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4376 Evas_Coord gith = 0;
4378 if (it->delete_me) return;
4379 if ((it->queued) || (!it->mincalcd))
4381 it->wd->show_item = it;
4382 it->wd->bring_in = EINA_TRUE;
4383 it->showme = EINA_TRUE;
4386 if (it->wd->show_item)
4388 it->wd->show_item->showme = EINA_FALSE;
4389 it->wd->show_item = NULL;
4391 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4392 if (it->group_item) gith = it->group_item->h;
4393 elm_smart_scroller_region_bring_in(it->wd->scr,
4394 it->x + it->block->x,
4395 it->y + it->block->y - gith,
4400 * Show the given item at the middle
4402 * This causes genlist to jump to the given item @p it and show it (by
4403 * scrolling), if it is not fully visible.
4405 * @param it The item
4410 elm_genlist_item_middle_show(Elm_Genlist_Item *it)
4412 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4415 if (it->delete_me) return;
4416 if ((it->queued) || (!it->mincalcd))
4418 it->wd->show_item = it;
4419 it->wd->bring_in = EINA_TRUE;
4420 it->showme = EINA_TRUE;
4423 if (it->wd->show_item)
4425 it->wd->show_item->showme = EINA_FALSE;
4426 it->wd->show_item = NULL;
4428 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4429 elm_smart_scroller_child_region_show(it->wd->scr,
4430 it->x + it->block->x,
4431 it->y + it->block->y - oh / 2 +
4432 it->h / 2, it->block->w, oh);
4436 * Bring in the given item at the middle
4438 * This causes genlist to jump to the given item @p it and show it (by
4439 * scrolling), if it is not fully visible. This may use animation to
4440 * do so and take a period of time
4442 * @param it The item
4447 elm_genlist_item_middle_bring_in(Elm_Genlist_Item *it)
4449 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4452 if (it->delete_me) return;
4453 if ((it->queued) || (!it->mincalcd))
4455 it->wd->show_item = it;
4456 it->wd->bring_in = EINA_TRUE;
4457 it->showme = EINA_TRUE;
4460 if (it->wd->show_item)
4462 it->wd->show_item->showme = EINA_FALSE;
4463 it->wd->show_item = NULL;
4465 evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh);
4466 elm_smart_scroller_region_bring_in(it->wd->scr,
4467 it->x + it->block->x,
4468 it->y + it->block->y - oh / 2 + it->h / 2,
4473 * Delete a given item
4475 * This deletes the item from genlist and calls the genlist item del
4476 * class callback defined in the item class, if it is set. This clears all
4477 * subitems if it is a tree.
4479 * @param it The item
4484 elm_genlist_item_del(Elm_Genlist_Item *it)
4486 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4487 if ((it->relcount > 0) || (it->walking > 0))
4489 elm_widget_item_pre_notify_del(it);
4490 elm_genlist_item_subitems_clear(it);
4491 it->delete_me = EINA_TRUE;
4492 if (it->wd->show_item == it) it->wd->show_item = NULL;
4494 it->wd->selected = eina_list_remove(it->wd->selected,
4498 if (it->realized) _item_unrealize(it);
4499 if (it->effect_item_realized) _effect_item_unrealize(it);
4500 it->block->changed = EINA_TRUE;
4501 if (it->wd->calc_job) ecore_job_del(it->wd->calc_job);
4502 it->wd->calc_job = ecore_job_add(_calc_job, it->wd);
4504 // if (it->itc->func.del)
4505 // it->itc->func.del((void *)it->base.data, it->base.widget);
4512 * Set the data item from the genlist item
4514 * This set the data value passed on the elm_genlist_item_append() and
4515 * related item addition calls. This function will also call
4516 * elm_genlist_item_update() so the item will be updated to reflect the
4519 * @param it The item
4520 * @param data The new data pointer to set
4525 elm_genlist_item_data_set(Elm_Genlist_Item *it,
4528 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4529 elm_widget_item_data_set(it, data);
4530 elm_genlist_item_update(it);
4534 * Get the data item from the genlist item
4536 * This returns the data value passed on the elm_genlist_item_append()
4537 * and related item addition calls and elm_genlist_item_data_set().
4539 * @param it The item
4540 * @return The data pointer provided when created
4545 elm_genlist_item_data_get(const Elm_Genlist_Item *it)
4547 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4548 return elm_widget_item_data_get(it);
4552 * Tells genlist to "orphan" icons fetchs by the item class
4554 * This instructs genlist to release references to icons in the item,
4555 * meaning that they will no longer be managed by genlist and are
4556 * floating "orphans" that can be re-used elsewhere if the user wants
4559 * @param it The item
4564 elm_genlist_item_icons_orphan(Elm_Genlist_Item *it)
4567 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4568 EINA_LIST_FREE(it->icon_objs, icon)
4570 elm_widget_sub_object_del(it->base.widget, icon);
4571 evas_object_smart_member_del(icon);
4572 evas_object_hide(icon);
4577 * Get the real evas object of the genlist item
4579 * This returns the actual evas object used for the specified genlist
4580 * item. This may be NULL as it may not be created, and may be deleted
4581 * at any time by genlist. Do not modify this object (move, resize,
4582 * show, hide etc.) as genlist is controlling it. This function is for
4583 * querying, emitting custom signals or hooking lower level callbacks
4584 * for events. Do not delete this object under any circumstances.
4586 * @param it The item
4587 * @return The object pointer
4591 EAPI const Evas_Object *
4592 elm_genlist_item_object_get(const Elm_Genlist_Item *it)
4594 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
4595 return it->base.view;
4599 * Update the contents of an item
4601 * This updates an item by calling all the item class functions again
4602 * to get the icons, labels and states. Use this when the original
4603 * item data has changed and the changes are desired to be reflected.
4605 * @param it The item
4610 elm_genlist_item_update(Elm_Genlist_Item *it)
4612 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4613 if (!it->block) return;
4614 if (it->delete_me) return;
4615 it->mincalcd = EINA_FALSE;
4616 it->updateme = EINA_TRUE;
4617 it->block->updateme = EINA_TRUE;
4618 if (it->wd->update_job) ecore_job_del(it->wd->update_job);
4619 it->wd->update_job = ecore_job_add(_update_job, it->wd);
4623 * Update the item class of an item
4625 * @param it The item
4626 * @parem itc The item class for the item
4631 elm_genlist_item_item_class_update(Elm_Genlist_Item *it,
4632 const Elm_Genlist_Item_Class *itc)
4634 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
4635 if (!it->block) return;
4636 EINA_SAFETY_ON_NULL_RETURN(itc);
4637 if (it->delete_me) return;
4639 it->nocache = EINA_TRUE;
4640 elm_genlist_item_update(it);
4643 static Evas_Object *
4644 _elm_genlist_item_label_create(void *data,
4646 void *item __UNUSED__)
4648 Evas_Object *label = elm_label_add(obj);
4651 elm_object_style_set(label, "tooltip");
4652 elm_label_label_set(label, data);
4657 _elm_genlist_item_label_del_cb(void *data,
4658 Evas_Object *obj __UNUSED__,
4659 void *event_info __UNUSED__)
4661 eina_stringshare_del(data);
4665 * Set the text to be shown in the genlist item.
4667 * @param item Target item
4668 * @param text The text to set in the content
4670 * Setup the text as tooltip to object. The item can have only one
4671 * tooltip, so any previous tooltip data is removed.
4676 elm_genlist_item_tooltip_text_set(Elm_Genlist_Item *item,
4679 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4680 text = eina_stringshare_add(text);
4681 elm_genlist_item_tooltip_content_cb_set(item, _elm_genlist_item_label_create,
4683 _elm_genlist_item_label_del_cb);
4687 * Set the content to be shown in the tooltip item
4689 * Setup the tooltip to item. The item can have only one tooltip, so
4690 * any previous tooltip data is removed. @p func(with @p data) will be
4691 * called every time that need to show the tooltip and it should return a
4692 * valid Evas_Object. This object is then managed fully by tooltip
4693 * system and is deleted when the tooltip is gone.
4695 * @param item the genlist item being attached by a tooltip.
4696 * @param func the function used to create the tooltip contents.
4697 * @param data what to provide to @a func as callback data/context.
4698 * @param del_cb called when data is not needed anymore, either when
4699 * another callback replaces @func, the tooltip is unset with
4700 * elm_genlist_item_tooltip_unset() or the owner @a item
4701 * dies. This callback receives as the first parameter the
4702 * given @a data, and @c event_info is the item.
4707 elm_genlist_item_tooltip_content_cb_set(Elm_Genlist_Item *item,
4708 Elm_Tooltip_Item_Content_Cb func,
4710 Evas_Smart_Cb del_cb)
4712 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_GOTO(item, error);
4714 if ((item->tooltip.content_cb == func) && (item->tooltip.data == data))
4717 if (item->tooltip.del_cb)
4718 item->tooltip.del_cb((void *)item->tooltip.data,
4719 item->base.widget, item);
4721 item->tooltip.content_cb = func;
4722 item->tooltip.data = data;
4723 item->tooltip.del_cb = del_cb;
4725 if (item->base.view)
4727 elm_widget_item_tooltip_content_cb_set(item,
4728 item->tooltip.content_cb,
4729 item->tooltip.data, NULL);
4730 elm_widget_item_tooltip_style_set(item, item->tooltip.style);
4736 if (del_cb) del_cb((void *)data, NULL, NULL);
4740 * Unset tooltip from item
4742 * @param item genlist item to remove previously set tooltip.
4744 * Remove tooltip from item. The callback provided as del_cb to
4745 * elm_genlist_item_tooltip_content_cb_set() will be called to notify
4746 * it is not used anymore.
4748 * @see elm_genlist_item_tooltip_content_cb_set()
4753 elm_genlist_item_tooltip_unset(Elm_Genlist_Item *item)
4755 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4756 if ((item->base.view) && (item->tooltip.content_cb))
4757 elm_widget_item_tooltip_unset(item);
4759 if (item->tooltip.del_cb)
4760 item->tooltip.del_cb((void *)item->tooltip.data, item->base.widget, item);
4761 item->tooltip.del_cb = NULL;
4762 item->tooltip.content_cb = NULL;
4763 item->tooltip.data = NULL;
4764 if (item->tooltip.style)
4765 elm_genlist_item_tooltip_style_set(item, NULL);
4769 * Sets a different style for this item tooltip.
4771 * @note before you set a style you should define a tooltip with
4772 * elm_genlist_item_tooltip_content_cb_set() or
4773 * elm_genlist_item_tooltip_text_set()
4775 * @param item genlist item with tooltip already set.
4776 * @param style the theme style to use (default, transparent, ...)
4781 elm_genlist_item_tooltip_style_set(Elm_Genlist_Item *item,
4784 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4785 eina_stringshare_replace(&item->tooltip.style, style);
4786 if (item->base.view) elm_widget_item_tooltip_style_set(item, style);
4790 * Get the style for this item tooltip.
4792 * @param item genlist item with tooltip already set.
4793 * @return style the theme style in use, defaults to "default". If the
4794 * object does not have a tooltip set, then NULL is returned.
4799 elm_genlist_item_tooltip_style_get(const Elm_Genlist_Item *item)
4801 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4802 return item->tooltip.style;
4806 * Set the cursor to be shown when mouse is over the genlist item
4808 * @param item Target item
4809 * @param cursor the cursor name to be used.
4811 * @see elm_object_cursor_set()
4815 elm_genlist_item_cursor_set(Elm_Genlist_Item *item,
4818 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4819 eina_stringshare_replace(&item->mouse_cursor, cursor);
4820 if (item->base.view) elm_widget_item_cursor_set(item, cursor);
4824 * Get the cursor to be shown when mouse is over the genlist item
4826 * @param item genlist item with cursor already set.
4827 * @return the cursor name.
4832 elm_genlist_item_cursor_get(const Elm_Genlist_Item *item)
4834 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4835 return elm_widget_item_cursor_get(item);
4839 * Unset the cursor to be shown when mouse is over the genlist item
4841 * @param item Target item
4843 * @see elm_object_cursor_unset()
4847 elm_genlist_item_cursor_unset(Elm_Genlist_Item *item)
4849 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4850 if (!item->mouse_cursor)
4853 if (item->base.view)
4854 elm_widget_item_cursor_unset(item);
4856 eina_stringshare_del(item->mouse_cursor);
4857 item->mouse_cursor = NULL;
4861 * Sets a different style for this item cursor.
4863 * @note before you set a style you should define a cursor with
4864 * elm_genlist_item_cursor_set()
4866 * @param item genlist item with cursor already set.
4867 * @param style the theme style to use (default, transparent, ...)
4872 elm_genlist_item_cursor_style_set(Elm_Genlist_Item *item,
4875 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4876 elm_widget_item_cursor_style_set(item, style);
4880 * Get the style for this item cursor.
4882 * @param item genlist item with cursor already set.
4883 * @return style the theme style in use, defaults to "default". If the
4884 * object does not have a cursor set, then NULL is returned.
4889 elm_genlist_item_cursor_style_get(const Elm_Genlist_Item *item)
4891 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
4892 return elm_widget_item_cursor_style_get(item);
4896 * Set if the cursor set should be searched on the theme or should use
4897 * the provided by the engine, only.
4899 * @note before you set if should look on theme you should define a
4900 * cursor with elm_object_cursor_set(). By default it will only look
4901 * for cursors provided by the engine.
4903 * @param item widget item with cursor already set.
4904 * @param engine_only boolean to define it cursors should be looked
4905 * only between the provided by the engine or searched on widget's
4911 elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item,
4912 Eina_Bool engine_only)
4914 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
4915 elm_widget_item_cursor_engine_only_set(item, engine_only);
4919 * Get the cursor engine only usage for this item cursor.
4921 * @param item widget item with cursor already set.
4922 * @return engine_only boolean to define it cursors should be looked
4923 * only between the provided by the engine or searched on widget's
4924 * theme as well. If the object does not have a cursor set, then
4925 * EINA_FALSE is returned.
4930 elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item)
4932 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
4933 return elm_widget_item_cursor_engine_only_get(item);
4937 * This sets the horizontal stretching mode
4939 * This sets the mode used for sizing items horizontally. Valid modes
4940 * are ELM_LIST_LIMIT and ELM_LIST_SCROLL. The default is
4941 * ELM_LIST_SCROLL. This mode means that if items are too wide to fit,
4942 * the scroller will scroll horizontally. Otherwise items are expanded
4943 * to fill the width of the viewport of the scroller. If it is
4944 * ELM_LIST_LIMIT, Items will be expanded to the viewport width and
4945 * limited to that size.
4947 * @param obj The genlist object
4948 * @param mode The mode to use
4953 elm_genlist_horizontal_mode_set(Evas_Object *obj,
4956 ELM_CHECK_WIDTYPE(obj, widtype);
4957 Widget_Data *wd = elm_widget_data_get(obj);
4959 if (wd->mode == mode) return;
4965 * Gets the horizontal stretching mode
4967 * @param obj The genlist object
4968 * @return The mode to use
4969 * (ELM_LIST_LIMIT, ELM_LIST_SCROLL)
4974 elm_genlist_horizontal_mode_get(const Evas_Object *obj)
4976 ELM_CHECK_WIDTYPE(obj, widtype) ELM_LIST_LAST;
4977 Widget_Data *wd = elm_widget_data_get(obj);
4978 if (!wd) return ELM_LIST_LAST;
4983 * Set the always select mode.
4985 * Items will only call their selection func and callback when first
4986 * becoming selected. Any further clicks will do nothing, unless you
4987 * enable always select with elm_genlist_always_select_mode_set().
4988 * This means even if selected, every click will make the selected
4989 * callbacks be called.
4991 * @param obj The genlist object
4992 * @param always_select The always select mode
4993 * (EINA_TRUE = on, EINA_FALSE = off)
4998 elm_genlist_always_select_mode_set(Evas_Object *obj,
4999 Eina_Bool always_select)
5001 ELM_CHECK_WIDTYPE(obj, widtype);
5002 Widget_Data *wd = elm_widget_data_get(obj);
5004 wd->always_select = always_select;
5008 * Get the always select mode.
5010 * @param obj The genlist object
5011 * @return The always select mode
5012 * (EINA_TRUE = on, EINA_FALSE = off)
5017 elm_genlist_always_select_mode_get(const Evas_Object *obj)
5019 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5020 Widget_Data *wd = elm_widget_data_get(obj);
5021 if (!wd) return EINA_FALSE;
5022 return wd->always_select;
5026 * Set no select mode
5028 * This will turn off the ability to select items entirely and they
5029 * will neither appear selected nor call selected callback functions.
5031 * @param obj The genlist object
5032 * @param no_select The no select mode
5033 * (EINA_TRUE = on, EINA_FALSE = off)
5038 elm_genlist_no_select_mode_set(Evas_Object *obj,
5039 Eina_Bool no_select)
5041 ELM_CHECK_WIDTYPE(obj, widtype);
5042 Widget_Data *wd = elm_widget_data_get(obj);
5044 wd->no_select = no_select;
5048 * Gets no select mode
5050 * @param obj The genlist object
5051 * @return The no select mode
5052 * (EINA_TRUE = on, EINA_FALSE = off)
5057 elm_genlist_no_select_mode_get(const Evas_Object *obj)
5059 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5060 Widget_Data *wd = elm_widget_data_get(obj);
5061 if (!wd) return EINA_FALSE;
5062 return wd->no_select;
5068 * This will enable the compress mode where items are "compressed"
5069 * horizontally to fit the genlist scrollable viewport width. This is
5070 * special for genlist. Do not rely on
5071 * elm_genlist_horizontal_mode_set() being set to ELM_LIST_COMPRESS to
5072 * work as genlist needs to handle it specially.
5074 * @param obj The genlist object
5075 * @param compress The compress mode
5076 * (EINA_TRUE = on, EINA_FALSE = off)
5081 elm_genlist_compress_mode_set(Evas_Object *obj,
5084 ELM_CHECK_WIDTYPE(obj, widtype);
5085 Widget_Data *wd = elm_widget_data_get(obj);
5087 wd->compress = compress;
5091 * Get the compress mode
5093 * @param obj The genlist object
5094 * @return The compress mode
5095 * (EINA_TRUE = on, EINA_FALSE = off)
5100 elm_genlist_compress_mode_get(const Evas_Object *obj)
5102 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5103 Widget_Data *wd = elm_widget_data_get(obj);
5104 if (!wd) return EINA_FALSE;
5105 return wd->compress;
5109 * Set height-for-width mode
5111 * With height-for-width mode the item width will be fixed (restricted
5112 * to a minimum of) to the list width when calculating its size in
5113 * order to allow the height to be calculated based on it. This allows,
5114 * for instance, text block to wrap lines if the Edje part is
5115 * configured with "text.min: 0 1".
5117 * @note This mode will make list resize slower as it will have to
5118 * recalculate every item height again whenever the list width
5121 * @note When height-for-width mode is enabled, it also enables
5122 * compress mode (see elm_genlist_compress_mode_set()) and
5123 * disables homogeneous (see elm_genlist_homogeneous_set()).
5125 * @param obj The genlist object
5126 * @param setting The height-for-width mode (EINA_TRUE = on,
5132 elm_genlist_height_for_width_mode_set(Evas_Object *obj,
5133 Eina_Bool height_for_width)
5135 ELM_CHECK_WIDTYPE(obj, widtype);
5136 Widget_Data *wd = elm_widget_data_get(obj);
5138 wd->height_for_width = !!height_for_width;
5139 if (wd->height_for_width)
5141 elm_genlist_homogeneous_set(obj, EINA_FALSE);
5142 elm_genlist_compress_mode_set(obj, EINA_TRUE);
5147 * Get the height-for-width mode
5149 * @param obj The genlist object
5150 * @return The height-for-width mode (EINA_TRUE = on, EINA_FALSE =
5156 elm_genlist_height_for_width_mode_get(const Evas_Object *obj)
5158 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5159 Widget_Data *wd = elm_widget_data_get(obj);
5160 if (!wd) return EINA_FALSE;
5161 return wd->height_for_width;
5167 * This will enable or disable the scroller bounce mode for the
5168 * genlist. See elm_scroller_bounce_set() for details
5170 * @param obj The genlist object
5171 * @param h_bounce Allow bounce horizontally
5172 * @param v_bounce Allow bounce vertically
5177 elm_genlist_bounce_set(Evas_Object *obj,
5181 ELM_CHECK_WIDTYPE(obj, widtype);
5182 Widget_Data *wd = elm_widget_data_get(obj);
5184 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
5188 * Get the bounce mode
5190 * @param obj The genlist object
5191 * @param h_bounce Allow bounce horizontally
5192 * @param v_bounce Allow bounce vertically
5197 elm_genlist_bounce_get(const Evas_Object *obj,
5198 Eina_Bool *h_bounce,
5199 Eina_Bool *v_bounce)
5201 ELM_CHECK_WIDTYPE(obj, widtype);
5202 Widget_Data *wd = elm_widget_data_get(obj);
5204 elm_smart_scroller_bounce_allow_get(obj, h_bounce, v_bounce);
5208 * Set homogenous mode
5210 * This will enable the homogeneous mode where items are of the same
5211 * height and width so that genlist may do the lazy-loading at its
5212 * maximum. This implies 'compressed' mode.
5214 * @param obj The genlist object
5215 * @param homogeneous Assume the items within the genlist are of the
5216 * same height and width (EINA_TRUE = on, EINA_FALSE = off)
5221 elm_genlist_homogeneous_set(Evas_Object *obj,
5222 Eina_Bool homogeneous)
5224 ELM_CHECK_WIDTYPE(obj, widtype);
5225 Widget_Data *wd = elm_widget_data_get(obj);
5227 if (homogeneous) elm_genlist_compress_mode_set(obj, EINA_TRUE);
5228 wd->homogeneous = homogeneous;
5232 * Get the homogenous mode
5234 * @param obj The genlist object
5235 * @return Assume the items within the genlist are of the same height
5236 * and width (EINA_TRUE = on, EINA_FALSE = off)
5241 elm_genlist_homogeneous_get(const Evas_Object *obj)
5243 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5244 Widget_Data *wd = elm_widget_data_get(obj);
5245 if (!wd) return EINA_FALSE;
5246 return wd->homogeneous;
5250 * Set the maximum number of items within an item block
5252 * This will configure the block count to tune to the target with
5253 * particular performance matrix.
5255 * @param obj The genlist object
5256 * @param n Maximum number of items within an item block
5261 elm_genlist_block_count_set(Evas_Object *obj,
5264 ELM_CHECK_WIDTYPE(obj, widtype);
5265 Widget_Data *wd = elm_widget_data_get(obj);
5267 wd->max_items_per_block = n;
5268 wd->item_cache_max = wd->max_items_per_block * 2;
5269 _item_cache_clean(wd);
5273 * Get the maximum number of items within an item block
5275 * @param obj The genlist object
5276 * @return Maximum number of items within an item block
5281 elm_genlist_block_count_get(const Evas_Object *obj)
5283 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5284 Widget_Data *wd = elm_widget_data_get(obj);
5286 return wd->max_items_per_block;
5290 * Set the timeout in seconds for the longpress event
5292 * @param obj The genlist object
5293 * @param timeout timeout in seconds
5298 elm_genlist_longpress_timeout_set(Evas_Object *obj,
5301 ELM_CHECK_WIDTYPE(obj, widtype);
5302 Widget_Data *wd = elm_widget_data_get(obj);
5304 wd->longpress_timeout = timeout;
5308 * Get the timeout in seconds for the longpress event
5310 * @param obj The genlist object
5311 * @return timeout in seconds
5316 elm_genlist_longpress_timeout_get(const Evas_Object *obj)
5318 ELM_CHECK_WIDTYPE(obj, widtype) 0;
5319 Widget_Data *wd = elm_widget_data_get(obj);
5321 return wd->longpress_timeout;
5325 * Set the scrollbar policy
5327 * This sets the scrollbar visibility policy for the given genlist
5328 * scroller. ELM_SMART_SCROLLER_POLICY_AUTO means the scrollbar is
5329 * made visible if it is needed, and otherwise kept hidden.
5330 * ELM_SMART_SCROLLER_POLICY_ON turns it on all the time, and
5331 * ELM_SMART_SCROLLER_POLICY_OFF always keeps it off. This applies
5332 * respectively for the horizontal and vertical scrollbars.
5334 * @param obj The genlist object
5335 * @param policy_h Horizontal scrollbar policy
5336 * @param policy_v Vertical scrollbar policy
5341 elm_genlist_scroller_policy_set(Evas_Object *obj,
5342 Elm_Scroller_Policy policy_h,
5343 Elm_Scroller_Policy policy_v)
5345 ELM_CHECK_WIDTYPE(obj, widtype);
5346 Widget_Data *wd = elm_widget_data_get(obj);
5348 if ((policy_h >= ELM_SCROLLER_POLICY_LAST) ||
5349 (policy_v >= ELM_SCROLLER_POLICY_LAST))
5352 elm_smart_scroller_policy_set(wd->scr, policy_h, policy_v);
5356 * Get the scrollbar policy
5358 * @param obj The genlist object
5359 * @param policy_h Horizontal scrollbar policy
5360 * @param policy_v Vertical scrollbar policy
5365 elm_genlist_scroller_policy_get(const Evas_Object *obj,
5366 Elm_Scroller_Policy *policy_h,
5367 Elm_Scroller_Policy *policy_v)
5369 ELM_CHECK_WIDTYPE(obj, widtype);
5370 Widget_Data *wd = elm_widget_data_get(obj);
5371 Elm_Smart_Scroller_Policy s_policy_h, s_policy_v;
5372 if ((!wd) || (!wd->scr)) return;
5373 elm_smart_scroller_policy_get(wd->scr, &s_policy_h, &s_policy_v);
5374 if (policy_h) *policy_h = (Elm_Scroller_Policy)s_policy_h;
5375 if (policy_v) *policy_v = (Elm_Scroller_Policy)s_policy_v;
5378 /****************************************************************************/
5383 * @param obj The genlist object
5384 * @param reorder_mode The reorder mode
5385 * (EINA_TRUE = on, EINA_FALSE = off)
5390 elm_genlist_reorder_mode_set(Evas_Object *obj,
5391 Eina_Bool reorder_mode)
5393 ELM_CHECK_WIDTYPE(obj, widtype);
5394 Widget_Data *wd = elm_widget_data_get(obj);
5396 wd->reorder_mode = reorder_mode;
5400 * Get the reorder mode
5402 * @param obj The genlist object
5403 * @return The reorder mode
5404 * (EINA_TRUE = on, EINA_FALSE = off)
5409 elm_genlist_reorder_mode_get(const Evas_Object *obj)
5411 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
5412 Widget_Data *wd = elm_widget_data_get(obj);
5413 if (!wd) return EINA_FALSE;
5414 return wd->reorder_mode;
5418 elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5424 elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5430 _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
5435 if (it->wd->ed->ec->move)
5436 it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE);
5438 // printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1);
5439 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5440 _item_block_del(it);
5442 it->wd->items = eina_inlist_append_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(after));
5444 it->rel->relcount++;
5445 it->before = EINA_FALSE;
5446 _item_queue(it->wd, it);
5450 _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before)
5453 if (!before) return;
5455 if (it->wd->ed->ec->move)
5456 it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE);
5458 // printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1);
5459 it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it));
5460 _item_block_del(it);
5461 it->wd->items = eina_inlist_prepend_relative(it->wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(before));
5463 it->rel->relcount++;
5464 it->before = EINA_TRUE;
5465 _item_queue(it->wd, it);
5469 elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode)
5471 ELM_CHECK_WIDTYPE(obj, widtype);
5472 Widget_Data *wd = elm_widget_data_get(obj);
5474 wd->effect_mode = emode;
5475 // wd->point_rect = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5476 // evas_object_resize(wd->point_rect, 10, 25);
5477 // evas_object_color_set(wd->point_rect, 255, 0, 0, 130);
5478 // evas_object_show(wd->point_rect);
5479 // evas_object_hide(wd->point_rect);
5483 _create_tray_alpha_bg(const Evas_Object *obj)
5485 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
5486 Widget_Data *wd = elm_widget_data_get(obj);
5487 if (!wd) return NULL;
5489 Evas_Object *bg = NULL;
5490 Evas_Coord ox, oy, ow, oh;
5492 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5493 bg = evas_object_rectangle_add(evas_object_evas_get(wd->obj));
5494 evas_object_color_set(bg,0,0,0,0);
5495 evas_object_resize(bg , ow, oh);
5496 evas_object_move(bg , ox, oy);
5497 evas_object_show(bg);
5498 evas_object_hide(bg);
5505 struct timeval timev;
5507 gettimeofday(&timev, NULL);
5508 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
5511 // added for item moving animation.
5513 _item_moving_effect_timer_cb(void *data)
5515 Widget_Data *wd = data;
5516 if (!wd) return EINA_FALSE;
5518 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh;
5519 Elm_Genlist_Item *it, *it2;
5521 double time = 0.4, t;
5523 Eina_Bool check, end = EINA_FALSE;
5524 // static Eina_Bool first = EINA_TRUE;
5527 t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
5529 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
5530 evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
5532 EINA_INLIST_FOREACH(wd->blocks, itb)
5535 if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox,
5536 itb->y - wd->pan_y + oy,
5538 cvx, cvy, cvw, cvh))
5540 EINA_LIST_FOREACH(itb->items, l, it)
5545 if(it2->parent == wd->expand_item) check = EINA_TRUE;
5550 // printf("item : %p - ", it);
5553 //printf(" s: %d %d ", oy, oh);
5554 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5555 dy = it->scrl_y - it->old_scrl_y;
5556 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5558 // printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
5559 if(wd->expand_item_end < it->old_scrl_y)
5560 dy = wd->expand_item_gap;
5562 // printf(" dy - %d -", dy);
5564 y = (1 * sin((t / time) * (M_PI / 2)) * dy);
5570 //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);
5572 if (!it->old_scrl_y)
5573 it->old_scrl_y = it->scrl_y;
5576 //printf(" %d | ", it->old_scrl_y + y);
5577 if (it->old_scrl_y + y < oy + oh)
5579 // printf("%p in pan | ", it);
5580 //if (!it->realized) printf("%p is not realized %d :: \n", it, it->old_scrl_y + y);
5582 if (!it->realized) _item_realize(it, in, 0);
5584 /* else if(first && wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5586 printf("1 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5587 it->old_scrl_y = it->old_scrl_y - ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5588 wd->expand_item_gap = wd->expand_item_gap + ((wd->expand_item_end - wd->expand_item_gap) - (oy + oh));
5589 printf("2 . %p ::%d %d %d\n", it, it->old_scrl_y, (wd->expand_item_end + wd->expand_item_gap) , (oy + oh));
5593 // printf("%p :: %d\n", it, it->old_scrl_y + y);
5594 evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h);
5595 evas_object_move(it->base.view, it->scrl_x+it->pad_left, it->old_scrl_y + y);
5596 evas_object_show(it->base.view);
5597 evas_object_raise(it->base.view);
5599 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5601 it2 = elm_genlist_item_prev_get(it);
5604 if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5606 if(!it2->effect_done)
5608 //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5609 evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
5610 evas_object_show(it2->base.view);
5611 it2->effect_done = EINA_TRUE;
5615 it2 = elm_genlist_item_prev_get(it2);
5618 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5620 it2 = elm_genlist_item_prev_get(it);
5623 if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
5625 if(!it2->effect_done)
5627 edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
5628 it2->effect_done = EINA_TRUE;
5633 it2 = elm_genlist_item_prev_get(it2);
5639 // first = EINA_FALSE;
5643 if (wd->item_moving_effect_timer)
5645 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5646 _item_subitems_clear(wd->expand_item);
5647 wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_NONE;
5648 EINA_INLIST_FOREACH(wd->blocks, itb)
5650 EINA_LIST_FOREACH(itb->items, l, it)
5652 it->effect_done = EINA_TRUE;
5653 it->list_expanded = 0;
5654 it->old_scrl_y = it->scrl_y;
5658 //evas_render(evas_object_evas_get(wd->obj));
5659 wd->item_moving_effect_timer = NULL;
5660 // first = EINA_TRUE;
5662 _item_auto_scroll(wd);
5663 evas_object_lower(wd->alpha_bg);
5664 evas_object_hide(wd->alpha_bg);
5666 if (wd->calc_job) ecore_job_del(wd->calc_job);
5667 wd->calc_job = ecore_job_add(_calc_job, wd);
5668 return ECORE_CALLBACK_CANCEL;
5670 return ECORE_CALLBACK_RENEW;
5674 _emit_contract(Elm_Genlist_Item *it)
5676 Elm_Genlist_Item *it2;
5679 // printf("%p is emited contract\n", it);
5680 edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
5681 it->effect_done = EINA_FALSE;
5683 EINA_LIST_FOREACH(it->items, l, it2)
5685 _emit_contract(it2);
5688 // added for item moving animation.
5690 _item_flip_effect_show(Elm_Genlist_Item *it)
5692 Elm_Genlist_Item *it2;
5694 Widget_Data *wd = it->wd;
5695 Eina_Bool check = EINA_FALSE;
5697 it2 = elm_genlist_item_next_get(it);
5700 if(it2->expanded_depth <= it->expanded_depth) check = EINA_TRUE;
5701 it2 = elm_genlist_item_next_get(it2);
5703 EINA_LIST_FOREACH(it->items, l, it2)
5705 if (it2->parent && it == it2->parent)
5707 if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
5709 // edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
5710 edje_object_signal_emit(it2->base.view, "flip_item", "");
5712 evas_object_move(it2->base.view, -9999, -9999);
5714 evas_object_show(it2->base.view);
5716 else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
5717 _emit_contract(it2);
5721 return ECORE_CALLBACK_CANCEL;
5726 _elm_genlist_pinch_zoom_execute(Evas_Object *obj, Eina_Bool emode)
5728 printf("!!! NOW FIXING \n");
5733 * Set pinch zoom mode
5735 * @param obj The genlist object
5737 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5742 elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode)
5744 printf("!!! NOW FIXING \n");
5748 * Get pinch zoom mode
5750 * @param obj The genlist object
5751 * @return The pinch mode
5752 * (EINA_TRUE = pinch contract (zoom in), EINA_FALSE = pinch expand (zoom out)
5757 elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj)
5759 printf("!!! NOW FIXING \n");
5764 elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode)
5766 printf("!!! NOW FIXING \n");
5770 ////////////////////////////////////////////////////////////////////////
5772 ////////////////////////////////////////////////////////////////////////
5774 _effect_item_update(Elm_Genlist_Item *it)
5776 if (it->edit_select_check)
5778 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5782 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5787 _edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state)
5790 if (edit_select_check_state)
5792 it->edit_select_check = EINA_TRUE;
5793 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5797 it->edit_select_check = EINA_FALSE;
5798 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5800 if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5801 it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5805 _edit_subitems_checkbox_set(Elm_Genlist_Item *it)
5808 Eina_List *tl = NULL, *l;
5809 Elm_Genlist_Item *it2;
5811 EINA_LIST_FOREACH(it->items, l, it2)
5812 tl = eina_list_append(tl, it2);
5813 EINA_LIST_FREE(tl, it2)
5814 if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check);
5818 _edit_parent_items_checkbox_set(Elm_Genlist_Item *it)
5821 Elm_Genlist_Item *tmp_it;
5822 Eina_Bool parent_check = EINA_TRUE;
5824 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5826 if (tmp_it->parent && it->parent)
5827 if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE;
5831 if (parent_check) it->parent->edit_select_check = EINA_TRUE;
5832 else it->parent->edit_select_check = EINA_FALSE;
5837 _effect_item_update(it->parent);
5838 return _edit_parent_items_checkbox_set(it->parent);
5843 _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items)
5845 if (!select_all_it || !select_all_it->wd) return;
5847 Eina_Bool old_check_state;
5848 Elm_Genlist_Item *it;
5849 Widget_Data *wd = select_all_it->wd;
5851 wd->select_all_check = checked;
5852 if (wd->select_all_check)
5853 edje_object_signal_emit(select_all_it->base.view, "elm,state,del_confirm", "elm");
5855 edje_object_signal_emit(select_all_it->base.view, "elm,state,del,animated,enable", "elm");
5859 EINA_INLIST_FOREACH(wd->items, it)
5861 old_check_state = it->edit_select_check;
5862 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
5863 else it->edit_select_check = EINA_FALSE;
5865 // TODO : check this
5866 // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5867 // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check);
5871 if (wd->ed->ec->item_selected)
5872 wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check);
5874 if (wd->calc_job) ecore_job_del(wd->calc_job);
5875 wd->calc_job = ecore_job_add(_calc_job, wd);
5879 _checkbox_item_select_process(Elm_Genlist_Item *it)
5881 Elm_Genlist_Item *tmp_it;
5882 Eina_Bool old_check_state;
5883 int check_cnt = 0, total_cnt = 0;
5886 _edit_item_checkbox_set(it, it->edit_select_check);
5887 _edit_subitems_checkbox_set(it);
5888 _edit_parent_items_checkbox_set(it);
5890 if (it->wd->ed) it->wd->ed->del_item = it;
5892 EINA_INLIST_FOREACH(it->wd->items, tmp_it)
5894 if (tmp_it->edit_select_check) check_cnt++;
5898 if (it->wd->select_all_item)
5900 old_check_state = it->wd->select_all_check;
5901 if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE;
5902 else it->wd->select_all_check = EINA_FALSE;
5904 if (check_cnt == total_cnt)
5906 it->wd->select_all_check = EINA_TRUE;
5907 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del_confirm", "elm");
5911 it->wd->select_all_check = EINA_FALSE;
5912 edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,del,animated,enable", "elm");
5915 if (old_check_state != it->wd->select_all_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected)
5916 it->wd->ed->ec->item_selected(it->wd->select_all_item->base.data, it->wd->select_all_item, it->wd->select_all_check);
5921 _checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
5923 Elm_Genlist_Item *it = data;
5925 it->edit_select_check = !it->edit_select_check;
5926 _checkbox_item_select_process(it);
5930 _select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
5932 Elm_Genlist_Item *select_all_it = data;
5933 Widget_Data *wd = select_all_it->wd;
5936 _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE);
5941 _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity)
5943 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
5945 evas_object_resize(it->edit_obj,it->w, it->h);
5946 evas_object_move(it->edit_obj, itx, ity);
5947 evas_object_raise(it->edit_obj);
5949 if (it->wd->select_all_check)
5950 it->edit_select_check = EINA_TRUE;
5953 if (it->edit_select_check)
5955 edje_object_signal_emit(it->edit_obj, "elm,state,del_confirm", "elm");
5959 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
5965 _effect_item_realize(Elm_Genlist_Item *it)
5967 if ((it->effect_item_realized) || (it->delete_me)) return;
5968 int itmode = 0, pad = 0;
5969 const char *pad_str;
5971 it->pad_left = it->pad_right = 0;
5973 if (it->itc->func.editmode_get)
5974 itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode);
5975 itmode &= it->wd->edit_mode;
5977 if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL)
5978 itmode |= ELM_GENLIST_EDIT_MODE_SELECT;
5980 it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget));
5981 edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) *
5982 _elm_config->scale);
5983 evas_object_smart_member_add(it->edit_obj, it->wd->pan_smart);
5984 elm_widget_sub_object_add(it->base.widget, it->edit_obj);
5986 if (it->flags & ELM_GENLIST_ITEM_SUBITEMS) strncpy(buf, "tree", sizeof(buf));
5987 else strncpy(buf, "item", sizeof(buf));
5988 if (it->wd->compress) strncat(buf, "_compress", sizeof(buf) - strlen(buf));
5990 strncat(buf, "/", sizeof(buf) - strlen(buf));
5992 if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default"))
5994 strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf));
5995 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget));
5999 _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget));
6002 pad_str = edje_object_data_get(it->edit_obj, "icon_width");
6003 if (pad_str) pad = atoi(pad_str);
6005 if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT))
6007 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6008 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
6009 "elm", _checkbox_item_select_cb);
6011 edje_object_signal_callback_add(it->edit_obj, "elm,action,item,delete",
6012 "elm", _checkbox_item_select_cb, it);
6013 it->pad_left += pad * _elm_config->scale;
6017 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6019 edje_object_signal_callback_del(it->edit_obj, "elm,action,item,delete",
6020 "elm", _checkbox_item_select_cb);
6023 if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed))
6025 if (it->itc->func.icon_get)
6030 it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons"));
6031 EINA_LIST_FOREACH(it->icons, l, key)
6033 Evas_Object *ic = it->itc->func.icon_get
6034 (it->base.data, it->base.widget, l->data);
6038 it->edit_icon_objs = eina_list_append(it->edit_icon_objs, ic);
6039 edje_object_part_swallow(it->edit_obj, key, ic);
6040 evas_object_show(ic);
6041 elm_widget_sub_object_add(it->base.widget, ic);
6047 _effect_item_controls(it,it->scrl_x, it->scrl_y);
6048 evas_object_show(it->edit_obj);
6050 it->effect_item_realized = EINA_TRUE;
6051 it->want_unrealize = EINA_FALSE;
6055 _effect_item_unrealize(Elm_Genlist_Item *it)
6059 if (!it->effect_item_realized) return;
6060 if (it->wd->reorder_it && it->wd->reorder_it == it) return;
6062 it->pad_left = it->pad_right = 0;
6063 // evas_object_smart_callback_call(it->edit_obj, "unrealized", it);
6064 // _item_cache_add(it);
6065 evas_object_del(it->edit_obj);
6066 it->edit_obj = NULL;
6067 EINA_LIST_FREE(it->edit_icon_objs, icon)
6068 evas_object_del(icon);
6070 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6071 it->effect_item_realized = EINA_FALSE;
6075 elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6077 fprintf(stderr, "=================> Caution!!! <========================\n");
6078 fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n");
6079 fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n");
6080 fprintf(stderr, "=======================================================\n");
6082 elm_genlist_edit_mode_set(obj, emode, edit_class);
6086 * Set Genlist edit mode
6088 * This sets Genlist edit mode.
6090 * @param obj The Genlist object
6091 * @param emode ELM_GENLIST_EDIT_MODE_{NONE & REORDER & INSERT & DELETE & SELECT & SELECT_ALL}
6092 * @param edit_class Genlist edit class (Elm_Genlist_Edit_Class structure)
6097 elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class)
6099 ELM_CHECK_WIDTYPE(obj, widtype);
6102 Eina_Bool done = EINA_FALSE;
6103 static Elm_Genlist_Item_Class itc;
6105 Elm_Genlist_Item *it;
6107 Widget_Data *wd = elm_widget_data_get(obj);
6109 if (wd->edit_mode == emode) return;
6111 wd->edit_mode = emode;
6113 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6114 wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT;
6117 if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6119 EINA_INLIST_FOREACH(wd->blocks, itb)
6124 EINA_LIST_FOREACH(itb->items, l, it)
6126 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6128 it->pad_left = it->pad_right = 0;
6129 if (it->realized) _effect_item_unrealize(it);
6138 if (wd->ed) free (wd->ed);
6140 wd->reorder_mode = EINA_FALSE;
6141 if (wd->select_all_item)
6143 wd->select_all_check = EINA_FALSE;
6144 edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,press", "elm", _select_all_down);
6145 elm_widget_item_pre_notify_del(wd->select_all_item);
6146 _item_unrealize(wd->select_all_item);
6147 elm_widget_item_del(wd->select_all_item);
6149 EINA_INLIST_FOREACH(wd->items, it)
6151 if (wd->select_all_check) it->edit_select_check = EINA_TRUE;
6152 else it->edit_select_check = EINA_FALSE;
6155 wd->select_all_item = NULL;
6158 Evas_Object *editfield;
6159 EINA_LIST_FREE(wd->edit_field, editfield)
6160 evas_object_del(editfield);
6161 wd->edit_field = NULL;
6166 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER)
6167 wd->reorder_mode = EINA_TRUE;
6170 wd->ed = calloc(1, sizeof(Edit_Data));
6172 wd->ed->ec = edit_class;
6174 EINA_INLIST_FOREACH(wd->blocks, itb)
6179 EINA_LIST_FOREACH(itb->items, l, it)
6181 if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized)
6183 if(it->selected) _item_unselect(it);
6184 _effect_item_realize(it);
6194 if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)
6196 if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default"))
6197 itc.item_style = edit_class->select_all_item_style;
6199 itc.item_style = "select_all";
6200 itc.func.label_get = NULL;
6201 itc.func.icon_get = NULL;
6202 itc.func.del = NULL;
6203 itc.func.editmode_get = NULL;
6204 wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
6207 if (!wd->select_all_item) return;
6209 _item_realize(wd->select_all_item, 0, 0);
6210 // edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,press", "elm", _select_all_down, wd->select_all_item);
6212 wd->select_all_item->rel = NULL;
6213 wd->select_all_item->block = NULL;
6217 if (wd->calc_job) ecore_job_del(wd->calc_job);
6218 wd->calc_job = ecore_job_add(_calc_job, wd);
6222 * Delete selected items in genlist edit mode.
6224 * @param obj The genlist object
6229 elm_genlist_edit_selected_items_del(Evas_Object *obj)
6231 ELM_CHECK_WIDTYPE(obj, widtype);
6232 Widget_Data *wd = elm_widget_data_get(obj);
6234 if (!wd->blocks) return;
6235 Elm_Genlist_Item *it;
6236 Eina_List *edit_selected_list, *l;
6239 edit_selected_list = elm_genlist_edit_selected_items_get(obj);
6240 cnt = eina_list_count(edit_selected_list);
6241 // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt);
6243 EINA_LIST_FOREACH(edit_selected_list, l, it)
6245 if (it->flags != ELM_GENLIST_ITEM_GROUP) elm_genlist_item_del(it);
6247 eina_list_free(edit_selected_list);
6249 evas_render(evas_object_evas_get(wd->obj));
6250 if (wd->calc_job) ecore_job_del(wd->calc_job);
6251 wd->calc_job = ecore_job_add(_calc_job, wd);
6255 elm_genlist_selected_items_del(Evas_Object *obj)
6257 fprintf(stderr, "=================> Caution!!! <========================\n");
6258 fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n");
6259 fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n");
6260 fprintf(stderr, "=======================================================\n");
6261 elm_genlist_edit_selected_items_del(obj);
6265 * Get a list of selected items in genlist
6267 * This returns a list of the selected items in the genlist. The list
6268 * contains Elm_Genlist_Item pointers. The list must be freed by the
6269 * caller when done with eina_list_free(). The item pointers in the list
6270 * are only vallid so long as those items are not deleted or the genlist is
6273 * @param obj The genlist object
6274 * @return The list of selected items, nor NULL if none are selected.
6279 elm_genlist_edit_selected_items_get(const Evas_Object *obj)
6281 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
6282 Widget_Data *wd = elm_widget_data_get(obj);
6283 Eina_List *list = NULL;
6284 Elm_Genlist_Item *it;
6285 if (!wd) return NULL;
6287 EINA_INLIST_FOREACH(wd->items, it)
6289 if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it);
6295 // TODO : add comment
6297 elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it,
6300 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
6301 Widget_Data *wd = elm_widget_data_get(it->base.widget);
6303 selected = !!selected;
6304 if (it->edit_select_check == selected) return;
6306 if (it->wd->edit_mode)
6308 it->edit_select_check = selected;
6309 _checkbox_item_select_process(it);
6313 // TODO : add comment
6314 EAPI const Eina_Bool
6315 elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it)
6317 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
6318 return it->edit_select_check;
6322 * Set a given item's rename mode
6324 * This renames the item's label from genlist
6326 * @param it The item
6327 * @param emode set if emode is EINA_TRUE, unset if emode is EINA_FALSE
6332 elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode)
6334 if (!it) return NULL;
6336 const Eina_List *l, *list, *l2;
6337 const char *label, *rename_swallow_part;
6339 Eina_Bool done = EINA_FALSE;
6340 int label_cnt = 0 , swallow_part_cnt = 0;
6343 Evas_Object *editfield;
6344 Evas_Object *entry = NULL;
6345 int edit_field_cnt = 0;
6347 EINA_INLIST_FOREACH(it->wd->blocks, itb)
6352 Elm_Genlist_Item *it;
6354 EINA_LIST_FOREACH(itb->items, l, it)
6358 it->renamed = EINA_FALSE;
6359 if (it->selected) _item_unselect(it);
6360 EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield)
6362 entry = elm_editfield_entry_get(editfield);
6363 const char *text = elm_entry_entry_get(entry);
6364 if (it->itc->func.label_changed)
6365 it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++);
6367 EINA_LIST_FREE(it->wd->edit_field, editfield)
6368 evas_object_del(editfield);
6369 it->wd->edit_field = NULL;
6371 if (it->wd->edit_mode)
6373 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm");
6374 edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm");
6375 if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT)
6376 edje_object_signal_emit(it->edit_obj, "elm,state,del,enable", "elm");
6379 if(!it->wd->edit_mode) _effect_item_unrealize(it);
6392 it->renamed = EINA_TRUE;
6393 if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE)
6395 it->wd->edit_mode = 0xF0;
6396 _effect_item_realize(it);
6397 it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE;
6400 EINA_LIST_FOREACH(it->labels, list, label)
6402 edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm");
6403 edje_object_signal_emit(it->edit_obj, "elm,state,ins,disable", "elm");
6404 edje_object_signal_emit(it->edit_obj, "elm,state,del,disable", "elm");
6405 edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,disable", "elm");
6407 if (it->itc->func.label_get)
6409 swallow_part_cnt = 0;
6411 Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename"));
6412 EINA_LIST_FOREACH(rename, l, rename_swallow_part)
6414 if (label_cnt == swallow_part_cnt)
6416 editfield = elm_editfield_add(it->base.widget);
6417 it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield);
6419 elm_editfield_entry_single_line_set(editfield, EINA_TRUE);
6420 elm_editfield_eraser_set(editfield, EINA_TRUE);
6421 edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield);
6422 elm_widget_sub_object_add(it->edit_obj, editfield);
6424 evas_object_show(editfield);
6426 s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data);
6429 entry = elm_editfield_entry_get(editfield);
6430 elm_entry_entry_set(entry,s);
6434 elm_editfield_guide_text_set(editfield, "Text Input");
6446 static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source)
6448 Elm_Genlist_Item *it = data;
6450 _delete_sweep_objs(it);
6454 _scr_hold_timer_cb(void *data)
6456 Elm_Genlist_Item *it = data;
6457 elm_smart_scroller_hold_set(it->wd->scr, EINA_FALSE);
6458 it->wd->scr_hold_timer = NULL;
6459 return ECORE_CALLBACK_CANCEL;
6463 _delete_sweep_objs(Elm_Genlist_Item *it)
6467 elm_widget_stringlist_free(it->sweep_labels);
6468 it->sweep_labels = NULL;
6469 elm_widget_stringlist_free(it->sweep_icons);
6470 it->sweep_icons = NULL;
6471 EINA_LIST_FREE(it->sweep_icon_objs, ic)
6472 evas_object_del(ic);
6476 _create_sweep_objs(Elm_Genlist_Item *it)
6482 if (it->itc->func.label_get)
6485 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6487 EINA_LIST_FOREACH(it->sweep_labels, l, key)
6489 char *s = it->itc->func.label_get
6490 ((void *)it->base.data, it->base.widget, l->data);
6494 edje_object_part_text_set(it->base.view, l->data, s);
6499 if (it->itc->func.icon_get)
6502 elm_widget_stringlist_get(edje_object_data_get(it->base.view,
6504 EINA_LIST_FOREACH(it->sweep_icons, l, key)
6506 ic = it->itc->func.icon_get
6507 ((void *)it->base.data, it->base.widget, l->data);
6511 it->sweep_icon_objs = eina_list_append(it->sweep_icon_objs, ic);
6512 edje_object_part_swallow(it->base.view, key, ic);
6513 evas_object_show(ic);
6514 elm_widget_sub_object_add(it->base.widget, ic);
6521 _item_slide(Elm_Genlist_Item *it, Eina_Bool slide_to_right)
6524 Elm_Genlist_Item *it2;
6525 const char *allow_slide;
6527 allow_slide = edje_object_data_get(it->base.view, "allow_slide");
6528 if ((!allow_slide) || (atoi(allow_slide) != 1))
6533 if (it->sweeped) return;
6534 if (it->wd->scr_hold_timer)
6536 ecore_timer_del(it->wd->scr_hold_timer);
6537 it->wd->scr_hold_timer = NULL;
6539 elm_smart_scroller_hold_set(it->wd->scr, EINA_TRUE);
6540 it->wd->scr_hold_timer = ecore_timer_add(0.1, _scr_hold_timer_cb, it);
6542 _delete_sweep_objs(it);
6543 _create_sweep_objs(it);
6544 edje_object_signal_emit(it->base.view, "elm,state,slide,right", "elm");
6545 it->wd->sweeped_items = eina_list_append(it->wd->sweeped_items, it);
6546 it->wassweeped = EINA_TRUE;
6547 it->sweeped = EINA_TRUE;
6549 EINA_LIST_FOREACH(it->wd->sweeped_items, l, it2)
6553 it2->sweeped = EINA_FALSE;
6554 edje_object_signal_emit(it2->base.view, "elm,state,slide,left", "elm");
6555 edje_object_signal_callback_add(it2->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it2);
6556 it2->wd->sweeped_items = eina_list_remove(it2->wd->sweeped_items, it2);
6562 if (!it->sweeped) return;
6563 edje_object_signal_emit(it->base.view, "elm,state,slide,left", "elm");
6564 edje_object_signal_callback_add(it->base.view, "elm,action,sweep,left,finish", "elm", _sweep_finish, it);
6565 it->wd->sweeped_items = eina_list_remove(it->wd->sweeped_items, it);
6566 it->sweeped = EINA_FALSE;
6571 _item_auto_scroll(void *data)
6573 Widget_Data *wd = data;
6576 if ((wd->expand_item) && (!wd->auto_scrolled))
6578 Elm_Genlist_Item *it;
6580 Evas_Coord ox, oy, ow, oh;
6581 evas_object_geometry_get(wd->obj, &ox, &oy, &ow, &oh);
6583 wd->auto_scrolled = EINA_TRUE;
6584 if (wd->expand_item->scrl_y > (oh + oy) / 2)
6586 EINA_LIST_FOREACH(wd->expand_item->items, l, it)
6588 elm_genlist_item_bring_in(it);