View: Draw the top menu area 99/42599/2
authorHyojung Jo <hj903.jo@samsung.com>
Tue, 30 Jun 2015 12:00:45 +0000 (21:00 +0900)
committerHyojung Jo <hj903.jo@samsung.com>
Wed, 1 Jul 2015 02:13:40 +0000 (11:13 +0900)
Change-Id: Id34aa530f8583fcf1933b4a6f0c34ce78e449603
Signed-off-by: Hyojung Jo <hj903.jo@samsung.com>
include/define.h
include/utils.h
res/apps.edc
res/view/action_menu.edc [new file with mode: 0644]
res/view/base.edc [new file with mode: 0644]
src/utils.c
src/view/view_base.c

index 221ccaf5bec4f7bac8e3c7beb19d0f7f60bddec7..3b3e7ee2035cb1a2f6553c76051b2400f12e5a84 100644 (file)
 
 /* Part for EDC */
 #define PART_TOP_TITLE "part.top.title"
-#define PART_MYAPPS_BTN "part.myapps.btn"
-#define PART_SORT_BTN "part.sort.btn"
-#define PART_CATEGORY_BTN "part.category.btn"
+#define PART_MENU "part.menu"
+#define PART_SORT "part.sort"
 
 /* String */
 #define STR_APPS "Apps"
+#define STR_MYAPPS "My Apps"
+#define STR_APPSTORE "App Store"
+
+/* Count */
+#define MENU_COUNT 2
 
 #endif /* __AIR_APPS_DEFINE_H__ */
index 746abe44886403195d6917208ad2fb33200fe05d..bc92948146b4e7397814e74fbf8da63f169ff7f6 100644 (file)
@@ -19,6 +19,9 @@
 
 Evas_Object *add_window(const char *name);
 Evas_Object *add_layout(Evas_Object *parent, const char *group);
-Evas_Object *add_button(Evas_Object *parent, const char *part);
+Evas_Object *add_box(Evas_Object *parent, const char *part,
+               Eina_Bool horizontal);
+Evas_Object *add_button(Evas_Object *parent, const char *part, const char *text,
+               const char *style);
 
 #endif /* __AIR_APPS_UTILS_H__ */
index 64bcfbcf93c91986179c471647df0de9c59ef4dc..fa9e5dbac9e9856ff3c8beced7e4eba1d721128e 100644 (file)
  * limitations under the License.
  */
 
-collections {
-       group {
-               name, GRP_VIEW_BASE;
-               /* It should be implemented later. */
-       }
+#include "../include/define.h"
 
-       group {
-               name, GRP_VIEW_ACTION_MENU;
-               /* It should be implemented later. */
-       }
+collections {
+       #include "view/base.edc"
+       #include "view/action_menu.edc"
 }
diff --git a/res/view/action_menu.edc b/res/view/action_menu.edc
new file mode 100644 (file)
index 0000000..3c72393
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * 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.
+ */
+
diff --git a/res/view/base.edc b/res/view/base.edc
new file mode 100644 (file)
index 0000000..05fec69
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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_BASE;
+       parts {
+               part {
+                       name, "bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 244 244 244 255;
+                       }
+               }
+
+               part {
+                       name, "title.bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 255 255 255 255;
+                               min, 0 184;
+                               rel2.relative, 1.0 0.0;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, "padding.title";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 44;
+                               rel2.relative, 1.0 0.0;
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                       }
+               }
+
+               part {
+                       name, PART_TOP_TITLE;
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 51 51 51 255;
+                               min, 0 46;
+                               rel1 {
+                                       to, "padding.title";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2.to, "padding.title";
+                               align, 0.5 0.0;
+                               fixed, 0 1;
+                               text {
+                                       font, FONT_TIZENSANS_REGULAR;
+                                       size, 46;
+                                       align, 0.5 0.5;
+                               }
+                       }
+               }
+
+               part {
+                       name, "padding.menu";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 12;
+                               rel1 {
+                                       to, PART_TOP_TITLE;
+                                       relative, 0.0 1.0;
+                               }
+                               rel2.to, PART_TOP_TITLE;
+                               fixed, 0 1;
+                               align, 0.5 0.0;
+                       }
+               }
+
+               part {
+                       name, PART_MENU;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 0 82;
+                               rel1 {
+                                       to, "padding.menu";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2.to, "padding.menu";
+                               fixed, 0 1;
+                               align, 0.5 0.0;
+                       }
+               }
+       }
+}
index 08f85ea35de184f01b6e1e7118ac3d7e0b4ccda2..8cb0e1dcc382b4c1a3fca55f263812d95f3a0201 100644 (file)
@@ -66,7 +66,38 @@ Evas_Object *add_layout(Evas_Object *parent, const char *group)
        return layout;
 }
 
-Evas_Object *add_button(Evas_Object *parent, const char *part)
+Evas_Object *add_box(Evas_Object *parent, const char *part,
+               Eina_Bool horizontal)
+{
+       Evas_Object *box;
+
+       if (!parent) {
+               _ERR("Invalid argument.");
+               return NULL;
+       }
+
+       box = elm_box_add(parent);
+       if (!box) {
+               _ERR("elm_box_add failed.");
+               return NULL;
+       }
+
+       elm_box_horizontal_set(box, horizontal);
+
+       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+       evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+       if (part)
+               elm_object_part_content_set(parent, part, box);
+
+       evas_object_show(box);
+
+       return box;
+}
+
+Evas_Object *add_button(Evas_Object *parent, const char *part,
+               const char *text, const char *style)
 {
        Evas_Object *btn;
 
@@ -83,6 +114,10 @@ Evas_Object *add_button(Evas_Object *parent, const char *part)
 
        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);
 
index c0bd47440d052a9a68a3e8d33948218ab02ba225..43e398697a0ac0b0470da38c39f0c9d878109c41 100644 (file)
 #include "utils.h"
 #include "layout_myapps.h"
 
+enum menu_type {
+       MENU_MYAPPS = 0,
+       MENU_APPSTORE,
+};
+
 struct _priv {
        Evas_Object *win;
        Evas_Object *base;
-       Evas_Object *myapps_btn;
+       Evas_Object *menu_btn[MENU_COUNT];
        Evas_Object *sort_btn;
-       Evas_Object *category_btn;
        layoutmgr *lmgr;
+       Evas_Object *focused_btn;
 };
 
-enum evas_object_id {
-       EO_MYAPPS_BTN = 0,
-       EO_SORT_BTN,
-       EO_CATEGORY_BTN,
+const char *str_menu[] = {
+       STR_MYAPPS,
+       STR_APPSTORE,
+       NULL
 };
 
-static void _clicked_cb(int id, void *data, Evas_Object *obj);
-static void _focused_cb(int id, void *data, Evas_Object *obj, Elm_Object_Item *item);
+static void _menu_clicked_cb(int id, void *data, Evas_Object *obj);
+static void _menu_focused_cb(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item);
+static void _sort_clicked_cb(int id, void *data, Evas_Object *obj);
+static void _sort_focused_cb(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item);
+
+static input_handler _menu_input_handler = {
+       .clicked = _menu_clicked_cb,
+       .focused = _menu_focused_cb
+       /* It will be implemented later. */
+};
 
-static input_handler _input_handler = {
-       .clicked = _clicked_cb,
-       .focused = _focused_cb
+static input_handler _sort_input_handler = {
+       .clicked = _sort_clicked_cb,
+       .focused = _sort_focused_cb
        /* It will be implemented later. */
 };
 
-static void _clicked_cb(int id, void *data, Evas_Object *obj)
+static void _menu_clicked_cb(int id, void *data, Evas_Object *obj)
 {
        /* It will be implemented later. */
 }
 
-static void _focused_cb(int id, void *data, Evas_Object *obj,
+static void _menu_focused_cb(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item)
+{
+       /* It will be implemented later. */
+}
+
+static void _sort_clicked_cb(int id, void *data, Evas_Object *obj)
+{
+       /* It will be implemented later. */
+}
+
+static void _sort_focused_cb(int id, void *data, Evas_Object *obj,
                Elm_Object_Item *item)
 {
        /* It will be implemented later. */
@@ -61,55 +87,63 @@ static void _focused_cb(int id, void *data, Evas_Object *obj,
 
 static bool _draw_top_area(struct _priv *priv)
 {
-       Evas_Object *btn;
+       Evas_Object *box, *btn;
+       int i;
 
-       if (!priv) {
+       if (!priv || !priv->base) {
                _ERR("Invalid argument.");
                return false;
        }
 
        elm_object_part_text_set(priv->base, PART_TOP_TITLE, STR_APPS);
 
-       btn = add_button(priv->base, PART_MYAPPS_BTN);
-       if (!btn) {
-               _ERR("Add button failed.");
+       box = add_box(priv->base, PART_MENU, EINA_TRUE);
+       if (!box) {
+               _ERR("Add box failed.");
                return false;
        }
 
-       inputmgr_add_callback(btn, EO_MYAPPS_BTN, &_input_handler, priv);
+       for (i = 0; i < MENU_COUNT; i++) {
+               btn = add_button(priv->base, NULL, str_menu[i], NULL);
+               if (!btn) {
+                       _ERR("elm_button_add failed.");
+                       evas_object_del(box);
+                       return false;
+               }
+
+               inputmgr_add_callback(btn, i, &_menu_input_handler, priv);
 
-       priv->myapps_btn = btn;
+               elm_box_pack_end(box, btn);
+
+               priv->menu_btn[i] = btn;
+       }
+
+       elm_object_focus_next_object_set(priv->menu_btn[0],
+                       priv->menu_btn[MENU_COUNT - 1], ELM_FOCUS_LEFT);
+       elm_object_focus_next_object_set(priv->menu_btn[MENU_COUNT -1],
+                       priv->menu_btn[0], ELM_FOCUS_RIGHT);
 
        return true;
 }
 
 static bool _draw_bottom_area(struct _priv *priv)
 {
-       Evas_Object *sort_btn, *ctgr_btn;
+       Evas_Object *btn;
 
-       if (!priv) {
+       if (!priv || !priv->base) {
                _ERR("Invalid argument.");
                return false;
        }
 
-       sort_btn = add_button(priv->base, PART_SORT_BTN);
-       if (!sort_btn) {
-               _ERR("Add button failed.");
-               return false;
-       }
-
-       inputmgr_add_callback(sort_btn, EO_SORT_BTN, &_input_handler, priv);
-
-       ctgr_btn = add_button(priv->base, PART_CATEGORY_BTN);
-       if (!ctgr_btn) {
+       btn = add_button(priv->base, PART_SORT, NULL, NULL);
+       if (!btn) {
                _ERR("Add button failed.");
                return false;
        }
 
-       inputmgr_add_callback(ctgr_btn, EO_CATEGORY_BTN, &_input_handler, priv);
+       inputmgr_add_callback(btn, 0, &_sort_input_handler, priv);
 
-       priv->sort_btn = sort_btn;
-       priv->category_btn = ctgr_btn;
+       priv->sort_btn = btn;
 
        return true;
 }