135 |
|
|
136 |
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS) |
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS) |
137 |
|
|
138 |
|
#if 0 |
139 |
#define FIN printf("entering function %s\n", __func__); |
#define FIN printf("entering function %s\n", __func__); |
140 |
#define FOUT printf("leaving function %s\n", __func__); |
#define FOUT printf("leaving function %s\n", __func__); |
141 |
|
#else |
142 |
|
#define FIN ; |
143 |
|
#define FOUT ; |
144 |
|
#endif |
145 |
|
|
146 |
/* draw the bubble shape. this is used twice, once for the shape and once */ |
/* draw the bubble shape. this is used twice, once for the shape and once */ |
147 |
/* for the shadow */ |
/* for the shadow */ |
189 |
|
|
190 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
191 |
|
|
192 |
|
if(!priv->balloon.surface) |
193 |
|
return; |
194 |
|
|
195 |
/* get zoom */ |
/* get zoom */ |
196 |
gint zoom; |
gint zoom; |
197 |
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
252 |
priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER; |
priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER; |
253 |
priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER; |
priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER; |
254 |
|
|
255 |
|
g_assert(priv->balloon.surface); |
256 |
cairo_t *cr = cairo_create(priv->balloon.surface); |
cairo_t *cr = cairo_create(priv->balloon.surface); |
257 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
258 |
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
652 |
/* internal value to draw the arrow on the "puller" */ |
/* internal value to draw the arrow on the "puller" */ |
653 |
#define OSD_S_D0 (OSD_S_RAD/2) |
#define OSD_S_D0 (OSD_S_RAD/2) |
654 |
#ifndef OSD_FONT_SIZE |
#ifndef OSD_FONT_SIZE |
655 |
#define OSD_FONT_SIZE 16.0 |
#define OSD_FONT_SIZE (16.0) |
656 |
#endif |
#endif |
657 |
#define OSD_TEXT_BORDER (OSD_FONT_SIZE/2) |
#define OSD_TEXT_BORDER (OSD_FONT_SIZE/2) |
658 |
#define OSD_TEXT_SKIP (OSD_FONT_SIZE/8) |
#define OSD_TEXT_SKIP (OSD_FONT_SIZE/8) |
764 |
|
|
765 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
766 |
|
|
767 |
if(priv->source_sel.rendered && !force_rerender) |
if(!priv->source_sel.surface || |
768 |
|
(priv->source_sel.rendered && !force_rerender)) |
769 |
return; |
return; |
770 |
|
|
771 |
priv->source_sel.rendered = TRUE; |
priv->source_sel.rendered = TRUE; |
777 |
#endif |
#endif |
778 |
|
|
779 |
/* draw source selector */ |
/* draw source selector */ |
780 |
|
g_assert(priv->source_sel.surface); |
781 |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
782 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
783 |
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); |
828 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
829 |
|
|
830 |
/* determine content size */ |
/* determine content size */ |
831 |
|
g_assert(priv->source_sel.surface); |
832 |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
cairo_t *cr = cairo_create(priv->source_sel.surface); |
833 |
cairo_select_font_face (cr, "Sans", |
cairo_select_font_face (cr, "Sans", |
834 |
CAIRO_FONT_SLANT_NORMAL, |
CAIRO_FONT_SLANT_NORMAL, |
1140 |
#ifdef OSD_COORDINATES |
#ifdef OSD_COORDINATES |
1141 |
|
|
1142 |
#ifndef OSD_COORDINATES_FONT_SIZE |
#ifndef OSD_COORDINATES_FONT_SIZE |
1143 |
#define OSD_COORDINATES_FONT_SIZE 12 |
#define OSD_COORDINATES_FONT_SIZE (12.0) |
1144 |
#endif |
#endif |
1145 |
|
|
1146 |
#define OSD_COORDINATES_OFFSET (OSD_COORDINATES_FONT_SIZE/6) |
#define OSD_COORDINATES_OFFSET (OSD_COORDINATES_FONT_SIZE/6) |
1209 |
osd_render_centered_text(cairo_t *cr, int y, int width, char *text) { |
osd_render_centered_text(cairo_t *cr, int y, int width, char *text) { |
1210 |
FIN; |
FIN; |
1211 |
|
|
|
printf("params: %p %d %d %p\n", cr, y, width, text); // XXX |
|
|
|
|
1212 |
if(!text) return y; |
if(!text) return y; |
1213 |
|
|
|
printf("text given: %s\n", text); // XXX |
|
|
|
|
1214 |
char *p = g_malloc(strlen(text)+4); // space for "...\n" |
char *p = g_malloc(strlen(text)+4); // space for "...\n" |
1215 |
strcpy(p, text); |
strcpy(p, text); |
1216 |
|
|
1217 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
1218 |
printf("getting extents for \"%s\"\n", p); // XXX |
memset(&extents, 0, sizeof(cairo_text_extents_t)); |
1219 |
cairo_text_extents (cr, p, &extents); |
cairo_text_extents (cr, p, &extents); |
1220 |
printf("initial extents.width = %f\n", extents.width); // XXX |
g_assert(extents.width != 0.0); |
1221 |
|
|
1222 |
/* check if text needs to be truncated */ |
/* check if text needs to be truncated */ |
1223 |
int trunc_at = strlen(text)-1; |
int trunc_at = strlen(text); |
1224 |
while(extents.width > width) { |
while(extents.width > width) { |
|
g_assert(trunc_at > 0); |
|
1225 |
|
|
1226 |
printf("trunc at %d\n", trunc_at); // XXX |
/* cut off all utf8 multibyte remains so the actual */ |
1227 |
printf("extents.width = %f > %d\n", extents.width, width); // XXX |
/* truncation only deals with one byte */ |
1228 |
|
while((p[trunc_at-1] & 0xc0) == 0x80) { |
1229 |
|
trunc_at--; |
1230 |
|
g_assert(trunc_at > 0); |
1231 |
|
} |
1232 |
|
|
1233 |
trunc_at--; |
trunc_at--; |
1234 |
|
g_assert(trunc_at > 0); |
1235 |
|
|
1236 |
strcpy(p+trunc_at, "..."); |
strcpy(p+trunc_at, "..."); |
|
printf("getting extents for \"%s\"\n", p); // XXX |
|
1237 |
cairo_text_extents (cr, p, &extents); |
cairo_text_extents (cr, p, &extents); |
1238 |
} |
} |
1239 |
|
|
|
printf("painting\n"); // XXX |
|
|
|
|
1240 |
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); |
1241 |
cairo_set_line_width (cr, OSD_COORDINATES_FONT_SIZE/6); |
cairo_set_line_width (cr, OSD_COORDINATES_FONT_SIZE/6); |
1242 |
cairo_move_to (cr, (width - extents.width)/2, y - extents.y_bearing); |
cairo_move_to (cr, (width - extents.width)/2, y - extents.y_bearing); |
1260 |
FIN; |
FIN; |
1261 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1262 |
|
|
1263 |
|
if(!priv->coordinates.surface) |
1264 |
|
return; |
1265 |
|
|
1266 |
/* get current map position */ |
/* get current map position */ |
1267 |
gfloat lat, lon; |
gfloat lat, lon; |
1268 |
g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL); |
g_object_get(osd->widget, "latitude", &lat, "longitude", &lon, NULL); |
1278 |
priv->coordinates.lon = lon; |
priv->coordinates.lon = lon; |
1279 |
|
|
1280 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1281 |
|
|
1282 |
|
g_assert(priv->coordinates.surface); |
1283 |
cairo_t *cr = cairo_create(priv->coordinates.surface); |
cairo_t *cr = cairo_create(priv->coordinates.surface); |
1284 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1285 |
// cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5); |
// cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5); |
1338 |
return; |
return; |
1339 |
|
|
1340 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1341 |
|
g_assert(priv->nav.surface); |
1342 |
cairo_t *cr = cairo_create(priv->nav.surface); |
cairo_t *cr = cairo_create(priv->nav.surface); |
1343 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1344 |
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); |
1535 |
FIN; |
FIN; |
1536 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1537 |
|
|
1538 |
if(priv->crosshair.rendered) |
if(!priv->crosshair.surface || priv->crosshair.rendered) |
1539 |
return; |
return; |
1540 |
|
|
1541 |
priv->crosshair.rendered = TRUE; |
priv->crosshair.rendered = TRUE; |
1542 |
|
|
1543 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1544 |
|
g_assert(priv->crosshair.surface); |
1545 |
cairo_t *cr = cairo_create(priv->crosshair.surface); |
cairo_t *cr = cairo_create(priv->crosshair.surface); |
1546 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1547 |
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); |
1566 |
#ifdef OSD_SCALE |
#ifdef OSD_SCALE |
1567 |
|
|
1568 |
#ifndef OSD_SCALE_FONT_SIZE |
#ifndef OSD_SCALE_FONT_SIZE |
1569 |
#define OSD_SCALE_FONT_SIZE 12 |
#define OSD_SCALE_FONT_SIZE (12.0) |
1570 |
#endif |
#endif |
1571 |
#define OSD_SCALE_W (10*OSD_SCALE_FONT_SIZE) |
#define OSD_SCALE_W (10*OSD_SCALE_FONT_SIZE) |
1572 |
#define OSD_SCALE_H (5*OSD_SCALE_FONT_SIZE/2) |
#define OSD_SCALE_H (5*OSD_SCALE_FONT_SIZE/2) |
1584 |
FIN; |
FIN; |
1585 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1586 |
|
|
1587 |
|
if(!priv->scale.surface) |
1588 |
|
return; |
1589 |
|
|
1590 |
/* this only needs to be rendered if the zoom has changed */ |
/* this only needs to be rendered if the zoom has changed */ |
1591 |
gint zoom; |
gint zoom; |
1592 |
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
g_object_get(OSM_GPS_MAP(osd->widget), "zoom", &zoom, NULL); |
1598 |
float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget)); |
float m_per_pix = osm_gps_map_get_scale(OSM_GPS_MAP(osd->widget)); |
1599 |
|
|
1600 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1601 |
|
g_assert(priv->scale.surface); |
1602 |
cairo_t *cr = cairo_create(priv->scale.surface); |
cairo_t *cr = cairo_create(priv->scale.surface); |
1603 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1604 |
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); |
1719 |
FIN; |
FIN; |
1720 |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
osd_priv_t *priv = (osd_priv_t*)osd->priv; |
1721 |
|
|
1722 |
|
if(!priv->controls.surface) |
1723 |
|
return; |
1724 |
|
|
1725 |
if(priv->controls.rendered |
if(priv->controls.rendered |
1726 |
#ifdef OSD_GPS_BUTTON |
#ifdef OSD_GPS_BUTTON |
1727 |
&& (priv->controls.gps_enabled == (osd->cb != NULL)) |
&& (priv->controls.gps_enabled == (osd->cb != NULL)) |
1741 |
#endif |
#endif |
1742 |
|
|
1743 |
/* first fill with transparency */ |
/* first fill with transparency */ |
1744 |
|
g_assert(priv->controls.surface); |
1745 |
cairo_t *cr = cairo_create(priv->controls.surface); |
cairo_t *cr = cairo_create(priv->controls.surface); |
1746 |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1747 |
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); |