2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 /*========================================================================*/
12 * @file CicoUISample.cpp
16 /*========================================================================*/
25 #include "CicoUISample.h"
26 #include "CicoBaseWin.h"
27 #include "CicoGeometry.h"
28 #include "CicoBackground.h"
29 #include "CicoColor.h"
31 #include "ico_syc_common.h"
32 #include "ico_syc_privilege.h"
35 CicoBackground* _background = NULL;
36 CicoBackground* _controlbar = NULL;
37 bool backgroundShow = false;
40 _syc_callback(const ico_syc_ev_e event,
41 const void *detail, void *user_data)
44 case ICO_SYC_EV_WIN_CREATE:
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);
52 ico_syc_win_info_t *info = (ico_syc_win_info_t *)detail;
53 if (0 == strcmp(info->name, "HSBackground")) {
54 if (backgroundShow == true) {
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);
63 ico_syc_map_thumb(info->surface, 0);
64 backgroundShow = true;
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);
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);
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);
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);
93 case ICO_SYC_EV_WIN_ATTR_CHANGE:
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);
111 ico_syc_win_attr_t *info = (ico_syc_win_attr_t *)detail;
112 if (0 == strcmp(info->name, "HSBackground")) {
113 if (backgroundShow == true) {
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;
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);
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);
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);
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);
166 printf("--- UNKNOWN");
175 * Default Constructor
177 CicoUISample::CicoUISample()
179 ICO_DBG("CicoUISample::CicoUISample Enter");
180 ICO_DBG("CicoUISample::CicoUISample Leave");
186 CicoUISample::~CicoUISample()
188 ICO_DBG("CicoUISample::~CicoUISample Enter");
189 ICO_DBG("CicoUISample::~CicoUISample Leave");
193 CicoUISample::onCreate(void *user_data)
195 ICO_DBG("CicoUISample::onCreate Enter");
198 ico_syc_connect(_syc_callback, NULL);
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));
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));
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)");
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)");
227 ICO_ERR("catch exception unknown");
228 ICO_DBG("CicoUISample::onCreate Leave(false)");
232 ICO_DBG("CicoUISample::onCreate Leave(true)");
239 CicoUISample::onTerminate(void *user_data)
241 _DBG("CicoUISample::onTerminate entry");
245 CicoUISample::onPause(void *user_data)
247 _DBG("CicoUISample::onPause entry");
251 CicoUISample::onResume(void *user_data)
253 _DBG("CicoUISample::onResume entry");
257 CicoUISample::onService(service_h service, void *user_data)
259 _DBG("CicoUISample::onService entry");
262 /* vim: set expandtab ts=4 sw=4: */