From f7181b5597e3d8a85f8e0502426a977e85d05481 Mon Sep 17 00:00:00 2001 From: Seunggyun Kim Date: Wed, 23 Mar 2011 18:08:31 +0900 Subject: [PATCH] [elm_genlist.c Elementary.h.in] Rollback edit mode --- src/lib/Elementary.h.in | 55 ++-- src/lib/elm_genlist.c | 715 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 591 insertions(+), 179 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 0e6dd91..6538f76 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -1742,9 +1742,7 @@ extern "C" { { ELM_GENLIST_ITEM_NONE = 0, ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), - ELM_GENLIST_ITEM_GROUP = (1 << 1), - ELM_GENLIST_ITEM_HEAD = (1 << 2), - ELM_GENLIST_ITEM_TAIL = (1 << 3) + ELM_GENLIST_ITEM_GROUP = (1 << 1) } Elm_Genlist_Item_Flags; typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class; typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */ @@ -1754,10 +1752,24 @@ extern "C" { typedef Eina_Bool (*GenlistItemStateGetFunc) (const void *data, Evas_Object *obj, const char *part); typedef void (*GenlistItemDelFunc) (const void *data, Evas_Object *obj); + typedef struct _Elm_Genlist_Edit_Class Elm_Genlist_Edit_Class; + typedef enum _Elm_Genlist_Edit_Mode + { + ELM_GENLIST_EDIT_MODE_NONE = 0, + ELM_GENLIST_EDIT_MODE_REORDER = (1 << 0), + ELM_GENLIST_EDIT_MODE_INSERT = (1 << 1), + ELM_GENLIST_EDIT_MODE_DELETE = (1 << 2), + ELM_GENLIST_EDIT_MODE_SELECT = (1 << 3), + ELM_GENLIST_EDIT_MODE_SELECTALL = (1 << 4) + } Elm_Genlist_Edit_Mode; // TODO : below should be fixed!!! + typedef char *(*GenlistItemLabelChangedFunc) (const void *data, Elm_Genlist_Item *it, const char *text, const int sub_text ); + typedef int (*GenlistItemEditModeGetFunc) (const void *data, Evas_Object *obj, const int enabled_edit_modes); + typedef void (*GenlistInsertNewFunc) (Evas_Object *genlist, Elm_Genlist_Item *rel_item); typedef void (*GenlistItemSelectedFunc) (const void *data, Elm_Genlist_Item *it, Eina_Bool selected); typedef void (*GenlistSelectedFunc) (const void *data, Elm_Genlist_Item *it, Eina_Bool selected); - typedef void (*GenlistItemMovedFunc) ( Evas_Object *genlist, Elm_Genlist_Item *item, Elm_Genlist_Item *rel_item, Eina_Bool move_after); + typedef Eina_Bool (*GenlistMoveFunc) ( Evas_Object *genlist, Elm_Genlist_Item *item, Elm_Genlist_Item *rel_item, Eina_Bool move_after); + typedef Eina_Bool (*GenlistRemoveItemFunc) (Evas_Object *genlist, Elm_Genlist_Item *rel_item); struct _Elm_Genlist_Item_Class { @@ -1767,9 +1779,21 @@ extern "C" { GenlistItemIconGetFunc icon_get; GenlistItemStateGetFunc state_get; GenlistItemDelFunc del; - GenlistItemMovedFunc moved; + GenlistItemEditModeGetFunc editmode_get; + GenlistItemLabelChangedFunc label_changed; } func; - const char *edit_item_style; + }; + + struct _Elm_Genlist_Edit_Class + { + GenlistRemoveItemFunc remove; + GenlistInsertNewFunc insert_new; + GenlistMoveFunc move; + GenlistItemSelectedFunc item_selected; + GenlistSelectedFunc selected; + const char *item_style; + const char *select_all_item_style; + const void *select_all_data; }; EAPI Evas_Object *elm_genlist_add(Evas_Object *parent) EINA_ARG_NONNULL(1); EAPI void elm_genlist_clear(Evas_Object *obj) EINA_ARG_NONNULL(1); @@ -1854,27 +1878,22 @@ extern "C" { EAPI void elm_genlist_item_cursor_engine_only_set(Elm_Genlist_Item *item, Eina_Bool engine_only) EINA_ARG_NONNULL(1); EAPI Eina_Bool elm_genlist_item_cursor_engine_only_get(const Elm_Genlist_Item *item) EINA_ARG_NONNULL(1); - EAPI void elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode); + EAPI void elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *ec); EAPI Eina_Bool elm_genlist_edit_mode_get(const Evas_Object *obj); - EAPI void elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed); - EAPI Eina_Bool elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item); + EAPI void elm_genlist_edit_selected_items_del(Evas_Object *obj); + EAPI Eina_List *elm_genlist_edit_selected_items_get(const Evas_Object *obj); + EAPI void elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected) EINA_ARG_NONNULL(1); + EAPI Eina_Bool elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it) EINA_ARG_NONNULL(1); + EAPI Evas_Object *elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode); EAPI void elm_genlist_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after ); EAPI void elm_genlist_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before); EAPI void elm_genlist_effect_set(const Evas_Object *obj, Eina_Bool emode); EAPI void elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode); EAPI void elm_genlist_pinch_zoom_mode_set(Evas_Object *obj, Eina_Bool emode); EAPI Eina_Bool elm_genlist_pinch_zoom_mode_get(const Evas_Object *obj); - EAPI int elm_genlist_item_flags_get(const Elm_Genlist_Item *item); - EAPI void elm_genlist_realized_items_update(const Evas_Object *obj); - EAPI void elm_genlist_reorder_mode_set(Evas_Object *obj, Eina_Bool reorder_mode); - EAPI Eina_Bool elm_genlist_reorder_mode_get(const Evas_Object *obj); -// EINA_DEPRECATED EAPI void elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *ec); + EINA_DEPRECATED EAPI void elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *ec); EINA_DEPRECATED EAPI void elm_genlist_selected_items_del(Evas_Object *obj); EINA_DEPRECATED EAPI void elm_genlist_queue_exception_set(const Evas_Object *obj, Eina_Bool emode); - EINA_DEPRECATED EAPI void elm_genlist_edit_selected_items_del(Evas_Object *obj); - EINA_DEPRECATED EAPI Eina_List *elm_genlist_edit_selected_items_get(const Evas_Object *obj); - EINA_DEPRECATED EAPI void elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected) EINA_ARG_NONNULL(1); - EINA_DEPRECATED EAPI Eina_Bool elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it) EINA_ARG_NONNULL(1);; /* check */ EAPI Evas_Object *elm_check_add(Evas_Object *parent) EINA_ARG_NONNULL(1); diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c index 4f90abc..34a366d 100644 --- a/src/lib/elm_genlist.c +++ b/src/lib/elm_genlist.c @@ -286,6 +286,7 @@ typedef struct _Widget_Data Widget_Data; typedef struct _Item_Block Item_Block; typedef struct _Pan Pan; typedef struct _Item_Cache Item_Cache; +typedef struct _Edit_Data Edit_Data; typedef enum _Elm_Genlist_Item_Move_effect_Mode { @@ -351,9 +352,13 @@ struct _Widget_Data Eina_Bool reorder_pan_move : 1; Eina_Bool reorder_deleted : 1; Eina_Bool effect_mode : 1; + Eina_Bool select_all_check : 1; Eina_Bool auto_scrolled : 1; Eina_Bool contracting : 1; int edit_mode; + Edit_Data *ed; + Eina_List *edit_field; + Elm_Genlist_Item *select_all_item; Eina_List *sweeped_items; Ecore_Timer *scr_hold_timer; int total_num; @@ -368,8 +373,6 @@ struct _Widget_Data Evas_Coord expand_item_gap; int move_effect_mode; unsigned int start_time; - Elm_Genlist_Item *head_item, *tail_item; - Elm_Genlist_Item *rename_it; }; struct _Item_Block @@ -454,6 +457,7 @@ struct _Elm_Genlist_Item Eina_Bool move_effect_me : 1; Eina_Bool effect_done : 1; Eina_Bool reordering : 1; + Eina_Bool edit_select_check: 1; Eina_Bool renamed : 1; Eina_Bool effect_item_realized : 1; Eina_Bool sweeped : 1; @@ -465,6 +469,7 @@ struct _Elm_Genlist_Item Ecore_Animator *item_moving_effect_timer; Evas_Coord old_scrl_x, old_scrl_y; Evas_Coord pad_left, pad_right; + int list_expanded; }; struct _Item_Cache @@ -483,6 +488,15 @@ struct _Item_Cache Eina_Bool expanded : 1; // it->expanded }; +struct _Edit_Data +{ + Elm_Genlist_Edit_Class *ec; + Elm_Genlist_Item *del_item; + Elm_Genlist_Item *reorder_item; + Elm_Genlist_Item *reorder_rel; + Evas_Object *del_confirm; +}; + #define ELM_GENLIST_ITEM_FROM_INLIST(item) \ ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Genlist_Item) : NULL) @@ -531,6 +545,8 @@ static void _delete_sweep_objs(Elm_Genlist_Item *it); static void _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after); static void _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before); static void _group_items_recalc(void *data); +static void _select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items); +static void _checkbox_item_select_process(Elm_Genlist_Item *it); static void _item_auto_scroll(void *data); static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_VERSION; @@ -789,7 +805,7 @@ _del_pre_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, EINA_FALSE); + if (wd->edit_mode) elm_genlist_edit_mode_set(wd->obj, ELM_GENLIST_EDIT_MODE_NONE, NULL); evas_object_del(wd->pan_smart); wd->pan_smart = NULL; elm_genlist_clear(obj); @@ -904,6 +920,7 @@ _item_hilight(Elm_Genlist_Item *it) evas_object_raise(it->group_item->base.view); } it->hilighted = EINA_TRUE; + if (it->wd->select_all_item) evas_object_raise(it->wd->select_all_item->base.view); } static void @@ -1012,7 +1029,6 @@ _item_del(Elm_Genlist_Item *it) it->wd->anchor_item = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev); } #endif - if (it->flags != ELM_GENLIST_ITEM_HEAD) it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it)); if (it->parent) it->parent->items = eina_list_remove(it->parent->items, it); @@ -1023,7 +1039,6 @@ _item_del(Elm_Genlist_Item *it) if (it->tooltip.del_cb) it->tooltip.del_cb((void *)it->tooltip.data, it->base.widget, it); - if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL; elm_widget_item_del(it); it->wd->total_num--; // todo : remove @@ -1033,6 +1048,14 @@ static void _item_select(Elm_Genlist_Item *it) { if ((it->wd->no_select) || (it->delete_me)) return; + if (it == it->wd->select_all_item) + { + if(it->wd->select_all_check) + _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_TRUE); + else + _select_all_down_process(it->wd->select_all_item, EINA_TRUE, EINA_TRUE); + return; + } if (it->selected) { if (it->wd->always_select) goto call; @@ -1068,6 +1091,7 @@ _item_unselect(Elm_Genlist_Item *it) { const char *stacking, *selectraise; + if (it == it->wd->select_all_item) return; if ((it->delete_me) || (!it->hilighted)) return; if (!it->sweeped) edje_object_signal_emit(it->base.view, "elm,state,unselected", "elm"); @@ -1097,7 +1121,6 @@ _mouse_move(void *data, Evas_Event_Mouse_Move *ev = event_info; Evas_Coord minw = 0, minh = 0, x, y, dx, dy, adx, ady; - if (it->renamed) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) { if (!it->wd->on_hold) @@ -1149,8 +1172,8 @@ _mouse_move(void *data, if (!it->wd->reorder_start_y) it->wd->reorder_start_y = it->block->y + it->y; evas_object_resize(it->base.view, it->w-(it->pad_left+it->pad_right), it->h); - if (it->wd->head_item) - sel_all_h = it->wd->head_item->h; + if (it->wd->select_all_item) + sel_all_h = it->wd->select_all_item->h; if (it_y < oy + sel_all_h) _effect_item_controls(it, it->scrl_x, oy + sel_all_h); else if (it_y + it->wd->reorder_it->h > oy+oh) _effect_item_controls(it, it->scrl_x, oy + oh - it->wd->reorder_it->h); else _effect_item_controls(it, it->scrl_x, it_y); @@ -1239,11 +1262,11 @@ _long_press(void *data) Item_Block *itb; it->long_timer = NULL; - if ((it->disabled) || (it->dragging) || (it->display_only) || (it->wd->rename_it)) + if ((it->disabled) || (it->dragging) || (it->display_only)) return ECORE_CALLBACK_CANCEL; it->wd->longpressed = EINA_TRUE; evas_object_smart_callback_call(it->base.widget, "longpressed", it); - if ((it->wd->reorder_mode) && (it != it->wd->head_item) && (it->flags != ELM_GENLIST_ITEM_GROUP)) + if ((it->wd->reorder_mode) && (it != it->wd->select_all_item) && (it->flags != ELM_GENLIST_ITEM_GROUP)) { it->wd->reorder_it = it; it->wd->reorder_start_y = 0; @@ -1285,6 +1308,8 @@ _long_press(void *data) elm_genlist_item_expanded_set(it, EINA_FALSE); return ECORE_CALLBACK_RENEW; } + if (it->wd->edit_field && it->renamed) + elm_genlist_item_rename_mode_set(it, EINA_FALSE); } return ECORE_CALLBACK_CANCEL; @@ -1472,13 +1497,14 @@ _mouse_down(void *data, Evas_Event_Mouse_Down *ev = event_info; Evas_Coord x, y; - if (it->renamed) return; if (ev->button != 1) return; if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) { it->wd->on_hold = EINA_TRUE; } - if (it->wd->rename_it) elm_genlist_item_rename_mode_set(it, EINA_FALSE); + + if (it->wd->edit_field && !it->renamed) + elm_genlist_item_rename_mode_set(it, EINA_FALSE); it->down = EINA_TRUE; it->dragging = EINA_FALSE; evas_object_geometry_get(obj, &x, &y, NULL, NULL); @@ -1523,7 +1549,6 @@ _mouse_up(void *data, Evas_Event_Mouse_Up *ev = event_info; Eina_Bool dragged = EINA_FALSE; - if (it->renamed) return; if (ev->button != 1) return; it->down = EINA_FALSE; it->wd->mouse_down = EINA_FALSE; @@ -1573,7 +1598,7 @@ _mouse_up(void *data, Evas_Coord ox,oy,oh,ow; evas_object_geometry_get(it->wd->pan_smart, &ox, &oy, &ow, &oh); evas_object_geometry_get(it->wd->reorder_it->base.view, &rox, &roy, &row, &roh); - if (it->wd->head_item) sel_all_h = it->wd->head_item->h; + if (it->wd->select_all_item) sel_all_h = it->wd->select_all_item->h; if (it->wd->reorder_rel) { if (it->wd->reorder_it->parent == it->wd->reorder_rel->parent) // todo : refactoring @@ -1999,23 +2024,6 @@ _item_realize(Elm_Genlist_Item *it, evas_object_event_callback_add(ic, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, it); } } - if (it->wd->rename_it && it->renamed) - { - it->icons = - elm_widget_stringlist_get(edje_object_data_get(it->base.view, "renames")); - EINA_LIST_FOREACH(it->icons, l, key) - { - Evas_Object *ic = it->itc->func.icon_get - ((void *)it->base.data, it->base.widget, l->data); - if (ic) - { - it->icon_objs = eina_list_append(it->icon_objs, ic); - edje_object_part_swallow(it->base.view, key, ic); - evas_object_show(ic); - elm_widget_sub_object_add(it->base.widget, ic); - } - } - } } if (it->itc->func.state_get) { @@ -2100,15 +2108,12 @@ _item_realize(Elm_Genlist_Item *it, if (itc) _item_cache_free(itc); evas_object_smart_callback_call(it->base.widget, "realized", it); - if ((!calc) && (it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && (it->flags != ELM_GENLIST_ITEM_HEAD)) - { - if (it->itc->edit_item_style ) + if ((it->wd->edit_mode) && (it->flags != ELM_GENLIST_ITEM_GROUP) && ((!it->wd->select_all_item) || ((it->wd->select_all_item) && (it != it->wd->select_all_item)))) { _effect_item_realize(it, EINA_FALSE); edje_object_message_signal_process(it->edit_obj); } } -} static void _item_unrealize(Elm_Genlist_Item *it) @@ -2148,7 +2153,9 @@ _item_unrealize(Elm_Genlist_Item *it) it->states = NULL; it->realized = EINA_FALSE; it->want_unrealize = EINA_FALSE; - if (it->wd->edit_mode) _effect_item_unrealize(it); + if (it->wd->edit_field && it->renamed) + elm_genlist_item_rename_mode_set(it, EINA_FALSE); + if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) _effect_item_unrealize(it); } static Eina_Bool @@ -2345,26 +2352,30 @@ _item_block_position(Item_Block *itb, Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh; int vis = 0; int sel_all_h = 0; - Elm_Genlist_Item *head_item = itb->wd->head_item; + Elm_Genlist_Item *select_all_item = NULL; evas_object_geometry_get(itb->wd->pan_smart, &ox, &oy, &ow, &oh); evas_output_viewport_get(evas_object_evas_get(itb->wd->obj), &cvx, &cvy, &cvw, &cvh); - if (head_item) + if (itb->wd->select_all_item && + (itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT || itb->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL)) { - if (!head_item->realized) - { - _item_realize(head_item, 0, 0); - itb->wd->minh += itb->wd->head_item->h; - } - evas_object_resize(head_item->base.view, itb->w, head_item->h); - evas_object_move(head_item->base.view, ox, oy); - evas_object_raise(head_item->base.view); + if (itb->wd->select_all_check) + edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_check", "elm"); + else + edje_object_signal_emit(itb->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm"); - y = head_item->h; - sel_all_h = head_item->h; + select_all_item = itb->wd->select_all_item; + + evas_object_resize(select_all_item->base.view, itb->w, select_all_item->h); + evas_object_move(select_all_item->base.view, ox, oy); + evas_object_raise(select_all_item->base.view); + + y = select_all_item->h; + sel_all_h = select_all_item->h; } + EINA_LIST_FOREACH(itb->items, l, it) { if (it->delete_me) continue; @@ -2382,15 +2393,7 @@ _item_block_position(Item_Block *itb, { if ((itb->realized) && (!it->realized)) { - if (vis) - { - _item_realize(it, in, 0); - if (it->renamed) - { - if (it->wd->edit_mode) edje_object_signal_emit(it->edit_obj, "elm,state,rename,enabled", "elm"); - edje_object_signal_emit(it->base.view, "elm,state,rename,enabled", "elm"); - } - } + if (vis) _item_realize(it, in, 0); } if (it->realized) { @@ -2420,7 +2423,7 @@ _item_block_position(Item_Block *itb, if (!it->move_effect_me ) if (!it->wd->effect_mode || it->wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_NONE || ((it->wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) && it->parent == it->wd->expand_item)) { - if (it->wd->edit_mode && it->itc->edit_item_style) + if (it->wd->edit_mode != ELM_GENLIST_EDIT_MODE_NONE) { _effect_item_controls(it, it->scrl_x, it->scrl_y); } @@ -2600,11 +2603,12 @@ _calc_job(void *data) } wd->realminw = minw; if (minw < wd->w) minw = wd->w; - if ((minw != wd->minw) || (minh != wd->minh) || (wd->head_item)) + if ((minw != wd->minw) || (minh != wd->minh) || (wd->select_all_item)) { wd->minw = minw; wd->minh = minh; - if (wd->head_item) wd->minh += wd->head_item->h; + if (wd->select_all_item) + wd->minh += wd->select_all_item->h; if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE) evas_object_smart_callback_call(wd->pan_smart, "changed", NULL); _sizing_eval(wd->obj); @@ -2643,12 +2647,6 @@ _update_job(void *data) if (!wd) return; wd->update_job = NULL; num = 0; - if (wd->head_item) - { - _item_unrealize(wd->head_item); - _item_realize(wd->head_item, 0, 0); - position = EINA_TRUE; - } EINA_INLIST_FOREACH(wd->blocks, itb) { Evas_Coord itminw, itminh; @@ -2667,8 +2665,8 @@ _update_job(void *data) { if (it->updateme) { - itminw = it->minw; - itminh = it->minh; + itminw = it->w; + itminh = it->h; it->updateme = EINA_FALSE; if (it->realized) @@ -2981,7 +2979,7 @@ _pan_calculate(Evas_Object *obj) } } else _item_auto_scroll(sd->wd); - if (sd->wd->head_item) evas_object_raise(sd->wd->head_item->base.view); + if (sd->wd->select_all_item) evas_object_raise(sd->wd->select_all_item->base.view); sd->wd->contracting = EINA_FALSE; } @@ -3188,6 +3186,9 @@ _item_new(Widget_Data *wd, it->func.data = func_data; it->mouse_cursor = NULL; it->expanded_depth = 0; + if ((it->parent) && (it->parent->edit_select_check)) it->edit_select_check = EINA_TRUE; + if ((!it->parent) && (it->wd->select_all_item)) + _select_all_down_process(it->wd->select_all_item, EINA_FALSE, EINA_FALSE); it->num = ++wd->total_num; // todo : remov return it; } @@ -3449,13 +3450,9 @@ elm_genlist_item_append(Evas_Object *obj, if (!it) return NULL; if (!it->parent) { - if (flags & ELM_GENLIST_ITEM_HEAD) wd->head_item = it; - else - { if (flags & ELM_GENLIST_ITEM_GROUP) wd->group_items = eina_list_append(wd->group_items, it); wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it)); - } it->rel = NULL; } else @@ -3477,8 +3474,7 @@ elm_genlist_item_append(Evas_Object *obj, it->group_item = it->parent->group_item; } it->before = EINA_FALSE; - if (flags != ELM_GENLIST_ITEM_HEAD) _item_queue(wd, it); - + _item_queue(wd, it); return it; } @@ -3679,7 +3675,6 @@ elm_genlist_clear(Evas_Object *obj) wd->items = eina_inlist_remove(wd->items, wd->items); if (it->flags & ELM_GENLIST_ITEM_GROUP) it->wd->group_items = eina_list_remove(it->wd->group_items, it); - if (it->flags & ELM_GENLIST_ITEM_HEAD) it->wd->head_item = NULL; elm_widget_item_pre_notify_del(it); if (it->effect_item_realized) _effect_item_unrealize(it); if (it->realized) _item_unrealize(it); @@ -3723,6 +3718,13 @@ elm_genlist_clear(Evas_Object *obj) eina_list_free(wd->selected); wd->selected = NULL; } + if (wd->edit_field) + { + Evas_Object *editfield; + EINA_LIST_FREE(wd->edit_field, editfield) + evas_object_del(editfield); + wd->edit_field = NULL; + } if (wd->item_moving_effect_timer) { ecore_animator_del(wd->item_moving_effect_timer); @@ -3906,21 +3908,18 @@ elm_genlist_at_xy_item_get(const Evas_Object *obj, ELM_CHECK_WIDTYPE(obj, widtype) NULL; Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord ox, oy, ow, oh; - Evas_Coord head_y = 0; Item_Block *itb; Evas_Coord lasty; if (!wd) return NULL; evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh); lasty = oy; - - if (wd->head_item) head_y = wd->head_item->h; EINA_INLIST_FOREACH(wd->blocks, itb) { Eina_List *l; Elm_Genlist_Item *it; if (!ELM_RECTS_INTERSECT(ox + itb->x - itb->wd->pan_x, - oy + itb->y + head_y - itb->wd->pan_y , + oy + itb->y - itb->wd->pan_y, itb->w, itb->h, x, y, 1, 1)) continue; EINA_LIST_FOREACH(itb->items, l, it) @@ -4707,14 +4706,11 @@ EAPI void elm_genlist_item_update(Elm_Genlist_Item *it) { ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); - if (it->flags != ELM_GENLIST_ITEM_HEAD) - { if (!it->block) return; if (it->delete_me) return; it->mincalcd = EINA_FALSE; it->updateme = EINA_TRUE; it->block->updateme = EINA_TRUE; - } if (it->wd->update_job) ecore_job_del(it->wd->update_job); it->wd->update_job = ecore_job_add(_update_job, it->wd); } @@ -5532,7 +5528,10 @@ _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after) if (!it) return; if (!after) return; -// printf("MOVE AFTER : it = %d after = %d \n", it->num, after->num); + if (it->wd->ed->ec->move) + it->wd->ed->ec->move(it->base.widget, it, after, EINA_TRUE); + +// printf("MOVE AFTER : %d after = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(after)+1); it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it)); it->wd->reorder_deleted = EINA_TRUE; _item_block_del(it); @@ -5542,9 +5541,6 @@ _effect_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after) it->rel->relcount++; it->before = EINA_FALSE; _item_queue(it->wd, it); - - if (it->itc->func.moved) - it->itc->func.moved(it->base.widget, it, after, EINA_TRUE); } static void @@ -5553,7 +5549,10 @@ _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before) if (!it) return; if (!before) return; -// printf("MOVE BEFORE : it = %d before = %d \n", it->num, before->num); + if (it->wd->ed->ec->move) + it->wd->ed->ec->move(it->base.widget, it, before, EINA_FALSE); + +// printf("MOVE BEFORE : %d before = %d \n", (int)elm_genlist_item_data_get(it)+1, (int)elm_genlist_item_data_get(before)+1); it->wd->items = eina_inlist_remove(it->wd->items, EINA_INLIST_GET(it)); it->wd->reorder_deleted = EINA_TRUE; _item_block_del(it); @@ -5562,9 +5561,6 @@ _effect_item_move_before(Elm_Genlist_Item *it, Elm_Genlist_Item *before) it->rel->relcount++; it->before = EINA_TRUE; _item_queue(it->wd, it); - - if (it->itc->func.moved) - it->itc->func.moved(it->base.widget, it, before, EINA_FALSE); } EAPI void @@ -5698,7 +5694,7 @@ _item_moving_effect_timer_cb(void *data) evas_object_raise(it->base.view); } - if(wd->head_item) evas_object_raise(wd->head_item->base.view); + if(wd->select_all_item) evas_object_raise(wd->select_all_item->base.view); if (it->group_item) evas_object_raise(it->group_item->base.view); } @@ -5755,6 +5751,7 @@ _item_moving_effect_timer_cb(void *data) EINA_LIST_FOREACH(itb->items, l, it) { it->effect_done = EINA_TRUE; + it->list_expanded = 0; it->old_scrl_y = it->scrl_y; } } @@ -5877,22 +5874,209 @@ elm_genlist_pinch_zoom_set(Evas_Object *obj, Eina_Bool emode) //////////////////////////////////////////////////////////////////////// // EDIT MODE //////////////////////////////////////////////////////////////////////// +EAPI void +_effect_item_update(Elm_Genlist_Item *it) +{ + if (it->edit_select_check) + { + edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm"); + } + else + { + edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm"); + } +} + +EAPI void +_edit_item_checkbox_set(Elm_Genlist_Item *it, Eina_Bool edit_select_check_state) +{ + if (!it) return; + if (edit_select_check_state) + { + it->edit_select_check = EINA_TRUE; + edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm"); + } + else + { + it->edit_select_check = EINA_FALSE; + edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm"); + } + if (it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected) + it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check); +} + +EAPI void +_edit_subitems_checkbox_set(Elm_Genlist_Item *it) +{ + if (!it) return; + Eina_List *tl = NULL, *l; + Elm_Genlist_Item *it2; + + EINA_LIST_FOREACH(it->items, l, it2) + tl = eina_list_append(tl, it2); + EINA_LIST_FREE(tl, it2) + if(it2->parent) _edit_item_checkbox_set(it2, it2->parent->edit_select_check); +} + +EAPI void +_edit_parent_items_checkbox_set(Elm_Genlist_Item *it) +{ + if (!it) return; + Elm_Genlist_Item *tmp_it; + Eina_Bool parent_check = EINA_TRUE; + + EINA_INLIST_FOREACH(it->wd->items, tmp_it) + { + if (tmp_it->parent && it->parent) + if(tmp_it->parent == it->parent && tmp_it->edit_select_check == EINA_FALSE) parent_check = EINA_FALSE; + } + if (it->parent) + { + if (parent_check) it->parent->edit_select_check = EINA_TRUE; + else it->parent->edit_select_check = EINA_FALSE; + } + + if (it->parent) + { + _effect_item_update(it->parent); + return _edit_parent_items_checkbox_set(it->parent); + } +} + +static void +_select_all_down_process(Elm_Genlist_Item *select_all_it, Eina_Bool checked, Eina_Bool update_items) +{ + if (!select_all_it || !select_all_it->wd) return; + + Eina_Bool old_check_state; + Elm_Genlist_Item *it; + Widget_Data *wd = select_all_it->wd; + + wd->select_all_check = checked; + if (wd->select_all_check) + edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_check", "elm"); + else + edje_object_signal_emit(select_all_it->base.view, "elm,state,sel_uncheck", "elm"); + + if (update_items) + { + EINA_INLIST_FOREACH(wd->items, it) + { + old_check_state = it->edit_select_check; + if (wd->select_all_check) it->edit_select_check = EINA_TRUE; + else it->edit_select_check = EINA_FALSE; + + // TODO : check this + // if (old_check_state != it->edit_select_check && it->wd->ed && it->wd->ed->ec && it->wd->ed->ec->item_selected) + // it->wd->ed->ec->item_selected(it->base.data, it, it->edit_select_check); + } + } + + if (wd->ed->ec->item_selected) + wd->ed->ec->item_selected(select_all_it->base.data, select_all_it, wd->select_all_check); + + if (wd->calc_job) ecore_job_del(wd->calc_job); + wd->calc_job = ecore_job_add(_calc_job, wd); +} + +static void +_checkbox_item_select_process(Elm_Genlist_Item *it) +{ + Elm_Genlist_Item *tmp_it; + Eina_Bool old_check_state; + int check_cnt = 0, total_cnt = 0; + if (!it) return; + + _edit_item_checkbox_set(it, it->edit_select_check); + _edit_subitems_checkbox_set(it); + _edit_parent_items_checkbox_set(it); + + if (it->wd->ed) it->wd->ed->del_item = it; + + EINA_INLIST_FOREACH(it->wd->items, tmp_it) + { + if (tmp_it->edit_select_check) check_cnt++; + total_cnt++; + } + + if (it->wd->select_all_item) + { + old_check_state = it->wd->select_all_check; + if (check_cnt == total_cnt) it->wd->select_all_check = EINA_TRUE; + else it->wd->select_all_check = EINA_FALSE; + + if (check_cnt == total_cnt) + { + it->wd->select_all_check = EINA_TRUE; + edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_check", "elm"); + } + else + { + it->wd->select_all_check = EINA_FALSE; + edje_object_signal_emit(it->wd->select_all_item->base.view, "elm,state,sel_uncheck", "elm"); + } + } +} + +static void +_checkbox_item_select_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Genlist_Item *it = data; + if (!it) return; + it->edit_select_check = !it->edit_select_check; + _checkbox_item_select_process(it); +} + +static void +_select_all_down(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + Elm_Genlist_Item *select_all_it = data; + Widget_Data *wd = select_all_it->wd; + if (!wd) return; + + _select_all_down_process(select_all_it, !wd->select_all_check, EINA_TRUE); +} + static void _effect_item_controls(Elm_Genlist_Item *it, int itx, int ity) { - if (!it->wd->edit_mode) return; + if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE) + return; evas_object_resize(it->edit_obj,it->w, it->h); evas_object_move(it->edit_obj, itx, ity); + + if (it->wd->select_all_check) + it->edit_select_check = EINA_TRUE; + if (!it->renamed) + { + if (it->edit_select_check) + { + edje_object_signal_emit(it->edit_obj, "elm,state,sel_check", "elm"); + } + else + { + edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm"); + } + } } static void _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on) { if ((it->effect_item_realized) || (it->delete_me)) return; + int itmode = 0, pad = 0; + const char *pad_str; char buf[1024]; it->pad_left = it->pad_right = 0; + if (it->itc->func.editmode_get) + itmode = it->itc->func.editmode_get(it->base.data, it->base.widget, it->wd->edit_mode); + itmode &= it->wd->edit_mode; + + if (itmode & ELM_GENLIST_EDIT_MODE_SELECTALL) + itmode |= ELM_GENLIST_EDIT_MODE_SELECT; + it->edit_obj = edje_object_add(evas_object_evas_get(it->base.widget)); edje_object_scale_set(it->edit_obj, elm_widget_scale_get(it->base.widget) * _elm_config->scale); @@ -5905,33 +6089,56 @@ _effect_item_realize(Elm_Genlist_Item *it, Eina_Bool effect_on) strncat(buf, "/", sizeof(buf) - strlen(buf)); - if (it->itc->edit_item_style && strcmp(it->itc->edit_item_style, "default")) + if (it->wd->ed && it->wd->ed->ec->item_style && strcmp(it->wd->ed->ec->item_style, "default")) { - strncat(buf, it->itc->edit_item_style, sizeof(buf) - strlen(buf)); + strncat(buf, it->wd->ed->ec->item_style, sizeof(buf) - strlen(buf)); _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", buf, elm_widget_style_get(it->base.widget)); } else { - _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_default", elm_widget_style_get(it->base.widget)); + _elm_theme_object_set(it->base.widget, it->edit_obj, "genlist", "item/edit_control", elm_widget_style_get(it->base.widget)); } - if (it->wd->reorder_mode) + pad_str = edje_object_data_get(it->edit_obj, "icon_width"); + if (pad_str) pad = atoi(pad_str); + + if ((itmode & ELM_GENLIST_EDIT_MODE_DELETE) || (itmode & ELM_GENLIST_EDIT_MODE_SELECT)) { - if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm"); - else edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm"); + if (effect_on) edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable_effect", "elm"); + else edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm"); + + edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm"); + edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select", + "elm", _checkbox_item_select_cb); + + edje_object_signal_callback_add(it->edit_obj, "elm,action,item,select", + "elm", _checkbox_item_select_cb, it); + it->pad_left += pad * _elm_config->scale; } + else + { + edje_object_signal_emit(it->edit_obj, "elm,state,sel,disable", "elm"); - if (it->disabled) edje_object_signal_emit(it->edit_obj, "elm,state,disabled", "elm"); - else edje_object_signal_emit(it->edit_obj, "elm,state,enabled", "elm"); + edje_object_signal_callback_del(it->edit_obj, "elm,action,item,select", + "elm", _checkbox_item_select_cb); + } - if ((it->wd->edit_mode)) + if (effect_on && itmode & ELM_GENLIST_EDIT_MODE_REORDER) + { + edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable_effect", "elm"); + edje_object_signal_emit(it->edit_obj, "elm,state,sel,enable", "elm"); + } + else if (itmode & ELM_GENLIST_EDIT_MODE_REORDER) + edje_object_signal_emit(it->edit_obj, "elm,state,reorder_enable", "elm"); + + if ((it->wd->edit_mode) || (!it->wd->edit_mode && it->renamed)) { if (it->itc->func.icon_get) { const Eina_List *l; const char *key; - it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "edit_icons")); + it->icons = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "icons")); EINA_LIST_FOREACH(it->icons, l, key) { Evas_Object *ic = it->itc->func.icon_get @@ -5981,6 +6188,17 @@ _effect_item_unrealize(Elm_Genlist_Item *it) it->effect_item_realized = EINA_FALSE; } +EAPI void +elm_genlist_set_edit_mode(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class) +{ + fprintf(stderr, "=================> Caution!!! <========================\n"); + fprintf(stderr, "==> elm_genlist_set_edit_mode() is deprecated. <=======\n"); + fprintf(stderr, "==> Please use elm_genlist_edit_mode_set() instead. <==\n"); + fprintf(stderr, "=======================================================\n"); + + elm_genlist_edit_mode_set(obj, emode, edit_class); +} + /** * Get Genlist edit mode * @@ -6013,25 +6231,33 @@ elm_genlist_edit_mode_get(const Evas_Object *obj) * @ingroup Genlist */ EAPI void -elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode) +elm_genlist_edit_mode_set(Evas_Object *obj, int emode, Elm_Genlist_Edit_Class *edit_class) { ELM_CHECK_WIDTYPE(obj, widtype); Item_Block *itb; + Eina_Bool done = EINA_FALSE; + static Elm_Genlist_Item_Class itc; Eina_List *l; Elm_Genlist_Item *it; Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - if (wd->edit_mode == edit_mode) return; + if (wd->edit_mode == emode) return; + + wd->edit_mode = emode; + + if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL) + wd->edit_mode |= ELM_GENLIST_EDIT_MODE_SELECT; - wd->edit_mode = edit_mode; - if (!wd->edit_mode) + + if (wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE) { EINA_INLIST_FOREACH(wd->blocks, itb) { if (itb->realized) { + done = 1; EINA_LIST_FOREACH(itb->items, l, it) { if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized) @@ -6041,25 +6267,87 @@ elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode) } } } + else + { + if (done) break; + } + } + + EINA_INLIST_FOREACH(wd->items, it) + { + it->edit_select_check = EINA_FALSE; + } + if (wd->ed) free (wd->ed); + wd->ed = NULL; + wd->reorder_mode = EINA_FALSE; + if (wd->select_all_item) + { + wd->select_all_check = EINA_FALSE; + edje_object_signal_callback_del(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down); + elm_widget_item_pre_notify_del(wd->select_all_item); + _item_unrealize(wd->select_all_item); + elm_widget_item_del(wd->select_all_item); + } + wd->select_all_item = NULL; + if (wd->edit_field) + { + Evas_Object *editfield; + EINA_LIST_FREE(wd->edit_field, editfield) + evas_object_del(editfield); + wd->edit_field = NULL; } _item_cache_zero(wd); } else { + if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_REORDER) + wd->reorder_mode = EINA_TRUE; + + if (!wd->ed) + wd->ed = calloc(1, sizeof(Edit_Data)); + + wd->ed->ec = edit_class; EINA_INLIST_FOREACH(wd->blocks, itb) { if (itb->realized) { + done = 1; EINA_LIST_FOREACH(itb->items, l, it) { if (it->flags != ELM_GENLIST_ITEM_GROUP && it->realized) { if(it->selected) _item_unselect(it); - if (it->itc->edit_item_style) _effect_item_realize(it, EINA_TRUE); + _effect_item_realize(it, EINA_TRUE); } } } + else + { + if (done) break; + } + } + + if (wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECTALL) + { + if (edit_class->select_all_item_style && strcmp(edit_class->select_all_item_style, "default")) + itc.item_style = edit_class->select_all_item_style; + else + itc.item_style = "select_all"; + itc.func.label_get = NULL; + itc.func.icon_get = NULL; + itc.func.del = NULL; + itc.func.editmode_get = NULL; + wd->select_all_item = _item_new(wd, &itc, (void *)(edit_class->select_all_data), NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + + if (!wd) return; + if (!wd->select_all_item) return; + + _item_realize(wd->select_all_item, 0, 0); + edje_object_signal_callback_add(wd->select_all_item->base.view, "elm,action,select,click", "elm", _select_all_down, wd->select_all_item); + + wd->select_all_item->rel = NULL; + wd->select_all_item->block = NULL; } } @@ -6077,9 +6365,55 @@ elm_genlist_edit_mode_set(Evas_Object *obj, Eina_Bool edit_mode) EAPI void elm_genlist_edit_selected_items_del(Evas_Object *obj) { - fprintf(stderr, "=================> Caution!!! <========================\n"); - fprintf(stderr, "==> elm_genlist_edit_selected_items_del() is deprecated. <=======\n"); - fprintf(stderr, "=======================================================\n"); + ELM_CHECK_WIDTYPE(obj, widtype); + Widget_Data *wd = elm_widget_data_get(obj); + if (!wd) return; + if (!wd->blocks) return; + Elm_Genlist_Item *it; + Eina_List *edit_selected_list, *l; + int cnt = 0; + Item_Block *itb; + + Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh; + int vis = 0; + + if (wd->edit_field) return; + evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh); + evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy,&cvw, &cvh); + EINA_INLIST_FOREACH(wd->blocks, itb) + { + if (ELM_RECTS_INTERSECT(itb->x - wd->pan_x + ox, + itb->y - wd->pan_y + oy, + itb->w, itb->h, + cvx, cvy, cvw, cvh)) + EINA_LIST_FOREACH(itb->items, l, it) + { + it->old_scrl_y =itb->y + it->y - it->wd->pan_y + oy; + } + } + edit_selected_list = elm_genlist_edit_selected_items_get(obj); + cnt = eina_list_count(edit_selected_list); + // printf("elm_genlist_edit_selected_items_del items selected counts = %d \n", cnt); + + wd->expand_item_gap = wd->expand_item_end = 0; + EINA_LIST_FOREACH(edit_selected_list, l, it) + { + if (it->flags != ELM_GENLIST_ITEM_GROUP) + { + it->wd->expand_item_gap += it->h * -1; + vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h, + cvx, cvy, cvw, cvh)); + if (!it->wd->expand_item_end && vis ) it->wd->expand_item_end = it->old_scrl_y; + it->wd->expand_item = elm_genlist_item_prev_get(it); + elm_genlist_item_del(it); + } + } + wd->move_effect_mode = ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE; + eina_list_free(edit_selected_list); + + evas_render(evas_object_evas_get(wd->obj)); + if (wd->calc_job) ecore_job_del(wd->calc_job); + wd->calc_job = ecore_job_add(_calc_job, wd); } EAPI void @@ -6089,6 +6423,7 @@ elm_genlist_selected_items_del(Evas_Object *obj) fprintf(stderr, "==> elm_genlist_selected_items_del() is deprecated. <=======\n"); fprintf(stderr, "==> Please use elm_genlist_edit_selected_items_del() instead. <==\n"); fprintf(stderr, "=======================================================\n"); + elm_genlist_edit_selected_items_del(obj); } /** @@ -6108,10 +6443,18 @@ elm_genlist_selected_items_del(Evas_Object *obj) EAPI Eina_List * elm_genlist_edit_selected_items_get(const Evas_Object *obj) { - fprintf(stderr, "========================> Caution!!! <==========================\n"); - fprintf(stderr, "==> elm_genlist_edit_selected_items_get() is deprecated. <=======\n"); - fprintf(stderr, "================================================================\n"); - return NULL; + ELM_CHECK_WIDTYPE(obj, widtype) NULL; + Widget_Data *wd = elm_widget_data_get(obj); + Eina_List *list = NULL; + Elm_Genlist_Item *it; + if (!wd) return NULL; + + EINA_INLIST_FOREACH(wd->items, it) + { + if (it->edit_select_check && it->flags != ELM_GENLIST_ITEM_GROUP) list = eina_list_append(list, it); + } + + return list; } // TODO : add comment @@ -6119,19 +6462,22 @@ EAPI void elm_genlist_edit_item_selected_set(Elm_Genlist_Item *it, Eina_Bool selected) { - fprintf(stderr, "========================> Caution!!! <==========================\n"); - fprintf(stderr, "==> elm_genlist_edit_item_selected_set() is deprecated. <=======\n"); - fprintf(stderr, "================================================================\n"); + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Widget_Data *wd = elm_widget_data_get(it->base.widget); + if (!wd) return; + selected = !!selected; + if (it->edit_select_check == selected) return; + + it->edit_select_check = selected; + _checkbox_item_select_process(it); } // TODO : add comment EAPI Eina_Bool elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it) { - fprintf(stderr, "========================> Caution!!! <==========================\n"); - fprintf(stderr, "==> elm_genlist_edit_item_selected_get() is deprecated. <=======\n"); - fprintf(stderr, "================================================================\n"); - return EINA_FALSE; + ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE); + return it->edit_select_check; } /** @@ -6144,12 +6490,22 @@ elm_genlist_edit_item_selected_get(const Elm_Genlist_Item *it) * * @ingroup Genlist */ -EAPI void -elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed) +EAPI Evas_Object * +elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, int emode) { - if (!it) return; + if (!it) return NULL; + if (it->wd->queue_idler) return NULL; + + const Eina_List *l, *list, *l2; + const char *label, *rename_swallow_part; + char *s; + Eina_Bool done = EINA_FALSE; + int label_cnt = 0 , swallow_part_cnt = 0; Item_Block *itb; + Evas_Object *editfield; + Evas_Object *entry = NULL; + int edit_field_cnt = 0; EINA_INLIST_FOREACH(it->wd->blocks, itb) { @@ -6163,32 +6519,90 @@ elm_genlist_item_rename_mode_set(Elm_Genlist_Item *it, Eina_Bool renamed) if (it->renamed) { it->renamed = EINA_FALSE; - it->nocache = EINA_TRUE; - it->wd->rename_it = NULL; - elm_genlist_item_update(it); + if (it->selected) _item_unselect(it); + EINA_LIST_FOREACH(it->wd->edit_field, l2, editfield) + { + entry = elm_editfield_entry_get(editfield); + const char *text = elm_entry_entry_get(entry); + if (it->itc->func.label_changed) + it->itc->func.label_changed(it->base.data, it, text, edit_field_cnt++); + } + EINA_LIST_FREE(it->wd->edit_field, editfield) + evas_object_del(editfield); + it->wd->edit_field = NULL; + + if (it->wd->edit_mode) + { + edje_object_signal_emit(it->edit_obj, "elm,state,edit_end,enable", "elm"); + edje_object_signal_emit(it->edit_obj, "elm,state,rename,disable", "elm"); + if (it->wd->edit_mode & ELM_GENLIST_EDIT_MODE_SELECT) + edje_object_signal_emit(it->edit_obj, "elm,state,sel_uncheck", "elm"); + } + + if(!it->wd->edit_mode) _effect_item_unrealize(it); + done = EINA_TRUE; + } } } + else + { + if (done) break; } } - if (renamed) + if (emode) { it->renamed = EINA_TRUE; - it->wd->rename_it = it; - it->nocache = EINA_TRUE; - if (it->selected) _item_unselect(it); + if (it->wd->edit_mode == ELM_GENLIST_EDIT_MODE_NONE) + { + it->wd->edit_mode = 0xF0; + _effect_item_realize(it, EINA_TRUE); + it->wd->edit_mode = ELM_GENLIST_EDIT_MODE_NONE; + } - _item_unrealize(it); - if (it->wd->calc_job) ecore_job_del(it->wd->calc_job); - it->wd->calc_job = ecore_job_add(_calc_job, it->wd); + edje_object_signal_emit(it->edit_obj, "elm,state,rename,enable", "elm"); + EINA_LIST_FOREACH(it->labels, list, label) + { + if (it->itc->func.label_get) + { + swallow_part_cnt = 0; + + Eina_List *rename = elm_widget_stringlist_get(edje_object_data_get(it->edit_obj, "rename")); + EINA_LIST_FOREACH(rename, l, rename_swallow_part) + { + if (label_cnt == swallow_part_cnt) + { + editfield = elm_editfield_add(it->base.widget); + it->wd->edit_field = eina_list_append(it->wd->edit_field, editfield); + + elm_editfield_entry_single_line_set(editfield, EINA_TRUE); + elm_editfield_eraser_set(editfield, EINA_TRUE); + edje_object_part_swallow(it->edit_obj, rename_swallow_part, editfield); + elm_widget_sub_object_add(it->edit_obj, editfield); + + evas_object_show(editfield); + + s = it->itc->func.label_get((void *)it->base.data, it->base.widget, list->data); + if (s) + { + entry = elm_editfield_entry_get(editfield); + elm_entry_entry_set(entry,s); + elm_entry_cursor_end_set(entry); + free(s); + } + else + elm_editfield_guide_text_set(editfield, "Text Input"); + } + swallow_part_cnt++; + } + label_cnt++; + } } + elm_widget_focused_object_clear(elm_widget_focused_object_get(it->wd->obj)); + elm_widget_focus_set(editfield, EINA_TRUE); } -EAPI Eina_Bool -elm_genlist_item_rename_mode_get(Elm_Genlist_Item *item) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return item->renamed; + return entry; } static void _sweep_finish(void *data, Evas_Object *o, const char *emission, const char *source) @@ -6338,24 +6752,3 @@ _item_auto_scroll(void *data) } } } - -EAPI int -elm_genlist_item_flags_get(const Elm_Genlist_Item *item) -{ - ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE); - return item->flags; -} - -EAPI void -elm_genlist_realized_items_update(const Evas_Object *obj) -{ - ELM_CHECK_WIDTYPE(obj, widtype); - - Eina_List *list, *l; - Elm_Genlist_Item *it; - - list = elm_genlist_realized_items_get(obj); - EINA_LIST_FOREACH(list, l, it) - elm_genlist_item_update(it); -} - -- 2.7.4