diff options
author | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-18 14:28:33 +0900 |
---|---|---|
committer | jinwoo.shin <jw0227.shin@samsung.com> | 2015-08-19 13:18:29 +0900 |
commit | 94978098d7df5e96124991057db50350199def3c (patch) | |
tree | 9dd436cd2a376ca3dbac4082dd4c8d3eef1f754f | |
parent | a88f3c59fa59462d55da505c11d7ae97b5ff8c40 (diff) | |
download | air_livetv-94978098d7df5e96124991057db50350199def3c.tar.gz air_livetv-94978098d7df5e96124991057db50350199def3c.tar.bz2 air_livetv-94978098d7df5e96124991057db50350199def3c.zip |
Add action menu view
Change-Id: I2003259bdb25f2d3b3dc7e333f4bbeab59c9c0ab
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
25 files changed, 1559 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bd285b..729813b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ SET(SRCS src/main.c src/layout_channelinfo_search.c src/view_channelnumber.c src/view_error.c + src/view_action_menu.c src/util.c) SET(TARGET_EDJ "${PROJECT_NAME}.edj") diff --git a/data/live-tv-theme.edc b/data/live-tv-theme.edc index 52e787d..f5c808a 100644 --- a/data/live-tv-theme.edc +++ b/data/live-tv-theme.edc @@ -17,4 +17,5 @@ #include "../include/define.h" collections { + #include "widget/button.edc" } diff --git a/data/live-tv.edc b/data/live-tv.edc index 2c43574..b5043e0 100644 --- a/data/live-tv.edc +++ b/data/live-tv.edc @@ -20,4 +20,5 @@ collections { #include "view/channelinfo.edc" #include "view/channelnumber.edc" #include "view/error.edc" + #include "view/action_menu.edc" } diff --git a/data/view/action_menu.edc b/data/view/action_menu.edc new file mode 100644 index 0000000..973423d --- /dev/null +++ b/data/view/action_menu.edc @@ -0,0 +1,211 @@ +/* + * 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. + */ + +group { + name, GRP_VIEW_ACTION_MENU; + parts { + part { + name, "bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 0 0 0 150; + } + } + part { + name, "menu_area"; + 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.0; + fixed, 1 1; + } + } + + part { + name, "view.divider"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + color, 0 0 0 25; + rel1.to, "menu_area"; + rel2 { + to, "menu_area"; + 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, "menu_area"; + rel2 { + to, "menu_area"; + relative, 1.0 0.0; + } + min, 0 118; + align, 0.5 0.0; + fixed, 0 1; + } + } + + part { + name, PART_TOP_BUTTON; + 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.menu.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, PART_MENU; + relative, 0.0 0.0; + } + rel2 { + to, PART_MENU; + relative, 1.0 1.0; + } + align, 0.0 0.0; + fixed, 1 1; + color, 224 224 224 255; + } + } + + part { + name, PART_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, 500 0; + 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_MENU; + relative, 0.0 1.0; + } + rel2 { + to, PART_MENU; + relative, 0.0 1.0; + } + min, 500 1; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, "padding.channelinfo"; + type, SPACER; + scale, 1; + description { + state, "default" 0.0; + rel1.relative, 0.0 0.0; + rel2.relative, 0.0 0.0; + min, 40 40; + align, 0.0 0.0; + fixed, 1 1; + } + } + + part { + name, PART_CHANNELINFO; + type, SWALLOW; + scale, 1; + description { + state, "default" 0.0; + rel1 { + to, "padding.channelinfo"; + relative, 1.0 1.0; + } + rel2 { + to, "padding.channelinfo"; + relative, 1.0 1.0; + } + min, 536 174; + align, 0.0 0.0; + fixed, 1 1; + } + } + } +} diff --git a/data/widget/button.edc b/data/widget/button.edc new file mode 100644 index 0000000..ff68e9f --- /dev/null +++ b/data/widget/button.edc @@ -0,0 +1,972 @@ +/* + * 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. + */ + +#define STATE_NORMAL 0 +#define STATE_SELECTED 1 + +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_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; + } + } + } +} + +#define DEFAULT 1 +#define SELECTED 2 +#define FOCUSED 3 +#define DISABLED 4 + +group { + name, "elm/button/base/style.action.menu.button"; + data.item, "focus_highlight" "on"; + script { + public is_toggle, is_selected, is_enabled, is_focused, is_init, cur_state; + + public init_values() { + if(get_int(is_init)==0) + { + set_int(is_toggle, 0); + set_int(is_enabled, 1); + set_int(is_focused, 1); + set_int(is_init, 1); + set_int(cur_state, -1); + } + } + public set_states() { + new togg; + new enab; + new foc; + new sel; + new c_state; + togg = get_int(is_toggle); + enab = get_int(is_enabled); + foc = get_int(is_focused); + sel = get_int(is_selected); + c_state = get_int(cur_state); + if(enab == 0) + { + if(c_state == DISABLED) + { + if (togg == 0) + { + run_program(PROGRAM:"do_disable"); + run_program(PROGRAM:"do_hide.1"); + } + else { + run_program(PROGRAM:"do_disable.1"); + run_program(PROGRAM:"do_hide"); + } + } + } + else + { + if(foc == 1) + { + if(c_state == FOCUSED) + { + if (togg == 0) + { + run_program(PROGRAM:"do_focus"); + run_program(PROGRAM:"do_hide.1"); + } + else { + run_program(PROGRAM:"do_focus.1"); + run_program(PROGRAM:"do_hide"); + } + } + } + else if(sel == 1) + { + if(c_state == SELECTED) + { + if (togg == 0) + { + run_program(PROGRAM:"do_select"); + run_program(PROGRAM:"do_hide.1"); + } + else { + run_program(PROGRAM:"do_select.1"); + run_program(PROGRAM:"do_hide"); + } + } + } + else + { + if(c_state == DEFAULT) + { + if (togg == 0) + { + run_program(PROGRAM:"do_default"); + run_program(PROGRAM:"do_hide.1"); + } + else { + run_program(PROGRAM:"do_default.1"); + run_program(PROGRAM:"do_hide"); + } + } + } + } + } + } + parts { + part { + name, "part.bg"; + type, RECT; + scale, 1; + description { + state, "default" 0.0; + min, 124 124; + color, 255 255 255 255; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, 0 119 246 255; + } + } + + 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, RECT; + 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; + min, 60 60; + } + } + + part { + name, "elm.swallow.icon"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect, 1.0 1.0; + aspect_preference, BOTH; + 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; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.focus"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.select"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.disable"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + + part { + name, "elm.swallow.icon.1"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect, 1.0 1.0; + aspect_preference, BOTH; + 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; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.1.focus"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.1.select"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + part { + name, "elm.swallow.icon.1.disable"; + type, SWALLOW; + scale, 1; + clip_to: "part.icon.bg"; + description { + state, "default" 0.0; + aspect: 1.0 1.0; + aspect_preference: BOTH; + 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; + visible, 0; + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + visible, 0; + } + description { + state, "disabled" 0.0; + inherit, "default" 0.0; + visible, 1; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + + 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_LIGHT; + size, 20; + align, 0.5 0.5; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, 255 255 255 255; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + color, 64 136 211 255; + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + color: 104 104 104 128; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + + part { + name, "elm.text.1"; + 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_LIGHT; + size, 20; + align, 0.5 0.5; + } + } + description { + state, "focused" 0.0; + inherit, "default" 0.0; + color, 255 255 255 255; + } + description { + state, "selected" 0.0; + inherit, "default" 0.0; + color, 64 136 211 255; + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + color: 104 104 104 128; + } + description { + state, "invisible" 0.0; + inherit, "default" 0.0; + visible, 0; + } + } + } + programs { + program { + name: "go_toggle"; + signal: "elm,state,toggle"; + source: "elm"; + script { + init_values(); + set_int(is_toggle, 1); + set_states(); + } + } + program { + name: "go_untoggle"; + signal: "elm,state,untoggle"; + source: "elm"; + script { + init_values(); + set_int(is_toggle, 0); + set_states(); + } + } + program { + name: "go_focused"; + signal: "elm,state,focused"; + source: "elm"; + script { + init_values(); + set_int(is_focused, 1); + set_states(); + } + } + program { + name: "go_unfocused"; + signal: "elm,state,unfocused"; + source: "elm"; + script { + init_values(); + set_int(is_focused, 0); + set_states(); + } + } + program { + name: "go_active"; + signal: "elm,state,selected"; + source: "elm"; + script { + init_values(); + set_int(is_selected, 1); + set_states(); + } + } + program { + name: "go_passive"; + signal: "elm,state,unselected"; + source: "elm"; + script { + init_values(); + set_int(is_selected, 0); + set_states(); + } + } + program { + name: "go_disabled"; + signal: "elm,state,disabled"; + source: "elm"; + script { + init_values(); + set_int(is_enabled, 0); + set_states(); + } + } + program { + name: "go_enabled"; + signal: "elm,state,enabled"; + source: "elm"; + script { + init_values(); + set_int(is_enabled, 1); + set_states(); + } + } + program { + name: "do_hide"; + action: STATE_SET "invisible" 0.0; + target: "elm.text"; + target: "elm.swallow.icon"; + target: "elm.swallow.icon.focus"; + target: "elm.swallow.icon.select"; + target: "elm.swallow.icon.disable"; + } + program { + name: "do_default"; + action: STATE_SET "default" 0.0; + target: "part.bg"; + target: "elm.text"; + target: "elm.swallow.icon"; + target: "elm.swallow.icon.focus"; + target: "elm.swallow.icon.select"; + target: "elm.swallow.icon.disable"; + } + program { + name: "do_focus"; + action: STATE_SET "focused" 0.0; + target: "part.bg"; + target: "elm.text"; + target: "elm.swallow.icon"; + target: "elm.swallow.icon.focus"; + target: "elm.swallow.icon.select"; + target: "elm.swallow.icon.disable"; + } + + program { + name: "do_select"; + action: STATE_SET "selected" 0.0; + target: "part.bg"; + target: "elm.text"; + target: "elm.swallow.icon"; + target: "elm.swallow.icon.focus"; + target: "elm.swallow.icon.select"; + target: "elm.swallow.icon.disable"; + } + + program { + name: "do_disable"; + action: STATE_SET "disabled" 0.0; + target: "part.bg"; + target: "elm.text"; + target: "elm.swallow.icon"; + target: "elm.swallow.icon.focus"; + target: "elm.swallow.icon.select"; + target: "elm.swallow.icon.disable"; + } + + program { + name: "do_hide.1"; + action: STATE_SET "invisible" 0.0; + target: "elm.text.1"; + target: "elm.swallow.icon.1"; + target: "elm.swallow.icon.1.focus"; + target: "elm.swallow.icon.1.select"; + target: "elm.swallow.icon.1.disable"; + } + + program { + name: "do_default.1"; + action: STATE_SET "default" 0.0; + target: "part.bg"; + target: "elm.text.1"; + target: "elm.swallow.icon.1"; + target: "elm.swallow.icon.1.focus"; + target: "elm.swallow.icon.1.select"; + target: "elm.swallow.icon.1.disable"; + } + program { + name: "do_focus.1"; + action: STATE_SET "focused" 0.0; + target: "part.bg"; + target: "elm.text.1"; + target: "elm.swallow.icon.1"; + target: "elm.swallow.icon.1.focus"; + target: "elm.swallow.icon.1.select"; + target: "elm.swallow.icon.1.disable"; + } + + program { + name: "do_select.1"; + action: STATE_SET "selected" 0.0; + target: "part.bg"; + target: "elm.text.1"; + target: "elm.swallow.icon.1"; + target: "elm.swallow.icon.1.focus"; + target: "elm.swallow.icon.1.select"; + target: "elm.swallow.icon.1.disable"; + } + + program { + name: "do_disable.1"; + action: STATE_SET "disabled" 0.0; + target: "part.bg"; + target: "elm.text.1"; + target: "elm.swallow.icon.1"; + target: "elm.swallow.icon.1.focus"; + target: "elm.swallow.icon.1.select"; + target: "elm.swallow.icon.1.disable"; + } + } +} + diff --git a/include/define.h b/include/define.h index ed6f92c..d521b65 100644 --- a/include/define.h +++ b/include/define.h @@ -23,6 +23,15 @@ #define PART_CONTENT "elm.swallow.content" #define PART_TEXT "elm.text" +#define PART_ICON "elm.swallow.icon" +#define PART_ICON_FOCUSED "elm.swallow.icon.focus" +#define PART_ICON_SELECTED "elm.swallow.icon.select" +#define PART_ICON_DISABLED "elm.swallow.icon.disable" +#define PART_TEXT_1 "elm.text.1" +#define PART_ICON_1 "elm.swallow.icon.1" +#define PART_ICON_1_FOCUSED "elm.swallow.icon.1.focus" +#define PART_ICON_1_SELECTED "elm.swallow.icon.1.select" +#define PART_ICON_1_DISABLED "elm.swallow.icon.1.disable" #define SOURCE_PROGRAM "program" #define SOURCE_ELM "elm" @@ -48,6 +57,19 @@ #define COLOR_OPTION_TEXT_FOCUSED 255 255 255 255 #define COLOR_OPTION_BORDER 154 154 154 255 +#define IMAGE_FAV_NOR IMAGEDIR"/btn_menu_favorite_nor.png" +#define IMAGE_FAV_FOC IMAGEDIR"/btn_menu_favorite_foc.png" +#define IMAGE_FAV_SEL IMAGEDIR"/btn_menu_favorite_sel.png" +#define IMAGE_FAV_DIS IMAGEDIR"/btn_menu_favorite_dis.png" +#define IMAGE_LOCK_NOR IMAGEDIR"/btn_menu_lock_nor.png" +#define IMAGE_LOCK_FOC IMAGEDIR"/btn_menu_lock_foc.png" +#define IMAGE_LOCK_SEL IMAGEDIR"/btn_menu_lock_sel.png" +#define IMAGE_LOCK_DIS IMAGEDIR"/btn_menu_lock_dis.png" +#define IMAGE_UNLOCK_NOR IMAGEDIR"/btn_menu_unlock_nor.png" +#define IMAGE_UNLOCK_FOC IMAGEDIR"/btn_menu_unlock_foc.png" +#define IMAGE_UNLOCK_SEL IMAGEDIR"/btn_menu_unlock_sel.png" +#define IMAGE_UNLOCK_DIS IMAGEDIR"/btn_menu_unlock_dis.png" + #define VIEW_CHANNELINFO "VIEW_CHANNELINFO" #define LAYOUT_CHANNELINFO "LAYOUT_CHANNELINFO" #define LAYOUT_CHANNELINFO_LIST "LAYOUT_CHANNELINFO_LIST" @@ -80,4 +102,10 @@ #define PART_ERROR_TITLE "part.error.title" #define PART_ERROR_TEXT "part.error.text" +#define VIEW_ACTION_MENU "VIEW_ACTION_MENU" +#define GRP_VIEW_ACTION_MENU "grp.view.action_menu" +#define PART_TOP_BUTTON "part.top.button" +#define PART_MENU "part.menu" +#define PART_CHANNELINFO "part.channelinfo" + #endif /* __LIVETV_DEFINE_H__*/ diff --git a/include/strings.h b/include/strings.h index 486c0bd..9722632 100644 --- a/include/strings.h +++ b/include/strings.h @@ -24,5 +24,9 @@ #define STR_NOCHANNEL_TEXT "The channel is not found" #define STR_NOSIGNAL_TITLE "Weak or No Signal" #define STR_NOSIGNAL_TEXT "Check the antenna cable connection" +#define STR_LIVETV "Live TV" +#define STR_BUTTON_FAVORITE "Favorite" +#define STR_BUTTON_LOCK "Lock" +#define STR_BUTTON_UNLOCK "Unlock" #endif /* __AIR_LIVETV_STRINGS_H__*/ diff --git a/include/util.h b/include/util.h index 25afbc3..045d39e 100644 --- a/include/util.h +++ b/include/util.h @@ -24,5 +24,7 @@ Evas_Object *util_add_box(Evas_Object *parent, bool horizon); Evas_Object *util_add_scroller(Evas_Object *parent, const char *part); Evas_Object *util_add_icon(Evas_Object *parent, const char *file, const char *part); +Evas_Object *util_add_button(Evas_Object *parent, const char *part, + const char *text, const char *style); #endif diff --git a/include/view.h b/include/view.h index 8e0fc8e..5fbf8d4 100644 --- a/include/view.h +++ b/include/view.h @@ -32,5 +32,6 @@ void draw_channel_info(Evas_Object *obj, const struct tv_channel_info *channel_i view_class *view_channelnumber_get_vclass(void); view_class *view_channelinfo_get_vclass(void); view_class *view_error_get_vclass(void); +view_class *view_action_menu_get_vclass(void); #endif /* __LIVETV_VIEW_H__*/ diff --git a/res/images/btn_menu_favorite_dis.png b/res/images/btn_menu_favorite_dis.png Binary files differnew file mode 100644 index 0000000..bd9bdd8 --- /dev/null +++ b/res/images/btn_menu_favorite_dis.png diff --git a/res/images/btn_menu_favorite_foc.png b/res/images/btn_menu_favorite_foc.png Binary files differnew file mode 100644 index 0000000..e4915d5 --- /dev/null +++ b/res/images/btn_menu_favorite_foc.png 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_favorite_sel.png b/res/images/btn_menu_favorite_sel.png Binary files differnew file mode 100644 index 0000000..bd2eeee --- /dev/null +++ b/res/images/btn_menu_favorite_sel.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_lock_foc.png b/res/images/btn_menu_lock_foc.png Binary files differnew file mode 100644 index 0000000..5671cfc --- /dev/null +++ b/res/images/btn_menu_lock_foc.png diff --git a/res/images/btn_menu_lock_nor.png b/res/images/btn_menu_lock_nor.png Binary files differnew file mode 100644 index 0000000..5f38494 --- /dev/null +++ b/res/images/btn_menu_lock_nor.png diff --git a/res/images/btn_menu_lock_sel.png b/res/images/btn_menu_lock_sel.png Binary files differnew file mode 100644 index 0000000..1baa790 --- /dev/null +++ b/res/images/btn_menu_lock_sel.png diff --git a/res/images/btn_menu_unlock_dis.png b/res/images/btn_menu_unlock_dis.png Binary files differnew file mode 100644 index 0000000..43dfb60 --- /dev/null +++ b/res/images/btn_menu_unlock_dis.png diff --git a/res/images/btn_menu_unlock_foc.png b/res/images/btn_menu_unlock_foc.png Binary files differnew file mode 100644 index 0000000..8e35489 --- /dev/null +++ b/res/images/btn_menu_unlock_foc.png diff --git a/res/images/btn_menu_unlock_nor.png b/res/images/btn_menu_unlock_nor.png Binary files differnew file mode 100644 index 0000000..fb89ee9 --- /dev/null +++ b/res/images/btn_menu_unlock_nor.png diff --git a/res/images/btn_menu_unlock_sel.png b/res/images/btn_menu_unlock_sel.png Binary files differnew file mode 100644 index 0000000..b41240a --- /dev/null +++ b/res/images/btn_menu_unlock_sel.png @@ -311,6 +311,7 @@ static bool _create(void *data) viewmgr_add_view(view_channelinfo_get_vclass(), NULL); viewmgr_add_view(view_channelnumber_get_vclass(), NULL); viewmgr_add_view(view_error_get_vclass(), NULL); + viewmgr_add_view(view_action_menu_get_vclass(), NULL); r = tv_create(); if (r < 0) { @@ -359,6 +360,7 @@ static void _terminate(void *data) viewmgr_remove_view(VIEW_CHANNELINFO); viewmgr_remove_view(VIEW_CHANNELNUMBER); viewmgr_remove_view(VIEW_ERROR); + viewmgr_remove_view(VIEW_ACTION_MENU); viewmgr_destroy(); evas_object_del(ad->win); @@ -1023,30 +1023,6 @@ void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data) } /** - * Sets window id for tv overlay. - * - * @param window_id The window id to overlay - * @return If the operation was sucessful 0 is returned; otherwise negative value is returned - */ -int tv_overlay_set(void *window_id) -{ - int r; - - if (!g_tv_info.live_svc) { - _ERR("failed to get live service"); - return -1; - } - - r = tv_service_live_set_window_overlay(g_tv_info.live_svc, window_id); - if (r < 0) { - _ERR("failed to set overlay"); - return -1; - } - - return 0; -} - -/** * Destory the tv service handles. * * @return If the operation was sucessful 0 is returned; otherwise negative value is returned @@ -124,5 +124,33 @@ Evas_Object *util_add_icon(Evas_Object *parent, const char *file, evas_object_show(ic); return ic; +} + +Evas_Object *util_add_button(Evas_Object *parent, const char *part, + const char *text, const char *style) +{ + Evas_Object *btn; + + if (!parent) { + _ERR("Invalid argument."); + return NULL; + } + btn = elm_button_add(parent); + if (!btn) { + _ERR("elm_button_add failed."); + return NULL; + } + + if (part) + elm_object_part_content_set(parent, part, btn); + if (text) + elm_object_text_set(btn, text); + if (style) + elm_object_style_set(btn, style); + + evas_object_show(btn); + + return btn; } + diff --git a/src/view_action_menu.c b/src/view_action_menu.c new file mode 100644 index 0000000..97f6473 --- /dev/null +++ b/src/view_action_menu.c @@ -0,0 +1,308 @@ +/* + * 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 "util.h" + +#define BUTTON_MAX 16 +#define BUTTON_BORDER 1 +#define ITEMS_IN_ROW 4 + +#define STYLE_LIVETV_BTN "style.livetv.button" +#define STYLE_ACTION_MENU_BTN "style.action.menu.button" + +#define UNTOGGLE 0 +#define TOGGLE 1 + +enum _button_id { + BUTTON_INVALID = -1, + BUTTON_FAV, + BUTTON_LOCK, +}; + +struct _priv { + Evas_Object *base; + Evas_Object *menu_btn[BUTTON_MAX]; +}; + +struct _button_state { + const char *text; + const char *normal; + const char *focused; + const char *selected; + const char *disabled; +}; + +struct _button { + int id; + struct _button_state state[2]; +}; + +static struct _button buttons[] = { + { + .id = BUTTON_FAV, + .state[UNTOGGLE] = { + .text = STR_BUTTON_FAVORITE, + .normal = IMAGE_FAV_NOR, + .focused = IMAGE_FAV_FOC, + .selected = IMAGE_FAV_SEL, + .disabled = IMAGE_FAV_DIS + }, + .state[TOGGLE] = { + .text = STR_BUTTON_FAVORITE, + .normal = IMAGE_FAV_NOR, + .focused = IMAGE_FAV_FOC, + .selected = IMAGE_FAV_SEL, + .disabled = IMAGE_FAV_DIS + } + }, + { + .id = BUTTON_LOCK, + .state[UNTOGGLE] = { + .text = STR_BUTTON_LOCK, + .normal = IMAGE_LOCK_NOR, + .focused = IMAGE_LOCK_FOC, + .selected = IMAGE_LOCK_SEL, + .disabled = IMAGE_LOCK_DIS + }, + .state[TOGGLE] = { + .text = STR_BUTTON_UNLOCK, + .normal = IMAGE_UNLOCK_NOR, + .focused = IMAGE_UNLOCK_FOC, + .selected = IMAGE_UNLOCK_SEL, + .disabled = IMAGE_UNLOCK_DIS + } + }, + { + .id = BUTTON_INVALID + } +}; + +static bool _draw_top_area(struct _priv *priv) +{ + Evas_Object *btn; + + btn = util_add_button(priv->base, + PART_TOP_BUTTON, 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 *table, *btn; + int i, row, col; + + table = elm_table_add(priv->base); + if (!table) { + _ERR("Add table failed."); + return false; + } + elm_table_padding_set(table, BUTTON_BORDER, BUTTON_BORDER); + evas_object_show(table); + elm_object_part_content_set(priv->base, PART_MENU, table); + + i = 0; + while (buttons[i].id != BUTTON_INVALID && i < BUTTON_MAX) { + btn = util_add_button(priv->base, NULL, + buttons[i].state[UNTOGGLE].text, + STYLE_ACTION_MENU_BTN); + if (!btn) { + _ERR("Add button failed."); + evas_object_del(table); + return false; + } + + util_add_icon(btn, buttons[i].state[UNTOGGLE].normal, + PART_ICON); + util_add_icon(btn, buttons[i].state[UNTOGGLE].focused, + PART_ICON_FOCUSED); + util_add_icon(btn, buttons[i].state[UNTOGGLE].selected, + PART_ICON_SELECTED); + util_add_icon(btn, buttons[i].state[UNTOGGLE].disabled, + PART_ICON_DISABLED); + elm_object_part_text_set(btn, PART_TEXT_1, + buttons[i].state[TOGGLE].text); + util_add_icon(btn, buttons[i].state[TOGGLE].normal, + PART_ICON_1); + util_add_icon(btn, buttons[i].state[TOGGLE].focused, + PART_ICON_1_FOCUSED); + util_add_icon(btn, buttons[i].state[TOGGLE].selected, + PART_ICON_1_SELECTED); + util_add_icon(btn, buttons[i].state[TOGGLE].disabled, + PART_ICON_1_DISABLED); + + col = i % ITEMS_IN_ROW; + row = i / ITEMS_IN_ROW; + elm_table_pack(table, btn, col, row, 1, 1); + + priv->menu_btn[i] = btn; + + i++; + } + + while (col + 1 != ITEMS_IN_ROW) { + btn = util_add_button(priv->base, NULL, NULL, + STYLE_ACTION_MENU_BTN); + if (!btn) { + _ERR("Add button failed."); + evas_object_del(table); + return false; + } + + col = i % ITEMS_IN_ROW; + + elm_table_pack(table, btn, col, row, 1, 1); + + i++; + } + + elm_object_focus_next_object_set(priv->menu_btn[0], + priv->menu_btn[i - 1], ELM_FOCUS_LEFT); + elm_object_focus_next_object_set(priv->menu_btn[i - 1], + priv->menu_btn[0], ELM_FOCUS_RIGHT); + + return true; +} + +static bool _draw_bottom_area(struct _priv *priv) +{ + /* It will be implemented later */ + + return true; +} + +static void _draw_view_content(struct _priv *priv) +{ + 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 = elm_layout_add(win); + if (!base) { + _ERR("failed to create base object"); + free(priv); + return NULL; + } + elm_layout_file_set(base, EDJEFILE, GRP_VIEW_ACTION_MENU); + evas_object_size_hint_weight_set(base, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, base); + + priv->base = base; + + if (!viewmgr_set_view_data(VIEW_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 = 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 = 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 = data; + + if (priv->base) + evas_object_del(priv->base); + + free(priv); +} + +static view_class _vclass = { + .view_id = VIEW_ACTION_MENU, + .create = _create, + .show = _show, + .hide = _hide, + .destroy = _destroy, +}; + +view_class *view_action_menu_get_vclass(void) +{ + return &_vclass; +} |