summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyojung Jo <hj903.jo@samsung.com>2015-08-19 16:12:45 +0900
committerHyojung Jo <hj903.jo@samsung.com>2015-08-19 16:12:45 +0900
commitd80c181486e5b50f827efe3f9367cf672bd21906 (patch)
treed85a21957c5fe591d35c18fddd5e92458e654238
parent0c369731c9ec3193a1e1b64f0e0e9da4004cf680 (diff)
downloadair_favorite-d80c181486e5b50f827efe3f9367cf672bd21906.tar.gz
air_favorite-d80c181486e5b50f827efe3f9367cf672bd21906.tar.bz2
air_favorite-d80c181486e5b50f827efe3f9367cf672bd21906.zip
View: Fixed the action menu to use table instead of box
Change-Id: I779cc5b383b4916e85b25cca7d15ef51a6b97ad0 Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
-rw-r--r--include/define.h3
-rw-r--r--include/utils.h2
-rw-r--r--res/widgets/button.edc76
-rw-r--r--src/common/utils.c25
-rw-r--r--src/view/view_action_menu.c108
5 files changed, 124 insertions, 90 deletions
diff --git a/include/define.h b/include/define.h
index f328d2b..d03a3f4 100644
--- a/include/define.h
+++ b/include/define.h
@@ -60,6 +60,7 @@
#define SIG_VISIBLE "visible"
#define SIG_INVISIBLE "invisible"
#define SIG_DISABLE "disable"
+#define SIG_BTN_DISABLE "elm,state,disabled"
/* Source */
#define SRC_EDC "edc"
@@ -107,6 +108,8 @@
#define SIZE_BOX_PAD_V 0
#define SIZE_STR 1024
#define SIZE_APP_ICON_MAX 100
+#define SIZE_ACTION_TABLE_BORDER 0
+#define SIZE_COL_MAX 4
/* Count */
#define COUNT_MENU 6
diff --git a/include/utils.h b/include/utils.h
index ac892a6..be99fb2 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -26,6 +26,8 @@ Evas_Object *utils_add_box(Evas_Object *parent, const char *part,
Evas_Coord padding_v);
Evas_Object *utils_add_button(Evas_Object *parent, const char *part,
const char *text, const char *style);
+Evas_Object *utils_add_table(Evas_Object *table, const char *part,
+ int padding_x, int padding_y);
bool utils_launch_app(const char *appid, const char *key, const char *value);
#endif /* __AIR_FAVORITE_UTILS_H__ */
diff --git a/res/widgets/button.edc b/res/widgets/button.edc
index c746e5a..23516a2 100644
--- a/res/widgets/button.edc
+++ b/res/widgets/button.edc
@@ -499,12 +499,19 @@ group {
}
group {
- name, "elm/button/base/style.action.menu.button";
+ name, "elm/button/base/style.action.menu.favorite.button";
data.item, "focus_highlight" "on";
script {
public cur_state;
}
+ images {
+ image, ACTION_FAV_NOR_PNG COMP;
+ image, ACTION_FAV_FOC_PNG COMP;
+ image, ACTION_FAV_SEL_PNG COMP;
+ image, ACTION_FAV_DIS_PNG COMP;
+ }
+
parts {
part {
name, "part.bg";
@@ -605,6 +612,7 @@ group {
scale, 1;
description {
state, "default" 0.0;
+ image.normal, ACTION_FAV_NOR_PNG;
rel1 {
to, "part.icon.bg";
relative, 0.5 0.5;
@@ -620,14 +628,17 @@ group {
description {
state, "focused" 0.0;
inherit, "default" 0.0;
+ image.normal, ACTION_FAV_FOC_PNG;
}
description {
- state, "focused" 0.0;
+ state, "selected" 0.0;
inherit, "default" 0.0;
+ image.normal, ACTION_FAV_SEL_PNG;
}
description {
- state, "focused" 0.0;
+ state, "disable" 0.0;
inherit, "default" 0.0;
+ image.normal, ACTION_FAV_DIS_PNG;
}
}
@@ -754,9 +765,9 @@ group {
}
program {
- name, SIG_DISABLE;
- signal, SIG_DISABLE;
- source, SRC_ACTION_BTN;
+ name, SIG_BTN_DISABLE;
+ signal, SIG_BTN_DISABLE;
+ source, "elm";
script {
set_int(cur_state, STATE_DISABLE);
set_state(PART:"part.bg", "disable", 0.0);
@@ -768,57 +779,8 @@ group {
}
group {
- name, "elm/button/base/style.action.menu.favorite.button";
- inherit, "elm/button/base/style.action.menu.button";
- data.item, "focus_highlight" "on";
- images {
- image, ACTION_FAV_NOR_PNG COMP;
- image, ACTION_FAV_FOC_PNG COMP;
- image, ACTION_FAV_SEL_PNG COMP;
- image, ACTION_FAV_DIS_PNG COMP;
- }
- parts {
- part {
- name, "part.icon";
- type, IMAGE;
- scale, 1;
- description {
- state, "default" 0.0;
- rel1 {
- to, "part.icon.bg";
- relative, 0.5 0.5;
- }
- rel2 {
- to, "part.icon.bg";
- relative, 0.5 0.5;
- }
- align, 0.5 0.5;
- fixed, 1 1;
- min, 60 60;
- image.normal, ACTION_FAV_NOR_PNG;
- }
- description {
- state, "focused" 0.0;
- inherit, "default" 0.0;
- image.normal, ACTION_FAV_FOC_PNG;
- }
- description {
- state, "selected" 0.0;
- inherit, "default" 0.0;
- image.normal, ACTION_FAV_SEL_PNG;
- }
- description {
- state, "disable" 0.0;
- inherit, "default" 0.0;
- image.normal, ACTION_FAV_DIS_PNG;
- }
- }
- }
-}
-
-group {
name, "elm/button/base/style.action.menu.lock.button";
- inherit, "elm/button/base/style.action.menu.button";
+ inherit, "elm/button/base/style.action.menu.favorite.button";
data.item, "focus_highlight" "on";
images {
image, ACTION_LOCK_NOR_PNG COMP;
@@ -867,7 +829,7 @@ group {
group {
name, "elm/button/base/style.action.menu.share.button";
- inherit, "elm/button/base/style.action.menu.button";
+ inherit, "elm/button/base/style.action.menu.favorite.button";
data.item, "focus_highlight" "on";
images {
image, ACTION_SHARE_NOR_PNG COMP;
diff --git a/src/common/utils.c b/src/common/utils.c
index 8da11a1..f3e7223 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -159,6 +159,31 @@ Evas_Object *utils_add_button(Evas_Object *parent, const char *part,
return btn;
}
+Evas_Object *utils_add_table(Evas_Object *parent, const char *part,
+ int padding_x, int padding_y)
+{
+ Evas_Object *table;
+
+ if (!parent) {
+ _ERR("Invalid argument.");
+ return NULL;
+ }
+
+ table = elm_table_add(parent);
+ if (!table) {
+ _ERR("elm_table_add failed.");
+ return NULL;
+ }
+
+ elm_table_padding_set(table, padding_x, padding_y);
+ evas_object_show(table);
+
+ if (part)
+ elm_object_part_content_set(parent, part, table);
+
+ return table;
+}
+
bool utils_launch_app(const char *appid, const char *key, const char *value)
{
app_control_h app_ctrl;
diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c
index 4176a0c..05ab27b 100644
--- a/src/view/view_action_menu.c
+++ b/src/view/view_action_menu.c
@@ -28,18 +28,28 @@ struct _priv {
Evas_Object *menu_btn[COUNT_ACTION];
};
-const char *str_action[] = {
- STR_FAVORITE,
- STR_LOCK,
- STR_SHARE,
- NULL
+struct _action_info {
+ const char *title;
+ const char *style;
+ Eina_Bool disable;
};
-const char *style_action[] = {
- STYLE_ACTION_MENU_FAV_BTN,
- STYLE_ACTION_MENU_LOCK_BTN,
- STYLE_ACTION_MENU_SHARE_BTN,
- NULL
+static struct _action_info action_info[] = {
+ {
+ .title = STR_FAVORITE,
+ .style = STYLE_ACTION_MENU_FAV_BTN,
+ .disable = EINA_FALSE
+ },
+ {
+ .title = STR_LOCK,
+ .style = STYLE_ACTION_MENU_LOCK_BTN,
+ .disable = EINA_TRUE
+ },
+ {
+ .title = STR_SHARE,
+ .style = STYLE_ACTION_MENU_SHARE_BTN,
+ .disable = EINA_TRUE
+ }
};
static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj,
@@ -54,17 +64,43 @@ 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)
+{
+ if (!ev) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)
+ || !strcmp(ev->keyname, KEY_BACK_REMOTE))
+ viewmgr_hide_view(VIEW_ID_ACTION_MENU);
+}
+
+static void _action_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ if (!ev) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)
+ || !strcmp(ev->keyname, KEY_BACK_REMOTE))
+ viewmgr_hide_view(VIEW_ID_ACTION_MENU);
+}
+
static input_handler _livetv_input_handler = {
- .mouse_move = _mouse_move_cb
- /* It will be implemented later. */
+ .mouse_move = _mouse_move_cb,
+ .key_down = _livetv_key_down_cb
};
static input_handler _action_input_handler = {
- .mouse_move = _mouse_move_cb
- /* It will be implemented later. */
+ .mouse_move = _mouse_move_cb,
+ .key_down = _action_key_down_cb
};
-static bool _draw_top_area(struct _priv *priv)
+static bool _draw_livetv_area(struct _priv *priv)
{
Evas_Object *btn;
@@ -82,6 +118,10 @@ static bool _draw_top_area(struct _priv *priv)
inputmgr_add_callback(btn, 0, &_livetv_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);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
+
priv->live_btn = btn;
return true;
@@ -89,37 +129,39 @@ static bool _draw_top_area(struct _priv *priv)
static bool _draw_menu_area(struct _priv *priv)
{
- Evas_Object *box, *btn;
- int i;
+ Evas_Object *table, *btn;
+ int i, row = 0, col = 0;
if (!priv || !priv->base) {
_ERR("Invalid argument.");
return false;
}
- box = utils_add_box(priv->base, PART_ACTION_MENU, EINA_TRUE, 0, 0);
- if (!box) {
- _ERR("Add box failed.");
+ table = utils_add_table(priv->base, PART_ACTION_MENU,
+ SIZE_ACTION_TABLE_BORDER, SIZE_ACTION_TABLE_BORDER);
+ if (!table) {
+ _ERR("Add table failed.");
return false;
}
for (i = 0; i < COUNT_ACTION; i++) {
- btn = utils_add_button(priv->base, NULL, str_action[i],
- style_action[i]);
+ btn = utils_add_button(priv->base, NULL, action_info[i].title,
+ action_info[i].style);
if (!btn) {
_ERR("Add button failed.");
- evas_object_del(box);
+ evas_object_del(table);
return false;
}
inputmgr_add_callback(btn, i, &_action_input_handler, priv);
- /* 'Lock' and 'Share' is not supported, so emit disable. */
- if (i != 0)
- elm_object_signal_emit(btn,
- SIG_DISABLE, SRC_ACTION_BTN);
+ if (action_info[i].disable)
+ elm_object_disabled_set(btn, EINA_TRUE);
+
+ col = i % SIZE_COL_MAX;
+ row = i / SIZE_COL_MAX;
- elm_box_pack_end(box, btn);
+ elm_table_pack(table, btn, col, row, 1, 1);
priv->menu_btn[i] = btn;
}
@@ -135,7 +177,7 @@ static bool _draw_menu_area(struct _priv *priv)
return true;
}
-static bool _draw_bottom_area(struct _priv *priv)
+static bool _draw_favorite_area(struct _priv *priv)
{
if (!priv || !priv->base) {
_ERR("Invalid argument.");
@@ -154,8 +196,8 @@ static void _draw_view_content(struct _priv *priv)
return;
}
- if (!_draw_top_area(priv)) {
- _ERR("Draw top area failed.");
+ if (!_draw_livetv_area(priv)) {
+ _ERR("Draw livetv area failed.");
return;
}
@@ -164,8 +206,8 @@ static void _draw_view_content(struct _priv *priv)
return;
}
- if (!_draw_bottom_area(priv))
- _ERR("Draw bottom area failed.");
+ if (!_draw_favorite_area(priv))
+ _ERR("Draw favorite area failed.");
}
static Evas_Object *_create(Evas_Object *win, void *data)