--- trunk/src/map-tool.c 2009/08/17 14:23:38 59 +++ trunk/src/map-tool.c 2009/08/17 19:44:00 60 @@ -301,10 +301,11 @@ // now draw this onto the original context cairo_set_source_surface(cr, image_surface, x, y); + cairo_paint(cr); } -#define LINE_SKIP 10 +#define LINE_SKIP 7 static void balloon_draw_cb(cairo_t *cr, OsmGpsMapRect_t *rect, gpointer data) { @@ -331,38 +332,86 @@ /* ... and right of it the waypoint id */ cairo_text_extents_t extents; - cairo_select_font_face (cr, "Sans", - CAIRO_FONT_SLANT_NORMAL, - CAIRO_FONT_WEIGHT_BOLD); + if(cache->id) { + cairo_select_font_face (cr, "Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_BOLD); - cairo_set_font_size (cr, 20.0); - cairo_text_extents (cr, cache->id, &extents); + cairo_set_font_size (cr, 20.0); + cairo_text_extents (cr, cache->id, &extents); - /* display id right of icon vertically centered */ - x += gdk_pixbuf_get_width(icon) + 5; - y += (gdk_pixbuf_get_height(icon) + extents.height)/2; - cairo_move_to (cr, x,y); - cairo_set_source_rgba (cr, 0, 0, 0, 1); - cairo_show_text (cr, cache->id); - cairo_stroke (cr); + /* display id right of icon vertically centered */ + x += gdk_pixbuf_get_width(icon) + 5; + y += (gdk_pixbuf_get_height(icon) + extents.height)/2; + cairo_move_to (cr, x, y); + cairo_set_source_rgba (cr, 0, 0, 0, 1); + cairo_show_text (cr, cache->id); + cairo_stroke (cr); + + y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP; + } else + y += gdk_pixbuf_get_height(icon); /* return to the left border and below icon/text */ x = rect->x; - y += (gdk_pixbuf_get_height(icon) - extents.height)/2 + LINE_SKIP; - cairo_select_font_face (cr, "Sans", - CAIRO_FONT_SLANT_NORMAL, + /* everything from here uses the same font */ + cairo_select_font_face (cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size (cr, 14.0); - cairo_text_extents (cr, cache->name, &extents); - cairo_move_to (cr, x,y); - cairo_show_text (cr, cache->name); - cairo_stroke (cr); + if(cache->name) { + /* draw cache name */ + cairo_text_extents (cr, cache->name, &extents); + y += extents.height; + cairo_move_to (cr, x, y); + cairo_set_source_rgba (cr, 0, 0, 0, 1); + cairo_show_text (cr, cache->name); + cairo_stroke (cr); - /* return to the left border and below text */ - x = rect->x; - y += extents.height + LINE_SKIP; + /* return to the left border and below text */ + y += LINE_SKIP; + x = rect->x; + } + + if(cache->terrain) { + /* draw cache rating */ + const char *terrain = "Terrain:"; + icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); + cairo_text_extents (cr, _(terrain), &extents); + y += (gdk_pixbuf_get_height(icon) + extents.height)/2; + + /* draw "Terrain:" string */ + cairo_move_to (cr, x, y); + cairo_set_source_rgba (cr, 0, 0, 0, 1); + cairo_show_text (cr, _(terrain)); + cairo_stroke (cr); + x += extents.width + 2; + + /* draw terrain stars */ + cairo_draw_pixbuf(cr, icon, x, y - + (gdk_pixbuf_get_height(icon) + extents.height)/2); + + x += gdk_pixbuf_get_width(icon) + LINE_SKIP; + y -= (gdk_pixbuf_get_height(icon) + extents.height)/2; + } + + if(cache->difficulty) { + const char *difficulty = "Difficulty:"; + cairo_text_extents (cr, _(difficulty), &extents); + y += (gdk_pixbuf_get_height(icon) + extents.height)/2; + + /* draw "Difficulty:" string */ + cairo_move_to (cr, x, y); + cairo_set_source_rgba (cr, 0, 0, 0, 1); + cairo_show_text (cr, _(difficulty)); + cairo_stroke (cr); + x += extents.width + 2; + + icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); + cairo_draw_pixbuf(cr, icon, x, y - + (gdk_pixbuf_get_height(icon) + extents.height)/2); + } } static gboolean