add initial view_photo
[profile/tv/apps/native/air_home.git] / src / view / view_photo.c
1 /*
2
3  * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <Elementary.h>
19 #include <app_debug.h>
20 #include <viewmgr.h>
21 #include <inputmgr.h>
22
23 #include "defs.h"
24 #include "view_photo.h"
25 #include "utils.h"
26
27 struct _priv {
28         Evas_Object *win;
29         Evas_Object *base;
30 };
31
32 static Evas_Object *_create(Evas_Object *win, void *data)
33 {
34         struct _priv *priv;
35         Evas_Object *base;
36
37         if (!win) {
38                 _ERR("Invalid argument");
39                 return NULL;
40         }
41
42         priv = calloc(1, sizeof(*priv));
43         if (!priv) {
44                 _ERR("failed to calloc priv");
45                 return NULL;
46         }
47
48         base = utils_add_layout(win, GRP_PHOTO, false, NULL);
49         if (!base) {
50                 _ERR("failed to create base");
51                 free(priv);
52                 return NULL;
53         }
54         evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
55                         EVAS_HINT_EXPAND);
56         elm_win_resize_object_add(win, base);
57
58         priv->win = win;
59         priv->base = base;
60
61         viewmgr_set_view_data(VIEW_PHOTO, priv);
62
63         return base;
64 }
65
66 static void _show(void *data)
67 {
68         struct _priv *priv;
69
70         if (!data) {
71                 _ERR("Invalid argument");
72                 return;
73         }
74
75         priv = data;
76
77         evas_object_show(priv->base);
78 }
79
80 static void _hide(void *data)
81 {
82         struct _priv *priv;
83
84         if (!data) {
85                 _ERR("Invalid argument");
86                 return;
87         }
88
89         priv = data;
90
91         evas_object_hide(priv->base);
92 }
93
94 static void _destroy(void *data)
95 {
96         struct _priv *priv;
97
98         if (!data) {
99                 _ERR("Invalid argument");
100                 return;
101         }
102
103         priv = data;
104
105         evas_object_del(priv->base);
106         free(priv);
107 }
108
109 static view_class vclass = {
110         .view_id = VIEW_PHOTO,
111         .create = _create,
112         .show = _show,
113         .hide = _hide,
114         .destroy = _destroy
115 };
116
117 view_class *view_photo_get_vclass(void)
118 {
119         return &vclass;
120 }
121