35 |
|
|
36 |
//the osd controls |
//the osd controls |
37 |
typedef struct { |
typedef struct { |
38 |
|
/* the offscreen representation of the OSD */ |
39 |
|
cairo_surface_t *overlay; |
40 |
|
|
41 |
|
/* stuff required to restore the original map content */ |
42 |
GdkPixmap *backup; |
GdkPixmap *backup; |
43 |
gint backup_x, backup_y; |
gint backup_x, backup_y; |
44 |
cairo_surface_t *overlay; |
|
45 |
|
GdkColor bg, fg, da; |
46 |
|
|
47 |
} osd_priv_t; |
} osd_priv_t; |
48 |
|
|
49 |
/* position and extent of bounding box */ |
/* position and extent of bounding box */ |
50 |
#define OSD_X (10) |
#define OSD_X (10) |
51 |
#define OSD_Y (10) |
#define OSD_Y (10) |
52 |
|
|
|
#define OSD_COLOR 0.5, 0.5, 1 |
|
|
#define OSD_COLOR_DISABLED 0.8, 0.8, 0.8 |
|
|
|
|
53 |
/* parameters of the direction shape */ |
/* parameters of the direction shape */ |
54 |
#ifndef OSM_GPS_MAP_OSD_DIAMETER |
#ifndef OSM_GPS_MAP_OSD_DIAMETER |
55 |
#define D_RAD (30) // diameter of dpad |
#define D_RAD (30) // diameter of dpad |
64 |
#define Z_STEP (D_RAD/4) // distance between dpad and zoom |
#define Z_STEP (D_RAD/4) // distance between dpad and zoom |
65 |
#define Z_RAD (D_RAD/2) // radius of "caps" of zoom bar |
#define Z_RAD (D_RAD/2) // radius of "caps" of zoom bar |
66 |
|
|
67 |
|
#ifdef OSD_SHADOW_ENABLE |
68 |
/* shadow also depends on control size */ |
/* shadow also depends on control size */ |
69 |
#define OSD_SHADOW (D_RAD/6) |
#define OSD_SHADOW (D_RAD/6) |
70 |
|
#else |
71 |
|
#define OSD_SHADOW (0) |
72 |
|
#endif |
73 |
|
|
74 |
/* total width and height of controls incl. shadow */ |
/* total width and height of controls incl. shadow */ |
75 |
#define OSD_W (2*D_RAD + OSD_SHADOW) |
#define OSD_W (2*D_RAD + OSD_SHADOW) |
76 |
#define OSD_H (2*D_RAD + Z_STEP + 2*Z_RAD + OSD_SHADOW) |
#define OSD_H (2*D_RAD + Z_STEP + 2*Z_RAD + OSD_SHADOW) |
77 |
|
|
78 |
|
#ifdef OSD_SHADOW_ENABLE |
79 |
#define OSD_LBL_SHADOW (OSD_SHADOW/2) |
#define OSD_LBL_SHADOW (OSD_SHADOW/2) |
80 |
|
#endif |
81 |
|
|
82 |
#define Z_TOP (2 * D_RAD + Z_STEP) |
#define Z_TOP (2 * D_RAD + Z_STEP) |
83 |
#define Z_MID (Z_TOP + Z_RAD) |
#define Z_MID (Z_TOP + Z_RAD) |
184 |
return but; |
return but; |
185 |
} |
} |
186 |
|
|
187 |
|
#ifdef OSD_SHADOW_ENABLE |
188 |
static void |
static void |
189 |
osm_gps_map_osd_shape_shadow(cairo_t *cr) { |
osm_gps_map_osd_shape_shadow(cairo_t *cr) { |
190 |
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
191 |
cairo_fill (cr); |
cairo_fill (cr); |
192 |
cairo_stroke (cr); |
cairo_stroke (cr); |
193 |
} |
} |
194 |
|
#endif |
195 |
|
|
196 |
|
#ifndef OSD_COLOR |
197 |
|
/* if no color has been specified we just use the gdks default colors */ |
198 |
|
static void |
199 |
|
osm_gps_map_osd_shape(cairo_t *cr, GdkColor *bg, GdkColor *fg) { |
200 |
|
gdk_cairo_set_source_color(cr, bg); |
201 |
|
cairo_fill_preserve (cr); |
202 |
|
gdk_cairo_set_source_color(cr, fg); |
203 |
|
cairo_set_line_width (cr, 1); |
204 |
|
cairo_stroke (cr); |
205 |
|
} |
206 |
|
#else |
207 |
static void |
static void |
208 |
osm_gps_map_osd_shape(cairo_t *cr) { |
osm_gps_map_osd_shape(cairo_t *cr) { |
209 |
cairo_set_source_rgb (cr, 1, 1, 1); |
cairo_set_source_rgb (cr, OSD_COLOR_BG); |
210 |
cairo_fill_preserve (cr); |
cairo_fill_preserve (cr); |
211 |
cairo_set_source_rgb (cr, OSD_COLOR); |
cairo_set_source_rgb (cr, OSD_COLOR); |
212 |
cairo_set_line_width (cr, 1); |
cairo_set_line_width (cr, 1); |
213 |
cairo_stroke (cr); |
cairo_stroke (cr); |
214 |
} |
} |
215 |
|
#endif |
216 |
|
|
217 |
static void |
static void |
218 |
osm_gps_map_osd_dpad_labels(cairo_t *cr, gint x, gint y) { |
osm_gps_map_osd_dpad_labels(cairo_t *cr, gint x, gint y) { |
278 |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID); |
279 |
} |
} |
280 |
|
|
281 |
|
#ifndef OSD_COLOR |
282 |
|
/* if no color has been specified we just use the gdks default colors */ |
283 |
|
static void |
284 |
|
osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled, |
285 |
|
GdkColor *fg, GdkColor *disabled) { |
286 |
|
if(enabled) gdk_cairo_set_source_color(cr, fg); |
287 |
|
else gdk_cairo_set_source_color(cr, disabled); |
288 |
|
cairo_set_line_width (cr, width); |
289 |
|
cairo_stroke (cr); |
290 |
|
} |
291 |
|
#else |
292 |
static void |
static void |
293 |
osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled) { |
osm_gps_map_osd_labels(cairo_t *cr, gint width, gboolean enabled) { |
294 |
if(enabled) cairo_set_source_rgb (cr, OSD_COLOR); |
if(enabled) cairo_set_source_rgb (cr, OSD_COLOR); |
296 |
cairo_set_line_width (cr, width); |
cairo_set_line_width (cr, width); |
297 |
cairo_stroke (cr); |
cairo_stroke (cr); |
298 |
} |
} |
299 |
|
#endif |
300 |
|
|
301 |
|
#ifdef OSD_SHADOW_ENABLE |
302 |
static void |
static void |
303 |
osm_gps_map_osd_labels_shadow(cairo_t *cr, gint width, gboolean enabled) { |
osm_gps_map_osd_labels_shadow(cairo_t *cr, gint width, gboolean enabled) { |
304 |
cairo_set_source_rgba (cr, 0, 0, 0, enabled?0.3:0.15); |
cairo_set_source_rgba (cr, 0, 0, 0, enabled?0.3:0.15); |
305 |
cairo_set_line_width (cr, width); |
cairo_set_line_width (cr, width); |
306 |
cairo_stroke (cr); |
cairo_stroke (cr); |
307 |
} |
} |
308 |
|
#endif |
309 |
|
|
310 |
static void |
static void |
311 |
osm_gps_map_osd_render(osm_gps_map_osd_t *osd) { |
osm_gps_map_osd_render(osm_gps_map_osd_t *osd) { |
322 |
/* --------- draw zoom and dpad shape shadow ----------- */ |
/* --------- draw zoom and dpad shape shadow ----------- */ |
323 |
gint x = 0, y = 0; |
gint x = 0, y = 0; |
324 |
|
|
325 |
|
#ifdef OSD_SHADOW_ENABLE |
326 |
osm_gps_map_osd_zoom_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
osm_gps_map_osd_zoom_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
327 |
osm_gps_map_osd_shape_shadow(cr); |
osm_gps_map_osd_shape_shadow(cr); |
328 |
osm_gps_map_osd_dpad_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
osm_gps_map_osd_dpad_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW); |
329 |
osm_gps_map_osd_shape_shadow(cr); |
osm_gps_map_osd_shape_shadow(cr); |
330 |
|
#endif |
331 |
|
|
332 |
/* --------- draw zoom and dpad shape ----------- */ |
/* --------- draw zoom and dpad shape ----------- */ |
333 |
|
|
334 |
osm_gps_map_osd_zoom_shape(cr, x, y); |
osm_gps_map_osd_zoom_shape(cr, x, y); |
335 |
|
#ifndef OSD_COLOR |
336 |
|
osm_gps_map_osd_shape(cr, &priv->bg, &priv->fg); |
337 |
|
#else |
338 |
osm_gps_map_osd_shape(cr); |
osm_gps_map_osd_shape(cr); |
339 |
|
#endif |
340 |
osm_gps_map_osd_dpad_shape(cr, x, y); |
osm_gps_map_osd_dpad_shape(cr, x, y); |
341 |
|
#ifndef OSD_COLOR |
342 |
|
osm_gps_map_osd_shape(cr, &priv->bg, &priv->fg); |
343 |
|
#else |
344 |
osm_gps_map_osd_shape(cr); |
osm_gps_map_osd_shape(cr); |
345 |
|
#endif |
346 |
|
|
347 |
/* --------- draw zoom and dpad labels --------- */ |
/* --------- draw zoom and dpad labels --------- */ |
348 |
|
|
349 |
|
#ifdef OSD_SHADOW_ENABLE |
350 |
osm_gps_map_osd_zoom_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
osm_gps_map_osd_zoom_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
351 |
osm_gps_map_osd_dpad_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
osm_gps_map_osd_dpad_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
352 |
osm_gps_map_osd_labels_shadow(cr, Z_RAD/3, TRUE); |
osm_gps_map_osd_labels_shadow(cr, Z_RAD/3, TRUE); |
353 |
osm_gps_map_osd_dpad_gps(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
osm_gps_map_osd_dpad_gps(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW); |
354 |
osm_gps_map_osd_labels_shadow(cr, Z_RAD/6, osd->cb != NULL); |
osm_gps_map_osd_labels_shadow(cr, Z_RAD/6, osd->cb != NULL); |
355 |
|
#endif |
356 |
|
|
357 |
osm_gps_map_osd_zoom_labels(cr, x, y); |
osm_gps_map_osd_zoom_labels(cr, x, y); |
358 |
osm_gps_map_osd_dpad_labels(cr, x, y); |
osm_gps_map_osd_dpad_labels(cr, x, y); |
359 |
|
#ifndef OSD_COLOR |
360 |
|
osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE, &priv->fg, &priv->da); |
361 |
|
#else |
362 |
osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE); |
osm_gps_map_osd_labels(cr, Z_RAD/3, TRUE); |
363 |
|
#endif |
364 |
osm_gps_map_osd_dpad_gps(cr, x, y); |
osm_gps_map_osd_dpad_gps(cr, x, y); |
365 |
|
#ifndef OSD_COLOR |
366 |
|
osm_gps_map_osd_labels(cr, Z_RAD/6, osd->cb != NULL, &priv->fg, &priv->da); |
367 |
|
#else |
368 |
osm_gps_map_osd_labels(cr, Z_RAD/6, osd->cb != NULL); |
osm_gps_map_osd_labels(cr, Z_RAD/6, osd->cb != NULL); |
369 |
|
#endif |
370 |
|
|
371 |
cairo_destroy(cr); |
cairo_destroy(cr); |
372 |
} |
} |
458 |
|
|
459 |
osd_classic.priv = priv; |
osd_classic.priv = priv; |
460 |
|
|
461 |
|
/* extract style info from the widget */ |
462 |
|
priv->bg = GTK_WIDGET(map)->style->bg[GTK_STATE_NORMAL]; |
463 |
|
priv->fg = GTK_WIDGET(map)->style->fg[GTK_STATE_NORMAL]; |
464 |
|
priv->da = GTK_WIDGET(map)->style->fg[GTK_STATE_INSENSITIVE]; |
465 |
|
|
466 |
osm_gps_map_register_osd(map, &osd_classic); |
osm_gps_map_register_osd(map, &osd_classic); |
467 |
} |
} |
468 |
|
|
469 |
|
|
470 |
|
/* below are osd specific functions which aren't used by osm-gps-map */ |
471 |
|
/* but instead are to be used by the main application */ |
472 |
void osm_gps_map_osd_enable_gps (OsmGpsMap *map, OsmGpsMapOsdCallback cb, gpointer data) { |
void osm_gps_map_osd_enable_gps (OsmGpsMap *map, OsmGpsMapOsdCallback cb, gpointer data) { |
473 |
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
osm_gps_map_osd_t *osd = osm_gps_map_osd_get(map); |
474 |
|
|