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); |
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, |
1215 |
strcpy(p, text); |
strcpy(p, text); |
1216 |
|
|
1217 |
cairo_text_extents_t extents; |
cairo_text_extents_t extents; |
1218 |
|
memset(&extents, 0, sizeof(cairo_text_extents_t)); |
1219 |
cairo_text_extents (cr, p, &extents); |
cairo_text_extents (cr, p, &extents); |
1220 |
g_assert(extents.width != 0.0); |
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) { |
1225 |
g_assert(trunc_at > 0); |
|
1226 |
|
/* cut off all utf8 multibyte remains so the actual */ |
1227 |
|
/* 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, "..."); |
1237 |
cairo_text_extents (cr, p, &extents); |
cairo_text_extents (cr, p, &extents); |
1238 |
} |
} |
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); |
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); |
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); |
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); |