From: Soohye Shin Date: Wed, 8 Jul 2015 03:53:41 +0000 (+0900) Subject: draw photo contents for no contents layout or gengrid X-Git-Tag: accepted/tizen/tv/20150728.070602~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=97227b7e8f2d478eb2c8f9ad56a9fcf8b8e1bb5f;p=profile%2Ftv%2Fapps%2Fnative%2Fair_home.git draw photo contents for no contents layout or gengrid Change-Id: Ifb1e4459ae96e8dfc8722ee7311436f7cf6c4c7e Signed-off-by: Soohye Shin --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f58ef70..e7a5be0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,7 @@ SET(SRCS src/data/data_home.c src/data/data_recent.c src/data/data_user.c + src/data/data_photo.c src/view/view_photo.c src/view/view_user_edit.c src/view/view_user.c diff --git a/include/data_photo.h b/include/data_photo.h new file mode 100644 index 0000000..4fcf256 --- /dev/null +++ b/include/data_photo.h @@ -0,0 +1,24 @@ +/* + * 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 __AIR_HOME_DATA_PHOTO_H__ +#define __AIR_HOME_DATA_PHOTO_H__ + +#include + +struct data_class *datamgr_photo_get_dclass(void); + +#endif /* __AIR_HOME_DATA_PHOTO_H__ */ diff --git a/src/data/data_photo.c b/src/data/data_photo.c new file mode 100644 index 0000000..6d704db --- /dev/null +++ b/src/data/data_photo.c @@ -0,0 +1,68 @@ +/* + * 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 +#include + +#include "data_photo.h" +#include "datamgr.h" + +static Eina_List *_get_items(struct datamgr *dm) +{ + if (!dm) { + _ERR("Invalid argument"); + return NULL; + } + + return dm->list; +} + +static bool _init(struct datamgr *dm) +{ + if (!dm) { + _ERR("Invalid argument"); + return false; + } + + return true; +} + +static void _fini(struct datamgr *dm) +{ + struct datamgr_item *di; + + if (!dm) { + _ERR("Invalid argument"); + return; + } + + EINA_LIST_FREE(dm->list, di) { + free(di->icon); + + free(di); + } +} + +static struct data_class dclass = { + .init = _init, + .fini = _fini, + .get_items = _get_items +}; + +struct data_class *datamgr_photo_get_dclass(void) +{ + return &dclass; +} diff --git a/src/view/view_photo.c b/src/view/view_photo.c index e3a0319..fa4c64d 100644 --- a/src/view/view_photo.c +++ b/src/view/view_photo.c @@ -22,16 +22,25 @@ #include "defs.h" #include "view_photo.h" +#include "data_photo.h" #include "utils.h" +#define GENGRID_ITEM_SIZE 200 + struct _priv { Evas_Object *win; Evas_Object *base; + Evas_Object *grid; + Evas_Object *ly; + Elm_Gengrid_Item_Class *grid_ic; + + struct datamgr *dm; }; static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; + struct datamgr *dm; Evas_Object *base; if (!win) { @@ -45,9 +54,17 @@ static Evas_Object *_create(Evas_Object *win, void *data) return NULL; } + dm = datamgr_init(datamgr_photo_get_dclass(), VIEW_PHOTO); + if (!dm) { + _ERR("failed to initialize datamgr"); + free(priv); + return NULL; + } + base = utils_add_layout(win, GRP_PHOTO, false, NULL); if (!base) { _ERR("failed to create base"); + datamgr_fini(dm); free(priv); return NULL; } @@ -57,12 +74,146 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->win = win; priv->base = base; + priv->dm = dm; viewmgr_set_view_data(VIEW_PHOTO, priv); return base; } +static void _ly_key_down(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + if (!strcmp(ev->keyname, KEY_BACK)) { + viewmgr_pop_view(); + } +} + +static input_handler ly_handler = { + .key_down = _ly_key_down +}; + +static void _load_no_content(struct _priv *priv) +{ + Evas_Object *ly; + + ly = utils_add_layout(priv->base, GRP_PHOTO_NO_CONTENT, true, + PART_PHOTO_LIST); + if (!ly) { + _ERR("failed to create layout"); + return; + } + evas_object_show(ly); + inputmgr_add_callback(ly, 0, &ly_handler, NULL); + + priv->ly = ly; +} +static void _grid_key_down(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) +{ + if (!strcmp(ev->keyname, KEY_BACK)) { + viewmgr_pop_view(); + } + /* It should be implemented later */ +} + +static input_handler grid_handler = { + .key_down = _grid_key_down +}; + +static Evas_Object *_add_photo_grid(struct _priv *priv) +{ + Evas_Object *grid; + + grid = elm_gengrid_add(priv->base); + if (!grid) { + _ERR("failed to add gend grid"); + return NULL; + } + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_part_content_set(priv->base, PART_PHOTO_LIST, grid); + elm_gengrid_select_mode_set(grid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(grid, EINA_FALSE); + elm_gengrid_item_size_set(grid, + GENGRID_ITEM_SIZE * elm_config_scale_get(), + GENGRID_ITEM_SIZE * elm_config_scale_get()); + elm_gengrid_horizontal_set(grid, EINA_TRUE); + elm_scroller_policy_set(grid, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + elm_gengrid_align_set(grid, 0.0, 0.5); + evas_object_show(grid); + + inputmgr_add_callback(grid, 0, &grid_handler, priv); + + return grid; +} + +static Evas_Object *_get_grid_content(void *data, Evas_Object *obj, + const char *part) +{ + /* It should be implemented later */ + + return NULL; +} + +static void _del_content(void *data, Evas_Object *obj) +{ + /* It should be implemented later */ +} + +static bool _add_photo_item(struct _priv *priv, Evas_Object *grid) +{ + Elm_Gengrid_Item_Class *ic; + + elm_gengrid_clear(grid); + + ic = elm_gengrid_item_class_new(); + if (!ic) { + _ERR("failed to add gengrid item class"); + return false; + } + + ic->item_style = STYLE_GENGRID_ITEM; + ic->func.text_get = NULL; + ic->func.content_get = _get_grid_content; + ic->func.state_get = NULL; + ic->func.del = _del_content; + + /* It should be implemented later */ + + priv->grid_ic = ic; + + return true; +} + +static void _load_photo(struct _priv *priv) +{ + Eina_List *list; + Evas_Object *grid; + + list = datamgr_get_items(priv->dm); + if (!list) { + _load_no_content(priv); + return; + } + + grid = _add_photo_grid(priv); + if (!grid) { + _ERR("failed to add grid"); + return; + } + + if (!_add_photo_item(priv, grid)) { + _ERR("failed to add photo item"); + evas_object_del(grid); + _load_no_content(priv); + return; + } + + priv->grid = grid; +} + static void _show(void *data) { struct _priv *priv; @@ -75,6 +226,11 @@ static void _show(void *data) priv = data; evas_object_show(priv->base); + + _load_photo(priv); + + if (priv->ly) + elm_object_focus_set(priv->ly, EINA_TRUE); } static void _hide(void *data) @@ -87,6 +243,16 @@ static void _hide(void *data) } priv = data; + if (priv->ly) { + inputmgr_remove_callback(priv->ly, &ly_handler); + evas_object_del(priv->ly); + priv->ly = NULL; + } else { + elm_gengrid_item_class_free(priv->grid_ic); + inputmgr_remove_callback(priv->grid, &grid_handler); + evas_object_del(priv->grid); + priv->grid = NULL; + } evas_object_hide(priv->base); } @@ -118,4 +284,3 @@ view_class *view_photo_get_vclass(void) { return &vclass; } -