Action menu 05/60505/4
authorRadek Kintop <r.kintop@samsung.com>
Fri, 26 Feb 2016 14:57:27 +0000 (15:57 +0100)
committerRadek Kintop <r.kintop@samsung.com>
Mon, 29 Feb 2016 13:45:52 +0000 (05:45 -0800)
TODO: icons

Change-Id: I3f1c656f7b23d548592d78ae09a7489ad6d1e5c5
Signed-off-by: Radek Kintop <r.kintop@samsung.com>
15 files changed:
CMakeLists.txt
include/common/menumgr.h
include/common/viewmgr.h
include/define.h
include/key_define.h
include/view/view_action_menu.h [new file with mode: 0644]
include/view/view_base.h
res/settings.edc
res/view/action_menu.edc [new file with mode: 0644]
src/common/menumgr.c
src/layout/layout_picture.c
src/layout/layout_system.c
src/main.c
src/view/view_action_menu.c [new file with mode: 0644]
src/view/view_base.c

index 77613c2..4fa3f55 100644 (file)
@@ -63,6 +63,7 @@ ENDIF(NOT DEFINED DESKTOP_ICON)
 SET(SRCS
        src/main.c
        src/view/view_base.c
+       src/view/view_action_menu.c
        src/view/common/view_generic_popup.c
        src/view/picture/view_picture_slider_generic.c
        src/view/picture/view_picture_mode.c
index ea7bf53..5f58c0f 100644 (file)
@@ -26,6 +26,7 @@ struct menumgr_info {
        Eina_Bool disabled;
        char *(*status)(void *data, int id);
        void (*selected)(void *data, int id);
+       void (*selected_menu)(void *data, int id);
 };
 
 struct menumgr *menumgr_create(Evas_Object *table, Evas_Object *tab_menu_btn,
index be8a440..d660300 100644 (file)
@@ -40,6 +40,14 @@ typedef struct _view_class {
        void (*resume)(void *view_data);
 } view_class;
 
+enum update_type {
+       UPDATE_FOCUS = 0,
+       UPDATE_TITLE,
+       UPDATE_CONTENT,
+       UPDATE_ENABLE,
+       UPDATE_DISABLE
+};
+
 /**
  * Creates view manager to manage views.
  *
index 71b8033..47985ec 100644 (file)
@@ -27,6 +27,9 @@
 /* View ID */
 #define VIEW_BASE "VIEW_BASE"
 
+/* View ID - Action menu*/
+#define VIEW_ACTION_MENU "VIEW_ACTION_MENU"
+
 /* View ID - Picture */
 #define VIEW_PICTURE_MODE "VIEW_PICTURE_MODE"
 #define VIEW_PICTURE_CONTRAST "VIEW_PICTURE_CONTRAST"
@@ -59,6 +62,7 @@
 
 /* Group for EDC */
 #define GRP_VIEW_BASE "grp.view.base"
+#define GRP_VIEW_ACTION_MENU "grp.view.action.menu"
 #define GRP_VIEW_CLOCK "grp.view.clock"
 #define GRP_VIEW_PIN "grp.view.pin"
 #define GRP_VIEW_LOCATION "grp.view.location"
@@ -82,6 +86,8 @@
 #define PART_BUTTON "part.button"
 #define PART_PROGRESSBAR "part.progressbar"
 #define PART_MENU_VALUE "part.menu.value"
+#define PART_LIVE_TV_BTN "part.live.tv.btn"
+#define PART_MORE_FAV_BTN "part.more.fav.btn"
 
 #define PART_GUIDE "part.guide"
 #define PART_GUIDE_2 "part.guide2"
 #define PART_VIEW_SLIDER_MAX "part.view.slider.max"
 #define PART_VIEW_SLIDER_CUR "part.view.slider.cur"
 
-/* Style */
+/* Styles */
 #define STYLE_MENU_BTN "style.menu.button"
 #define STYLE_BASE_BTN "style.base.button"
 #define STYLE_NORMAL_BTN "style.normal.button"
 #define STYLE_OPTION_LIST_BTN "style.option.list.button"
 #define STYLE_CTXPOPUP "style.ctxpopup"
 
-/* Signal */
+/* Signals */
 #define SIG_FOCUSED "elm,action,focus"
 #define SIG_UNFOCUSED "elm,action,unfocus"
 #define SIG_DISABLED "elm,state,disabled"
 #define SIG_NOTAVAILABLE "state,notavailable"
 #define SIG_ITEM_SELECTED "sig.item.selected"
 
-/* Source */
+/* Sources */
 #define SRC_ELM "elm"
 #define SRC_EDC "edc"
 
-/* Font */
+/* Fonts */
 #define FONT_REGULAR "BreezeSans"
 #define FONT_LIGHT "BreezeSans:style=Light"
 
index a0dbcef..9e8c7f1 100644 (file)
@@ -25,5 +25,6 @@
 #define KEY_ENTER              "Return"
 #define KEY_ESC                        "Escape"
 #define KEY_BACK               "XF86Back"
+#define KEY_MENU               "XF86SysMenu"
 
 #endif /* __AIR_SETTINGS_KEY_DEFINE_H__ */
diff --git a/include/view/view_action_menu.h b/include/view/view_action_menu.h
new file mode 100644 (file)
index 0000000..cf4bd04
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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 VIEW_ACTION_MENU_H_
+#define VIEW_ACTION_MENU_H_
+
+#include "common/viewmgr.h"
+
+enum {
+       ACT_MENU_SRC_VIEW_UPDATE
+};
+view_class *view_action_menu_get_vclass(void);
+
+#endif /* VIEW_ACTION_MENU_H_ */
index 507d2b8..3c9ff5e 100644 (file)
 
 view_class *view_base_get_vclass(void);
 
-enum update_type {
-       UPDATE_FOCUS = 0,
-       UPDATE_TITLE,
-       UPDATE_CONTENT
-};
-
 #endif /* __AIR_SETTINGS_VIEW_BASE_H__ */
index 79994d7..9bcb303 100644 (file)
@@ -19,6 +19,7 @@
 collections {
        base_scale: APP_BASE_SCALE;
        #include "view/base.edc"
+       #include "view/action_menu.edc"
        #include "view/common/popup_2btns.edc"
        #include "view/common/popup_screen_adj.edc"
        #include "view/common/generic_slider_view.edc"
diff --git a/res/view/action_menu.edc b/res/view/action_menu.edc
new file mode 100644 (file)
index 0000000..a78a475
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ */
+
+/* inner to white bg: */
+#define BUTTON_BG_HEIGHT 0.10
+#define ICONS_AREA_HEIGHT 0.18
+#define FAVORITES_AREA_HEIGHT 0.62
+#define STRIPE_WIDTH 0.95
+#define STRIPE_X1 ((1.0 - STRIPE_WIDTH) / 2.0)
+#define STRIPE_X2 (STRIPE_X1 + STRIPE_WIDTH)
+
+/* inner to deeper parts: */
+#define BUTTON_WIDTH 0.89
+#define BUTTON_HEIGHT 0.54
+#define BUTTON_X1 ((1.0 - BUTTON_WIDTH) / 2.0)
+#define BUTTON_X2 (BUTTON_X1 + BUTTON_WIDTH)
+#define BUTTON_Y1 ((1.0 - BUTTON_HEIGHT) / 2.0)
+#define BUTTON_Y2 (BUTTON_Y1 + BUTTON_HEIGHT)
+
+group
+{
+       name: GRP_VIEW_ACTION_MENU;
+       parts
+       {
+               part
+               {
+                       name: "black bg";
+                       type: RECT;
+                       scale: 1;
+                       description
+                       {
+                               state: "default" 0.0;
+                               color: 0 0 0 255;
+                               rel1.relative: 0.0 0.0;
+                               rel2.relative: 1.0 1.0;
+                       }
+                       part
+                       {
+                               name: "white bg";
+                               type: RECT;
+                               scale: 1;
+                               description
+                               {
+                                       state: "default" 0.0;
+                                       color: 255 255 255 255;
+                                       rel1.relative: 0.0 0.0;
+                                       rel2.relative: 1.0 1.0;
+                                       rel1.offset: 2 2;
+                                       rel2.offset: -2 -2;
+                               }
+
+                               part
+                               {
+                                       name: "live TV button bg";
+                                       type: RECT;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               color: 255 255 255 255;
+                                               rel1.relative: 0.0 0.0;
+                                               rel2.relative: 1.0 BUTTON_BG_HEIGHT;
+                                       }
+                                       part
+                                       {
+                                               name: PART_LIVE_TV_BTN;
+                                               type: SWALLOW;
+                                               scale: 1;
+                                               description
+                                               {
+                                                       state: "default" 0.0;
+                                                       rel1.relative: BUTTON_X1 BUTTON_Y1;
+                                                       rel2.relative: BUTTON_X2 BUTTON_Y2;
+                                               }
+                                       }
+                               }
+
+                               part
+                               {
+                                       name: "icons area";
+                                       type: RECT;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               color: 255 255 255 255;
+                                               rel1.relative: 0.0 BUTTON_BG_HEIGHT;
+                                               rel2.relative: 1.0 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT);
+                                       }
+                               }
+
+                               part
+                               {
+                                       name: "favorites area";
+                                       type: SWALLOW;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               rel1.relative: 0.0 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT);
+                                               rel2.relative: 1.0 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT + FAVORITES_AREA_HEIGHT);
+                                       }
+                               }
+
+                               part
+                               {
+                                       name: "More favorite button bg";
+                                       type: RECT;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               color: 255 255 255 255;
+                                               rel1.relative: 0.0 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT + FAVORITES_AREA_HEIGHT);
+                                               rel2.relative: 1.0 1.0;
+                                       }
+                                       part
+                                       {
+                                               name: PART_MORE_FAV_BTN;
+                                               type: SWALLOW;
+                                               scale: 1;
+                                               description
+                                               {
+                                                       state: "default" 0.0;
+                                                       rel1.relative: BUTTON_X1 BUTTON_Y1;
+                                                       rel2.relative: BUTTON_X2 BUTTON_Y2;
+                                               }
+                                       }
+                               }
+
+                               part
+                               {
+                                       name: "stripe under live button area";
+                                       type: RECT;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               color: 194 194 194 255;
+                                               rel1.relative: STRIPE_X1 BUTTON_BG_HEIGHT;
+                                               rel2.relative: STRIPE_X2 BUTTON_BG_HEIGHT;
+                                               rel1.offset: 0 -1;
+                                               rel2.offset: 0 1;
+                                       }
+                               }
+
+                               part
+                               {
+                                       name: "stripe under icons area";
+                                       type: RECT;
+                                       scale: 1;
+                                       description
+                                       {
+                                               state: "default" 0.0;
+                                               color: 194 194 194 255;
+                                               rel1.relative: STRIPE_X1 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT);
+                                               rel2.relative: STRIPE_X2 (BUTTON_BG_HEIGHT + ICONS_AREA_HEIGHT);
+                                               rel1.offset: 0 -1;
+                                               rel2.offset: 0 1;
+                                       }
+                               }
+                       }
+               }
+       }
+}
index bf9860b..1b3e25c 100644 (file)
@@ -66,9 +66,14 @@ static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
        if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC)) {
                /* move the focus to the menu */
                viewmgr_update_view(VIEW_BASE, UPDATE_FOCUS, NULL);
-       } else if (!strcmp(ev->keyname, KEY_ENTER)) {
-               if (m->info[id] && m->info[id]->selected)
-                       m->info[id]->selected(m->data, id);
+       }
+
+       if (m->info[id]) {
+               if (!strcmp(ev->keyname, KEY_ENTER) && m->info[id]->selected)
+                               m->info[id]->selected(m->data, id);
+
+               if (!strcmp(ev->keyname, KEY_MENU) && m->info[id]->selected_menu)
+                       m->info[id]->selected_menu(m->data, id);
        }
 }
 
index 59e81cd..806bf9b 100644 (file)
@@ -25,6 +25,7 @@
 #include "common/menumgr.h"
 #include "common/viewmgr.h"
 #include "data/settings_picture.h"
+#include "view/view_action_menu.h"
 
 #define PADDING_X 26
 #define PADDING_Y 26
@@ -55,6 +56,7 @@ static char *_get_color(void *data, int id);
 static char *_get_tint(void *data, int id);
 static char *_get_screen_adj(void *data, int id);
 static void _selected(void *data, int id);
+static void _selected_menu(void *data, int id);
 
 /* Class functions: */
 static bool _create(layoutmgr *lmgr, void *data);
@@ -71,6 +73,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_picture_mode,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_CONTRAST,
@@ -79,6 +82,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_contrast,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_BRIGHTNESS,
@@ -87,6 +91,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_brightness,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_SHARPNESS,
@@ -95,6 +100,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_sharpness,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_COLOR,
@@ -103,6 +109,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_color,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_TINT,
@@ -111,6 +118,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_tint,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_SCREEN_ADJ,
@@ -119,6 +127,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_screen_adj,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
 };
 
@@ -236,7 +245,40 @@ static void _selected(void *data, int id)
                        if (!viewmgr_show_view(VIEW_PICTURE_SCREEN_ADJ))
                                _ERR("Push Picture screen adjustment view failed.");
                                break;
+               default:
+                       break;
+       }
+}
+
+static void _selected_menu(void *data, int id)
+{
+       switch (id)
+       {
+               case MENU_PICTURE_MODE:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_MODE);
+                       break;
+               case MENU_CONTRAST:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_CONTRAST);
+                       break;
+               case MENU_BRIGHTNESS:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_BRIGHTNESS);
+                       break;
+               case MENU_SHARPNESS:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_SHARPNESS);
+                       break;
+               case MENU_COLOR:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_COLOR);
+                       break;
+               case MENU_TINT:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_TINT);
+                       break;
+               case MENU_SCREEN_ADJ:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_PICTURE_SCREEN_ADJ);
+                       break;
+               default:
+                       return;
        }
+       viewmgr_show_view(VIEW_ACTION_MENU);
 }
 
 static bool _add_layout_contents(struct _priv *priv, Evas_Object *tab_button)
index bfd3c59..ec032b7 100644 (file)
@@ -29,6 +29,7 @@
 #include "view/system/view_clock.h"
 #include "view/system/view_location.h"
 #include "view/system/view_reset.h"
+#include "view/view_action_menu.h"
 #include "data/system/settings_clock.h"
 #include "data/system/settings_language.h"
 
@@ -68,6 +69,7 @@ static char *_get_subtitle(void *data, int id);
 static char *_get_location(void *data, int id);
 
 static void _selected(void *data, int id);
+static void _selected_menu(void *data, int id);
 static void _location_selected(void *data, int id);
 
 static struct menumgr_info menu_info[] = {
@@ -78,6 +80,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_clock_mode,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_SLEEP_TIMER,
@@ -86,6 +89,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_sleep_timer,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_WAKEUP_TIMER,
@@ -94,6 +98,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_status,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_CHANGE_PINCODE,
@@ -101,6 +106,7 @@ static struct menumgr_info menu_info[] = {
                .style = STYLE_NORMAL_BTN,
                .disabled = EINA_FALSE,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_LANGUAGE,
@@ -109,6 +115,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_language,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_SUBTITLE,
@@ -117,6 +124,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_subtitle,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_LOCATION,
@@ -125,6 +133,7 @@ static struct menumgr_info menu_info[] = {
                .disabled = EINA_FALSE,
                .status = _get_location,
                .selected = _location_selected,
+               .selected_menu = _selected_menu
        },
        {
                .id = MENU_RESET,
@@ -132,6 +141,7 @@ static struct menumgr_info menu_info[] = {
                .style = STYLE_NORMAL_BTN,
                .disabled = EINA_FALSE,
                .selected = _selected,
+               .selected_menu = _selected_menu
        },
 };
 
@@ -244,6 +254,37 @@ static void _selected(void *data, int id)
        }
 }
 
+static void _selected_menu(void *data, int id)
+{
+       switch (id)
+       {
+               case MENU_CLOCK:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_CLOCK);
+                       break;
+               case MENU_SLEEP_TIMER:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_SLEEP_TIMER);
+                       break;
+               case MENU_WAKEUP_TIMER:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_WAKEUP_TIMER);
+                       break;
+               case MENU_CHANGE_PINCODE:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_CHANGE_PINCODE);
+                       break;
+               case MENU_LANGUAGE:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_LANGUAGE);
+                       break;
+               case MENU_SUBTITLE:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_SUBTITLE);
+                       break;
+               case MENU_RESET:
+                       viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, VIEW_RESET);
+                       break;
+               default:
+                       return;
+       }
+       viewmgr_show_view(VIEW_ACTION_MENU);
+}
+
 static void _location_selected(void *data, int id)
 {
        SETTING_TRACE_BEGIN;
index 852d87a..c6a7fb5 100644 (file)
@@ -21,6 +21,7 @@
 #include "app_debug.h"
 #include "define.h"
 #include "view/view_base.h"
+#include "view/view_action_menu.h"
 #include "view/picture/view_picture_mode.h"
 #include "view/picture/view_picture_contrast.h"
 #include "view/picture/view_picture_brightness.h"
@@ -89,6 +90,12 @@ static bool _create(void *data)
                return false;
        }
 
+       if (!viewmgr_add_view(view_action_menu_get_vclass(), NULL)) {
+               _ERR("Add action menu view failed.");
+               evas_object_del(win);
+               return false;
+       }
+
        if (!_create_picture_ui()) {
                evas_object_del(win);
                return false;
@@ -120,6 +127,9 @@ static void _terminate(void *data)
        _destroy_picture_ui();
        _destroy_system_ui();
 
+       if (!viewmgr_remove_view(VIEW_ACTION_MENU))
+               _ERR("Remove view failed.");
+
        if (!viewmgr_destroy())
                _ERR("Destroy viewmgr failed.");
 
diff --git a/src/view/view_action_menu.c b/src/view/view_action_menu.c
new file mode 100644 (file)
index 0000000..51de160
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * 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 "view/view_action_menu.h"
+
+#include "define.h"
+#include "common/utils.h"
+#include "app_debug.h"
+#include "common/inputmgr.h"
+
+#define ACT_MENU_WIDTH_PRCNT 0.75
+
+enum {
+       LIVE_TV_BUTTON_ID,
+       MORE_FAV_BUTTON_ID
+};
+
+#define LIVE_TV_BTN_TXT "Live TV"
+#define MORE_FAVS_BTN_TXT "More Favorite"
+
+struct _priv {
+       Evas_Object *action_menu_layout;
+       Evas_Object *live_tv_btn;
+       Evas_Object *more_fav_btn;
+};
+
+/* Class functions: */
+static Evas_Object *_create(Evas_Object *win, void *data);
+static void _show(void *data);
+static void _hide(void *data);
+static void _destroy(void *data);
+static void _update(void *view_data, int update_type, void *data);
+
+static void _mouse_cb(int id, void *data, Evas_Object *obj);
+static void _keypad_cb(int id, void *data, Evas *e,
+               Evas_Object *obj, Evas_Event_Key_Down *ev);
+
+static view_class _vclass = {
+       .view_id = VIEW_ACTION_MENU,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy,
+       .update = _update
+};
+
+static input_handler _btn_handler = {
+       .clicked = _mouse_cb,
+       .key_down = _keypad_cb
+};
+
+view_class *view_action_menu_get_vclass(void)
+{
+       return &_vclass;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv = NULL;
+       int w = 0;
+       int h = 0;
+
+       evas_object_geometry_get(win, NULL, NULL, &w, &h);
+
+       if (!win || !w || !h) {
+               _ERR("Get window object failed.");
+               return NULL;
+       }
+
+       priv = (struct _priv *)calloc(1, sizeof(struct _priv));
+
+       if (!priv) {
+               _ERR("Calloc failed.");
+               return NULL;
+       }
+
+       priv->action_menu_layout = utils_add_layout(win, GRP_VIEW_ACTION_MENU, EINA_FALSE);
+
+       if (!priv->action_menu_layout) {
+               free(priv);
+               return NULL;
+       }
+
+       evas_object_move(priv->action_menu_layout, ACT_MENU_WIDTH_PRCNT * w, 0);
+       evas_object_resize(priv->action_menu_layout, (1.0 - ACT_MENU_WIDTH_PRCNT) * w, h);
+
+       priv->live_tv_btn = utils_add_button(priv->action_menu_layout, PART_LIVE_TV_BTN, NULL, LIVE_TV_BTN_TXT);
+       priv->more_fav_btn = utils_add_button(priv->action_menu_layout, PART_MORE_FAV_BTN, NULL, MORE_FAVS_BTN_TXT);
+
+       if (!priv->live_tv_btn || !priv->more_fav_btn) {
+               evas_object_del(priv->action_menu_layout);
+               free(priv);
+       }
+
+       inputmgr_add_callback(priv->live_tv_btn, LIVE_TV_BUTTON_ID, &_btn_handler, priv);
+       inputmgr_add_callback(priv->more_fav_btn, MORE_FAV_BUTTON_ID, &_btn_handler, priv);
+
+       if (!viewmgr_set_view_data(VIEW_ACTION_MENU, priv)) {
+               evas_object_del(priv->action_menu_layout);
+               free(priv);
+               return NULL;
+       }
+
+       return priv->action_menu_layout;
+}
+
+static void _show(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+       evas_object_show(priv->action_menu_layout);
+       elm_object_focus_set(priv->live_tv_btn, EINA_TRUE);
+       viewmgr_update_view(VIEW_BASE, UPDATE_DISABLE, NULL);
+}
+
+static void _hide(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+       evas_object_hide(priv->action_menu_layout);
+       viewmgr_update_view(VIEW_BASE, UPDATE_ENABLE, NULL);
+}
+
+static void _destroy(void *data)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+       evas_object_del(priv->action_menu_layout);
+       free(priv);
+}
+
+static void _update(void *view_data, int update_type, void *data)
+{
+       const char *view_id = (const char *)data;
+
+       if (!view_id)
+               return;
+
+       if (ACT_MENU_SRC_VIEW_UPDATE == update_type) {
+
+               if (!strcmp(view_id, VIEW_BASE)) {
+                       /* TODO: prepare icons for base view */
+               }
+
+               if (!strcmp(view_id, VIEW_PICTURE_MODE) ||
+                       !strcmp(view_id, VIEW_PICTURE_CONTRAST) ||
+                       !strcmp(view_id, VIEW_PICTURE_BRIGHTNESS) ||
+                       !strcmp(view_id, VIEW_PICTURE_SHARPNESS) ||
+                       !strcmp(view_id, VIEW_PICTURE_COLOR) ||
+                       !strcmp(view_id, VIEW_PICTURE_TINT) ||
+                       !strcmp(view_id, VIEW_PICTURE_SCREEN_ADJ) ||
+                       !strcmp(view_id, VIEW_CLOCK) ||
+                       !strcmp(view_id, VIEW_SLEEP_TIMER) ||
+                       !strcmp(view_id, VIEW_WAKEUP_TIMER) ||
+                       !strcmp(view_id, VIEW_CHANGE_PINCODE) ||
+                       !strcmp(view_id, VIEW_LANGUAGE) ||
+                       !strcmp(view_id, VIEW_SUBTITLE) ||
+                       !strcmp(view_id, VIEW_LOCATION) ||
+                       !strcmp(view_id, VIEW_RESET) ||
+                       !strcmp(view_id, VIEW_NEW_NETWORK)
+                       ) {
+                       /* TODO: prepare icons for specific view */
+               }
+       }
+
+}
+
+static void _mouse_cb(int id, void *data, Evas_Object *obj)
+{
+       struct _priv *priv = (struct _priv *)data;
+
+       if (!priv) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+}
+
+static void _keypad_cb(int id, void *data, Evas *e,
+               Evas_Object *obj, Evas_Event_Key_Down *ev)
+{
+       if (!data|| !ev) {
+               _ERR("Invalid parameter.");
+               return;
+       }
+
+       if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC))
+               viewmgr_pop_view();
+}
index 1391af5..ed605c8 100644 (file)
@@ -26,6 +26,7 @@
 #include "layout.h"
 #include "common/utils.h"
 #include "view/view_base.h"
+#include "view/view_action_menu.h"
 
 struct _priv {
        Evas_Object *win;
@@ -117,6 +118,11 @@ static void _menu_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
 
        if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC))
                ui_app_exit();
+
+       if (!strcmp(ev->keyname, KEY_MENU)) {
+               viewmgr_update_view(VIEW_ACTION_MENU, ACT_MENU_SRC_VIEW_UPDATE, (void *)view_base_get_vclass()->view_id);
+               viewmgr_show_view(VIEW_ACTION_MENU);
+       }
 }
 
 static void _menu_focused_cb(int id, void *data, Evas_Object *obj,
@@ -297,25 +303,32 @@ static void _hide(void *data)
 
 static void _update(void *view_data, int update_type, void *data)
 {
-       struct _priv *priv;
+       int i = 0;
+       struct _priv *priv = (struct _priv *)view_data;
 
-       if (!view_data) {
+       if (!priv) {
                _ERR("Get data failed.");
                return;
        }
-       priv = view_data;
 
-       if (update_type == UPDATE_FOCUS)
+       switch (update_type) {
+       case UPDATE_FOCUS:
                elm_object_focus_set(priv->menu[priv->cur_menu], EINA_TRUE);
-       else if (update_type == UPDATE_TITLE) {
-               // title
+               break;
+       case UPDATE_TITLE:
                elm_object_part_text_set(priv->base, PART_TOP_TITLE, _(STR_SETTINGS));
-
                // tabbar buttons
-               int i;
-               for (i = 0; i < LAYOUT_MAX; i++) {
+               for (i = 0; i < LAYOUT_MAX; i++)
                        elm_object_domain_translatable_text_set(priv->menu[i], SETTINGS_PACKAGE, _mdata[i].name);
-               }
+               break;
+       case UPDATE_ENABLE:
+               elm_object_disabled_set(priv->base, EINA_FALSE);
+               break;
+       case UPDATE_DISABLE:
+               elm_object_disabled_set(priv->base, EINA_TRUE);
+               break;
+       default:
+               break;
        }
 }