Diff of /trunk/src/osm-gps-map-osd-classic.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 150 by harbaum, Thu Oct 29 20:25:11 2009 UTC revision 152 by harbaum, Mon Nov 2 10:53:01 2009 UTC
# Line 252  osd_render_balloon(osm_gps_map_osd_t *os Line 252  osd_render_balloon(osm_gps_map_osd_t *os
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);
# Line 776  osd_render_source_sel(osm_gps_map_osd_t Line 777  osd_render_source_sel(osm_gps_map_osd_t
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);
# Line 826  osd_source_reallocate(osm_gps_map_osd_t Line 828  osd_source_reallocate(osm_gps_map_osd_t
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,
# Line 1212  osd_render_centered_text(cairo_t *cr, in Line 1215  osd_render_centered_text(cairo_t *cr, in
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      }      }
# Line 1267  osd_render_coordinates(osm_gps_map_osd_t Line 1279  osd_render_coordinates(osm_gps_map_osd_t
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);
# Line 1325  osd_render_nav(osm_gps_map_osd_t *osd) Line 1338  osd_render_nav(osm_gps_map_osd_t *osd)
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);
# Line 1527  osd_render_crosshair(osm_gps_map_osd_t * Line 1541  osd_render_crosshair(osm_gps_map_osd_t *
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);
# Line 1583  osd_render_scale(osm_gps_map_osd_t *osd) Line 1598  osd_render_scale(osm_gps_map_osd_t *osd)
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);
# Line 1725  osd_render_controls(osm_gps_map_osd_t *o Line 1741  osd_render_controls(osm_gps_map_osd_t *o
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);

Legend:
Removed from v.150  
changed lines
  Added in v.152