From e31ba17519104cb73959c5802769880222f22d30 Mon Sep 17 00:00:00 2001 From: Soohye Shin Date: Tue, 16 Jun 2015 18:02:45 +0900 Subject: [PATCH] pack home data and modify home edc Change-Id: I1c44199b9cddfea992b366c0331cbc176b088786 Signed-off-by: Soohye Shin --- edje/view/home.edc | 34 +++++++++++++++----- src/view/view_home.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 10 deletions(-) diff --git a/edje/view/home.edc b/edje/view/home.edc index 83321ad..465ad00 100644 --- a/edje/view/home.edc +++ b/edje/view/home.edc @@ -303,6 +303,7 @@ group { group { name, GRP_HOME_ITEM; + data.item, TITLE_WIDTH "128"; parts { part { name, "bg"; @@ -398,6 +399,17 @@ group { } } part { + name, PART_HOME_ITEM_ICON_FOCUS; + type, SWALLOW; + scale, 1; + clip_to, "clip"; + description { + state, "default" 0.0; + rel1.to, PART_HOME_ITEM_ICON; + rel2.to, PART_HOME_ITEM_ICON; + } + } + part { name, "pad.text"; type, RECT; scale, 1; @@ -412,12 +424,11 @@ group { } } part { - name, PART_HOME_ITEM_NAME; - type, TEXT; + name, PART_HOME_ITEM_TITLE; + type, SWALLOW; scale, 1; description { state, "default" 0.0; - min, 127 38; rel1 { to, "pad.text"; relative, 0.0 0.0; @@ -428,11 +439,18 @@ group { } align, 0.5 1.0; fixed, 1 1; - text { - size, 22; - font, "TizenSans"; - } - color, 104 104 104 255; + min, 128 38; + } + } + part { + name, PART_HOME_ITEM_TITLE_FOCUS; + type, SWALLOW; + scale, 1; + clip_to, "clip"; + description { + state, "default" 0.0; + rel1.to, PART_HOME_ITEM_TITLE; + rel2.to, PART_HOME_ITEM_TITLE; } } part { diff --git a/src/view/view_home.c b/src/view/view_home.c index db4e0f7..17eeed6 100644 --- a/src/view/view_home.c +++ b/src/view/view_home.c @@ -28,10 +28,17 @@ struct _priv { Evas_Object *win; Evas_Object *base; + Eina_List *list; struct datamgr *dm; }; +struct bar_item { + Evas_Object *eo; + + struct _priv *priv; +}; + static inline Evas_Object *_add_layout(Evas_Object *base, const char *group, bool focus_allow) { @@ -128,11 +135,69 @@ static bool _add_navigations(Evas_Object *base) return true; } +static struct bar_item *_pack_bar_item(struct _priv *priv, Evas_Object *box, + struct datamgr_item *di) +{ + struct bar_item *bi; + Evas_Object *eo, *ic, *focus_ic, *lbl, *focus_lbl; + + if (!priv || !box || !di) { + _ERR("Invalid argument"); + return NULL; + } + + bi = calloc(1, sizeof(*bi)); + if (!bi) { + _ERR("failed to calloc bar item"); + return NULL; + } + + eo = _add_layout(box, GRP_HOME_ITEM, true); + if (!eo) { + _ERR("failed to add layout"); + free(bi); + return NULL; + } + + ic = _add_icon(eo, di->icon, PART_HOME_ITEM_ICON); + if (!ic) + goto err; + + focus_ic = _add_icon(eo, di->focus_icon, PART_HOME_ITEM_ICON_FOCUS); + if (!focus_ic) + goto err; + + lbl = _add_label(eo, di->title, STYLE_LABEL_TITLE, PART_HOME_ITEM_TITLE); + if (!lbl) + goto err; + + focus_lbl = _add_label(eo, di->title, STYLE_LABEL_TITLE_FOCUS, + PART_HOME_ITEM_TITLE_FOCUS); + if (!focus_lbl) + goto err; + + elm_box_pack_end(box, eo); + + bi->priv = priv; + bi->eo = eo; + + return bi; +err: + _ERR("failed to add home item"); + evas_object_del(eo); + free(bi); + + return NULL; +} + static bool _add_home_menu(struct _priv *priv, Evas_Object *base) { + Eina_List *list, *l; Evas_Object *scr, *box; + struct bar_item *bi; + struct datamgr_item *di; - if (!priv) { + if (!priv || !base) { _ERR("Invalid argument"); return false; } @@ -156,7 +221,20 @@ static bool _add_home_menu(struct _priv *priv, Evas_Object *base) elm_object_part_content_set(base, PART_HOME_MENU_BAR, scr); elm_box_horizontal_set(box, EINA_TRUE); - /* Packing item will be implemented later */ + list = datamgr_get_items(priv->dm); + if (!list) { + _ERR("failed to load list"); + evas_object_del(scr); + return false; + } + + EINA_LIST_FOREACH(list, l, di) { + bi = _pack_bar_item(priv, box, di); + if (!bi) + continue; + + priv->list = eina_list_append(priv->list, bi); + } return true; } @@ -264,6 +342,7 @@ static void _hide(void *data) static void _destroy(void *data) { struct _priv *priv; + struct bar_item *bi; if (!data) { _ERR("Invalid argument"); @@ -272,8 +351,15 @@ static void _destroy(void *data) priv = data; + EINA_LIST_FREE(priv->list, bi) { + evas_object_del(bi->eo); + free(bi); + } + datamgr_fini(priv->dm); evas_object_del(priv->base); + + priv->list = NULL; free(priv); } -- 2.7.4