62cae573a6a18911baa69d6d8177ee13f347f94c
[profile/ivi/ico-uxf-homescreen.git] / tests / system-controller / test-dummy-hs / CicoUISample.cpp
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 /*========================================================================*/    
11 /**
12  *  @file   CicoUISample.cpp
13  *
14  *  @brief  
15  */
16 /*========================================================================*/    
17
18 #include <exception>
19 #include <iostream>
20 #include <string>
21
22 #include <stdlib.h>
23 #include <stdio.h>
24
25 #include "CicoUISample.h"
26 #include "CicoBaseWin.h"
27 #include "CicoGeometry.h"
28 #include "CicoBackground.h"
29 #include "CicoColor.h"
30 #include "CicoLog.h"
31 #include "ico_syc_common.h"
32 #include "ico_syc_privilege.h"
33
34
35 CicoBackground* _background = NULL;
36 CicoBackground* _controlbar = NULL;
37 bool backgroundShow = false;
38 extern "C" {
39 static void
40 _syc_callback(const ico_syc_ev_e event,
41               const void *detail, void *user_data)
42 {
43     switch (event) {
44     case ICO_SYC_EV_WIN_CREATE:
45     {
46         ICO_DBG("--- ICO_SYC_EV_WIN_CREATE "
47                 "(appid[%s], name[%s], surface[%d])",
48                ((ico_syc_win_info_t *)detail)->appid,
49                ((ico_syc_win_info_t *)detail)->name,
50                ((ico_syc_win_info_t *)detail)->surface);
51
52         ico_syc_win_info_t *info = (ico_syc_win_info_t *)detail;
53         if (0 == strcmp(info->name, "HSBackground")) {
54             if (backgroundShow == true) {
55                 break;
56             }
57             ico_syc_change_layer(info->appid, info->surface, 0);
58             ico_syc_animation_t animation = {"fade", 500};
59             ico_syc_win_move_t win_move = {NULL, 0, 64, 300, 300};
60             ico_syc_move(info->appid, info->surface, &win_move, &animation);
61             ico_syc_show(info->appid, info->surface, &animation);
62
63             ico_syc_map_thumb(info->surface, 0);
64             backgroundShow = true;
65         }
66         if (0 == strcmp(info->name, "HSControllBar")) {
67             ico_syc_change_layer(info->appid, info->surface, 1);
68             ico_syc_show(info->appid, info->surface, NULL);
69             ico_syc_win_move_t win_move = {NULL, 0, 1920-128, 1080, 128};
70             ico_syc_move(info->appid, info->surface, &win_move, NULL);
71
72             ico_syc_change_layer(info->appid, info->surface, 0);
73             ico_syc_win_move_t win_move2 = {NULL, 0, 128, 1080, 512};
74             ico_syc_move(info->appid, info->surface, &win_move2, NULL);
75         }
76
77         break;
78     }
79     case ICO_SYC_EV_WIN_DESTROY:
80         printf("--- ICO_SYC_EV_WIN_DESTROY ");
81         printf("(appid[%s], name[%s], surface[%d])\n",
82                ((ico_syc_win_info_t *)detail)->appid,
83                ((ico_syc_win_info_t *)detail)->name,
84                ((ico_syc_win_info_t *)detail)->surface);
85         break;
86     case ICO_SYC_EV_WIN_ACTIVE:
87         printf("--- ICO_SYC_EV_WIN_ACTIVE ");
88         printf("(appid[%s], name[%s], surface[%d])\n",
89                ((ico_syc_win_info_t *)detail)->appid,
90                ((ico_syc_win_info_t *)detail)->name,
91                ((ico_syc_win_info_t *)detail)->surface);
92         break;
93     case ICO_SYC_EV_WIN_ATTR_CHANGE:
94     {
95         ICO_DBG("--- ICO_SYC_EV_WIN_ATTR_CHANGE"
96                 "(appid[%s], name[%s], surface[%d], node[%d], layer[%d], "
97                 "(x,y)[%d, %d], width[%d], height[%d], raise[%d], visible[%d], active[%d])",
98                ((ico_syc_win_attr_t *)detail)->appid,
99                ((ico_syc_win_attr_t *)detail)->name,
100                ((ico_syc_win_attr_t *)detail)->surface,
101                ((ico_syc_win_attr_t *)detail)->nodeid,
102                ((ico_syc_win_attr_t *)detail)->layer,
103                ((ico_syc_win_attr_t *)detail)->pos_x,
104                ((ico_syc_win_attr_t *)detail)->pos_y,
105                ((ico_syc_win_attr_t *)detail)->width,
106                ((ico_syc_win_attr_t *)detail)->height,
107                ((ico_syc_win_attr_t *)detail)->raise,
108                ((ico_syc_win_attr_t *)detail)->visible,
109                ((ico_syc_win_attr_t *)detail)->active);
110
111         ico_syc_win_attr_t *info = (ico_syc_win_attr_t *)detail;
112         if (0 == strcmp(info->name, "HSBackground")) {
113             if (backgroundShow == true) {
114                 break;
115             }
116             ico_syc_change_layer(info->appid, info->surface, 1);
117             ico_syc_show_layer(1);
118             ico_syc_animation_t animation = {"fade", 500};
119             ico_syc_show(info->appid, info->surface, &animation);
120             ico_syc_win_move_t win_move = {NULL, 100, 64, 300, 300};
121             ico_syc_move(info->appid, info->surface, &win_move, &animation);
122             ico_syc_hide(info->appid, info->surface, &animation);
123             ico_syc_show(info->appid, info->surface, &animation);
124             backgroundShow = true;
125         }
126         break;
127     }
128     case ICO_SYC_EV_THUMB_ERROR:
129         printf("--- ICO_SYC_EV_THUMB_ERROR\n");
130         printf("\t(appid[%s], surface[%d], error[%d]",
131                ((ico_syc_thumb_info_t *)detail)->appid,
132                ((ico_syc_thumb_info_t *)detail)->surface,
133                ((ico_syc_thumb_info_t *)detail)->target);
134         break;
135     case ICO_SYC_EV_THUMB_CHANGE:
136         printf("--- ICO_SYC_EV_THUMB_CHANGE\n");
137         printf("\t(appid[%s], surface[%d], name[%d], width[%d], height[%d], ",
138                ((ico_syc_thumb_info_t *)detail)->appid,
139                ((ico_syc_thumb_info_t *)detail)->surface,
140                ((ico_syc_thumb_info_t *)detail)->name,
141                ((ico_syc_thumb_info_t *)detail)->width,
142                ((ico_syc_thumb_info_t *)detail)->height);
143         printf("stride[%d], format[%d])\n",
144                ((ico_syc_thumb_info_t *)detail)->stride,
145                ((ico_syc_thumb_info_t *)detail)->format);
146         break;
147     case ICO_SYC_EV_THUMB_UNMAP:
148         printf("--- ICO_SYC_EV_THUMB_UNMAP\n");
149         printf("\t(appid[%s], surface[%d], name[%d], width[%d], height[%d], ",
150                ((ico_syc_thumb_info_t *)detail)->appid,
151                ((ico_syc_thumb_info_t *)detail)->surface,
152                ((ico_syc_thumb_info_t *)detail)->name,
153                ((ico_syc_thumb_info_t *)detail)->width,
154                ((ico_syc_thumb_info_t *)detail)->height);
155         printf("stride[%d], format[%d])\n",
156                ((ico_syc_thumb_info_t *)detail)->stride,
157                ((ico_syc_thumb_info_t *)detail)->format);
158         break;
159     case ICO_SYC_EV_LAYER_ATTR_CHANGE:
160         printf("--- ICO_SYC_EV_LAYER_ATTR_CHANGE ");
161         printf("(layer[%d], visible[%d])\n",
162                ((ico_syc_layer_attr_t *)detail)->layer,
163                ((ico_syc_layer_attr_t *)detail)->visible);
164         break;
165     default:
166         printf("--- UNKNOWN");
167         break;
168     }
169
170     return;
171 }
172 }
173
174 /**
175  *  Default Constructor
176  */
177 CicoUISample::CicoUISample()
178 {
179     ICO_DBG("CicoUISample::CicoUISample Enter");
180     ICO_DBG("CicoUISample::CicoUISample Leave");
181 }
182
183 /**
184  *  Destructor
185  */
186 CicoUISample::~CicoUISample()
187 {
188     ICO_DBG("CicoUISample::~CicoUISample Enter");
189     ICO_DBG("CicoUISample::~CicoUISample Leave");
190 }
191
192 bool
193 CicoUISample::onCreate(void *user_data)
194 {
195     ICO_DBG("CicoUISample::onCreate Enter");
196
197     try {
198         ico_syc_connect(_syc_callback, NULL);
199
200         ecore_evas_init();
201         CicoBaseWin* _bgwin = new CicoBaseWin("HSBackground",
202                                               CicoGeometry(0, 64, 300, 300));
203         _background = new CicoBackground(_bgwin->getEvas(),
204                                          CicoGeometry(0, 0, 300, 300),
205                                          CicoColor(128, 0, 128, 255));
206
207 //        CicoBaseWin* _ctlwin = new CicoBaseWin("HSControllBar",
208 //                                               CicoGeometry(0, 0, 1080, 128));
209 //        _controlbar = new CicoBackground(_ctlwin->getEvas(),
210 //                                         CicoGeometry(0, 0, 1080, 128),
211 //                                         CicoColor(128, 128, 128, 255));
212  
213     }
214     catch (const std::exception& e) {
215         std::cerr << e.what() << std::endl;
216         ICO_ERR("catch exception %s", e.what());
217         ICO_DBG("CicoUISample::onCreate Leave(false)");
218         return false;
219     }
220     catch (const std::string& str) {
221         std::cerr << str << std::endl;
222         ICO_ERR("catch exception %s", str.c_str());
223         ICO_DBG("CicoUISample::onCreate Leave(false)");
224         return false;
225     }
226     catch (...) {
227         ICO_ERR("catch exception unknown");
228         ICO_DBG("CicoUISample::onCreate Leave(false)");
229         return false;
230     }
231
232     ICO_DBG("CicoUISample::onCreate Leave(true)");
233
234     return true;
235 }
236
237 #if 0
238 void
239 CicoUISample::onTerminate(void *user_data)
240 {
241     _DBG("CicoUISample::onTerminate entry");
242 }
243
244 void
245 CicoUISample::onPause(void *user_data)
246 {
247     _DBG("CicoUISample::onPause entry");
248 }
249
250 void
251 CicoUISample::onResume(void *user_data)
252 {
253     _DBG("CicoUISample::onResume entry");
254 }
255
256 void
257 CicoUISample::onService(service_h service, void *user_data)
258 {
259     _DBG("CicoUISample::onService entry");
260 }
261 #endif
262 /* vim: set expandtab ts=4 sw=4: */