draw home menu box 52/41452/2
authorSoohye Shin <soohye.shin@samsung.com>
Mon, 15 Jun 2015 11:41:11 +0000 (20:41 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Mon, 15 Jun 2015 11:49:21 +0000 (20:49 +0900)
Change-Id: Ida16f9c579c02115262858813e1ef424ce32725b
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
include/defs.h
src/view/view_home.c

index 1d5578a..2d2733f 100644 (file)
 #define PART_HOME_UP_ARROW "part.home.up.arrow"
 #define PART_HOME_DOWN_ARROW "part.home.down.arrow"
 #define PART_HOME_ITEM_ICON "part.home.item.icon"
-#define PART_HOME_ITEM_NAME "part.home.item.name"
+#define PART_HOME_ITEM_ICON_FOCUS "part.home.item.icon.focus"
 #define PART_HOME_ITEM_BG "part.home.item.bg"
+#define PART_HOME_ITEM_TITLE "part.home.item.title"
+#define PART_HOME_ITEM_TITLE_FOCUS "part.home.item.focus"
 #define PART_RECENT_DELETE_ICON "part.recent.delete.icon"
 #define PART_RECENT_CONTENTS "part.recent.contents"
 #define PART_RECENT_NO_CONTENTS "part.recent.no.contents"
@@ -54,6 +56,8 @@
 #define SIG_SHOW_RECENT "sig.show.recent"
 #define SIG_HIDE_RECENT "sig.hide.recent"
 
+#define TITLE_WIDTH "title.width"
+
 #define STYLE_LABEL_TITLE "slide_home_title"
 #define STYLE_LABEL_TITLE_FOCUS "slide_home_title_focus"
 
index 39b1eca..48fccc2 100644 (file)
@@ -28,6 +28,76 @@ struct _priv {
        Evas_Object *base;
 };
 
+static inline Evas_Object *_add_layout(Evas_Object *base, const char *group,
+               bool focus_allow)
+{
+       Evas_Object *ly;
+
+       if (!base || !group) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       ly = elm_layout_add(base);
+       if (!ly) {
+               _ERR("failed to add layout");
+               return false;
+       }
+       elm_layout_file_set(ly, EDJEFILE, group);
+       if (focus_allow)
+               elm_object_focus_allow_set(ly, EINA_TRUE);
+       evas_object_show(ly);
+
+       return ly;
+}
+
+static inline Evas_Object *_add_icon(Evas_Object *eo, const char *file, const char *part)
+{
+       Evas_Object *ic;
+
+       if (!eo || !file || !part) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       ic = elm_icon_add(eo);
+       if (!ic) {
+               _ERR("failed to add icon");
+               return NULL;
+       }
+
+       elm_image_file_set(ic, file, NULL);
+       elm_object_part_content_set(eo, part, ic);
+
+       return ic;
+}
+
+static inline Evas_Object *_add_label(Evas_Object *eo, char *name,
+               const char *style, const char *part)
+{
+       Evas_Object *lbl;
+       const char *s;
+
+       if (!eo || !name || !style || !part) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       lbl = elm_label_add(eo);
+       if (!lbl) {
+               _ERR("failed to add label");
+               return NULL;
+       }
+       elm_object_style_set(lbl, style);
+       s = edje_object_data_get(elm_layout_edje_get(eo), TITLE_WIDTH);
+       if (s)
+               elm_label_wrap_width_set(lbl, atoi(s));
+       elm_object_text_set(lbl, name);
+       elm_object_part_content_set(eo, part, lbl);
+
+       return lbl;
+}
+
 static bool _add_navigations(Evas_Object *base)
 {
        Evas_Object *ly;
@@ -37,27 +107,56 @@ static bool _add_navigations(Evas_Object *base)
                return false;
        }
 
-       ly = elm_layout_add(base);
+       ly = _add_layout(base, GRP_HOME_DOWN_ARROW, true);
        if (!ly) {
                _ERR("failed to add layout");
                return false;
        }
-       elm_layout_file_set(ly, EDJEFILE, GRP_HOME_DOWN_ARROW);
-       elm_object_focus_allow_set(ly, EINA_TRUE);
        elm_object_part_content_set(base, PART_HOME_DOWN_ARROW, ly);
 
-       ly = elm_layout_add(base);
+       ly = _add_layout(base, GRP_HOME_UP_ARROW, true);
        if (!ly) {
                _ERR("failed to add layout");
                return false;
        }
-       elm_layout_file_set(ly, EDJEFILE, GRP_HOME_UP_ARROW);
-       elm_object_focus_allow_set(ly, EINA_TRUE);
        elm_object_part_content_set(base, PART_HOME_UP_ARROW, ly);
 
        return true;
 }
 
+static bool _add_home_menu(struct _priv *priv, Evas_Object *base)
+{
+       Evas_Object *scr, *box;
+
+       if (!priv) {
+               _ERR("Invalid argument");
+               return false;
+       }
+
+       scr = elm_scroller_add(base);
+       if (!scr) {
+               _ERR("failed to add scroller");
+               return false;
+       }
+       elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,
+                       ELM_SCROLLER_POLICY_OFF);
+
+       box = elm_box_add(scr);
+       if (!box) {
+               _ERR("failed to add box");
+               evas_object_del(scr);
+               return false;
+       }
+       evas_object_show(box);
+       elm_object_content_set(scr, box);
+       elm_object_part_content_set(base, PART_HOME_MENU_BAR, scr);
+       elm_box_horizontal_set(box, EINA_TRUE);
+
+       /* Packing item will be implemented later */
+
+       return true;
+}
+
 static bool _add_home(struct _priv *priv, Evas_Object *base)
 {
        if (!priv || !base) {
@@ -70,7 +169,10 @@ static bool _add_home(struct _priv *priv, Evas_Object *base)
                return false;
        }
 
-       /* It should be implemented later */
+       if (!_add_home_menu(priv, base)) {
+               _ERR("failed to add menu");
+               return false;
+       }
 
        return true;
 }
@@ -91,13 +193,12 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                return NULL;
        }
 
-       base = elm_layout_add(win);
+       base =_add_layout(win, GRP_HOME, false);
        if (!base) {
                _ERR("failed to create base");
                free(priv);
                return NULL;
        }
-       elm_layout_file_set(base, EDJEFILE, GRP_HOME);
        evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        elm_win_resize_object_add(win, base);