1 /* Copyright (c) 2010-2014 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "runtime_data.h"
19 #include "maps_util.h"
20 #include "maps_view_plugin.h"
24 view::touch_point::touch_point()
32 view::touch_point::~touch_point()
36 view::touch_point::touch_point(const int x,
38 const unsigned int ts)
45 view::touch_point::touch_point(const touch_point &src)
53 view::touch_point &view::touch_point::operator=(const touch_point &src)
58 _timestamp = src._timestamp;
63 void view::touch_point::reset()
70 bool view::touch_point::empty() const
80 /* ---------------------------------------------------------------------------*/
83 view::map_state::map_state()
87 , _prev_zoom_factor(.1)
88 , _prev_rotation_angle(.0)
93 view::map_state::~map_state()
96 maps_coordinates_destroy(_center);
100 view::map_state::map_state(const map_state &src)
103 , _rotation_angle(.0)
104 , _prev_zoom_factor(.1)
105 , _prev_rotation_angle(.0)
110 view::map_state &view::map_state::operator=(const map_state &src)
114 maps_coordinates_clone(src._center, &_center);
115 _zoom_factor = src._zoom_factor;
116 _rotation_angle = src._rotation_angle;
117 _prev_zoom_factor = src._prev_zoom_factor;
118 _prev_rotation_angle = src._prev_rotation_angle;
123 void view::map_state::reset()
126 maps_coordinates_destroy(_center);
130 _rotation_angle = .0;
131 _prev_zoom_factor = .1;
132 _prev_rotation_angle = .0;
135 MAPS_LOGI("%c[%d;%d;%dm"
136 "central coordinates: RESET"
143 void view::map_state::capture(maps_view_h view)
150 maps_view_get_center(view, &_center);
151 maps_view_get_zoom_factor(view, &_zoom_factor);
152 maps_view_get_orientation(view, &_rotation_angle);
153 _prev_zoom_factor = _zoom_factor;
154 _prev_rotation_angle = _rotation_angle;
157 maps_coordinates_h central_coords = NULL;
158 maps_view_get_center(view, ¢ral_coords);
159 double lat = .0, lon = .0;
160 maps_coordinates_get_latitude_longitude(central_coords, &lat, &lon);
161 maps_coordinates_destroy(central_coords);
162 MAPS_LOGI("%c[%d;%d;%dm"
163 "central coordinates: (%f, %f)"
170 void view::map_state::trace()
172 double latitude = .0;
173 double longitude = .0;
174 maps_coordinates_get_latitude_longitude(_center, &latitude, &longitude);
176 MAPS_LOGI("%c[%d;%d;%dm"
177 "Map State: center(%f,%f), zoom(%f), angle(%f)"
180 latitude, longitude, _zoom_factor, _rotation_angle,
183 /* ---------------------------------------------------------------------------*/
185 view::runtime_touch_info::runtime_touch_info()
186 : _fingers_pressed(0)
187 , _cur_gesture(MAPS_VIEW_GESTURE_NONE)
193 view::runtime_touch_info::~runtime_touch_info()
197 view::runtime_touch_info::runtime_touch_info(const runtime_touch_info &src)
202 view::runtime_touch_info &view::runtime_touch_info::operator=(const
207 _fingers_pressed = src._fingers_pressed;
208 _cur_gesture = src._cur_gesture;
209 /*_going = src._going;*/
210 _start_view_state = src._start_view_state;
212 for(unsigned int i = 0; i < MAX_FINGERS; i ++) {
213 _finger_down[i] = src._finger_down[i];
214 _finger_move[i] = src._finger_move[i];
215 _prev_finger_down[i] = src._prev_finger_down[i];
216 _finger_up[i] = src._finger_up[i];
217 _is_finger_pressed[i] = src._is_finger_pressed[i];
223 void view::runtime_touch_info::reset()
227 _fingers_pressed = 0;
229 for(unsigned int i = 0; i < MAX_FINGERS; i ++) {
230 _finger_down[i].reset();
231 _finger_move[i].reset();
232 _prev_finger_down[i].reset();
233 _finger_up[i].reset();
234 _is_finger_pressed[i] = false;
237 _cur_gesture = MAPS_VIEW_GESTURE_NONE;
239 _start_view_state.reset();
242 int view::runtime_touch_info::calc_finger_pressed()
245 for(unsigned int i = 0; i < MAX_FINGERS; i ++)
246 if(_is_finger_pressed[i])