remove edit mode in custom bar 17/39017/2
authorSoohye Shin <soohye.shin@samsung.com>
Thu, 7 May 2015 05:29:39 +0000 (14:29 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Thu, 7 May 2015 05:35:39 +0000 (14:35 +0900)
Change-Id: If28a6649401aaf0642c32517c6827b3ff3b2e50d
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
src/custombar.cpp
src/homescreen.cpp

index d8bd4ab..1d2f4c1 100644 (file)
  */
 
 #include <ctype.h>
-
 #include <AppCommon.h>
+
 #include "i18n.h"
 #include "bar.h"
 #include "engine.h"
 #include "defs.h"
 
-#define KEY_LONG_DUR 1.0
-#define EDIT_ARROW_UP_H 50
-#define BTN_MAX 2
-#define NO_PIN_ITEM 3
-#define BUF_MESSAGE_MAX 256
-#define POPUP_DUR 3.0
-#define PIN_ITEM_WIDTH 270
-#define PIN_ITEM_HEIGHT 150
-#define CBAR_HEIGHT (1080 * elm_config_scale_get())
-
-#define TITLE_DELETE "Delete Menu"
-#define MESSAGE_DELETE "Are you sure you want to delete the"
-#define MESSAGE_PIN_BANNER "is deleted"
-
 enum _cbar_state {
        CBAR_STATE_HIDE,
        CBAR_STATE_CBAR,
        CBAR_STATE_DBAR,
-       CBAR_STATE_EDIT,
-       CBAR_STATE_X
 };
 
 struct _cbar_item;
-struct _edit_item;
 
 struct _cbar_data {
        Evas_Object *ly;
@@ -53,42 +36,22 @@ struct _cbar_data {
        Evas_Object *pin;
        Evas_Object *scr;
        Eina_List *list;
-       Ecore_Timer *key_timer;
-       Evas_Coord x;
-       Evas_Coord y;
 
        struct _cbar_item *cur;
        CEngine *eng;
        enum _cbar_state state;
        struct bar_info *cbar;
-       enum bar_direction pin_dir;
 };
 
 struct _cbar_item {
        Evas_Object *eo;
        Evas_Object *lbl;
        Evas_Object *ic;
-       Elm_Transit *trans;
 
        CEngineBarItem *it;
        Eina_Bool dirty;
        struct _cbar_data *bar;
        struct bar_info *dbar;
-       struct _edit_item *edit;
-};
-
-struct _edit_item {
-       Evas_Object *x;
-       Evas_Object *up;
-       Evas_Object *down;
-       Evas_Object *popup;
-       Evas_Object *btn[BTN_MAX];
-};
-
-struct _btn_info {
-       const char *part;
-       const char *text;
-       void (*click_cb)(void *, Evas *, Evas_Object *, void *);
 };
 
 static const char *_trim(char *str)
@@ -112,32 +75,8 @@ static const char *_trim(char *str)
        return str;
 }
 
-static Eina_Bool _move_edit_item(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       item = bar->cur;
-       if (!item || !item->eo)
-               return EINA_FALSE;
-
-       elm_object_signal_emit(item->edit->x, SIG_UNFOCUS, SRC_PROG);
-       elm_object_signal_emit(item->eo, SIG_FOCUS_FROM_EDIT, SRC_PROG);
-
-       bar->state = CBAR_STATE_EDIT;
-
-       return EINA_TRUE;
-}
-
-static Eina_Bool _move(struct bar_info *info);
-
 static enum bar_event _move_left(struct bar_info *info)
 {
-       struct _cbar_item *item;
        struct _cbar_data *bar;
        Eina_Bool r;
 
@@ -145,21 +84,10 @@ static enum bar_event _move_left(struct bar_info *info)
                return BAR_EVENT_ERROR;
 
        bar = (struct _cbar_data *)info->data;
-       item = bar->cur;
-
-       if (!item)
-               return BAR_EVENT_ERROR;
 
        switch (bar->state) {
        case CBAR_STATE_CBAR:
                return BAR_EVENT_MOVE;
-       case CBAR_STATE_EDIT:
-               return BAR_EVENT_PASS;
-       case CBAR_STATE_X:
-               if (item->edit && item->edit->popup)
-                       return BAR_EVENT_PASS;
-               r = _move_edit_item(bar);
-               break;
        default:
                return BAR_EVENT_ERROR;
        }
@@ -175,665 +103,32 @@ static bool _launch_app(struct bar_info *info)
        if (!info || !info->data)
                return false;
 
-       bar = (struct _cbar_data *)info->data;
-       item = bar->cur;
-
-       if (!item) {
-               _ERR("Invalid argument");
-               return false;
-       }
-
-       return item->it->Launch();
-}
-
-static void _locate_edit_item(Evas_Object *eo, Evas_Object *p,
-               const char *file, struct _cbar_data *bar)
-{
-       Evas_Coord x, y, w, h;
-       Evas_Coord mx, my;
-       double s;
-
-       if (!eo || !p || !file || !bar) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       s = elm_config_scale_get();
-       evas_object_geometry_get(p, &x, &y, &w, &h);
-       if (!x || !y) {
-               x = bar->x;
-               if (bar->pin_dir == BAR_DIR_UP)
-                       y = bar->y - PIN_ITEM_HEIGHT;
-               else
-                       y = bar->y + PIN_ITEM_HEIGHT;
-               w = PIN_ITEM_WIDTH;
-               h = PIN_ITEM_HEIGHT;
-       }
-
-       if (!strcmp(file, GRP_EDIT_X)) {
-               mx = x * s + w * s;
-               my = y * s;
-       } else if (!strcmp(file, GRP_EDIT_ARROW_DOWN)) {
-               mx = x * s;
-               my = y * s + h * s;
-       } else if (!strcmp(file, GRP_EDIT_ARROW_UP)) {
-               mx = x * s;
-               my = y * s - EDIT_ARROW_UP_H * s;
-       } else
-               return;
-
-       evas_object_move(eo, mx, my);
-}
-
-static Eina_Bool _set_x_item(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       struct _edit_item *edit;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       item = bar->cur;
-       edit = item->edit;
-       if (!edit || !edit->x)
-               return EINA_FALSE;
-
-       elm_object_signal_emit(item->eo, SIG_UNFOCUS_TO_DBAR, SRC_PROG);
-       elm_object_signal_emit(edit->x, SIG_INITIAL_FOCUS, SRC_PROG);
-
-       bar->state = CBAR_STATE_X;
-
-       return EINA_TRUE;
-}
-
-static void _x_mouse_over(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       struct _cbar_item *item;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       item = (struct _cbar_item *)data;
-
-       if (item->bar->state != CBAR_STATE_EDIT)
-               return;
-
-       _set_x_item(item->bar);
-}
-
-static Eina_Bool _add_del_popup(struct _cbar_data *);
-
-static void _x_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       struct _cbar_item *item;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       item = (struct _cbar_item *)data;
-
-       if (item->bar->state != CBAR_STATE_X)
-               return;
-
-       _add_del_popup(item->bar);
-}
-
-static inline Evas_Object *_add_cbar_item_bg(Evas_Object *,
-               CEngineBarItem *);
-static Eina_Bool _swap_pin(struct _cbar_data *bar);
-static Eina_Bool _change_edit_mode(struct _cbar_data *bar);
-
-static void _arrow_down_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       struct _cbar_item *item;
-       struct _cbar_data *bar;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       item = (struct _cbar_item *)data;
-       bar = item->bar;
-
-       if (obj == item->edit->up) {
-               bar->pin_dir = BAR_DIR_UP;
-               _swap_pin(bar);
-       } else if (obj == item->edit->down) {
-               bar->pin_dir = BAR_DIR_DOWN;
-               _swap_pin(bar);
-       } else
-               return;
-
-       elm_object_signal_emit(bar->ly, SIG_SWAP_PIN, SRC_PROG);
-}
-
-static Evas_Object *_add_edit_item(struct _cbar_item *item, const char *file)
-{
-       Evas_Object *eo, *bg;
-
-       if (!item || !item->eo || !file) {
-               _ERR("Invalid argument");
-               return NULL;
-       }
-
-       eo = elm_layout_add(item->eo);
-       if (!eo) {
-               _ERR("layout add failed");
-               return NULL;
-       }
-       elm_object_focus_allow_set(eo, EINA_TRUE);
-       elm_layout_file_set(eo, EDJEFILE, file);
-       evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_DOWN,
-                       _arrow_down_clicked, item);
-       evas_object_show(eo);
-
-       if (!strcmp(file, GRP_EDIT_X)) {
-               bg = _add_cbar_item_bg(eo, item->it);
-               if (!bg) {
-                       evas_object_del(eo);
-                       return NULL;
-               }
-               elm_object_part_content_set(eo, PART_BG, bg);
-               evas_object_show(bg);
-
-               evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_MOVE,
-                               _x_mouse_over, item);
-               evas_object_event_callback_add(eo, EVAS_CALLBACK_MOUSE_UP,
-                               _x_clicked, item);
-       }
-
-       _locate_edit_item(eo, item->eo, file, item->bar);
-
-       return eo;
-}
-
-enum _edit_item_order {
-       EDIT_ITEM_ORDER_ONE,
-       EDIT_ITEM_ORDER_FIRST,
-       EDIT_ITEM_ORDER_LAST,
-       EDIT_ITEM_ORDER_OTHERS,
-       EDIT_ITEM_ORDER_MAX
-};
-
-static enum _edit_item_order _get_edit_item_order(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       Eina_List *l;
-       int i, cnt;
-       void *obj;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EDIT_ITEM_ORDER_MAX;
-       }
-
-       i = 0;
-       cnt = 0;
-       EINA_LIST_FOREACH(bar->list, l, obj) {
-               item = (struct _cbar_item *)obj;
-               if (item->it->Int(CEngineBarItem::VINT_IS_PINNED)) {
-                       if (item == bar->cur)
-                               i = cnt;
-                       cnt++;
-               }
-       }
-
-       if (cnt == 1)
-               return EDIT_ITEM_ORDER_ONE;
-
-       if (i == 0)
-               return EDIT_ITEM_ORDER_FIRST;
-       else if (i == cnt - 1)
-               return EDIT_ITEM_ORDER_LAST;
-
-       return EDIT_ITEM_ORDER_OTHERS;
-}
-
-static Elm_Transit *_set_transit_icon(Evas_Object *ic)
-{
-       Elm_Transit *trans;
-
-       if (!ic)
-               return NULL;
-
-       trans = elm_transit_add();
-       if (!trans) {
-               _ERR("transit add failed");
-               return NULL;
-       }
-
-       elm_transit_object_add(trans, ic);
-       elm_transit_effect_color_add(trans, 255, 255, 255,
-                       255, 255, 255, 255, 50);
-       elm_transit_objects_final_state_keep_set(trans, EINA_TRUE);
-       elm_transit_duration_set(trans, 0.3);
-       elm_transit_go(trans);
-
-       return trans;
-}
-
-static void _dim_item(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       Eina_List *l;
-       void *obj;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       elm_object_signal_emit(bar->pin, SIG_DIM_ITEM, SRC_PROG);
-       elm_object_signal_emit(bar->ly, SIG_DIM_ITEM, SRC_PROG);
-       elm_object_focus_set(bar->scr, EINA_FALSE);
-
-       EINA_LIST_FOREACH(bar->list, l, obj) {
-               item = (struct _cbar_item *)obj;
-               elm_object_focus_allow_set(item->eo, EINA_FALSE);
-               if (item == bar->cur)
-                       continue;
-
-               elm_object_signal_emit(item->eo, SIG_DIM_ITEM, SRC_PROG);
-               elm_object_signal_emit(item->lbl, SIG_DIM_ITEM, SRC_PROG);
-               item->trans = _set_transit_icon(item->ic);
-       }
-}
-
-static void _undim_item(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       Eina_List *l;
-       void *obj;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       elm_object_signal_emit(bar->pin, SIG_UNDIM_ITEM, SRC_PROG);
-       elm_object_signal_emit(bar->ly, SIG_UNDIM_ITEM, SRC_PROG);
-       elm_object_focus_set(bar->scr, EINA_TRUE);
-
-       EINA_LIST_FOREACH(bar->list, l, obj) {
-               item = (struct _cbar_item *)obj;
-               elm_object_focus_allow_set(item->eo, EINA_TRUE);
-               if (item == bar->cur)
-                       continue;
-
-               elm_object_signal_emit(item->eo, SIG_UNDIM_ITEM, SRC_PROG);
-               elm_object_signal_emit(item->lbl, SIG_UNDIM_ITEM, SRC_PROG);
-               evas_object_color_set(item->ic, 255, 255, 255, 255);
-               elm_transit_del(item->trans);
-       }
-}
-
-static void _emit_arrow_signal(struct _cbar_item *item)
-{
-       struct _edit_item *edit;
-
-       if (!item || !item->edit) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       edit = item->edit;
-
-       if (item->eo)
-               elm_object_signal_emit(item->eo, SIG_SHOW_EDIT_ITEM, SRC_PROG);
-       if (edit->up)
-               elm_object_signal_emit(edit->up, SIG_FOCUS_ARROW, SRC_PROG);
-       if (edit->down)
-               elm_object_signal_emit(edit->down, SIG_FOCUS_ARROW, SRC_PROG);
-}
-
-static void _free_item(struct _edit_item *edit)
-{
-       if (!edit) {
-               _ERR("Invalid Argument");
-               return;
-       }
-
-       if (edit->x) {
-               evas_object_del(edit->x);
-               edit->x = NULL;
-       }
-       if (edit->up) {
-               evas_object_del(edit->up);
-               edit->up = NULL;
-       }
-       if (edit->down) {
-               evas_object_del(edit->down);
-               edit->down = NULL;
-       }
-       if (edit->popup) {
-               evas_object_del(edit->popup);
-               edit->popup = NULL;
-       }
-
-       free(edit);
-}
-
-static Eina_Bool _change_edit_mode(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       struct _edit_item *edit;
-       enum _edit_item_order order;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       item = bar->cur;
-       if (!item || !item->eo) {
-               _ERR("There is no item");
-               return EINA_FALSE;
-       }
-
-       if (item->edit) {
-               _ERR("Already edit mode");
-               return EINA_FALSE;
-       }
-
-       edit = (struct _edit_item *)calloc(1, sizeof(*edit));
-       if (!edit) {
-               _ERR("failed to calloc edit item");
-               return EINA_FALSE;
-       }
-       item->edit = edit;
-
-       order = _get_edit_item_order(bar);
-       switch (order) {
-       case EDIT_ITEM_ORDER_ONE:
-               edit->x = _add_edit_item(item, GRP_EDIT_X);
-               if (!edit->x)
-                       goto err;
-               break;
-       case EDIT_ITEM_ORDER_OTHERS:
-               edit->up = _add_edit_item(item, GRP_EDIT_ARROW_UP);
-               if (!edit->up)
-                       goto err;
-               /* fallthrough */
-       case EDIT_ITEM_ORDER_FIRST:
-               edit->x = _add_edit_item(item, GRP_EDIT_X);
-               if (!edit->x)
-                       goto err;
-
-               edit->down = _add_edit_item(item, GRP_EDIT_ARROW_DOWN);
-               if (!edit->down)
-                       goto err;
-               break;
-       case EDIT_ITEM_ORDER_LAST:
-               edit->up = _add_edit_item(item, GRP_EDIT_ARROW_UP);
-               if (!edit->up)
-                       goto err;
-
-               edit->x = _add_edit_item(item, GRP_EDIT_X);
-               if (!edit->x)
-                       goto err;
-               break;
-       default:
-               goto err;
-       }
-
-       bar->state = CBAR_STATE_EDIT;
-
-       _dim_item(bar);
-       _emit_arrow_signal(item);
-
-       return EINA_TRUE;
-
-err:
-       _ERR("item add failed");
-       _free_item(edit);
-       return EINA_FALSE;
-}
-
-static Eina_Bool _long_key_cb(void *data)
-{
-       struct _cbar_data *bar;
-       struct _cbar_item *item;
-
-       if (!data)
-               return ECORE_CALLBACK_CANCEL;
-
-       bar = (struct _cbar_data *)data;
-       item = bar->cur;
-
-       if (item->it->Int(CEngineBarItem::VINT_IS_PINNED))
-               _change_edit_mode(bar);
-               return ECORE_CALLBACK_DONE;
-
-       return ECORE_CALLBACK_CANCEL;
-}
-
-static Eina_Bool _change_cbar_mode(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       item = bar->cur;
-
-       _free_item(item->edit);
-       _undim_item(bar);
-       item->edit = NULL;
-
-       elm_object_focus_set(item->eo, EINA_TRUE);
-       elm_object_signal_emit(item->eo, SIG_SHOW_EDIT_ITEM, SRC_PROG);
-
-       bar->state = CBAR_STATE_CBAR;
-
-       return EINA_TRUE;
-}
-
-static void _free_popup(struct _cbar_data *bar)
-{
-       if (!bar) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       if (!bar->cur->edit->popup)
-               return;
-
-       evas_object_del(bar->cur->edit->popup);
-       bar->cur->edit->popup = NULL;
-}
-
-static void _update_pin(void *data, bool focus);
-
-static void _del_pin(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       int r;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       item = bar->cur;
-
-       r = bar->eng->DelPin(item->it);
-       if (r < 0) {
-               _ERR("failed to del pin");
-               return;
-       }
-
-       _free_popup(bar);
-       _free_item(item->edit);
-       _undim_item(bar);
-
-       bar->state = CBAR_STATE_CBAR;
-}
-
-static void _del_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       _del_pin((struct _cbar_data *)data);
-}
-
-static void _cancel_clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       _free_popup((struct _cbar_data *)data);
-}
-
-static void _btn_mouse_over(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       elm_object_focus_set(obj, EINA_TRUE);
-}
-
-static int _add_btn(Evas_Object *p, struct _cbar_item *item)
-{
-       Evas_Object *btn;
-       struct _edit_item *edit;
-       struct _btn_info btn_info[] = {
-               {
-                       "button1",
-                       "Delete",
-                       _del_clicked
-               },
-               {
-                       "button2",
-                       "Cancel",
-                       _cancel_clicked
-               }
-       };
-       int i;
-
-       if (!p || !item) {
-               _ERR("Invalid argument");
-               return -1;
-       }
-
-       edit = item->edit;
-       for (i = 0; i < (int) (sizeof(btn_info) / sizeof(*btn_info)); i++) {
-               btn = elm_button_add(p);
-               if (!btn) {
-                       _ERR("failed to create button");
-                       memset(edit->btn, 0x00, sizeof(edit->btn));
-                       return -1;
-               }
-               elm_object_part_content_set(p, btn_info[i].part, btn);
-               elm_object_text_set(btn, btn_info[i].text);
-               evas_object_show(btn);
-               edit->btn[i] = btn;
-
-               evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN,
-                               btn_info[i].click_cb, item->bar);
-               evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_MOVE,
-                               _btn_mouse_over, item);
-
-               if (i == 0)
-                       elm_object_focus_set(btn, EINA_TRUE);
-       }
-
-       return 0;
-}
-
-static Eina_Bool _add_del_popup(struct _cbar_data *bar)
-{
-       struct _cbar_item *item;
-       struct _edit_item *edit;
-       Evas_Object *popup, *win;
-       char buf[BUF_MESSAGE_MAX];
-       int r;
-
-       if (!bar) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       item = bar->cur;
-       edit = item->edit;
-
-       if (edit->popup) {
-               _ERR("Already popup created");
-               return EINA_FALSE;
-       }
-
-       win = elm_object_parent_widget_get(bar->ly);
-       if (!win) {
-               _ERR("failed to get win eo");
-               return EINA_FALSE;
-       }
+       bar = (struct _cbar_data *)info->data;
+       item = bar->cur;
 
-       popup = elm_popup_add(win);
-       if (!popup) {
-               _ERR("failed to create popup");
-               return EINA_FALSE;
-       }
-       elm_object_part_text_set(popup, PART_POPUP_TEXT, TITLE_DELETE);
-       elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
-       elm_object_focus_allow_set(popup, EINA_FALSE);
-       evas_object_show(popup);
-       snprintf(buf, sizeof(buf), "%s %s?", MESSAGE_DELETE,
-                       _trim((char *)item->it->Str(CEngineBarItem::VSTR_NAME)));
-       elm_object_text_set(popup, buf);
-
-       r = _add_btn(popup, item);
-       if (r < 0) {
-               _ERR("failed to add btn");
-               evas_object_del(popup);
-               return EINA_FALSE;
+       if (!item) {
+               _ERR("Invalid argument");
+               return false;
        }
 
-       edit->popup = popup;
-
-       return EINA_TRUE;
+       return item->it->Launch();
 }
 
 static enum bar_event _enter(struct bar_info *info)
 {
        struct _cbar_data *bar;
-       struct _cbar_item *item;
        Eina_Bool r;
 
        if (!info || !info->data)
                return BAR_EVENT_ERROR;
 
        bar = (struct _cbar_data *)info->data;
-       item = bar->cur;
-
-       if (!item)
-               return BAR_EVENT_ERROR;
 
        r = EINA_FALSE;
 
        switch (bar->state) {
        case CBAR_STATE_CBAR:
-               if (!bar->key_timer)
-                       bar->key_timer = ecore_timer_add(KEY_LONG_DUR,
-                                       _long_key_cb, bar);
-               r = EINA_TRUE;
-               break;
-       case CBAR_STATE_EDIT:
-               if (item->edit && !bar->key_timer)
-                       r = _change_cbar_mode(bar);
-               break;
-       case CBAR_STATE_X:
-               if (!item->edit)
-                       break;
-
-               if (item->edit->popup) {
-                       if (elm_object_focus_get(item->edit->btn[0]))
-                               _del_pin(bar);
-                       else
-                               _free_popup(bar);
-                       r = EINA_TRUE;
-               } else {
-                       r = _add_del_popup(bar);
-               }
+               r = _launch_app(info);
                break;
        default:
                return BAR_EVENT_ERROR;
@@ -860,144 +155,53 @@ static enum bar_event _move_right(struct bar_info *info)
        r = EINA_FALSE;
 
        switch (bar->state) {
-       case CBAR_STATE_X:
-               if (item->edit && item->edit->popup)
-                       return BAR_EVENT_PASS;
-               break;
        case CBAR_STATE_CBAR:
                if (!item->dbar) {
-                       r = EINA_FALSE;
+                       r = EINA_TRUE;
                        break;
                }
 
                r = item->dbar->ops->move(item->dbar);
                break;
-       case CBAR_STATE_EDIT:
-               r = _set_x_item(bar);
-               break;
        default:
-               return BAR_EVENT_ERROR;
+               return BAR_EVENT_PASS;
        }
 
        return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
 }
 
-static enum bar_event _back(struct bar_info *info)
+static Eina_Bool _move(struct bar_info *info)
 {
-       struct _cbar_item *item;
        struct _cbar_data *bar;
-       Eina_Bool r;
-
-       if (!info || !info->data)
-               return BAR_EVENT_ERROR;
-
-       bar = (struct _cbar_data *)info->data;
-       item = bar->cur;
-
-       r = EINA_FALSE;
-
-       if (!item)
-               return BAR_EVENT_ERROR;
-
-       switch (bar->state) {
-       case CBAR_STATE_DBAR:
-               r = _move(info);
-               break;
-       case CBAR_STATE_CBAR:
-               return BAR_EVENT_BACK;
-       case CBAR_STATE_EDIT:
-               if (item->edit)
-                       r = _change_cbar_mode(bar);
-               break;
-       case CBAR_STATE_X:
-               if (item->edit && item->edit->popup) {
-                       _free_popup(bar);
-                       return BAR_EVENT_DONE;
-               }
-               r = _move_edit_item(bar);
-               break;
-       default:
-               return BAR_EVENT_ERROR;
-       }
-
-       return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
-}
-
-static int _update(struct bar_info *info, void *eng, void *data);
-
-
-static Eina_Bool _swap_pin(struct _cbar_data *bar)
-{
-       struct _cbar_item *item, *_item, *swap_item;
+       struct _cbar_item *item;
        Eina_List *l;
-       int i, cnt;
        void *obj;
 
-       if (!bar || !bar->cur || !bar->list) {
+       if (!info || !info->data) {
                _ERR("Invalid argument");
                return EINA_FALSE;
        }
 
+       bar = (struct _cbar_data *)info->data;
        item = bar->cur;
 
-       i = 0;
-       EINA_LIST_FOREACH(bar->list, l, obj) {
-               _item = (struct _cbar_item *)obj;
-               if (item == _item)
-                       break;
-
-               i++;
-       }
-
-       if (i == 0) {
-               _ERR("There is no pin item");
-               return EINA_FALSE;
-       }
-
-       cnt = eina_list_count(bar->list);
-
-       switch (bar->pin_dir) {
-       case BAR_DIR_DOWN:
-               if (i == cnt - 1) {
-                       _ERR("There is no lower pin item");
-                       return EINA_FALSE;
-               }
-               i++;
-               break;
-       case BAR_DIR_UP:
-               if (i < NO_PIN_ITEM) {
-                       _ERR("There is no upper pin item");
-                       return EINA_FALSE;
+       if (!item) {
+               EINA_LIST_FOREACH(bar->list, l, obj) {
+                       item = (struct _cbar_item *)obj;
+                       if (elm_object_focus_allow_get(item->eo))
+                               break;
                }
-               i--;
-               break;
-       default:
-               _ERR("Not appropriate direction");
-               return EINA_FALSE;
-       }
-
-       swap_item = (struct _cbar_item *)eina_list_nth(bar->list, i);
-       if (!swap_item) {
-               _ERR("failed to get lower pin item");
-               return EINA_FALSE;
-       }
 
-       if (!bar->eng->Swap(item->it, swap_item->it)) {
-               _ERR("failed to swap pin");
-               return EINA_FALSE;
+               if (!item)
+                       return EINA_FALSE;
        }
 
-       _change_cbar_mode(bar);
-       _update(bar->cbar, bar->eng, NULL);
-
-       bar->state = CBAR_STATE_EDIT;
-       bar->cur = (struct _cbar_item *)eina_list_nth(bar->list, i);
-       elm_object_focus_set(bar->cur->eo, EINA_TRUE);
+       elm_object_focus_set(item->eo, EINA_TRUE);
 
        return EINA_TRUE;
 }
 
-static enum bar_event _move_up(struct bar_info *info)
+static enum bar_event _back(struct bar_info *info)
 {
        struct _cbar_data *bar;
        Eina_Bool r;
@@ -1010,36 +214,13 @@ static enum bar_event _move_up(struct bar_info *info)
        r = EINA_FALSE;
 
        switch (bar->state) {
-       case CBAR_STATE_EDIT:
-               bar->pin_dir = BAR_DIR_UP;
-               r = _swap_pin(bar);
+       case CBAR_STATE_DBAR:
+               r = _move(info);
                break;
+       case CBAR_STATE_CBAR:
+               return BAR_EVENT_BACK;
        default:
-               return BAR_EVENT_PASS;
-       }
-
-       return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
-}
-
-static enum bar_event _move_down(struct bar_info *info)
-{
-       struct _cbar_data *bar;
-       Eina_Bool r;
-
-       if (!info || !info->data)
                return BAR_EVENT_ERROR;
-
-       bar = (struct _cbar_data *)info->data;
-
-       r = EINA_FALSE;
-
-       switch (bar->state) {
-       case CBAR_STATE_EDIT:
-               bar->pin_dir = BAR_DIR_DOWN;
-               r = _swap_pin(bar);
-               break;
-       default:
-               return BAR_EVENT_PASS;
        }
 
        return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
@@ -1084,10 +265,6 @@ static enum bar_event _key_event(struct bar_info *info, void *ei)
                r = _move_right(info);
        else if (!strcmp(ev->keyname, KEY_LEFT))
                r = _move_left(info);
-       else if (!strcmp(ev->keyname, KEY_UP))
-               r = _move_up(info);
-       else if (!strcmp(ev->keyname, KEY_DOWN))
-               r = _move_down(info);
        else if (!strcmp(ev->keyname, KEY_HOME))
                r = _home(info);
        else
@@ -1151,8 +328,6 @@ static enum bar_event _key_down(struct bar_info *info, void *ei)
        r = BAR_EVENT_PASS;
 
        switch (bar->state) {
-       case CBAR_STATE_EDIT:
-       case CBAR_STATE_X:
        case CBAR_STATE_CBAR:
                r = BAR_EVENT_PASS;
                break;
@@ -1170,114 +345,6 @@ static enum bar_event _key_down(struct bar_info *info, void *ei)
        return _bar_event(info, ei, r);
 }
 
-static int _bring_in_middle(Evas_Object *scr,
-               Evas_Object *obj, Evas_Object *pin)
-{
-       Evas_Coord y, h, sy, sh, rx, ry, rw, rh, my, smy, ch;
-       Evas_Coord min_h, max_h;
-       const char *s;
-
-       if (!scr || !obj || !pin)
-               return -1;
-
-       evas_object_geometry_get(obj, NULL, &y, NULL, &h);
-       evas_object_geometry_get(scr, NULL, &sy, NULL, &sh);
-       elm_scroller_region_get(scr, &rx, &ry, &rw, &rh);
-       elm_scroller_child_size_get(scr, NULL, &ch);
-
-       if (ch < rh)
-               return 0;
-
-       s = edje_object_data_get(elm_layout_edje_get(pin), DATA_PIN_HEIGHT);
-       min_h = atoi(s);
-       max_h = CBAR_HEIGHT - h;
-
-       if (y >= min_h && y <= max_h)
-               return 0;
-
-       my = y + (h >> 1);
-       smy = sy + (sh >> 1);
-
-       ry = ry - smy + my;
-
-       if (ry < 0)
-               ry = 0;
-       else if (ry + rh > ch)
-               ry = ch - rh;
-
-       elm_scroller_region_show(scr, rx, ry, rw, rh);
-
-       return 1;
-}
-
-static enum bar_event _key_up(struct bar_info *info, void *ei)
-{
-       struct _cbar_data *bar;
-       Ecore_Event_Key *ev;
-
-       if (!info || !info->data || !ei)
-               return BAR_EVENT_ERROR;
-
-       ev = (Ecore_Event_Key *)ei;
-       bar = (struct _cbar_data *)info->data;
-
-       if (!strcmp(ev->keyname, KEY_ENTER) ||
-                       !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
-               if (!bar->key_timer)
-                       return BAR_EVENT_DONE;
-
-               ecore_timer_del(bar->key_timer);
-               bar->key_timer = NULL;
-
-               if (bar->state == CBAR_STATE_CBAR) {
-                       if (_launch_app(info) == true)
-                               return BAR_EVENT_DONE;
-               }
-       } else if (!strcmp(ev->keyname, KEY_UP) ||
-                       !strcmp(ev->keyname, KEY_DOWN)) {
-               if (bar->state != CBAR_STATE_EDIT)
-                       return BAR_EVENT_DONE;
-
-               _bring_in_middle(bar->scr, bar->cur->eo, bar->pin);
-               _change_edit_mode(bar);
-
-               return BAR_EVENT_DONE;
-       }
-
-       return BAR_EVENT_PASS;
-}
-
-static Eina_Bool _move(struct bar_info *info)
-{
-       struct _cbar_data *bar;
-       struct _cbar_item *item;
-       Eina_List *l;
-       void *obj;
-
-       if (!info || !info->data) {
-               _ERR("Invalid argument");
-               return EINA_FALSE;
-       }
-
-       bar = (struct _cbar_data *)info->data;
-       item = bar->cur;
-
-       if (!item) {
-               EINA_LIST_FOREACH(bar->list, l, obj) {
-                       item = (struct _cbar_item *)obj;
-                       if (elm_object_focus_allow_get(item->eo))
-                               break;
-               }
-
-               if (!item)
-                       return EINA_FALSE;
-       }
-
-       elm_object_focus_set(item->eo, EINA_TRUE);
-
-       return EINA_TRUE;
-}
-
 static void _hide(struct bar_info *info)
 {
        struct _cbar_data *bar;
@@ -1385,12 +452,8 @@ static void _mouse_over(void *data, Evas *e, Evas_Object *obj, void *ei)
        case CBAR_STATE_CBAR:
                elm_object_focus_set(item->eo, EINA_TRUE);
                break;
-       case CBAR_STATE_X:
-               if (obj == item->bar->cur->eo)
-                       _move_edit_item(item->bar);
-               break;
        default:
-               break;
+               return;
        }
 }
 
@@ -1544,7 +607,6 @@ static void _focused(void *data, Evas_Object *obj, void *ei)
        struct _cbar_item *foc;
        struct _cbar_item *cur;
        struct _cbar_data *bar;
-       Evas_Coord x, y, w, h;
        Evas_Object *eo;
        int next;
 
@@ -1557,12 +619,6 @@ static void _focused(void *data, Evas_Object *obj, void *ei)
        bar = foc->bar;
        cur = bar->cur;
 
-       evas_object_geometry_get(foc->eo, &x, &y, &w, &h);
-       if (x && y) {
-               bar->x = x;
-               bar->y = y;
-       }
-
        switch (bar->state) {
        case CBAR_STATE_DBAR:
                if (!cur) {
@@ -1610,11 +666,6 @@ static void _focused(void *data, Evas_Object *obj, void *ei)
                                cur->dbar->ops->hide(cur->dbar);
                }
                break;
-       case CBAR_STATE_EDIT:
-               elm_object_signal_emit(foc->eo, SIG_FOCUS, SRC_PROG);
-               return;
-       case CBAR_STATE_X:
-               return;
        case CBAR_STATE_HIDE:
                elm_object_signal_emit(foc->eo, SIG_INITIAL_FOCUS, SRC_PROG);
                break;
@@ -1677,7 +728,7 @@ static Eina_Bool _dbar_focused(void *data, Evas_Object *foc)
        return r;
 }
 
-static void _mouse_down(void *data, Evas *e, Evas_Object *obj, void *ei)
+static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *ei)
 {
        struct _cbar_data *bar;
        struct _cbar_item *item;
@@ -1697,37 +748,6 @@ static void _mouse_down(void *data, Evas *e, Evas_Object *obj, void *ei)
                        ev->canvas.y < y || ev->canvas.y > y + h)
                return;
 
-       switch (bar->state) {
-       case CBAR_STATE_CBAR:
-               if (!bar->key_timer)
-                       bar->key_timer = ecore_timer_add(KEY_LONG_DUR,
-                                       _long_key_cb, bar);
-               break;
-       case CBAR_STATE_EDIT:
-               _change_cbar_mode(bar);
-               break;
-       default:
-               return;
-       }
-}
-
-static void _mouse_up(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
-       struct _cbar_item *item;
-       struct _cbar_data *bar;
-
-       if (!data || !ei)
-               return;
-
-       item = (struct _cbar_item *)data;
-       bar = item->bar;
-
-       if (!bar->key_timer)
-               return;
-
-       ecore_timer_del(bar->key_timer);
-       bar->key_timer = NULL;
-
        if (bar->state == CBAR_STATE_CBAR)
                item->it->Launch();
 }
@@ -1830,8 +850,6 @@ static Evas_Object *_new_cbar_item(Evas_Object *p,
                        EVAS_CALLBACK_MOUSE_MOVE, _mouse_over, item);
        evas_object_event_callback_add(ly,
                        EVAS_CALLBACK_MOUSE_UP, _mouse_up, item);
-       evas_object_event_callback_add(ly,
-                       EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, item);
        evas_object_smart_callback_add(ly, "focused", _focused, item);
 
        item->lbl = lbl;
@@ -1922,6 +940,8 @@ err:
        return NULL;
 }
 
+static int _update(struct bar_info *info, void *eng, void *data);
+
 static void _update_pin(void *data, bool focus)
 {
        struct bar_info *info;
@@ -2026,40 +1046,6 @@ static Evas_Object *_add_pin(Evas_Object *p)
        return ly;
 }
 
-static void _scroll_cb(void *data, Evas_Object *obj,
-               const char *emission, const char *source)
-{
-       struct _cbar_data *bar;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       bar = (struct _cbar_data *)data;
-
-       if (bar->state != CBAR_STATE_EDIT)
-               return;
-
-       _change_edit_mode(bar);
-}
-
-static void _swap_pin_done(void *data, Evas_Object *obj,
-               const char *emission, const char *source)
-{
-       struct _cbar_data *bar;
-
-       if (!data) {
-               _ERR("Invalid argument");
-               return;
-       }
-
-       bar = (struct _cbar_data *)data;
-
-       _bring_in_middle(bar->scr, bar->cur->eo, bar->pin);
-       _change_edit_mode(bar);
-}
-
 static int _add_bar(struct bar_info *info, Evas_Object *base)
 {
        Evas_Object *scr, *bx, *pin;
@@ -2086,12 +1072,6 @@ static int _add_bar(struct bar_info *info, Evas_Object *base)
        }
        elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,
                        ELM_SCROLLER_POLICY_OFF);
-       elm_object_signal_callback_add(scr, SIG_SCROLL_DOWN, SRC_ELM,
-                       _scroll_cb, bar);
-       elm_object_signal_callback_add(scr, SIG_SCROLL_UP, SRC_ELM,
-                       _scroll_cb, bar);
-       elm_object_signal_callback_add(base, SIG_SWAP_PIN_DONE, SRC_EDJE,
-                       _swap_pin_done, bar);
 
        bx = elm_box_add(scr);
        if (!bx) {
@@ -2137,7 +1117,7 @@ static void _release(struct bar_info *info)
                                item->dbar->ops->release(item->dbar);
                        free(item);
                }
-               
+
                bar->eng->SetUpdateCallback(NULL, NULL);
                evas_object_del(bar->pin);
                free(bar);
@@ -2160,7 +1140,6 @@ int init_custom_bar(struct bar_info *info)
        cbar_ops.hide           = _hide;
        cbar_ops.move           = _move;
        cbar_ops.key_down       = _key_down;
-       cbar_ops.key_up         = _key_up;
        cbar_ops.release        = _release;
 
        if (!info)
index e2e3b84..dd18b19 100644 (file)
@@ -264,33 +264,6 @@ static Eina_Bool _bar_event(struct homescreen *hscr, enum bar_event ev)
        return r;
 }
 
-static Eina_Bool _key_up(void *data, int type, void *ei)
-{
-       struct homescreen *hscr;
-       Eina_Bool r;
-       enum bar_event ev;
-
-       if (!data || !ei)
-               return ECORE_CALLBACK_PASS_ON;
-
-       hscr = (struct homescreen *)data;
-
-       switch (hscr->state) {
-       case HOMESCREEN_STATE_CBAR:
-               if (!hscr->cbar)
-                       return ECORE_CALLBACK_CANCEL;
-
-               ev = hscr->cbar->ops->key_up(hscr->cbar, ei);
-               break;
-       default:
-               return ECORE_CALLBACK_PASS_ON;
-       }
-
-       r = _bar_event(hscr, ev);
-
-       return r;
-}
-
 static Eina_Bool _check_home_key(struct homescreen *hscr, void *ei)
 {
        Ecore_Event_Key *ev;
@@ -407,8 +380,6 @@ struct homescreen *homescreen_init(CEngine *eng)
 
        ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
                        _key_down, hscr);
-       ecore_event_handler_add(ECORE_EVENT_KEY_UP,
-                       _key_up, hscr);
 
        hscr->eng = eng;