From 923a9ac527733c857a33ff71232d2298868fba98 Mon Sep 17 00:00:00 2001 From: Hyojung Jo Date: Wed, 19 Aug 2015 21:00:49 +0900 Subject: View: Enabled the buttons to be clicked Change-Id: I31e7350387e069646ed2ed361e3dee4c347f5049 Signed-off-by: Hyojung Jo --- include/define.h | 4 +-- res/widgets/button.edc | 50 ++++++++++++++++++++++++++++++-- src/view/view_action_menu.c | 70 +++++++++++++++++++++++++++++++++------------ 3 files changed, 99 insertions(+), 25 deletions(-) diff --git a/include/define.h b/include/define.h index d03a3f4..505fa8a 100644 --- a/include/define.h +++ b/include/define.h @@ -59,13 +59,11 @@ #define SIG_ITEM_SELECTED "item.selected" #define SIG_VISIBLE "visible" #define SIG_INVISIBLE "invisible" -#define SIG_DISABLE "disable" -#define SIG_BTN_DISABLE "elm,state,disabled" +#define SIG_DISABLE "elm,state,disabled" /* Source */ #define SRC_EDC "edc" #define SRC_MENU_BTN "menubtn" -#define SRC_LIVETV_BTN "source.livetv.btn" #define SRC_ACTION_BTN "source.action.btn" /* Transition */ diff --git a/res/widgets/button.edc b/res/widgets/button.edc index 23516a2..0782ec8 100644 --- a/res/widgets/button.edc +++ b/res/widgets/button.edc @@ -460,6 +460,20 @@ group { color, 194 194 194 127; } } + + part { + name, "event"; + type, RECT; + description { + state, "default" 0.0; + color, 0 0 0 0; + } + description { + state, "disable" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } } programs { @@ -486,15 +500,23 @@ group { program { name, SIG_DISABLE; signal, SIG_DISABLE; - source, SRC_LIVETV_BTN; + source, "elm"; script { set_state(PART:"elm.text", "disable", 0.0); set_state(PART:"part.inside.line.up", "disable", 0.0); set_state(PART:"part.inside.line.down", "disable", 0.0); set_state(PART:"part.inside.line.left", "disable", 0.0); set_state(PART:"part.inside.line.right", "disable", 0.0); + set_state(PART:"event", "disable", 0.0); } } + + program { + name, "mouse_unclick_after"; + signal, "mouse,clicked,1"; + source, "event"; + action, SIGNAL_EMIT "elm,action,click" ""; + } } } @@ -696,6 +718,20 @@ group { color, 104 104 104 127; } } + + part { + name, "event"; + type, RECT; + description { + state, "default" 0.0; + color, 0 0 0 0; + } + description { + state, "disable" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } } programs{ @@ -765,16 +801,24 @@ group { } program { - name, SIG_BTN_DISABLE; - signal, SIG_BTN_DISABLE; + name, SIG_DISABLE; + signal, SIG_DISABLE; source, "elm"; script { set_int(cur_state, STATE_DISABLE); set_state(PART:"part.bg", "disable", 0.0); set_state(PART:"elm.text", "disable", 0.0); set_state(PART:"part.icon", "disable", 0.0); + set_state(PART:"event", "disable", 0.0); } } + + program { + name, "mouse_unclick_after"; + signal, "mouse,clicked,1"; + source, "event"; + action, SIGNAL_EMIT "elm,action,click" ""; + } } } diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c index 05ab27b..988442b 100644 --- a/src/view/view_action_menu.c +++ b/src/view/view_action_menu.c @@ -21,6 +21,13 @@ #include "define.h" #include "utils.h" +enum button_type { + BTN_LIVETV = 0, + BTN_FAVORITE, + BTN_LOCK, + BTN_SHARE, +}; + struct _priv { Evas_Object *win; Evas_Object *base; @@ -29,6 +36,7 @@ struct _priv { }; struct _action_info { + int id; const char *title; const char *style; Eina_Bool disable; @@ -36,16 +44,19 @@ struct _action_info { static struct _action_info action_info[] = { { + .id = BTN_FAVORITE, .title = STR_FAVORITE, .style = STYLE_ACTION_MENU_FAV_BTN, .disable = EINA_FALSE }, { + .id = BTN_LOCK, .title = STR_LOCK, .style = STYLE_ACTION_MENU_LOCK_BTN, .disable = EINA_TRUE }, { + .id = BTN_SHARE, .title = STR_SHARE, .style = STYLE_ACTION_MENU_SHARE_BTN, .disable = EINA_TRUE @@ -64,20 +75,42 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, elm_object_focus_set(obj, EINA_TRUE); } -static void _livetv_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Down *ev) +static void _favorite_selected(void *data, Evas_Object *obj) { - if (!ev) { - _ERR("Invalid argument."); - return; - } + /* It will be implemented later */ +} - if (!strcmp(ev->keyname, KEY_BACK) - || !strcmp(ev->keyname, KEY_BACK_REMOTE)) - viewmgr_hide_view(VIEW_ID_ACTION_MENU); +static void _livetv_selected(void *data, Evas_Object *obj) +{ + /* It will be implemented later */ } -static void _action_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, +static void _clicked_cb(int id, void *data, Evas_Object *obj) +{ + + switch (id) { + case BTN_LIVETV: + _livetv_selected(data, obj); + break; + + case BTN_FAVORITE: + _favorite_selected(data, obj); + break; + + case BTN_LOCK: + /* It is not supported yet. */ + break; + + case BTN_SHARE: + /* It is not supported yet. */ + break; + + default: + _ERR("Unhandled action type."); + } +} + +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { if (!ev) { @@ -90,14 +123,10 @@ static void _action_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, viewmgr_hide_view(VIEW_ID_ACTION_MENU); } -static input_handler _livetv_input_handler = { - .mouse_move = _mouse_move_cb, - .key_down = _livetv_key_down_cb -}; - -static input_handler _action_input_handler = { +static input_handler _btn_input_handler = { .mouse_move = _mouse_move_cb, - .key_down = _action_key_down_cb + .clicked = _clicked_cb, + .key_down = _key_down_cb }; static bool _draw_livetv_area(struct _priv *priv) @@ -116,7 +145,7 @@ static bool _draw_livetv_area(struct _priv *priv) return false; } - inputmgr_add_callback(btn, 0, &_livetv_input_handler, priv); + inputmgr_add_callback(btn, BTN_LIVETV, &_btn_input_handler, priv); elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP); elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT); @@ -153,7 +182,8 @@ static bool _draw_menu_area(struct _priv *priv) return false; } - inputmgr_add_callback(btn, i, &_action_input_handler, priv); + inputmgr_add_callback(btn, action_info[i].id, + &_btn_input_handler, priv); if (action_info[i].disable) elm_object_disabled_set(btn, EINA_TRUE); @@ -171,6 +201,8 @@ static bool _draw_menu_area(struct _priv *priv) priv->menu_btn[0], ELM_FOCUS_LEFT); elm_object_focus_next_object_set(priv->menu_btn[0], priv->menu_btn[0], ELM_FOCUS_RIGHT); + elm_object_focus_next_object_set(priv->menu_btn[0], + priv->menu_btn[0], ELM_FOCUS_DOWN); elm_object_focus_next_object_set(priv->live_btn, priv->menu_btn[0], ELM_FOCUS_DOWN); -- cgit v1.2.3