diff options
author | Hyojung Jo <hj903.jo@samsung.com> | 2015-08-13 14:29:28 +0900 |
---|---|---|
committer | Hyojung Jo <hj903.jo@samsung.com> | 2015-08-13 14:29:28 +0900 |
commit | ae321772f121eb81dbb20fde3cde2d304f0c60b7 (patch) | |
tree | da0f3c37b86897a44351cff663b5597be617c311 | |
parent | d4a82c86eff229ecd3a0c2e51e18843b1b3c34c9 (diff) | |
download | air_favorite-ae321772f121eb81dbb20fde3cde2d304f0c60b7.tar.gz air_favorite-ae321772f121eb81dbb20fde3cde2d304f0c60b7.tar.bz2 air_favorite-ae321772f121eb81dbb20fde3cde2d304f0c60b7.zip |
View: Added action menu view
Change-Id: I25fb76d12d208790d88ca4b39cbdc5e23230a9e1
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/define.h | 13 | ||||
-rw-r--r-- | include/view_action_menu.h | 22 | ||||
-rw-r--r-- | res/favorite.edc | 143 | ||||
-rw-r--r-- | res/images/btn_menu_favorite_nor.png | bin | 0 -> 1871 bytes | |||
-rw-r--r-- | res/images/btn_menu_lock_dis.png | bin | 0 -> 1369 bytes | |||
-rw-r--r-- | res/images/btn_menu_share_dis.png | bin | 0 -> 1270 bytes | |||
-rw-r--r-- | res/widgets/button.edc | 297 | ||||
-rw-r--r-- | src/common/utils.c | 1 | ||||
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/view/view_action_menu.c | 240 | ||||
-rw-r--r-- | src/view/view_base.c | 11 |
12 files changed, 729 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e91d4db..1bef08a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,7 @@ SET(SRCS src/data/web.c src/common/utils.c src/view/view_base.c + src/view/view_action_menu.c src/grid/grid_tv.c src/grid/grid_movie.c src/grid/grid_gallery.c diff --git a/include/define.h b/include/define.h index e2014e0..26e4c0b 100644 --- a/include/define.h +++ b/include/define.h @@ -19,9 +19,11 @@ /* View ID */ #define VIEW_ID_BASE "VIEW_ID_BASE" +#define VIEW_ID_ACTION_MENU "VIEW_ID_ACTION_MENU" /* Group */ #define GRP_VIEW_BASE "grp.view.base" +#define GRP_VIEW_ACTION_MENU "grp.view.action.menu" /* Part for edc file */ #define PART_TOP_TITLE "part.top.title" @@ -39,9 +41,13 @@ #define PART_THUMB_SUBTEXT2 "part.thumb.subtext2" #define PART_THUMB_PLAY_ICON "part.thumb.play.icon" #define PART_THUMB_DEFAULT_TV_ICON "part.thumb.default.tv.icon" +#define PART_LIVETV_BTN "part.livetv.button" +#define PART_ACTION_MENU "part.action.menu" /* Style */ #define STYLE_MENU_BTN "style.menu.button" +#define STYLE_LIVETV_BTN "style.livetv.button" +#define STYLE_ACTION_MENU_BTN "style.action.menu.button" /* Signal */ #define SIG_FOCUSED "focused" @@ -62,6 +68,8 @@ /* Text */ #define STR_FAVORITE "Favorite" +#define STR_LOCK "Lock" +#define STR_SHARE "Share" #define STR_NULL "(NULL)" #define STR_NO_CONTENTS "No Contents" #define STR_CNT_TV "channels" @@ -78,6 +86,7 @@ #define STR_KEY_SERVICE_ID "service_id" #define STR_BROWSER "Web Browser" #define STR_BROWSER_ID "org.tizen.browser" +#define STR_LIVETV "Live TV" /* Font */ #define FONT_TIZENSANS_REGULAR "TizenSans" @@ -96,6 +105,7 @@ /* Count */ #define COUNT_MENU 6 +#define COUNT_ACTION 3 /* Image */ #define PLAY_ICON_PNG "ic_thumbnail_play.png" @@ -104,6 +114,9 @@ #define DEFAULT_TV_PNG IMGDIR"/ic_default_tv.png" #define BROWSER_ICON_PNG IMGDIR"/ic_apps_web.png" #define GULLIVER_PNG IMGDIR"/gulliver.png" +#define ACTION_FAV_NOR_PNG IMGDIR"/btn_menu_favorite_nor.png" +#define ACTION_LOCK_DIS_PNG IMGDIR"/btn_menu_lock_dis.png" +#define ACTION_SHARE_DIS_PNG IMGDIR"/btn_menu_share_dis.png" /* Path */ #define PATH_PLAY_ICON_PNG IMGDIR"/ic_thumbnail_play.png" diff --git a/include/view_action_menu.h b/include/view_action_menu.h new file mode 100644 index 0000000..4b44c54 --- /dev/null +++ b/include/view_action_menu.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __AIR_FAVORITE_VIEW_ACTION_MENU_H__ +#define __AIR_FAVORITE_VIEW_ACTION_MENU_H__ + +view_class *view_action_menu_get_vclass(void); + +#endif /* __AIR_FAVORITE_VIEW_ACTION_MENU_H__ */ diff --git a/res/favorite.edc b/res/favorite.edc index 3875b1f..128a83a 100644 --- a/res/favorite.edc +++ b/res/favorite.edc @@ -340,4 +340,147 @@ collections { } } } + + group { + name, GRP_VIEW_ACTION_MENU; + parts { + part { + name, "bg.dark"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 0 0 0 150; + } + } + + part { + name, "bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 255 255 255 255; + rel1.relative, 1.0 0.0; + min, 500 0; + align, 1.0 0.5; + fixed, 1 0; + } + } + + part { + name, "view.divider"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 0 0 0 25; + rel1.to, "bg"; + rel2 { + to, "bg"; + relative, 0.0 1.0; + } + min, 1 0; + align, 1.0 0.5; + fixed, 1 0; + } + } + + part { + name, "padding.livetv.btn"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1.to, "bg"; + rel2 { + to, "bg"; + relative, 1.0 0.0; + } + min, 0 118; + align, 0.5 0.0; + fixed, 0 1; + } + } + + part { + name, PART_LIVETV_BTN; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.livetv.btn"; + relative, 0.5 0.5; + } + rel2 { + to, "padding.livetv.btn"; + relative, 0.5 0.5; + } + min, 327 64; + align, 0.5 0.5; + fixed, 1 1; + } + } + + part { + name, "padding.menu.divider.up"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 224 224 224 255; + rel1 { + to, "padding.livetv.btn"; + relative, 0.0 1.0; + } + rel2.to, "padding.livetv.btn"; + min, 0 1; + align, 0.5 1.0; + fixed, 0 1; + } + } + + part { + name, PART_ACTION_MENU; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.menu.divider.up"; + relative, 0.0 1.0; + } + rel2 { + to, "padding.menu.divider.up"; + relative, 0.0 1.0; + } + min, 375 124; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, "padding.menu.divider.down"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 224 224 224 255; + rel1 { + to, PART_ACTION_MENU; + relative, 0.0 1.0; + } + rel2 { + to, PART_ACTION_MENU; + relative, 0.0 1.0; + } + min, 500 1; + align, 0.0 0.0; + fixed, 1 1; + } + } + } + } } diff --git a/res/images/btn_menu_favorite_nor.png b/res/images/btn_menu_favorite_nor.png Binary files differnew file mode 100644 index 0000000..a472976 --- /dev/null +++ b/res/images/btn_menu_favorite_nor.png diff --git a/res/images/btn_menu_lock_dis.png b/res/images/btn_menu_lock_dis.png Binary files differnew file mode 100644 index 0000000..d5827a0 --- /dev/null +++ b/res/images/btn_menu_lock_dis.png diff --git a/res/images/btn_menu_share_dis.png b/res/images/btn_menu_share_dis.png Binary files differnew file mode 100644 index 0000000..0a793aa --- /dev/null +++ b/res/images/btn_menu_share_dis.png diff --git a/res/widgets/button.edc b/res/widgets/button.edc index c0094c7..61e552b 100644 --- a/res/widgets/button.edc +++ b/res/widgets/button.edc @@ -271,3 +271,300 @@ group { } } } + +group { + name, "elm/button/base/style.livetv.button"; + data.item, "focus_highlight" "on"; + parts { + part { + name, "part.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + min, 0 64; + } + } + + part { + name, "padding.text.left"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 20 0; + rel1.to, "part.bg"; + rel2 { + to, "part.bg"; + relative, 0.0 1.0; + } + align, 0.0 0.5; + fixed, 1 0; + } + } + + part { + name, "padding.text.right"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + min, 20 0; + rel1 { + to, "part.bg"; + relative, 1.0 0.0; + } + rel2.to, "part.bg"; + align, 1.0 0.5; + fixed, 1 0; + } + } + + part { + name, "elm.text"; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 87 87 87 255; + rel1 { + to, "padding.text.left"; + relative, 1.0 0.0; + } + rel2 { + to, "padding.text.right"; + relative, 0.0 1.0; + } + text { + font, FONT_TIZENSANS_LIGHT; + size, 28; + align, 0.5 0.5; + } + } + } + + part { + name, "part.inside.line.up"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 194 194 194 255; + rel1.to, "part.bg"; + rel2 { + to, "part.bg"; + relative, 1.0 0.0; + } + min, 0 1; + align, 0.5 0.0; + fixed, 0 1; + } + } + + part { + name, "part.inside.line.left"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 194 194 194 255; + rel1 { + to, "part.inside.line.up"; + relative, 0.0 1.0; + } + rel2 { + to, "part.bg"; + relative, 0.0 1.0; + } + min, 1 0; + align, 0.0 0.5; + fixed, 1 0; + } + } + + part { + name, "part.inside.line.down"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 194 194 194 255; + rel1 { + to, "part.inside.line.left"; + relative, 1.0 1.0; + } + rel2.to, "part.bg"; + min, 0 1; + align, 0.5 1.0; + fixed, 0 1; + } + } + + part { + name, "part.inside.line.right"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 194 194 194 255; + rel1 { + to, "part.inside.line.up"; + relative, 1.0 1.0; + } + rel2 { + to, "part.inside.line.down"; + relative, 1.0 0.0; + } + min, 1 0; + align, 1.0 0.5; + fixed, 1 0; + } + } + } +} + +group { + name, "elm/button/base/style.action.menu.button"; + data.item, "focus_highlight" "on"; + parts { + part { + name, "part.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + min, 125 124; + } + } + + part { + name, "part.divider.right"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 224 224 224 255; + rel1 { + to, "part.bg"; + relative, 1.0 0.0; + } + rel2.to, "part.bg"; + min, 1 0; + align, 1.0 0.5; + fixed, 1 0; + } + } + + part { + name, "padding.icon1"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1.to, "part.bg"; + rel2 { + to, "part.bg"; + relative, 1.0 0.0; + } + min, 0 14; + align, 0.5 0.0; + fixed, 0 1; + } + } + + part { + name, "padding.icon2"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "part.bg"; + relative, 0.0 1.0; + } + rel2.to, "part.bg"; + min, 0 50; + align, 0.5 1.0; + fixed, 0 1; + } + } + + part { + name, "part.icon.bg"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.icon1"; + relative, 0.0 1.0; + } + rel2 { + to, "padding.icon2"; + relative, 1.0 0.0; + } + align, 0.5 0.5; + } + } + + part { + name, "elm.swallow.content"; + type, SWALLOW; + 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; + } + } + + part { + name, "padding.text"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "part.bg"; + relative, 0.0 1.0; + } + rel2.to, "part.bg"; + min, 0 24; + align, 0.5 1.0; + fixed, 0 1; + } + } + + part { + name, "elm.text"; + type, TEXT; + scale, 1; + description { + state, "default" 0.0; + color, 104 104 104 255; + rel1.to, "padding.text"; + rel2 { + to, "padding.text"; + relative, 1.0 0.0; + } + min, 0 20; + align, 0.5 1.0; + fixed, 0 1; + text { + font, FONT_TIZENSANS_LIGHT; + size, 20; + align, 0.5 0.5; + } + } + } + } +} diff --git a/src/common/utils.c b/src/common/utils.c index 55cdc72..8da11a1 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -62,6 +62,7 @@ Evas_Object *utils_add_layout(Evas_Object *parent, const char *group) evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, layout); return layout; } @@ -22,6 +22,7 @@ #include "define.h" #include "utils.h" #include "view_base.h" +#include "view_action_menu.h" SET_TAG(PACKAGE); @@ -62,6 +63,13 @@ static bool _create(void *data) return false; } + if (!viewmgr_add_view(view_action_menu_get_vclass(), NULL)) { + _ERR("Add view faild."); + viewmgr_destroy(); + evas_object_del(win); + return false; + } + ad->win = win; return true; @@ -83,6 +91,7 @@ static void _terminate(void *data) } viewmgr_remove_view(VIEW_ID_BASE); + viewmgr_remove_view(VIEW_ID_ACTION_MENU); viewmgr_destroy(); } diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c new file mode 100644 index 0000000..f260b05 --- /dev/null +++ b/src/view/view_action_menu.c @@ -0,0 +1,240 @@ +/* Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <Elementary.h> +#include <viewmgr.h> +#include <app_debug.h> + +#include "define.h" +#include "utils.h" + +struct _priv { + Evas_Object *win; + Evas_Object *base; + Evas_Object *box; + Evas_Object *menu_btn[COUNT_ACTION]; +}; + +const char *str_action[] = { + STR_FAVORITE, + STR_LOCK, + STR_SHARE, + NULL +}; + +/* 'Lock' and 'Share' is not supported now, so the disable image is used. */ +const char *str_action_icon_png[] = { + ACTION_FAV_NOR_PNG, + ACTION_LOCK_DIS_PNG, + ACTION_SHARE_DIS_PNG, + NULL +}; + +static bool _draw_top_area(struct _priv *priv) +{ + Evas_Object *btn; + + if (!priv || !priv->base) { + _ERR("Invalid argument."); + return false; + } + + btn = utils_add_button(priv->base, + PART_LIVETV_BTN, STR_LIVETV, STYLE_LIVETV_BTN); + if (!btn) { + _ERR("Add button failed."); + return false; + } + + return true; +} + +static bool _draw_menu_area(struct _priv *priv) +{ + Evas_Object *box, *btn, *img; + int i; + + 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."); + return false; + } + + for (i = 0; i < COUNT_ACTION; i++) { + btn = utils_add_button(priv->base, NULL, str_action[i], + STYLE_ACTION_MENU_BTN); + if (!btn) { + _ERR("Add button failed."); + evas_object_del(box); + return false; + } + + img = elm_image_add(btn); + if (!img) { + _ERR("elm_image_add failed."); + evas_object_del(box); + return false; + } + + elm_image_file_set(img, str_action_icon_png[i], NULL); + evas_object_show(img); + + elm_object_part_content_set(btn, NULL, img); + + elm_box_pack_end(box, btn); + + priv->menu_btn[i] = btn; + } + + elm_object_focus_next_object_set(priv->menu_btn[0], + priv->menu_btn[COUNT_ACTION - 1], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(priv->menu_btn[COUNT_ACTION - 1], + priv->menu_btn[0], ELM_FOCUS_RIGHT); + + return true; +} + +static bool _draw_bottom_area(struct _priv *priv) +{ + if (!priv || !priv->base) { + _ERR("Invalid argument."); + return false; + } + + /* It will be implemented later */ + + return true; +} + +static void _draw_view_content(struct _priv *priv) +{ + if (!priv) { + _ERR("Invalid argument."); + return; + } + + if (!_draw_top_area(priv)) { + _ERR("Draw top area failed."); + return; + } + + if (!_draw_menu_area(priv)) { + _ERR("Draw menu area failed."); + return; + } + + if (!_draw_bottom_area(priv)) + _ERR("Draw bottom area failed."); +} + +static Evas_Object *_create(Evas_Object *win, void *data) +{ + struct _priv *priv; + Evas_Object *base; + + if (!win) { + _ERR("Get window object failed."); + return NULL; + } + + priv = calloc(1, sizeof(*priv)); + if (!priv) { + _ERR("Calloc failed."); + return NULL; + } + + base = utils_add_layout(win, GRP_VIEW_ACTION_MENU); + if (!base) { + _ERR("Add layout failed."); + free(priv); + return NULL; + } + + priv->win = win; + priv->base = base; + + if (!viewmgr_set_view_data(VIEW_ID_ACTION_MENU, priv)) { + _ERR("Set view data failed."); + evas_object_del(base); + free(priv); + return NULL; + } + + _draw_view_content(priv); + + return base; +} + +static void _show(void *data) +{ + struct _priv *priv; + + if (!data) { + _ERR("Get data failed."); + return; + } + priv = (struct _priv *)data; + + if (priv->base) + evas_object_show(priv->base); +} + +static void _hide(void *data) +{ + struct _priv *priv; + + if (!data) { + _ERR("Get data failed."); + return; + } + priv = (struct _priv *)data; + + if (priv->base) + evas_object_hide(priv->base); +} + +static void _destroy(void *data) +{ + struct _priv *priv; + + if (!data) { + _ERR("Get data failed."); + return; + } + priv = (struct _priv *)data; + + if (priv->base) + evas_object_del(priv->base); + + free(priv); +} + +static view_class _vclass = { + .view_id = VIEW_ID_ACTION_MENU, + .create = _create, + .show = _show, + .hide = _hide, + .destroy = _destroy, +}; + +view_class *view_action_menu_get_vclass(void) +{ + return &_vclass; +} diff --git a/src/view/view_base.c b/src/view/view_base.c index 2b6735d..8d1c63b 100644 --- a/src/view/view_base.c +++ b/src/view/view_base.c @@ -142,11 +142,6 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, elm_object_focus_set(obj, EINA_TRUE); } -static void _menu_clicked_cb(int id, void *data, Evas_Object *obj) -{ - /* It will be implemented later. */ -} - static void _menu_focused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item) { @@ -296,14 +291,15 @@ static void _grid_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) elm_object_focus_set(priv->menu[priv->cur_menu_id], EINA_TRUE); + else if (!strcmp(ev->keyname, KEY_MENU) + || !strcmp(ev->keyname, KEY_MENU_REMOTE)) + viewmgr_show_view(VIEW_ID_ACTION_MENU); } static input_handler _menu_input_handler = { .mouse_move = _mouse_move_cb, - .clicked = _menu_clicked_cb, .focused = _menu_focused_cb, .key_down = _menu_key_down_cb - /* It will be implemented later. */ }; static input_handler _grid_input_handler = { @@ -312,7 +308,6 @@ static input_handler _grid_input_handler = { .realized = _grid_realized_cb, .unrealized = _grid_unrealized_cb, .key_down = _grid_key_down_cb - /* It will be implemented later. */ }; static bool _draw_top_area(struct _priv *priv) |