Revert "Corresponding to TizenIVI3.0 M14.3, GENIVI-LayerManagement was used instead...
[profile/ivi/ico-uxf-homescreen.git] / src / homescreen / CicoHSSwipeInputWindow.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  * @brief   swipe input window
11  *
12  * @date    Sep-20-2013
13  */
14 #include "CicoHSSwipeInputWindow.h"
15 #include "CicoHSSwipeTouch.h"
16 #include "CicoHomeScreen.h"
17 #include "CicoHSSystemState.h"
18
19 /*============================================================================*/
20 /* functions                                                                  */
21 /*============================================================================*/
22 /*--------------------------------------------------------------------------*/
23 /**
24  * @brief   CicoHSSwipeInputWindow::CicoHSSwipeInputWindow
25  *          Constractor
26  *
27  * @param[in]   none
28  * @return      none
29  */
30 /*--------------------------------------------------------------------------*/
31 CicoHSSwipeInputWindow::CicoHSSwipeInputWindow(void)
32 {
33     ICO_DBG("CicoHSSwipeInputWindow::CicoHSSwipeInputWindow: constractor");
34     evas = NULL;
35     background = NULL;
36     setuped = false;
37 }
38
39 /*--------------------------------------------------------------------------*/
40 /**
41  * @brief   CicoHSSwipeInputWindow::~CicoHSSwipeInputWindow
42  *          Destractor
43  *
44  * @param[in]   none
45  * @return      none
46  */
47 /*--------------------------------------------------------------------------*/
48 CicoHSSwipeInputWindow::~CicoHSSwipeInputWindow(void)
49 {
50     ICO_DBG("CicoHSSwipeInputWindow::CicoHSSwipeInputWindow: destractor");
51     /* not somthing to do */
52 }
53
54 /*--------------------------------------------------------------------------*/
55 /**
56  * @brief   CicoHSSwipeInputWindow::CreateSwipeInputWindow
57  *          crate window (swipe input window)
58  *
59  * @param[in]   pos_x    position x
60  * @param[in]   pos_y    position y
61  * @param[in]   width    width
62  * @param[in]   height   height
63  * @param[in]   subname  swipe input window sub name
64  * @return      OK or ERRROR
65  */
66 /*--------------------------------------------------------------------------*/
67 int
68 CicoHSSwipeInputWindow::CreateSwipeInputWindow(int pos_x, int pos_y,
69                                                int width, int height, const char *subname)
70 {
71     int ret;
72
73     ICO_DBG("CreateSwipeInputWindow: start(%s,x/y=%d/%d,w/h=%d/%d)",
74             subname ? subname : "(null)", pos_x, pos_y, width, height);
75
76     /*create window*/
77     if (subname)    {
78         snprintf(winname, sizeof(winname), "%s_%s",
79                  ICO_HS_SWIPE_INPUT_WINDOW_TITLE, subname);
80     }
81     else    {
82         strncpy(winname, ICO_HS_SWIPE_INPUT_WINDOW_TITLE, ICO_SYC_MAX_WINNAME_LEN);
83     }
84     winname[ICO_SYC_MAX_WINNAME_LEN-1] = 0;
85     ICO_DBG("CreateSwipeInputWindow: winname=%s", winname);
86     ret = CreateWindow(winname, pos_x, pos_y, width, height, EINA_TRUE);
87     if(ret != ICO_OK){
88         ICO_CRI("CicoHSSwipeInputWindow::CreateSwipeInputWindow: can not create window");
89         return ret;
90     }
91
92     /* get evas */
93     evas = ecore_evas_get(window);
94     if (!evas) {
95         ICO_CRI("CicoHSSwipeInputWindow::CreateSwipeInputWindow: could not get evas.");
96         return ICO_ERROR;
97     }
98
99     /* background object(transparent)    */
100     background = evas_object_image_filled_add(evas);
101
102     /* set mouse/touch callback */
103     evas_object_event_callback_add(background, EVAS_CALLBACK_MOUSE_DOWN,
104                                        CicoHSSwipeTouch::TouchDownSwipe, this);
105     evas_object_event_callback_add(background, EVAS_CALLBACK_MOUSE_UP,
106                                        CicoHSSwipeTouch::TouchUpSwipe, this);
107     evas_object_event_callback_add(background, EVAS_CALLBACK_MOUSE_MOVE,
108                                        CicoHSSwipeTouch::TouchMoveSwipe, this);
109     /* move and show window     */
110     evas_object_move(background, 0, 0);
111     evas_object_resize(background, width, height);
112     evas_object_show(background);
113
114     ICO_DBG("CreateSwipeInputWindow: end");
115     return ICO_OK;
116 }
117
118 /*--------------------------------------------------------------------------*/
119 /**
120  * @brief   CicoHSSwipeInputWindow::FreeSwipeInputWindow
121  *          free window (swipe input window)
122  *
123  * @param[in]   none
124  * @return      none
125  */
126 /*--------------------------------------------------------------------------*/
127 void
128 CicoHSSwipeInputWindow::FreeSwipeInputWindow(void)
129 {
130     evas_object_del(background);
131     FreeWindow();
132 }
133
134 /*--------------------------------------------------------------------------*/
135 /**
136  * @brief   CicoHSSwipeInputWindow::SetupSwipeWindow
137  *          initiale setup swipe input window
138  *
139  * @param       none
140  * @return      none
141  */
142 /*--------------------------------------------------------------------------*/
143 void
144 CicoHSSwipeInputWindow::SetupSwipeWindow(void)
145 {
146     ico_syc_win_move_t move;
147     ico_syc_animation_t show;
148
149     if (! setuped)  {
150         ICO_DBG("SetupSwipeWindow: start");
151         setuped = true;
152         move.zone = NULL;
153         move.pos_x = pos_x;
154         move.pos_y = pos_y;
155         move.width = width;
156         move.height = height;
157         memset(&show, 0, sizeof(show));
158         show.name = (char *)"none";
159
160         /* set default animation                    */
161         ico_syc_set_animation(appid, surface, ICO_SYC_ANIMATION_TYPE_ALL, &show);
162         /* move swipe input window to TouchLayer    */
163         ico_syc_change_layer(appid, surface, HS_LAYER_TOUCHPANEL);
164         /* move window position and size            */
165         ico_syc_move(appid, surface, &move, NULL);
166         /* show and raise window                    */
167         show.time = ICO_SYC_WIN_SURF_RAISE;
168         ico_syc_show(appid, surface, &show);
169
170         /* show touch layer                         */
171         ico_syc_show_layer(HS_LAYER_TOUCHPANEL);
172
173         ICO_DBG("SetupSwipeWindow: end");
174     }
175 }
176
177 /*--------------------------------------------------------------------------*/
178 /**
179  * @brief   CicoHSSwipeInputWindow::Show
180  *          show my window
181  *
182  * @param       none
183  * @return      none
184  */
185 /*--------------------------------------------------------------------------*/
186 void
187 CicoHSSwipeInputWindow::Show(void)
188 {
189     ICO_DBG("CicoHSSwipeInputWindow::Show: %08x.%s", surface, this->winname);
190     ico_syc_show(appid, surface, NULL);
191 }
192
193 /*--------------------------------------------------------------------------*/
194 /**
195  * @brief   CicoHSSwipeInputWindow::Hide
196  *          hide my window
197  *
198  * @param       none
199  * @return      none
200  */
201 /*--------------------------------------------------------------------------*/
202 void
203 CicoHSSwipeInputWindow::Hide(void)
204 {
205     ICO_DBG("CicoHSSwipeInputWindow::Hide: %08x.%s", surface, this->winname);
206     ico_syc_hide(appid, surface, NULL);
207 }
208
209 /*--------------------------------------------------------------------------*/
210 /**
211  * @brief   CicoHSSwipeInputWindow::isMyWindowName
212  *          check window name
213  *
214  * @param[in]   winname     target window name
215  * @return      check result
216  * @retval      true        my window name is winname
217  * @retval      false       my window name is NOT winname
218  */
219 /*--------------------------------------------------------------------------*/
220 bool
221 CicoHSSwipeInputWindow::isMyWindowName(const char *winname)
222 {
223     bool    ret;
224
225     ret = (strcmp(winname, this->winname)) ? false : true;
226     ICO_DBG("isMyWindowName: %s is %s", winname, ret ? "TRUE" : "FALSE");
227     return ret;
228 }
229
230 int
231 CicoHSSwipeInputWindow::GetPosX(void)
232 {
233     return pos_x;
234 }
235
236 int
237 CicoHSSwipeInputWindow::GetPosY(void)
238 {
239     return pos_y;
240 }
241
242 int
243 CicoHSSwipeInputWindow::GetWidth(void)
244 {
245     return width;
246 }
247
248 int
249 CicoHSSwipeInputWindow::GetHeight(void)
250 {
251     return height;
252 }
253
254 /*--------------------------------------------------------------------------*/
255 /**
256  * @brief   CicoHSSwipeInputWindow::SetWindowID
257  *          set appid and surface
258  *
259  * @param[in]   none
260  * @return      none
261  */
262 /*--------------------------------------------------------------------------*/
263 void
264 CicoHSSwipeInputWindow::SetWindowID(const char *appid, int surface)
265 {
266     ICO_DBG("SetWindowID: appid=%s surface=%08x", appid, surface);
267     strncpy(this->appid, appid, ICO_HS_MAX_PROCESS_NAME);
268     this->surface = surface;
269 }
270 // vim: set expandtab ts=4 sw=4: