32 |
#include <cairo.h> |
#include <cairo.h> |
33 |
|
|
34 |
#include "osm-gps-map.h" |
#include "osm-gps-map.h" |
35 |
|
#include "converter.h" |
36 |
#include "osm-gps-map-osd-classic.h" |
#include "osm-gps-map-osd-classic.h" |
37 |
|
|
38 |
//the osd controls |
//the osd controls |
39 |
typedef struct { |
typedef struct { |
40 |
/* the offscreen representation of the OSD */ |
/* the offscreen representation of the OSD */ |
41 |
cairo_surface_t *overlay; |
struct { |
42 |
|
cairo_surface_t *surface; |
43 |
|
gboolean rendered; |
44 |
|
#ifdef OSD_GPS_BUTTON |
45 |
|
gboolean gps_enabled; |
46 |
|
#endif |
47 |
|
} controls; |
48 |
|
|
49 |
/* values to handle the "source" menu */ |
#ifdef OSD_BALLOON |
50 |
cairo_surface_t *map_source; |
//a balloon with additional info |
51 |
gboolean expanded; |
struct { |
52 |
gint shift, dir, count; |
cairo_surface_t *surface; |
53 |
gint handler_id; |
int orientation, offset_x, offset_y; |
54 |
gint width, height; |
|
55 |
|
float lat, lon; |
56 |
|
OsmGpsMapRect_t rect; |
57 |
|
|
58 |
|
/* function called to have the user app draw the contents */ |
59 |
|
OsmGpsMapBalloonCallback cb; |
60 |
|
gpointer data; |
61 |
|
} balloon; |
62 |
|
#endif |
63 |
|
|
64 |
|
#ifdef OSD_SCALE |
65 |
|
struct { |
66 |
|
cairo_surface_t *surface; |
67 |
|
int zoom; |
68 |
|
} scale; |
69 |
|
#endif |
70 |
|
|
71 |
|
#ifdef OSD_CROSSHAIR |
72 |
|
struct { |
73 |
|
cairo_surface_t *surface; |
74 |
|
gboolean rendered; |
75 |
|
} crosshair; |
76 |
|
#endif |
77 |
|
|
78 |
|
#ifdef OSD_COORDINATES |
79 |
|
struct { |
80 |
|
cairo_surface_t *surface; |
81 |
|
float lat, lon; |
82 |
|
} coordinates; |
83 |
|
#endif |
84 |
|
|
85 |
|
#ifdef OSD_SOURCE_SEL |
86 |
|
struct { |
87 |
|
/* values to handle the "source" menu */ |
88 |
|
cairo_surface_t *surface; |
89 |
|
gboolean expanded; |
90 |
|
gint shift, dir, count; |
91 |
|
gint handler_id; |
92 |
|
gint width, height; |
93 |
|
gboolean rendered; |
94 |
|
} source_sel; |
95 |
|
#endif |
96 |
|
|
97 |
} osd_priv_t; |
} osd_priv_t; |
98 |
|
|
99 |
|
#ifdef OSD_BALLOON |
100 |
|
/* most visual effects are hardcoded by now, but may be made */ |
101 |
|
/* available via properties later */ |
102 |
|
#ifndef BALLOON_AREA_WIDTH |
103 |
|
#define BALLOON_AREA_WIDTH 290 |
104 |
|
#endif |
105 |
|
#ifndef BALLOON_AREA_HEIGHT |
106 |
|
#define BALLOON_AREA_HEIGHT 75 |
107 |
|
#endif |
108 |
|
#ifndef BALLOON_CORNER_RADIUS |
109 |
|
#define BALLOON_CORNER_RADIUS 10 |
110 |
|
#endif |
111 |
|
|
112 |
|
#define BALLOON_BORDER (BALLOON_CORNER_RADIUS/2) |
113 |
|
#define BALLOON_WIDTH (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER) |
114 |
|
#define BALLOON_HEIGHT (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER) |
115 |
|
#define BALLOON_TRANSPARENCY 0.8 |
116 |
|
#define POINTER_HEIGHT 20 |
117 |
|
#define POINTER_FOOT_WIDTH 20 |
118 |
|
#define POINTER_OFFSET (BALLOON_CORNER_RADIUS*3/4) |
119 |
|
#define BALLOON_SHADOW (BALLOON_CORNER_RADIUS/2) |
120 |
|
#define BALLOON_SHADOW_TRANSPARENCY 0.2 |
121 |
|
|
122 |
|
#define BALLOON_W (BALLOON_WIDTH + BALLOON_SHADOW) |
123 |
|
#define BALLOON_H (BALLOON_HEIGHT + POINTER_HEIGHT + BALLOON_SHADOW) |
124 |
|
|
125 |
|
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS) |
126 |
|
|
127 |
|
|
128 |
|
/* draw the bubble shape. this is used twice, once for the shape and once */ |
129 |
|
/* for the shadow */ |
130 |
|
static void |
131 |
|
osm_gps_map_draw_balloon_shape (cairo_t *cr, int x0, int y0, int x1, int y1, |
132 |
|
gboolean bottom, int px, int py, int px0, int px1) { |
133 |
|
|
134 |
|
cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS); |
135 |
|
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
136 |
|
BALLOON_CORNER_RADIUS, -M_PI, -M_PI/2); |
137 |
|
if(!bottom) { |
138 |
|
/* insert top pointer */ |
139 |
|
cairo_line_to (cr, px1, y0); |
140 |
|
cairo_line_to (cr, px, py); |
141 |
|
cairo_line_to (cr, px0, y0); |
142 |
|
} |
143 |
|
|
144 |
|
cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0); |
145 |
|
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
146 |
|
BALLOON_CORNER_RADIUS, -M_PI/2, 0); |
147 |
|
cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS); |
148 |
|
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
149 |
|
BALLOON_CORNER_RADIUS, 0, M_PI/2); |
150 |
|
if(bottom) { |
151 |
|
/* insert bottom pointer */ |
152 |
|
cairo_line_to (cr, px0, y1); |
153 |
|
cairo_line_to (cr, px, py); |
154 |
|
cairo_line_to (cr, px1, y1); |
155 |
|
} |
156 |
|
|
157 |
|
cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1); |
158 |
|
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
159 |
|
BALLOON_CORNER_RADIUS, M_PI/2, M_PI); |
160 |
|
|
161 |
|
cairo_close_path (cr); |
162 |
|
} |
163 |
|
|
164 |
|
static void |
165 |
|
osd_render_balloon(osm_gps_map_osd_t *osd) { |
166 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
167 |
|
|
168 |
|
/* get zoom */ |
169 |
|
gint zoom; |
170 |
|
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
171 |
|
|
172 |
|
/* ------- convert given coordinate into screen position --------- */ |
173 |
|
gint xs, ys; |
174 |
|
osm_gps_map_geographic_to_screen (OSM_GPS_MAP(osd->widget), |
175 |
|
priv->balloon.lat, priv->balloon.lon, |
176 |
|
&xs, &ys); |
177 |
|
|
178 |
|
gint x0 = 1, y0 = 1; |
179 |
|
|
180 |
|
/* check position of this relative to screen center to determine */ |
181 |
|
/* pointer direction ... */ |
182 |
|
int pointer_x, pointer_x0, pointer_x1; |
183 |
|
int pointer_y; |
184 |
|
|
185 |
|
/* ... and calculate position */ |
186 |
|
int orientation = 0; |
187 |
|
if(xs > osd->widget->allocation.width/2) { |
188 |
|
priv->balloon.offset_x = -BALLOON_WIDTH + POINTER_OFFSET; |
189 |
|
pointer_x = x0 - priv->balloon.offset_x; |
190 |
|
pointer_x0 = pointer_x - (BALLOON_CORNER_RADIUS - POINTER_OFFSET); |
191 |
|
pointer_x1 = pointer_x0 - POINTER_FOOT_WIDTH; |
192 |
|
orientation |= 1; |
193 |
|
} else { |
194 |
|
priv->balloon.offset_x = -POINTER_OFFSET; |
195 |
|
pointer_x = x0 - priv->balloon.offset_x; |
196 |
|
pointer_x1 = pointer_x + (BALLOON_CORNER_RADIUS - POINTER_OFFSET); |
197 |
|
pointer_x0 = pointer_x1 + POINTER_FOOT_WIDTH; |
198 |
|
} |
199 |
|
|
200 |
|
gboolean bottom = FALSE; |
201 |
|
if(ys > osd->widget->allocation.height/2) { |
202 |
|
priv->balloon.offset_y = -BALLOON_HEIGHT - POINTER_HEIGHT; |
203 |
|
pointer_y = y0 - priv->balloon.offset_y; |
204 |
|
bottom = TRUE; |
205 |
|
orientation |= 2; |
206 |
|
} else { |
207 |
|
priv->balloon.offset_y = 0; |
208 |
|
pointer_y = y0 - priv->balloon.offset_y; |
209 |
|
y0 += POINTER_HEIGHT; |
210 |
|
} |
211 |
|
|
212 |
|
/* if required orientation equals current one, then don't render */ |
213 |
|
/* anything */ |
214 |
|
if(orientation == priv->balloon.orientation) |
215 |
|
return; |
216 |
|
|
217 |
|
priv->balloon.orientation = orientation; |
218 |
|
|
219 |
|
/* calculate bottom/right of box */ |
220 |
|
int x1 = x0 + BALLOON_WIDTH, y1 = y0 + BALLOON_HEIGHT; |
221 |
|
|
222 |
|
/* save balloon screen coordinates for later use */ |
223 |
|
priv->balloon.rect.x = x0 + BALLOON_BORDER; |
224 |
|
priv->balloon.rect.y = y0 + BALLOON_BORDER; |
225 |
|
priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER; |
226 |
|
priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER; |
227 |
|
|
228 |
|
cairo_t *cr = cairo_create(priv->balloon.surface); |
229 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
230 |
|
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
231 |
|
cairo_paint(cr); |
232 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
233 |
|
|
234 |
|
/* --------- draw shadow --------------- */ |
235 |
|
osm_gps_map_draw_balloon_shape (cr, |
236 |
|
x0 + BALLOON_SHADOW, y0 + BALLOON_SHADOW, |
237 |
|
x1 + BALLOON_SHADOW, y1 + BALLOON_SHADOW, |
238 |
|
bottom, pointer_x, pointer_y, |
239 |
|
pointer_x0 + BALLOON_SHADOW, pointer_x1 + BALLOON_SHADOW); |
240 |
|
|
241 |
|
cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_SHADOW_TRANSPARENCY); |
242 |
|
cairo_fill_preserve (cr); |
243 |
|
cairo_set_source_rgba (cr, 1, 0, 0, 1.0); |
244 |
|
cairo_set_line_width (cr, 0); |
245 |
|
cairo_stroke (cr); |
246 |
|
|
247 |
|
/* --------- draw main shape ----------- */ |
248 |
|
osm_gps_map_draw_balloon_shape (cr, x0, y0, x1, y1, |
249 |
|
bottom, pointer_x, pointer_y, pointer_x0, pointer_x1); |
250 |
|
|
251 |
|
cairo_set_source_rgba (cr, 1, 1, 1, BALLOON_TRANSPARENCY); |
252 |
|
cairo_fill_preserve (cr); |
253 |
|
cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_TRANSPARENCY); |
254 |
|
cairo_set_line_width (cr, 1); |
255 |
|
cairo_stroke (cr); |
256 |
|
|
257 |
|
if (priv->balloon.cb) { |
258 |
|
/* clip in case application tries to draw in */ |
259 |
|
/* exceed of the balloon */ |
260 |
|
cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y, |
261 |
|
priv->balloon.rect.w, priv->balloon.rect.h); |
262 |
|
cairo_clip (cr); |
263 |
|
cairo_new_path (cr); /* current path is not |
264 |
|
consumed by cairo_clip() */ |
265 |
|
|
266 |
|
priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data); |
267 |
|
} |
268 |
|
|
269 |
|
cairo_destroy(cr); |
270 |
|
} |
271 |
|
|
272 |
|
/* return true if balloon is being displayed and if */ |
273 |
|
/* the given coordinate is within this balloon */ |
274 |
|
static gboolean |
275 |
|
osd_balloon_check(osm_gps_map_osd_t *osd, gint x, gint y) |
276 |
|
{ |
277 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
278 |
|
|
279 |
|
if(!priv->balloon.surface) |
280 |
|
return FALSE; |
281 |
|
|
282 |
|
gint xs, ys; |
283 |
|
osm_gps_map_geographic_to_screen (OSM_GPS_MAP(osd->widget), |
284 |
|
priv->balloon.lat, priv->balloon.lon, |
285 |
|
&xs, &ys); |
286 |
|
|
287 |
|
xs += priv->balloon.rect.x + priv->balloon.offset_x; |
288 |
|
ys += priv->balloon.rect.y + priv->balloon.offset_y; |
289 |
|
|
290 |
|
return (priv->balloon.surface && |
291 |
|
(x > xs) && (x < xs + priv->balloon.rect.w) && |
292 |
|
(y > ys) && (y < ys + priv->balloon.rect.h)); |
293 |
|
} |
294 |
|
|
295 |
|
void osm_gps_map_osd_clear_balloon (OsmGpsMap *map) { |
296 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
297 |
|
|
298 |
|
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
299 |
|
g_return_if_fail (osd); |
300 |
|
|
301 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
302 |
|
g_return_if_fail (priv); |
303 |
|
|
304 |
|
printf("request to clear balloon\n"); |
305 |
|
|
306 |
|
if(priv->balloon.surface) { |
307 |
|
cairo_surface_destroy(priv->balloon.surface); |
308 |
|
priv->balloon.surface = NULL; |
309 |
|
priv->balloon.lat = OSM_GPS_MAP_INVALID; |
310 |
|
priv->balloon.lon = OSM_GPS_MAP_INVALID; |
311 |
|
} |
312 |
|
osm_gps_map_redraw(map); |
313 |
|
} |
314 |
|
|
315 |
|
void |
316 |
|
osm_gps_map_osd_draw_balloon (OsmGpsMap *map, float latitude, float longitude, |
317 |
|
OsmGpsMapBalloonCallback cb, gpointer data) { |
318 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
319 |
|
|
320 |
|
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
321 |
|
g_return_if_fail (osd); |
322 |
|
|
323 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
324 |
|
g_return_if_fail (priv); |
325 |
|
|
326 |
|
osm_gps_map_osd_clear_balloon (map); |
327 |
|
|
328 |
|
printf("request to draw balloon at %f %f\n", latitude, longitude); |
329 |
|
|
330 |
|
/* allocate balloon surface */ |
331 |
|
priv->balloon.surface = |
332 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
333 |
|
BALLOON_W+2, BALLOON_H+2); |
334 |
|
|
335 |
|
priv->balloon.lat = latitude; |
336 |
|
priv->balloon.lon = longitude; |
337 |
|
priv->balloon.cb = cb; |
338 |
|
priv->balloon.data = data; |
339 |
|
|
340 |
|
priv->balloon.orientation = -1; |
341 |
|
|
342 |
|
osd_render_balloon(osd); |
343 |
|
|
344 |
|
osm_gps_map_redraw(map); |
345 |
|
} |
346 |
|
|
347 |
|
#endif // OSD_BALLOON |
348 |
|
|
349 |
/* position and extent of bounding box */ |
/* position and extent of bounding box */ |
350 |
#ifndef OSD_X |
#ifndef OSD_X |
351 |
#define OSD_X (10) |
#define OSD_X (10) |
556 |
return OSD_NONE; |
return OSD_NONE; |
557 |
} |
} |
558 |
|
|
559 |
|
#ifdef OSD_SOURCE_SEL |
560 |
|
|
561 |
/* place source selection at right border */ |
/* place source selection at right border */ |
562 |
#define OSD_S_RAD (Z_RAD) |
#define OSD_S_RAD (Z_RAD) |
563 |
#define OSD_S_X (-OSD_X) |
#define OSD_S_X (-OSD_X) |
568 |
#define OSD_S_H (OSD_S_PH + OSD_SHADOW) |
#define OSD_S_H (OSD_S_PH + OSD_SHADOW) |
569 |
|
|
570 |
/* size of usable area when expanded */ |
/* size of usable area when expanded */ |
571 |
#define OSD_S_AREA_W (priv->width) |
#define OSD_S_AREA_W (priv->source_sel.width) |
572 |
#define OSD_S_AREA_H (priv->height) |
#define OSD_S_AREA_H (priv->source_sel.height) |
573 |
#define OSD_S_EXP_W (OSD_S_PW + OSD_S_AREA_W + OSD_SHADOW) |
#define OSD_S_EXP_W (OSD_S_PW + OSD_S_AREA_W + OSD_SHADOW) |
574 |
#define OSD_S_EXP_H (OSD_S_AREA_H + OSD_SHADOW) |
#define OSD_S_EXP_H (OSD_S_AREA_H + OSD_SHADOW) |
575 |
|
|
581 |
#define OSD_TEXT_BORDER (OSD_FONT_SIZE/2) |
#define OSD_TEXT_BORDER (OSD_FONT_SIZE/2) |
582 |
#define OSD_TEXT_SKIP (OSD_FONT_SIZE/8) |
#define OSD_TEXT_SKIP (OSD_FONT_SIZE/8) |
583 |
|
|
584 |
|
/* draw the shape of the source selection OSD, either only the puller (not expanded) */ |
585 |
|
/* or the entire menu incl. the puller (expanded) */ |
586 |
static void |
static void |
587 |
osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) { |
osd_source_shape(osd_priv_t *priv, cairo_t *cr, gint x, gint y) { |
588 |
if(!priv->expanded) { |
if(!priv->source_sel.expanded) { |
589 |
/* just draw the puller */ |
/* just draw the puller */ |
590 |
cairo_move_to (cr, x + OSD_S_PW, y + OSD_S_PH); |
cairo_move_to (cr, x + OSD_S_PW, y + OSD_S_PH); |
591 |
cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2); |
cairo_arc (cr, x+OSD_S_RAD, y+OSD_S_RAD, OSD_S_RAD, M_PI/2, -M_PI/2); |
613 |
|
|
614 |
int py = offset + OSD_S_RAD - OSD_S_D0; |
int py = offset + OSD_S_RAD - OSD_S_D0; |
615 |
|
|
616 |
if(!priv->expanded) { |
if(!priv->source_sel.expanded) { |
617 |
/* draw the "puller" open (<) arrow */ |
/* draw the "puller" open (<) arrow */ |
618 |
cairo_move_to (cr, offset + OSD_S_RAD + OSD_S_D0/2, py); |
cairo_move_to (cr, offset + OSD_S_RAD + OSD_S_D0/2, py); |
619 |
cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0); |
cairo_rel_line_to (cr, -OSD_S_D0, +OSD_S_D0); |
638 |
CAIRO_FONT_WEIGHT_BOLD); |
CAIRO_FONT_WEIGHT_BOLD); |
639 |
cairo_set_font_size (cr, OSD_FONT_SIZE); |
cairo_set_font_size (cr, OSD_FONT_SIZE); |
640 |
|
|
641 |
int i, step = (priv->height - 2*OSD_TEXT_BORDER) |
int i, step = (priv->source_sel.height - 2*OSD_TEXT_BORDER) / |
642 |
/ OSM_GPS_MAP_SOURCE_LAST; |
OSM_GPS_MAP_SOURCE_LAST; |
643 |
for(i=OSM_GPS_MAP_SOURCE_NULL+1;i<=OSM_GPS_MAP_SOURCE_LAST;i++) { |
for(i=OSM_GPS_MAP_SOURCE_NULL+1;i<=OSM_GPS_MAP_SOURCE_LAST;i++) { |
644 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
645 |
const char *src = osm_gps_map_source_get_friendly_name(i); |
const char *src = osm_gps_map_source_get_friendly_name(i); |
652 |
if(source == i) { |
if(source == i) { |
653 |
cairo_rectangle(cr, x - OSD_TEXT_BORDER/2, |
cairo_rectangle(cr, x - OSD_TEXT_BORDER/2, |
654 |
y - OSD_TEXT_SKIP, |
y - OSD_TEXT_SKIP, |
655 |
priv->width - OSD_TEXT_BORDER, |
priv->source_sel.width - OSD_TEXT_BORDER, |
656 |
step + OSD_TEXT_SKIP); |
step + OSD_TEXT_SKIP); |
657 |
cairo_fill(cr); |
cairo_fill(cr); |
658 |
|
|
683 |
} |
} |
684 |
|
|
685 |
static void |
static void |
686 |
osd_render_source_sel(osm_gps_map_osd_t *osd) { |
osd_render_source_sel(osm_gps_map_osd_t *osd, gboolean force_rerender) { |
687 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
688 |
|
|
689 |
|
if(priv->source_sel.rendered && !force_rerender) |
690 |
|
return; |
691 |
|
|
692 |
|
priv->source_sel.rendered = TRUE; |
693 |
|
|
694 |
#ifndef OSD_COLOR |
#ifndef OSD_COLOR |
695 |
GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL]; |
GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL]; |
696 |
GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL]; |
GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL]; |
698 |
#endif |
#endif |
699 |
|
|
700 |
/* draw source selector */ |
/* draw source selector */ |
701 |
cairo_t *cr = cairo_create(priv->map_source); |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
702 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
703 |
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
704 |
cairo_paint(cr); |
cairo_paint(cr); |
732 |
cairo_destroy(cr); |
cairo_destroy(cr); |
733 |
} |
} |
734 |
|
|
735 |
|
/* re-allocate the buffer used to draw the menu. This is used */ |
736 |
|
/* to collapse/expand the buffer */ |
737 |
static void |
static void |
738 |
osd_source_reallocate(osm_gps_map_osd_t *osd) { |
osd_source_reallocate(osm_gps_map_osd_t *osd) { |
739 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
740 |
|
|
741 |
/* re-allocate offscreen bitmap */ |
/* re-allocate offscreen bitmap */ |
742 |
g_assert (priv->map_source); |
g_assert (priv->source_sel.surface); |
743 |
|
|
744 |
int w = OSD_S_W, h = OSD_S_H; |
int w = OSD_S_W, h = OSD_S_H; |
745 |
if(priv->expanded) { |
if(priv->source_sel.expanded) { |
|
/* ... and right of it the waypoint id */ |
|
746 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
747 |
|
|
748 |
/* determine content size */ |
/* determine content size */ |
749 |
cairo_t *cr = cairo_create(priv->map_source); |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
750 |
cairo_select_font_face (cr, "Sans", |
cairo_select_font_face (cr, "Sans", |
751 |
CAIRO_FONT_SLANT_NORMAL, |
CAIRO_FONT_SLANT_NORMAL, |
752 |
CAIRO_FONT_WEIGHT_BOLD); |
CAIRO_FONT_WEIGHT_BOLD); |
758 |
const char *src = osm_gps_map_source_get_friendly_name(i); |
const char *src = osm_gps_map_source_get_friendly_name(i); |
759 |
cairo_text_extents (cr, src, &extents); |
cairo_text_extents (cr, src, &extents); |
760 |
|
|
|
// printf("Source %d: %s = %f %f\n", i, src, |
|
|
// extents.width, extents.height); |
|
|
|
|
761 |
if(extents.width > max_w) max_w = extents.width; |
if(extents.width > max_w) max_w = extents.width; |
762 |
if(extents.height > max_h) max_h = extents.height; |
if(extents.height > max_h) max_h = extents.height; |
763 |
} |
} |
764 |
cairo_destroy(cr); |
cairo_destroy(cr); |
765 |
|
|
766 |
priv->width = max_w + 2*OSD_TEXT_BORDER; |
priv->source_sel.width = max_w + 2*OSD_TEXT_BORDER; |
767 |
priv->height = OSM_GPS_MAP_SOURCE_LAST * |
priv->source_sel.height = OSM_GPS_MAP_SOURCE_LAST * |
768 |
(max_h + 2*OSD_TEXT_SKIP) + 2*OSD_TEXT_BORDER; |
(max_h + 2*OSD_TEXT_SKIP) + 2*OSD_TEXT_BORDER; |
769 |
|
|
770 |
w = OSD_S_EXP_W; |
w = OSD_S_EXP_W; |
771 |
h = OSD_S_EXP_H; |
h = OSD_S_EXP_H; |
772 |
} |
} |
773 |
|
|
774 |
cairo_surface_destroy(priv->map_source); |
cairo_surface_destroy(priv->source_sel.surface); |
775 |
priv->map_source = |
priv->source_sel.surface = |
776 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w+2, h+2); |
777 |
|
|
778 |
osd_render_source_sel(osd); |
osd_render_source_sel(osd, TRUE); |
|
|
|
779 |
} |
} |
780 |
|
|
781 |
#define OSD_HZ 15 |
#define OSD_HZ 15 |
786 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
787 |
int diff = OSD_S_EXP_W - OSD_S_W - OSD_S_X; |
int diff = OSD_S_EXP_W - OSD_S_W - OSD_S_X; |
788 |
gboolean done = FALSE; |
gboolean done = FALSE; |
789 |
priv->count += priv->dir; |
priv->source_sel.count += priv->source_sel.dir; |
790 |
|
|
791 |
/* shifting in */ |
/* shifting in */ |
792 |
if(priv->dir < 0) { |
if(priv->source_sel.dir < 0) { |
793 |
if(priv->count <= 0) { |
if(priv->source_sel.count <= 0) { |
794 |
priv->count = 0; |
priv->source_sel.count = 0; |
795 |
done = TRUE; |
done = TRUE; |
796 |
} |
} |
797 |
} else { |
} else { |
798 |
if(priv->count >= 1000) { |
if(priv->source_sel.count >= 1000) { |
799 |
priv->expanded = FALSE; |
priv->source_sel.expanded = FALSE; |
800 |
osd_source_reallocate(osd); |
osd_source_reallocate(osd); |
801 |
|
|
802 |
priv->count = 1000; |
priv->source_sel.count = 1000; |
803 |
done = TRUE; |
done = TRUE; |
804 |
} |
} |
805 |
} |
} |
807 |
|
|
808 |
/* count runs linearly from 0 to 1000, map this nicely onto a position */ |
/* count runs linearly from 0 to 1000, map this nicely onto a position */ |
809 |
|
|
810 |
/* simple linear mapping */ |
/* nice sinoid mapping */ |
811 |
// priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + |
float m = 0.5-cos(priv->source_sel.count * M_PI / 1000.0)/2; |
812 |
// (diff * priv->count)/1000; |
priv->source_sel.shift = |
813 |
|
(osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + |
|
/* nicer sinoid mapping */ |
|
|
float m = 0.5-cos(priv->count * M_PI / 1000.0)/2; |
|
|
priv->shift = (osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X) + |
|
814 |
m * diff; |
m * diff; |
815 |
|
|
816 |
|
/* make sure the screen is updated */ |
817 |
osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); |
osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); |
818 |
|
|
819 |
|
/* stop animation if done */ |
820 |
if(done) |
if(done) |
821 |
priv->handler_id = 0; |
priv->source_sel.handler_id = 0; |
822 |
|
|
823 |
return !done; |
return !done; |
824 |
} |
} |
830 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
831 |
|
|
832 |
/* ignore clicks while animation is running */ |
/* ignore clicks while animation is running */ |
833 |
if(priv->handler_id) |
if(priv->source_sel.handler_id) |
834 |
return; |
return; |
835 |
|
|
836 |
/* expand immediately, collapse is handle at the end of the collapse animation */ |
/* expand immediately, collapse is handle at the end of the */ |
837 |
if(!priv->expanded) { |
/* collapse animation */ |
838 |
priv->expanded = TRUE; |
if(!priv->source_sel.expanded) { |
839 |
|
priv->source_sel.expanded = TRUE; |
840 |
osd_source_reallocate(osd); |
osd_source_reallocate(osd); |
841 |
|
|
842 |
priv->count = 1000; |
priv->source_sel.count = 1000; |
843 |
priv->shift = osd->widget->allocation.width - OSD_S_W; |
priv->source_sel.shift = osd->widget->allocation.width - OSD_S_W; |
844 |
priv->dir = -1000/OSD_HZ; |
priv->source_sel.dir = -1000/OSD_HZ; |
845 |
} else { |
} else { |
846 |
priv->count = 0; |
priv->source_sel.count = 0; |
847 |
priv->shift = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
priv->source_sel.shift = osd->widget->allocation.width - |
848 |
priv->dir = +1000/OSD_HZ; |
OSD_S_EXP_W + OSD_S_X; |
849 |
|
priv->source_sel.dir = +1000/OSD_HZ; |
850 |
} |
} |
851 |
|
|
852 |
priv->handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, osd_source_animate, osd); |
/* start timer to handle animation */ |
853 |
|
priv->source_sel.handler_id = gtk_timeout_add(OSD_TIME/OSD_HZ, |
854 |
|
osd_source_animate, osd); |
855 |
} |
} |
856 |
|
|
857 |
|
/* check if the user clicked inside the source selection area */ |
858 |
static osd_button_t |
static osd_button_t |
859 |
osd_source_check(osm_gps_map_osd_t *osd, gint x, gint y) { |
osd_source_check(osm_gps_map_osd_t *osd, gint x, gint y) { |
860 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
861 |
|
|
862 |
if(!priv->expanded) |
if(!priv->source_sel.expanded) |
863 |
x -= osd->widget->allocation.width - OSD_S_W; |
x -= osd->widget->allocation.width - OSD_S_W; |
864 |
else |
else |
865 |
x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
x -= osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
881 |
return OSD_BG; |
return OSD_BG; |
882 |
} |
} |
883 |
} |
} |
884 |
|
|
885 |
|
/* check for clicks into data area */ |
886 |
|
if(priv->source_sel.expanded && !priv->source_sel.handler_id) { |
887 |
|
/* re-adjust from puller top to content top */ |
888 |
|
if(OSD_S_Y < 0) |
889 |
|
y += OSD_S_EXP_H - OSD_S_PH; |
890 |
|
|
891 |
|
if(x > OSD_S_PW && |
892 |
|
x < OSD_S_PW + OSD_S_EXP_W && |
893 |
|
y > 0 && |
894 |
|
y < OSD_S_EXP_H) { |
895 |
|
|
896 |
|
int step = (priv->source_sel.height - 2*OSD_TEXT_BORDER) |
897 |
|
/ OSM_GPS_MAP_SOURCE_LAST; |
898 |
|
|
899 |
|
y -= OSD_TEXT_BORDER - OSD_TEXT_SKIP; |
900 |
|
y /= step; |
901 |
|
y += 1; |
902 |
|
|
903 |
|
gint old = 0; |
904 |
|
g_object_get(osd->widget, "map-source", &old, NULL); |
905 |
|
|
906 |
|
if(y > OSM_GPS_MAP_SOURCE_NULL && |
907 |
|
y <= OSM_GPS_MAP_SOURCE_LAST && |
908 |
|
old != y) { |
909 |
|
g_object_set(osd->widget, "map-source", y, NULL); |
910 |
|
|
911 |
|
osd_render_source_sel(osd, TRUE); |
912 |
|
osm_gps_map_repaint(OSM_GPS_MAP(osd->widget)); |
913 |
|
} |
914 |
|
|
915 |
|
/* return "clicked in OSD background" to prevent further */ |
916 |
|
/* processing by application */ |
917 |
|
return OSD_BG; |
918 |
|
} |
919 |
|
} |
920 |
|
|
921 |
return OSD_NONE; |
return OSD_NONE; |
922 |
} |
} |
923 |
|
#endif // OSD_SOURCE_SEL |
924 |
|
|
925 |
static osd_button_t |
static osd_button_t |
926 |
osd_check(osm_gps_map_osd_t *osd, gint x, gint y) { |
osd_check(osm_gps_map_osd_t *osd, gint x, gint y) { |
927 |
osd_button_t but = OSD_NONE; |
osd_button_t but = OSD_NONE; |
928 |
|
|
929 |
|
#ifdef OSD_BALLOON |
930 |
|
/* check if user clicked into balloon */ |
931 |
|
if(osd_balloon_check(osd, x, y)) |
932 |
|
return OSD_BG; |
933 |
|
#endif |
934 |
|
|
935 |
#ifdef OSD_SOURCE_SEL |
#ifdef OSD_SOURCE_SEL |
936 |
/* the source selection area is handles internally */ |
/* the source selection area is handles internally */ |
937 |
but = osd_source_check(osd, x, y); |
but = osd_source_check(osd, x, y); |
1032 |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
1033 |
} |
} |
1034 |
|
|
1035 |
|
#ifdef OSD_COORDINATES |
1036 |
|
|
1037 |
|
#ifndef OSD_COORDINATES_FONT_SIZE |
1038 |
|
#define OSD_COORDINATES_FONT_SIZE 12 |
1039 |
|
#endif |
1040 |
|
|
1041 |
|
#define OSD_COORDINATES_OFFSET (OSD_COORDINATES_FONT_SIZE/6) |
1042 |
|
|
1043 |
|
#define OSD_COORDINATES_W (8*OSD_COORDINATES_FONT_SIZE+2*OSD_COORDINATES_OFFSET) |
1044 |
|
#define OSD_COORDINATES_H (2*OSD_COORDINATES_FONT_SIZE+OSD_COORDINATES_OFFSET) |
1045 |
|
|
1046 |
|
/* these can be overwritten with versions that support */ |
1047 |
|
/* localization */ |
1048 |
|
#ifndef OSD_COORDINATES_CHR_N |
1049 |
|
#define OSD_COORDINATES_CHR_N "N" |
1050 |
|
#endif |
1051 |
|
#ifndef OSD_COORDINATES_CHR_S |
1052 |
|
#define OSD_COORDINATES_CHR_S "S" |
1053 |
|
#endif |
1054 |
|
#ifndef OSD_COORDINATES_CHR_E |
1055 |
|
#define OSD_COORDINATES_CHR_E "E" |
1056 |
|
#endif |
1057 |
|
#ifndef OSD_COORDINATES_CHR_W |
1058 |
|
#define OSD_COORDINATES_CHR_W "W" |
1059 |
|
#endif |
1060 |
|
|
1061 |
|
|
1062 |
|
|
1063 |
|
/* this is the classic geocaching notation */ |
1064 |
|
static char |
1065 |
|
*osd_latitude_str(float latitude) { |
1066 |
|
char *c = OSD_COORDINATES_CHR_N; |
1067 |
|
float integral, fractional; |
1068 |
|
|
1069 |
|
if(isnan(latitude)) |
1070 |
|
return NULL; |
1071 |
|
|
1072 |
|
if(latitude < 0) { |
1073 |
|
latitude = fabs(latitude); |
1074 |
|
c = OSD_COORDINATES_CHR_S; |
1075 |
|
} |
1076 |
|
|
1077 |
|
fractional = modff(latitude, &integral); |
1078 |
|
|
1079 |
|
return g_strdup_printf("%s %02d° %06.3f'", |
1080 |
|
c, (int)integral, fractional*60.0); |
1081 |
|
} |
1082 |
|
|
1083 |
|
static char |
1084 |
|
*osd_longitude_str(float longitude) { |
1085 |
|
char *c = OSD_COORDINATES_CHR_E; |
1086 |
|
float integral, fractional; |
1087 |
|
|
1088 |
|
if(isnan(longitude)) |
1089 |
|
return NULL; |
1090 |
|
|
1091 |
|
if(longitude < 0) { |
1092 |
|
longitude = fabs(longitude); |
1093 |
|
c = OSD_COORDINATES_CHR_W; |
1094 |
|
} |
1095 |
|
|
1096 |
|
fractional = modff(longitude, &integral); |
1097 |
|
|
1098 |
|
return g_strdup_printf("%s %03d° %06.3f'", |
1099 |
|
c, (int)integral, fractional*60.0); |
1100 |
|
} |
1101 |
|
|
1102 |
|
static void |
1103 |
|
osd_render_coordinates(osm_gps_map_osd_t *osd) |
1104 |
|
{ |
1105 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1106 |
|
|
1107 |
|
/* get current map position */ |
1108 |
|
gfloat lat, lon; |
1109 |
|
g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL); |
1110 |
|
|
1111 |
|
/* check if position has changed enough to require redraw */ |
1112 |
|
if(!isnan(priv->coordinates.lat) && !isnan(priv->coordinates.lon)) |
1113 |
|
/* 1/60000 == 1/1000 minute */ |
1114 |
|
if((fabsf(lat - priv->coordinates.lat) < 1/60000) && |
1115 |
|
(fabsf(lon - priv->coordinates.lon) < 1/60000)) |
1116 |
|
return; |
1117 |
|
|
1118 |
|
priv->coordinates.lat = lat; |
1119 |
|
priv->coordinates.lon = lon; |
1120 |
|
|
1121 |
|
/* first fill with transparency */ |
1122 |
|
cairo_t *cr = cairo_create(priv->coordinates.surface); |
1123 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1124 |
|
// cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5); |
1125 |
|
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
1126 |
|
cairo_paint(cr); |
1127 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1128 |
|
|
1129 |
|
cairo_select_font_face (cr, "Sans", |
1130 |
|
CAIRO_FONT_SLANT_NORMAL, |
1131 |
|
CAIRO_FONT_WEIGHT_BOLD); |
1132 |
|
cairo_set_font_size (cr, OSD_COORDINATES_FONT_SIZE); |
1133 |
|
|
1134 |
|
char *latitude = osd_latitude_str(lat); |
1135 |
|
char *longitude = osd_longitude_str(lon); |
1136 |
|
|
1137 |
|
cairo_text_extents_t lat_extents, lon_extents; |
1138 |
|
cairo_text_extents (cr, latitude, &lat_extents); |
1139 |
|
cairo_text_extents (cr, longitude, &lon_extents); |
1140 |
|
|
1141 |
|
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |
1142 |
|
cairo_set_line_width (cr, OSD_COORDINATES_FONT_SIZE/6); |
1143 |
|
cairo_move_to (cr, |
1144 |
|
(OSD_COORDINATES_W - lat_extents.width)/2, |
1145 |
|
OSD_COORDINATES_OFFSET - lat_extents.y_bearing); |
1146 |
|
cairo_text_path (cr, latitude); |
1147 |
|
cairo_move_to (cr, |
1148 |
|
(OSD_COORDINATES_W - lon_extents.width)/2, |
1149 |
|
OSD_COORDINATES_OFFSET - lon_extents.y_bearing + |
1150 |
|
OSD_COORDINATES_FONT_SIZE); |
1151 |
|
cairo_text_path (cr, longitude); |
1152 |
|
cairo_stroke (cr); |
1153 |
|
|
1154 |
|
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); |
1155 |
|
cairo_move_to (cr, |
1156 |
|
(OSD_COORDINATES_W - lat_extents.width)/2, |
1157 |
|
OSD_COORDINATES_OFFSET - lat_extents.y_bearing); |
1158 |
|
cairo_show_text (cr, latitude); |
1159 |
|
cairo_move_to (cr, |
1160 |
|
(OSD_COORDINATES_W - lon_extents.width)/2, |
1161 |
|
OSD_COORDINATES_OFFSET - lon_extents.y_bearing + |
1162 |
|
OSD_COORDINATES_FONT_SIZE); |
1163 |
|
cairo_show_text (cr, longitude); |
1164 |
|
|
1165 |
|
g_free(latitude); |
1166 |
|
g_free(longitude); |
1167 |
|
|
1168 |
|
cairo_destroy(cr); |
1169 |
|
} |
1170 |
|
#endif // OSD_COORDINATES |
1171 |
|
|
1172 |
|
#ifdef OSD_CROSSHAIR |
1173 |
|
|
1174 |
|
#ifndef OSD_CROSSHAIR_RADIUS |
1175 |
|
#define OSD_CROSSHAIR_RADIUS 10 |
1176 |
|
#endif |
1177 |
|
|
1178 |
|
#define OSD_CROSSHAIR_TICK (OSD_CROSSHAIR_RADIUS/2) |
1179 |
|
#define OSD_CROSSHAIR_BORDER (OSD_CROSSHAIR_TICK + OSD_CROSSHAIR_RADIUS/4) |
1180 |
|
#define OSD_CROSSHAIR_W ((OSD_CROSSHAIR_RADIUS+OSD_CROSSHAIR_BORDER)*2) |
1181 |
|
#define OSD_CROSSHAIR_H ((OSD_CROSSHAIR_RADIUS+OSD_CROSSHAIR_BORDER)*2) |
1182 |
|
|
1183 |
|
static void |
1184 |
|
osd_render_crosshair_shape(cairo_t *cr) { |
1185 |
|
cairo_arc (cr, OSD_CROSSHAIR_W/2, OSD_CROSSHAIR_H/2, |
1186 |
|
OSD_CROSSHAIR_RADIUS, 0, 2*M_PI); |
1187 |
|
|
1188 |
|
cairo_move_to (cr, OSD_CROSSHAIR_W/2 - OSD_CROSSHAIR_RADIUS, |
1189 |
|
OSD_CROSSHAIR_H/2); |
1190 |
|
cairo_rel_line_to (cr, -OSD_CROSSHAIR_TICK, 0); |
1191 |
|
cairo_move_to (cr, OSD_CROSSHAIR_W/2 + OSD_CROSSHAIR_RADIUS, |
1192 |
|
OSD_CROSSHAIR_H/2); |
1193 |
|
cairo_rel_line_to (cr, OSD_CROSSHAIR_TICK, 0); |
1194 |
|
|
1195 |
|
cairo_move_to (cr, OSD_CROSSHAIR_W/2, |
1196 |
|
OSD_CROSSHAIR_H/2 - OSD_CROSSHAIR_RADIUS); |
1197 |
|
cairo_rel_line_to (cr, 0, -OSD_CROSSHAIR_TICK); |
1198 |
|
cairo_move_to (cr, OSD_CROSSHAIR_W/2, |
1199 |
|
OSD_CROSSHAIR_H/2 + OSD_CROSSHAIR_RADIUS); |
1200 |
|
cairo_rel_line_to (cr, 0, OSD_CROSSHAIR_TICK); |
1201 |
|
|
1202 |
|
cairo_stroke (cr); |
1203 |
|
} |
1204 |
|
|
1205 |
static void |
static void |
1206 |
osd_render(osm_gps_map_osd_t *osd) { |
osd_render_crosshair(osm_gps_map_osd_t *osd) |
1207 |
|
{ |
1208 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1209 |
|
|
1210 |
|
if(priv->crosshair.rendered) |
1211 |
|
return; |
1212 |
|
|
1213 |
|
priv->crosshair.rendered = TRUE; |
1214 |
|
|
1215 |
|
/* first fill with transparency */ |
1216 |
|
cairo_t *cr = cairo_create(priv->crosshair.surface); |
1217 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1218 |
|
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
1219 |
|
cairo_paint(cr); |
1220 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1221 |
|
|
1222 |
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
1223 |
|
|
1224 |
|
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.5); |
1225 |
|
cairo_set_line_width (cr, OSD_CROSSHAIR_RADIUS/2); |
1226 |
|
osd_render_crosshair_shape(cr); |
1227 |
|
|
1228 |
|
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5); |
1229 |
|
cairo_set_line_width (cr, OSD_CROSSHAIR_RADIUS/4); |
1230 |
|
osd_render_crosshair_shape(cr); |
1231 |
|
|
1232 |
|
cairo_destroy(cr); |
1233 |
|
} |
1234 |
|
#endif |
1235 |
|
|
1236 |
|
#ifdef OSD_SCALE |
1237 |
|
|
1238 |
|
#ifndef OSD_SCALE_FONT_SIZE |
1239 |
|
#define OSD_SCALE_FONT_SIZE 12 |
1240 |
|
#endif |
1241 |
|
#define OSD_SCALE_W (10*OSD_SCALE_FONT_SIZE) |
1242 |
|
#define OSD_SCALE_H (5*OSD_SCALE_FONT_SIZE/2) |
1243 |
|
|
1244 |
|
/* various parameters used to create the scale */ |
1245 |
|
#define OSD_SCALE_H2 (OSD_SCALE_H/2) |
1246 |
|
#define OSD_SCALE_TICK (2*OSD_SCALE_FONT_SIZE/3) |
1247 |
|
#define OSD_SCALE_M (OSD_SCALE_H2 - OSD_SCALE_TICK) |
1248 |
|
#define OSD_SCALE_I (OSD_SCALE_H2 + OSD_SCALE_TICK) |
1249 |
|
#define OSD_SCALE_FD (OSD_SCALE_FONT_SIZE/4) |
1250 |
|
|
1251 |
|
static void |
1252 |
|
osd_render_scale(osm_gps_map_osd_t *osd) |
1253 |
|
{ |
1254 |
|
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1255 |
|
|
1256 |
|
/* this only needs to be rendered if the zoom has changed */ |
1257 |
|
gint zoom; |
1258 |
|
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
1259 |
|
if(zoom == priv->scale.zoom) |
1260 |
|
return; |
1261 |
|
|
1262 |
|
priv->scale.zoom = zoom; |
1263 |
|
|
1264 |
|
float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget)); |
1265 |
|
|
1266 |
|
/* first fill with transparency */ |
1267 |
|
cairo_t *cr = cairo_create(priv->scale.surface); |
1268 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1269 |
|
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
1270 |
|
// pink for testing: cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.2); |
1271 |
|
cairo_paint(cr); |
1272 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_OVER); |
1273 |
|
|
1274 |
|
/* determine the size of the scale width in meters */ |
1275 |
|
float width = (OSD_SCALE_W-OSD_SCALE_FONT_SIZE/6) * m_per_pix; |
1276 |
|
|
1277 |
|
/* scale this to useful values */ |
1278 |
|
int exp = logf(width)*M_LOG10E; |
1279 |
|
int mant = width/pow(10,exp); |
1280 |
|
int width_metric = mant * pow(10,exp); |
1281 |
|
char *dist_str = NULL; |
1282 |
|
if(width_metric<1000) |
1283 |
|
dist_str = g_strdup_printf("%u m", width_metric); |
1284 |
|
else |
1285 |
|
dist_str = g_strdup_printf("%u km", width_metric/1000); |
1286 |
|
width_metric /= m_per_pix; |
1287 |
|
|
1288 |
|
/* and now the hard part: scale for useful imperial values :-( */ |
1289 |
|
/* try to convert to feet, 1ft == 0.3048 m */ |
1290 |
|
width /= 0.3048; |
1291 |
|
float imp_scale = 0.3048; |
1292 |
|
char *dist_imp_unit = "ft"; |
1293 |
|
|
1294 |
|
if(width >= 100) { |
1295 |
|
/* 1yd == 3 feet */ |
1296 |
|
width /= 3.0; |
1297 |
|
imp_scale *= 3.0; |
1298 |
|
dist_imp_unit = "yd"; |
1299 |
|
|
1300 |
|
if(width >= 1760.0) { |
1301 |
|
/* 1mi == 1760 yd */ |
1302 |
|
width /= 1760.0; |
1303 |
|
imp_scale *= 1760.0; |
1304 |
|
dist_imp_unit = "mi"; |
1305 |
|
} |
1306 |
|
} |
1307 |
|
|
1308 |
|
/* also convert this to full tens/hundreds */ |
1309 |
|
exp = logf(width)*M_LOG10E; |
1310 |
|
mant = width/pow(10,exp); |
1311 |
|
int width_imp = mant * pow(10,exp); |
1312 |
|
char *dist_str_imp = g_strdup_printf("%u %s", width_imp, dist_imp_unit); |
1313 |
|
|
1314 |
|
/* convert back to pixels */ |
1315 |
|
width_imp *= imp_scale; |
1316 |
|
width_imp /= m_per_pix; |
1317 |
|
|
1318 |
|
cairo_select_font_face (cr, "Sans", |
1319 |
|
CAIRO_FONT_SLANT_NORMAL, |
1320 |
|
CAIRO_FONT_WEIGHT_BOLD); |
1321 |
|
cairo_set_font_size (cr, OSD_SCALE_FONT_SIZE); |
1322 |
|
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); |
1323 |
|
|
1324 |
|
cairo_text_extents_t extents; |
1325 |
|
cairo_text_extents (cr, dist_str, &extents); |
1326 |
|
|
1327 |
|
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |
1328 |
|
cairo_set_line_width (cr, OSD_SCALE_FONT_SIZE/6); |
1329 |
|
cairo_move_to (cr, 2*OSD_SCALE_FD, OSD_SCALE_H2-OSD_SCALE_FD); |
1330 |
|
cairo_text_path (cr, dist_str); |
1331 |
|
cairo_stroke (cr); |
1332 |
|
cairo_move_to (cr, 2*OSD_SCALE_FD, |
1333 |
|
OSD_SCALE_H2+OSD_SCALE_FD + extents.height); |
1334 |
|
cairo_text_path (cr, dist_str_imp); |
1335 |
|
cairo_stroke (cr); |
1336 |
|
|
1337 |
|
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); |
1338 |
|
cairo_move_to (cr, 2*OSD_SCALE_FD, OSD_SCALE_H2-OSD_SCALE_FD); |
1339 |
|
cairo_show_text (cr, dist_str); |
1340 |
|
cairo_move_to (cr, 2*OSD_SCALE_FD, |
1341 |
|
OSD_SCALE_H2+OSD_SCALE_FD + extents.height); |
1342 |
|
cairo_show_text (cr, dist_str_imp); |
1343 |
|
|
1344 |
|
g_free(dist_str); |
1345 |
|
g_free(dist_str_imp); |
1346 |
|
|
1347 |
|
/* draw white line */ |
1348 |
|
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
1349 |
|
cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); |
1350 |
|
cairo_set_line_width (cr, OSD_SCALE_FONT_SIZE/3); |
1351 |
|
cairo_move_to (cr, OSD_SCALE_FONT_SIZE/6, OSD_SCALE_M); |
1352 |
|
cairo_rel_line_to (cr, 0, OSD_SCALE_TICK); |
1353 |
|
cairo_rel_line_to (cr, width_metric, 0); |
1354 |
|
cairo_rel_line_to (cr, 0, -OSD_SCALE_TICK); |
1355 |
|
cairo_stroke(cr); |
1356 |
|
cairo_move_to (cr, OSD_SCALE_FONT_SIZE/6, OSD_SCALE_I); |
1357 |
|
cairo_rel_line_to (cr, 0, -OSD_SCALE_TICK); |
1358 |
|
cairo_rel_line_to (cr, width_imp, 0); |
1359 |
|
cairo_rel_line_to (cr, 0, +OSD_SCALE_TICK); |
1360 |
|
cairo_stroke(cr); |
1361 |
|
|
1362 |
|
/* draw black line */ |
1363 |
|
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0); |
1364 |
|
cairo_set_line_width (cr, OSD_SCALE_FONT_SIZE/6); |
1365 |
|
cairo_move_to (cr, OSD_SCALE_FONT_SIZE/6, OSD_SCALE_M); |
1366 |
|
cairo_rel_line_to (cr, 0, OSD_SCALE_TICK); |
1367 |
|
cairo_rel_line_to (cr, width_metric, 0); |
1368 |
|
cairo_rel_line_to (cr, 0, -OSD_SCALE_TICK); |
1369 |
|
cairo_stroke(cr); |
1370 |
|
cairo_move_to (cr, OSD_SCALE_FONT_SIZE/6, OSD_SCALE_I); |
1371 |
|
cairo_rel_line_to (cr, 0, -OSD_SCALE_TICK); |
1372 |
|
cairo_rel_line_to (cr, width_imp, 0); |
1373 |
|
cairo_rel_line_to (cr, 0, +OSD_SCALE_TICK); |
1374 |
|
cairo_stroke(cr); |
1375 |
|
|
1376 |
|
cairo_destroy(cr); |
1377 |
|
} |
1378 |
|
#endif |
1379 |
|
|
1380 |
|
static void |
1381 |
|
osd_render_controls(osm_gps_map_osd_t *osd) |
1382 |
|
{ |
1383 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1384 |
|
|
1385 |
|
if(priv->controls.rendered |
1386 |
|
#ifdef OSD_GPS_BUTTON |
1387 |
|
&& (priv->controls.gps_enabled == (osd->cb != NULL)) |
1388 |
|
#endif |
1389 |
|
) |
1390 |
|
return; |
1391 |
|
|
1392 |
|
#ifdef OSD_GPS_BUTTON |
1393 |
|
priv->controls.gps_enabled = (osd->cb != NULL); |
1394 |
|
#endif |
1395 |
|
priv->controls.rendered = TRUE; |
1396 |
|
|
1397 |
#ifndef OSD_COLOR |
#ifndef OSD_COLOR |
1398 |
GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL]; |
GdkColor bg = GTK_WIDGET(osd->widget)->style->bg[GTK_STATE_NORMAL]; |
1399 |
GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL]; |
GdkColor fg = GTK_WIDGET(osd->widget)->style->fg[GTK_STATE_NORMAL]; |
1401 |
#endif |
#endif |
1402 |
|
|
1403 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1404 |
cairo_t *cr = cairo_create(priv->overlay); |
cairo_t *cr = cairo_create(priv->controls.surface); |
1405 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1406 |
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
1407 |
cairo_paint(cr); |
cairo_paint(cr); |
1472 |
cairo_stroke(cr); |
cairo_stroke(cr); |
1473 |
|
|
1474 |
cairo_destroy(cr); |
cairo_destroy(cr); |
1475 |
|
} |
1476 |
|
|
1477 |
|
static void |
1478 |
|
osd_render(osm_gps_map_osd_t *osd) |
1479 |
|
{ |
1480 |
|
/* this function is actually called pretty often since the */ |
1481 |
|
/* OSD contents may have changed (due to a coordinate/zoom change). */ |
1482 |
|
/* The different OSD parts have to make sure that they don't */ |
1483 |
|
/* render unneccessarily often and thus waste CPU power */ |
1484 |
|
|
1485 |
|
osd_render_controls(osd); |
1486 |
|
|
1487 |
osd_render_source_sel(osd); |
#ifdef OSD_SOURCE_SEL |
1488 |
|
osd_render_source_sel(osd, FALSE); |
1489 |
|
#endif |
1490 |
|
|
1491 |
|
#ifdef OSD_SCALE |
1492 |
|
osd_render_scale(osd); |
1493 |
|
#endif |
1494 |
|
|
1495 |
|
#ifdef OSD_CROSSHAIR |
1496 |
|
osd_render_crosshair(osd); |
1497 |
|
#endif |
1498 |
|
|
1499 |
|
#ifdef OSD_COORDINATES |
1500 |
|
osd_render_coordinates(osd); |
1501 |
|
#endif |
1502 |
} |
} |
1503 |
|
|
1504 |
static void |
static void |
1508 |
|
|
1509 |
/* OSD itself uses some off-screen rendering, so check if the */ |
/* OSD itself uses some off-screen rendering, so check if the */ |
1510 |
/* offscreen buffer is present and create it if not */ |
/* offscreen buffer is present and create it if not */ |
1511 |
if(!priv->overlay) { |
if(!priv->controls.surface) { |
1512 |
/* create overlay ... */ |
/* create overlay ... */ |
1513 |
priv->overlay = |
priv->controls.surface = |
1514 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W+2, OSD_H+2); |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W+2, OSD_H+2); |
1515 |
|
|
1516 |
|
priv->controls.rendered = FALSE; |
1517 |
|
#ifdef OSD_GPS_BUTTON |
1518 |
|
priv->controls.gps_enabled = FALSE; |
1519 |
|
#endif |
1520 |
|
|
1521 |
|
#ifdef OSD_SOURCE_SEL |
1522 |
/* the initial OSD state is alway not-expanded */ |
/* the initial OSD state is alway not-expanded */ |
1523 |
priv->map_source = |
priv->source_sel.surface = |
1524 |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
1525 |
OSD_S_W+2, OSD_S_H+2); |
OSD_S_W+2, OSD_S_H+2); |
1526 |
|
priv->source_sel.rendered = FALSE; |
1527 |
|
#endif |
1528 |
|
|
1529 |
|
#ifdef OSD_SCALE |
1530 |
|
priv->scale.surface = |
1531 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
1532 |
|
OSD_SCALE_W, OSD_SCALE_H); |
1533 |
|
priv->scale.zoom = -1; |
1534 |
|
#endif |
1535 |
|
|
1536 |
|
#ifdef OSD_CROSSHAIR |
1537 |
|
priv->crosshair.surface = |
1538 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
1539 |
|
OSD_CROSSHAIR_W, OSD_CROSSHAIR_H); |
1540 |
|
priv->crosshair.rendered = FALSE; |
1541 |
|
#endif |
1542 |
|
|
1543 |
|
#ifdef OSD_COORDINATES |
1544 |
|
priv->coordinates.surface = |
1545 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, |
1546 |
|
OSD_COORDINATES_W, OSD_COORDINATES_H); |
1547 |
|
|
1548 |
|
priv->coordinates.lat = priv->coordinates.lon = OSM_GPS_MAP_INVALID; |
1549 |
|
#endif |
1550 |
|
|
1551 |
/* ... and render it */ |
/* ... and render it */ |
1552 |
osd_render(osd); |
osd_render(osd); |
1555 |
// now draw this onto the original context |
// now draw this onto the original context |
1556 |
cairo_t *cr = gdk_cairo_create(drawable); |
cairo_t *cr = gdk_cairo_create(drawable); |
1557 |
|
|
1558 |
int x = OSD_X, y = OSD_Y; |
gint x, y; |
|
if(OSD_X < 0) |
|
|
x = osd->widget->allocation.width - OSD_W + OSD_X; |
|
1559 |
|
|
1560 |
if(OSD_Y < 0) |
#ifdef OSD_SCALE |
1561 |
y = osd->widget->allocation.height - OSD_H + OSD_Y; |
x = OSD_X; |
1562 |
|
y = -OSD_Y; |
1563 |
|
if(x < 0) x += osd->widget->allocation.width - OSD_SCALE_W; |
1564 |
|
if(y < 0) y += osd->widget->allocation.height - OSD_SCALE_H; |
1565 |
|
|
1566 |
|
cairo_set_source_surface(cr, priv->scale.surface, x, y); |
1567 |
|
cairo_paint(cr); |
1568 |
|
#endif |
1569 |
|
|
1570 |
|
#ifdef OSD_CROSSHAIR |
1571 |
|
x = (osd->widget->allocation.width - OSD_CROSSHAIR_W)/2; |
1572 |
|
y = (osd->widget->allocation.height - OSD_CROSSHAIR_H)/2; |
1573 |
|
|
1574 |
|
cairo_set_source_surface(cr, priv->crosshair.surface, x, y); |
1575 |
|
cairo_paint(cr); |
1576 |
|
#endif |
1577 |
|
|
1578 |
|
#ifdef OSD_COORDINATES |
1579 |
|
x = -OSD_X; |
1580 |
|
y = -OSD_Y; |
1581 |
|
if(x < 0) x += osd->widget->allocation.width - OSD_COORDINATES_W; |
1582 |
|
if(y < 0) y += osd->widget->allocation.height - OSD_COORDINATES_H; |
1583 |
|
|
1584 |
|
cairo_set_source_surface(cr, priv->coordinates.surface, x, y); |
1585 |
|
cairo_paint(cr); |
1586 |
|
#endif |
1587 |
|
|
1588 |
|
#ifdef OSD_BALLOON |
1589 |
|
if(priv->balloon.surface) { |
1590 |
|
|
1591 |
|
/* convert given lat lon into screen coordinates */ |
1592 |
|
gint x, y; |
1593 |
|
osm_gps_map_geographic_to_screen (OSM_GPS_MAP(osd->widget), |
1594 |
|
priv->balloon.lat, priv->balloon.lon, |
1595 |
|
&x, &y); |
1596 |
|
|
1597 |
|
/* check if balloon needs to be rerendered */ |
1598 |
|
osd_render_balloon(osd); |
1599 |
|
|
1600 |
|
cairo_set_source_surface(cr, priv->balloon.surface, |
1601 |
|
x + priv->balloon.offset_x, |
1602 |
|
y + priv->balloon.offset_y); |
1603 |
|
cairo_paint(cr); |
1604 |
|
} |
1605 |
|
#endif |
1606 |
|
|
1607 |
|
x = OSD_X; |
1608 |
|
if(x < 0) |
1609 |
|
x += osd->widget->allocation.width - OSD_W; |
1610 |
|
|
1611 |
|
y = OSD_Y; |
1612 |
|
if(y < 0) |
1613 |
|
y += osd->widget->allocation.height - OSD_H; |
1614 |
|
|
1615 |
cairo_set_source_surface(cr, priv->overlay, x, y); |
cairo_set_source_surface(cr, priv->controls.surface, x, y); |
1616 |
cairo_paint(cr); |
cairo_paint(cr); |
1617 |
|
|
1618 |
#ifdef OSD_SOURCE_SEL |
#ifdef OSD_SOURCE_SEL |
1619 |
if(!priv->handler_id) { |
if(!priv->source_sel.handler_id) { |
1620 |
/* the OSD source selection is not being animated */ |
/* the OSD source selection is not being animated */ |
1621 |
if(!priv->expanded) |
if(!priv->source_sel.expanded) |
1622 |
x = osd->widget->allocation.width - OSD_S_W; |
x = osd->widget->allocation.width - OSD_S_W; |
1623 |
else |
else |
1624 |
x = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
x = osd->widget->allocation.width - OSD_S_EXP_W + OSD_S_X; |
1625 |
} else |
} else |
1626 |
x = priv->shift; |
x = priv->source_sel.shift; |
1627 |
|
|
1628 |
y = OSD_S_Y; |
y = OSD_S_Y; |
1629 |
if(OSD_S_Y < 0) { |
if(OSD_S_Y < 0) { |
1630 |
if(!priv->expanded) |
if(!priv->source_sel.expanded) |
1631 |
y = osd->widget->allocation.height - OSD_S_H + OSD_S_Y; |
y = osd->widget->allocation.height - OSD_S_H + OSD_S_Y; |
1632 |
else |
else |
1633 |
y = osd->widget->allocation.height - OSD_S_EXP_H + OSD_S_Y; |
y = osd->widget->allocation.height - OSD_S_EXP_H + OSD_S_Y; |
1634 |
} |
} |
1635 |
|
|
1636 |
cairo_set_source_surface(cr, priv->map_source, x, y); |
cairo_set_source_surface(cr, priv->source_sel.surface, x, y); |
1637 |
cairo_paint(cr); |
cairo_paint(cr); |
1638 |
#endif |
#endif |
1639 |
|
|
1645 |
{ |
{ |
1646 |
osd_priv_t *priv = (osd_priv_t *)(osd->priv); |
osd_priv_t *priv = (osd_priv_t *)(osd->priv); |
1647 |
|
|
1648 |
if(priv->handler_id) |
if (priv->controls.surface) |
1649 |
gtk_timeout_remove(priv->handler_id); |
cairo_surface_destroy(priv->controls.surface); |
1650 |
|
|
1651 |
if (priv->overlay) |
#ifdef OSD_SOURCE_SEL |
1652 |
cairo_surface_destroy(priv->overlay); |
if(priv->source_sel.handler_id) |
1653 |
|
gtk_timeout_remove(priv->source_sel.handler_id); |
1654 |
|
|
1655 |
if (priv->map_source) |
if (priv->source_sel.surface) |
1656 |
cairo_surface_destroy(priv->map_source); |
cairo_surface_destroy(priv->source_sel.surface); |
1657 |
|
#endif |
1658 |
|
|
1659 |
|
#ifdef OSD_SCALE |
1660 |
|
if (priv->scale.surface) |
1661 |
|
cairo_surface_destroy(priv->scale.surface); |
1662 |
|
#endif |
1663 |
|
|
1664 |
|
#ifdef OSD_CROSSHAIR |
1665 |
|
if (priv->crosshair.surface) |
1666 |
|
cairo_surface_destroy(priv->crosshair.surface); |
1667 |
|
#endif |
1668 |
|
|
1669 |
|
#ifdef OSD_COORDINATES |
1670 |
|
if (priv->coordinates.surface) |
1671 |
|
cairo_surface_destroy(priv->coordinates.surface); |
1672 |
|
#endif |
1673 |
|
|
1674 |
|
#ifdef OSD_BALLOON |
1675 |
|
if (priv->balloon.surface) |
1676 |
|
cairo_surface_destroy(priv->balloon.surface); |
1677 |
|
#endif |
1678 |
|
|
1679 |
g_free(priv); |
g_free(priv); |
1680 |
} |
} |
1681 |
|
|
|
/* this is the only function that's externally visible */ |
|
1682 |
static gboolean |
static gboolean |
1683 |
osd_busy(osm_gps_map_osd_t *osd) |
osd_busy(osm_gps_map_osd_t *osd) |
1684 |
{ |
{ |
1685 |
|
#ifdef OSD_SOURCE_SEL |
1686 |
osd_priv_t *priv = (osd_priv_t *)(osd->priv); |
osd_priv_t *priv = (osd_priv_t *)(osd->priv); |
1687 |
return (priv->handler_id != 0); |
return (priv->source_sel.handler_id != 0); |
1688 |
|
#else |
1689 |
|
return FALSE; |
1690 |
|
#endif |
1691 |
} |
} |
1692 |
|
|
1693 |
static osm_gps_map_osd_t osd_classic = { |
static osm_gps_map_osd_t osd_classic = { |
1694 |
|
.widget = NULL, |
1695 |
|
|
1696 |
.draw = osd_draw, |
.draw = osd_draw, |
1697 |
.check = osd_check, |
.check = osd_check, |
1698 |
.render = osd_render, |
.render = osd_render, |
1711 |
{ |
{ |
1712 |
osd_priv_t *priv = osd_classic.priv = g_new0(osd_priv_t, 1); |
osd_priv_t *priv = osd_classic.priv = g_new0(osd_priv_t, 1); |
1713 |
|
|
1714 |
|
#ifdef OSD_BALLOON |
1715 |
|
priv->balloon.lat = OSM_GPS_MAP_INVALID; |
1716 |
|
priv->balloon.lon = OSM_GPS_MAP_INVALID; |
1717 |
|
#endif |
1718 |
|
|
1719 |
osd_classic.priv = priv; |
osd_classic.priv = priv; |
1720 |
|
|
1721 |
osm_gps_map_register_osd(map, &osd_classic); |
osm_gps_map_register_osd(map, &osd_classic); |