107 |
gpointer data; |
gpointer data; |
108 |
} balloon; |
} balloon; |
109 |
|
|
110 |
|
#ifdef ENABLE_OSD |
111 |
|
//the osd controls |
112 |
|
struct { |
113 |
|
GdkPixmap *backup; |
114 |
|
gint backup_x, backup_y; |
115 |
|
|
116 |
|
|
117 |
|
// GdkPixbuf *pixbuf; |
118 |
|
} osd; |
119 |
|
#endif |
120 |
|
|
121 |
//additional images or tracks added to the map |
//additional images or tracks added to the map |
122 |
GSList *tracks; |
GSList *tracks; |
123 |
GSList *images; |
GSList *images; |
704 |
cairo_close_path (cr); |
cairo_close_path (cr); |
705 |
} |
} |
706 |
|
|
|
/* http://cairographics.org/samples/ */ |
|
707 |
static void |
static void |
708 |
osm_gps_map_draw_balloon_int (OsmGpsMap *map) |
osm_gps_map_draw_balloon_int (OsmGpsMap *map) |
709 |
{ |
{ |
811 |
priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data); |
priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data); |
812 |
} |
} |
813 |
|
|
814 |
|
cairo_destroy(cr); |
815 |
|
|
816 |
gtk_widget_queue_draw_area (GTK_WIDGET(map), |
gtk_widget_queue_draw_area (GTK_WIDGET(map), |
817 |
x0, y0, BALLOON_WIDTH, |
x0, y0, BALLOON_WIDTH, |
818 |
BALLOON_HEIGHT + POINTER_HEIGHT); |
BALLOON_HEIGHT + POINTER_HEIGHT); |
1407 |
g_hash_table_foreach_remove(priv->tile_cache, osm_gps_map_purge_cache_check, priv); |
g_hash_table_foreach_remove(priv->tile_cache, osm_gps_map_purge_cache_check, priv); |
1408 |
} |
} |
1409 |
|
|
1410 |
|
#ifdef ENABLE_OSD |
1411 |
|
/* position and extent of bounding box */ |
1412 |
|
#define OSD_X (10) |
1413 |
|
#define OSD_Y (10) |
1414 |
|
#define OSD_W (80+5) |
1415 |
|
#define OSD_H (120+5) |
1416 |
|
|
1417 |
|
static void |
1418 |
|
osm_gps_map_draw_osd_controls (OsmGpsMap *map, gint xoffset, gint yoffset) |
1419 |
|
{ |
1420 |
|
/* xyz */ |
1421 |
|
OsmGpsMapPrivate *priv = map->priv; |
1422 |
|
|
1423 |
|
/* backup previous contents */ |
1424 |
|
if(!priv->osd.backup) |
1425 |
|
priv->osd.backup = gdk_pixmap_new(priv->pixmap, OSD_W, OSD_H, -1); |
1426 |
|
|
1427 |
|
gint x = OSD_X + EXTRA_BORDER + xoffset; |
1428 |
|
gint y = OSD_Y + EXTRA_BORDER + yoffset; |
1429 |
|
|
1430 |
|
/* create backup of background */ |
1431 |
|
gdk_draw_drawable(priv->osd.backup, |
1432 |
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
1433 |
|
priv->pixmap, x, y, 0, 0, OSD_W, OSD_H); |
1434 |
|
priv->osd.backup_x = x; |
1435 |
|
priv->osd.backup_y = y; |
1436 |
|
|
1437 |
|
#if 0 |
1438 |
|
/* create pixbuf for osd */ |
1439 |
|
if(!priv->osd.pixbuf) |
1440 |
|
priv->osd.pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, |
1441 |
|
TRUE, 8, OSD_W, OSD_H); |
1442 |
|
cairo_surface_t *surface = |
1443 |
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H); |
1444 |
|
|
1445 |
|
/* fill with transparency */ |
1446 |
|
{ |
1447 |
|
cairo_t *cr = cairo_create(surface); |
1448 |
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
1449 |
|
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
1450 |
|
cairo_paint(cr); |
1451 |
|
cairo_destroy(cr); |
1452 |
|
} |
1453 |
|
#endif |
1454 |
|
|
1455 |
|
|
1456 |
|
#ifdef USE_CAIRO |
1457 |
|
// cairo_t *cr = cairo_create(surface); |
1458 |
|
cairo_t *cr = gdk_cairo_create(priv->pixmap); |
1459 |
|
|
1460 |
|
#define RAD 40 |
1461 |
|
#define TIP 35 |
1462 |
|
#define LEN 15 |
1463 |
|
#define WID 15 |
1464 |
|
|
1465 |
|
/* --------- the direction "pad" shape and shadow ----------- */ |
1466 |
|
cairo_arc (cr, x+RAD+5, y+RAD+5, RAD, 0, 2 * M_PI); |
1467 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
1468 |
|
cairo_fill (cr); |
1469 |
|
cairo_stroke (cr); |
1470 |
|
|
1471 |
|
cairo_arc (cr, x+RAD, y+RAD, RAD, 0, 2 * M_PI); |
1472 |
|
cairo_set_source_rgb (cr, 1, 1, 1); |
1473 |
|
cairo_fill_preserve (cr); |
1474 |
|
cairo_set_source_rgb (cr, 0.6, 0.6, 1); |
1475 |
|
cairo_set_line_width (cr, 1); |
1476 |
|
cairo_stroke (cr); |
1477 |
|
|
1478 |
|
/* ---------- the zoom pad shape and shadow -------------- */ |
1479 |
|
cairo_move_to (cr, x, y+2*RAD); |
1480 |
|
cairo_line_to (cr, x+2*RAD-10, y+2*RAD); |
1481 |
|
cairo_curve_to (cr, x+2*RAD, y+2*RAD, |
1482 |
|
x+2*RAD, y+3*RAD, |
1483 |
|
x+2*RAD-10, y+3*RAD); |
1484 |
|
cairo_close_path (cr); |
1485 |
|
|
1486 |
|
|
1487 |
|
cairo_set_source_rgba (cr, 1, 1, 1, 1.0); |
1488 |
|
cairo_fill (cr); |
1489 |
|
cairo_stroke (cr); |
1490 |
|
|
1491 |
|
|
1492 |
|
/* left arrow/triangle */ |
1493 |
|
cairo_move_to (cr, x+RAD-TIP, y+RAD); |
1494 |
|
cairo_rel_line_to (cr, +LEN, -WID/2); |
1495 |
|
cairo_rel_line_to (cr, 0, +WID); |
1496 |
|
cairo_rel_line_to (cr, -LEN, -WID/2); |
1497 |
|
cairo_close_path (cr); |
1498 |
|
|
1499 |
|
/* right arrow/triangle */ |
1500 |
|
cairo_move_to (cr, x+RAD+TIP, y+RAD); |
1501 |
|
cairo_rel_line_to (cr, -LEN, -WID/2); |
1502 |
|
cairo_rel_line_to (cr, 0, +WID); |
1503 |
|
cairo_rel_line_to (cr, +LEN, -WID/2); |
1504 |
|
cairo_close_path (cr); |
1505 |
|
|
1506 |
|
/* top arrow/triangle */ |
1507 |
|
cairo_move_to (cr, x+RAD, y+RAD-TIP); |
1508 |
|
cairo_rel_line_to (cr, -WID/2, +LEN); |
1509 |
|
cairo_rel_line_to (cr, +WID, 0); |
1510 |
|
cairo_rel_line_to (cr, -WID/2, -LEN); |
1511 |
|
cairo_close_path (cr); |
1512 |
|
|
1513 |
|
/* bottom arrow/triangle */ |
1514 |
|
cairo_move_to (cr, x+RAD, y+RAD+TIP); |
1515 |
|
cairo_rel_line_to (cr, -WID/2, -LEN); |
1516 |
|
cairo_rel_line_to (cr, +WID, 0); |
1517 |
|
cairo_rel_line_to (cr, -WID/2, +LEN); |
1518 |
|
cairo_close_path (cr); |
1519 |
|
|
1520 |
|
cairo_set_source_rgb (cr, 0.6, 0.6, 1); |
1521 |
|
cairo_fill_preserve (cr); |
1522 |
|
cairo_set_line_width (cr, 0); |
1523 |
|
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
1524 |
|
cairo_stroke (cr); |
1525 |
|
|
1526 |
|
|
1527 |
|
cairo_destroy(cr); |
1528 |
|
|
1529 |
|
#else |
1530 |
|
#warning "OSD control display lacks a non-cairo implementation!" |
1531 |
|
#endif |
1532 |
|
} |
1533 |
|
|
1534 |
|
static void |
1535 |
|
osm_gps_map_osd_restore (OsmGpsMap *map) |
1536 |
|
{ |
1537 |
|
OsmGpsMapPrivate *priv = map->priv; |
1538 |
|
|
1539 |
|
/* restore backup of previous contents */ |
1540 |
|
if(priv->osd.backup) { |
1541 |
|
/* create backup of background */ |
1542 |
|
gdk_draw_drawable(priv->pixmap, |
1543 |
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
1544 |
|
priv->osd.backup, 0, 0, |
1545 |
|
priv->osd.backup_x, priv->osd.backup_y, OSD_W, OSD_H); |
1546 |
|
} |
1547 |
|
} |
1548 |
|
|
1549 |
|
#endif |
1550 |
|
|
1551 |
static gboolean |
static gboolean |
1552 |
osm_gps_map_map_redraw (OsmGpsMap *map) |
osm_gps_map_map_redraw (OsmGpsMap *map) |
1553 |
{ |
{ |
1579 |
osm_gps_map_draw_gps_point(map); |
osm_gps_map_draw_gps_point(map); |
1580 |
osm_gps_map_print_images(map); |
osm_gps_map_print_images(map); |
1581 |
osm_gps_map_draw_balloon_int(map); |
osm_gps_map_draw_balloon_int(map); |
1582 |
|
#ifdef ENABLE_OSD |
1583 |
|
osm_gps_map_draw_osd_controls(map, 0, 0); |
1584 |
|
#endif |
1585 |
|
|
1586 |
//osm_gps_map_osd_speed(map, 1.5); |
//osm_gps_map_osd_speed(map, 1.5); |
1587 |
osm_gps_map_purge_cache(map); |
osm_gps_map_purge_cache(map); |
1617 |
priv->balloon.valid = FALSE; |
priv->balloon.valid = FALSE; |
1618 |
priv->balloon.cb = NULL; |
priv->balloon.cb = NULL; |
1619 |
|
|
1620 |
|
#ifdef ENABLE_OSD |
1621 |
|
priv->osd.backup = NULL; |
1622 |
|
#endif |
1623 |
|
|
1624 |
priv->tracks = NULL; |
priv->tracks = NULL; |
1625 |
priv->images = NULL; |
priv->images = NULL; |
1626 |
|
|
1781 |
g_free(priv->gps); |
g_free(priv->gps); |
1782 |
g_free(priv->balloon.coo); |
g_free(priv->balloon.coo); |
1783 |
|
|
1784 |
|
#ifdef ENABLE_OSD |
1785 |
|
if (priv->osd.backup) |
1786 |
|
g_object_unref(priv->osd.backup); |
1787 |
|
#endif |
1788 |
|
|
1789 |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
1790 |
} |
} |
1791 |
|
|
2097 |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
2098 |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
2099 |
|
|
2100 |
|
#ifdef ENABLE_OSD |
2101 |
|
/* undo OSD */ |
2102 |
|
osm_gps_map_osd_restore (OSM_GPS_MAP(widget)); |
2103 |
|
|
2104 |
|
/* draw new OSD */ |
2105 |
|
osm_gps_map_draw_osd_controls (OSM_GPS_MAP(widget), |
2106 |
|
-priv->drag_mouse_dx, |
2107 |
|
-priv->drag_mouse_dy); |
2108 |
|
#endif |
2109 |
|
|
2110 |
gdk_draw_drawable ( |
gdk_draw_drawable ( |
2111 |
widget->window, |
widget->window, |
2112 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2200 |
event->area.x, event->area.y, |
event->area.x, event->area.y, |
2201 |
event->area.width, event->area.height); |
event->area.width, event->area.height); |
2202 |
|
|
2203 |
|
#ifdef ENABLE_OSD_OVL |
2204 |
|
/* TODO: intersect with area */ |
2205 |
|
if (priv->osd.pixbuf) |
2206 |
|
{ |
2207 |
|
// gdk_draw_drawable (widget->window, |
2208 |
|
// widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2209 |
|
// priv->osd.pixbuf, 0, 0, |
2210 |
|
// OSD_X, OSD_Y, OSD_W, OSD_H); |
2211 |
|
} |
2212 |
|
#endif |
2213 |
|
|
2214 |
return FALSE; |
return FALSE; |
2215 |
} |
} |
2216 |
|
|