24 |
|
|
25 |
/* |
/* |
26 |
* TODO: |
* TODO: |
|
* - draw caches only once |
|
|
* - prefer duplicates from selected files |
|
27 |
* - make semi-transparent caches selectable |
* - make semi-transparent caches selectable |
28 |
*/ |
*/ |
29 |
|
|
153 |
} |
} |
154 |
|
|
155 |
static void map_draw_cache(GtkWidget *map, cache_t *cache, gboolean semi) { |
static void map_draw_cache(GtkWidget *map, cache_t *cache, gboolean semi) { |
156 |
GdkPixbuf *icon = icon_get(semi?ICON_CACHE_TYPE_SEMI:ICON_CACHE_TYPE, |
int type = semi?ICON_CACHE_TYPE_SEMI:ICON_CACHE_TYPE; |
157 |
cache->type); |
|
158 |
|
GdkPixbuf *icon = icon_get(type, cache->type); |
159 |
|
|
160 |
/* check if there's also an overwritten coordinate */ |
/* check if there's also an overwritten coordinate */ |
161 |
if(cache->notes && cache->notes->override) { |
if(cache->notes && cache->notes->override) { |
162 |
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
GdkPixbuf *over = icon_get(type, 11); |
163 |
|
|
164 |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
osm_gps_map_add_image(OSM_GPS_MAP(map), |
165 |
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
cache->notes->pos.lat, cache->notes->pos.lon, icon); |
492 |
} |
} |
493 |
|
|
494 |
#ifndef BIG_BALLOONS |
#ifndef BIG_BALLOONS |
495 |
#define LINE_SKIP 7 |
#define ICON_SIZE ICON_CACHE_TYPE |
496 |
#else |
#else |
497 |
#define LINE_SKIP 12 |
#define ICON_SIZE ICON_CACHE_TYPE_1_5X |
498 |
#endif |
#endif |
499 |
|
|
500 |
|
#ifndef BIG_BALLOONS |
501 |
|
#define FONT_SIZE 14.0 |
502 |
|
#else |
503 |
|
#define FONT_SIZE 22.0 |
504 |
|
#endif |
505 |
|
#define LINE_SKIP (FONT_SIZE/4) |
506 |
|
|
507 |
|
|
508 |
static void |
static void |
509 |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
balloon_cb(osm_gps_map_balloon_event_t *event, gpointer data) { |
510 |
printf("balloon event: "); |
printf("balloon event: "); |
530 |
gint x = event->data.draw.rect->x, y = event->data.draw.rect->y; |
gint x = event->data.draw.rect->x, y = event->data.draw.rect->y; |
531 |
|
|
532 |
/* draw the cache type icon ... */ |
/* draw the cache type icon ... */ |
533 |
GdkPixbuf *icon = icon_get(ICON_CACHE_TYPE, cache->type); |
GdkPixbuf *icon = icon_get(ICON_SIZE, cache->type); |
534 |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y); |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y); |
535 |
|
|
536 |
if(cache->notes && cache->notes->override) { |
if(cache->notes && cache->notes->override) { |
537 |
GdkPixbuf *over = icon_get(ICON_MISC, 1); |
GdkPixbuf *over = icon_get(ICON_SIZE, 11); |
538 |
cairo_draw_pixbuf(event->data.draw.cr, over, x, y); |
cairo_draw_pixbuf(event->data.draw.cr, over, x, y); |
539 |
} |
} |
540 |
|
|
570 |
x = event->data.draw.rect->x; |
x = event->data.draw.rect->x; |
571 |
|
|
572 |
/* everything from here uses the same font */ |
/* everything from here uses the same font */ |
573 |
cairo_select_font_face (event->data.draw.cr, "Sans", CAIRO_FONT_SLANT_NORMAL, |
cairo_select_font_face (event->data.draw.cr, "Sans", |
574 |
|
CAIRO_FONT_SLANT_NORMAL, |
575 |
CAIRO_FONT_WEIGHT_NORMAL); |
CAIRO_FONT_WEIGHT_NORMAL); |
576 |
#ifndef BIG_BALLOONS |
|
577 |
cairo_set_font_size (event->data.draw.cr, 14.0); |
cairo_set_font_size (event->data.draw.cr, FONT_SIZE); |
|
#else |
|
|
cairo_set_font_size (event->data.draw.cr, 22.0); |
|
|
#endif |
|
578 |
|
|
579 |
if(cache->name) { |
if(cache->name) { |
580 |
/* draw cache name */ |
/* draw cache name */ |
581 |
cairo_text_extents (event->data.draw.cr, cache->name, &extents); |
cairo_text_extents (event->data.draw.cr, cache->name, &extents); |
582 |
y += extents.height; |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing); |
|
cairo_move_to (event->data.draw.cr, x, y); |
|
583 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
584 |
cairo_show_text (event->data.draw.cr, cache->name); |
cairo_show_text (event->data.draw.cr, cache->name); |
585 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
586 |
|
|
587 |
/* return to the left border and below text */ |
/* return to the left border and below text */ |
588 |
y += LINE_SKIP; |
y += LINE_SKIP + FONT_SIZE; |
589 |
x = event->data.draw.rect->x; |
x = event->data.draw.rect->x; |
590 |
} |
} |
591 |
|
|
592 |
if(cache->terrain) { |
if(cache->terrain) { |
593 |
|
int text_y = 0, icon_y = 0; |
594 |
|
|
595 |
/* draw cache rating */ |
/* draw cache rating */ |
596 |
const char *terrain = "Terrain:"; |
const char *terrain = "Terrain:"; |
597 |
icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); |
icon = icon_get(ICON_STARS, (int)(cache->terrain*2-2)); |
598 |
cairo_text_extents (event->data.draw.cr, _(terrain), &extents); |
cairo_text_extents (event->data.draw.cr, _(terrain), &extents); |
599 |
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
600 |
|
if(gdk_pixbuf_get_height(icon) > FONT_SIZE) |
601 |
|
text_y = (gdk_pixbuf_get_height(icon) - FONT_SIZE)/2; |
602 |
|
else |
603 |
|
icon_y = (FONT_SIZE - gdk_pixbuf_get_height(icon))/2; |
604 |
|
|
605 |
/* draw "Terrain:" string */ |
/* draw "Terrain:" string */ |
606 |
cairo_move_to (event->data.draw.cr, x, y); |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing + text_y); |
607 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
608 |
cairo_show_text (event->data.draw.cr, _(terrain)); |
cairo_show_text (event->data.draw.cr, _(terrain)); |
609 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
610 |
x += extents.width + 2; |
x += extents.width + 2; |
611 |
|
|
612 |
/* draw terrain stars */ |
/* draw terrain stars */ |
613 |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y - |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y + icon_y); |
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
|
614 |
|
|
615 |
x += gdk_pixbuf_get_width(icon) + LINE_SKIP; |
x += gdk_pixbuf_get_width(icon) + LINE_SKIP; |
|
y -= (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
616 |
} |
} |
617 |
|
|
618 |
if(cache->difficulty) { |
if(cache->difficulty) { |
619 |
|
int text_y = 0, icon_y = 0; |
620 |
|
|
621 |
const char *difficulty = "Difficulty:"; |
const char *difficulty = "Difficulty:"; |
622 |
|
icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); |
623 |
cairo_text_extents (event->data.draw.cr, _(difficulty), &extents); |
cairo_text_extents (event->data.draw.cr, _(difficulty), &extents); |
|
y += (gdk_pixbuf_get_height(icon) + extents.height)/2; |
|
624 |
|
|
625 |
|
if(gdk_pixbuf_get_height(icon) > FONT_SIZE) |
626 |
|
text_y = (gdk_pixbuf_get_height(icon) - FONT_SIZE)/2; |
627 |
|
else |
628 |
|
icon_y = (FONT_SIZE - gdk_pixbuf_get_height(icon))/2; |
629 |
|
|
630 |
/* draw "Difficulty:" string */ |
/* draw "Difficulty:" string */ |
631 |
cairo_move_to (event->data.draw.cr, x, y); |
cairo_move_to (event->data.draw.cr, x, y - extents.y_bearing + text_y); |
632 |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
cairo_set_source_rgba (event->data.draw.cr, 0, 0, 0, 1); |
633 |
cairo_show_text (event->data.draw.cr, _(difficulty)); |
cairo_show_text (event->data.draw.cr, _(difficulty)); |
634 |
cairo_stroke (event->data.draw.cr); |
cairo_stroke (event->data.draw.cr); |
635 |
x += extents.width + 2; |
x += extents.width + 2; |
636 |
|
|
637 |
icon = icon_get(ICON_STARS, (int)(cache->difficulty*2-2)); |
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y + icon_y); |
|
cairo_draw_pixbuf(event->data.draw.cr, icon, x, y - |
|
|
(gdk_pixbuf_get_height(icon) + extents.height)/2); |
|
638 |
} |
} |
639 |
} else if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK) { |
} else if(event->type == OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK) { |
640 |
printf("click %s event at %d %d\n", |
printf("click %s event at %d %d\n", |