--- /dev/null
+/*
+ * 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 <datamgr.h>
+
+struct data_class *datamgr_photo_get_dclass(void);
+
+#endif /* __AIR_HOME_DATA_PHOTO_H__ */
--- /dev/null
+/*
+ * 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 <app_debug.h>
+#include <Eina.h>
+
+#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;
+}
#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) {
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;
}
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;
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)
}
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);
}
{
return &vclass;
}
-