summaryrefslogtreecommitdiff
path: root/src/view/view_action_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/view_action_menu.c')
-rw-r--r--src/view/view_action_menu.c240
1 files changed, 240 insertions, 0 deletions
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;
+}