98 |
coord_t *gps; |
coord_t *gps; |
99 |
gboolean gps_valid; |
gboolean gps_valid; |
100 |
|
|
101 |
|
#ifdef ENABLE_BALLOON |
102 |
//a balloon with additional info |
//a balloon with additional info |
103 |
struct { |
struct { |
104 |
coord_t *coo; |
coord_t *coo; |
107 |
OsmGpsMapBalloonCallback cb; |
OsmGpsMapBalloonCallback cb; |
108 |
gpointer data; |
gpointer data; |
109 |
} balloon; |
} balloon; |
110 |
|
#endif |
111 |
|
|
112 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
113 |
//the osd controls |
//the osd controls (if present) |
114 |
struct { |
osm_gps_map_osd_t *osd; |
|
GdkPixmap *backup; |
|
|
gint backup_x, backup_y; |
|
|
// GdkPixbuf *pixbuf; |
|
|
} osd; |
|
115 |
#endif |
#endif |
116 |
|
|
117 |
//additional images or tracks added to the map |
//additional images or tracks added to the map |
118 |
GSList *tracks; |
GSList *tracks; |
119 |
GSList *images; |
GSList *images; |
649 |
} |
} |
650 |
} |
} |
651 |
|
|
652 |
|
#ifdef ENABLE_BALLOON |
653 |
/* most visual effects are hardcoded by now, but may be made */ |
/* most visual effects are hardcoded by now, but may be made */ |
654 |
/* available via properties later */ |
/* available via properties later */ |
655 |
|
#ifndef BALLOON_AREA_WIDTH |
656 |
#define BALLOON_AREA_WIDTH 290 |
#define BALLOON_AREA_WIDTH 290 |
657 |
|
#endif |
658 |
|
#ifndef BALLOON_AREA_HEIGHT |
659 |
#define BALLOON_AREA_HEIGHT 75 |
#define BALLOON_AREA_HEIGHT 75 |
660 |
|
#endif |
661 |
|
#ifndef BALLOON_CORNER_RADIUS |
662 |
|
#define BALLOON_CORNER_RADIUS 10 |
663 |
|
#endif |
664 |
|
|
665 |
#define BALLOON_CORNER_RADIUS 20 |
#define BALLOON_BORDER (BALLOON_CORNER_RADIUS/2) |
|
#define BALLOON_BORDER (BALLOON_CORNER_RADIUS/4) |
|
666 |
#define BALLOON_WIDTH (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER) |
#define BALLOON_WIDTH (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER) |
667 |
#define BALLOON_HEIGHT (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER) |
#define BALLOON_HEIGHT (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER) |
668 |
#define BALLOON_TRANSPARENCY 0.8 |
#define BALLOON_TRANSPARENCY 0.8 |
669 |
#define POINTER_HEIGHT 20 |
#define POINTER_HEIGHT 20 |
670 |
#define POINTER_FOOT_WIDTH 20 |
#define POINTER_FOOT_WIDTH 20 |
671 |
#define POINTER_OFFSET (BALLOON_CORNER_RADIUS*3/4) |
#define POINTER_OFFSET (BALLOON_CORNER_RADIUS*3/4) |
672 |
#define BALLOON_SHADOW 5 |
#define BALLOON_SHADOW (BALLOON_CORNER_RADIUS/2) |
673 |
#define BALLOON_SHADOW_TRANSPARENCY 0.2 |
#define BALLOON_SHADOW_TRANSPARENCY 0.2 |
674 |
|
|
675 |
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS/3) |
#define CLOSE_BUTTON_RADIUS (BALLOON_CORNER_RADIUS) |
676 |
|
|
677 |
|
|
678 |
/* draw the bubble shape. this is used twice, once for the shape and once */ |
/* draw the bubble shape. this is used twice, once for the shape and once */ |
682 |
gboolean bottom, int px, int py, int px0, int px1) { |
gboolean bottom, int px, int py, int px0, int px1) { |
683 |
|
|
684 |
cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS); |
cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS); |
685 |
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + BALLOON_CORNER_RADIUS, y0); |
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
686 |
|
BALLOON_CORNER_RADIUS, -M_PI, -M_PI/2); |
687 |
if(!bottom) { |
if(!bottom) { |
688 |
/* insert top pointer */ |
/* insert top pointer */ |
689 |
cairo_line_to (cr, px1, y0); |
cairo_line_to (cr, px1, y0); |
692 |
} |
} |
693 |
|
|
694 |
cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0); |
cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0); |
695 |
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + BALLOON_CORNER_RADIUS); |
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y0 + BALLOON_CORNER_RADIUS, |
696 |
|
BALLOON_CORNER_RADIUS, -M_PI/2, 0); |
697 |
cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS); |
cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS); |
698 |
cairo_curve_to (cr, x1, y1, x1, y1, x1 - BALLOON_CORNER_RADIUS, y1); |
cairo_arc (cr, x1 - BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
699 |
|
BALLOON_CORNER_RADIUS, 0, M_PI/2); |
700 |
if(bottom) { |
if(bottom) { |
701 |
/* insert bottom pointer */ |
/* insert bottom pointer */ |
702 |
cairo_line_to (cr, px0, y1); |
cairo_line_to (cr, px0, y1); |
705 |
} |
} |
706 |
|
|
707 |
cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1); |
cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1); |
708 |
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - BALLOON_CORNER_RADIUS); |
cairo_arc (cr, x0 + BALLOON_CORNER_RADIUS, y1 - BALLOON_CORNER_RADIUS, |
709 |
|
BALLOON_CORNER_RADIUS, M_PI/2, M_PI); |
710 |
|
|
711 |
cairo_close_path (cr); |
cairo_close_path (cr); |
712 |
} |
} |
797 |
cairo_stroke(cr); |
cairo_stroke(cr); |
798 |
|
|
799 |
cairo_set_source_rgba (cr, 1, 1, 1, 1.0); |
cairo_set_source_rgba (cr, 1, 1, 1, 1.0); |
800 |
cairo_set_line_width (cr, 3); |
cairo_set_line_width (cr, BALLOON_CORNER_RADIUS/3.3); |
801 |
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); |
802 |
cairo_move_to (cr, cx - crad/2, cy - crad/2); |
cairo_move_to (cr, cx - crad/2, cy - crad/2); |
803 |
cairo_line_to (cr, cx + crad/2, cy + crad/2); |
cairo_line_to (cr, cx + crad/2, cy + crad/2); |
859 |
(y > priv->balloon.rect.y) && |
(y > priv->balloon.rect.y) && |
860 |
(y < priv->balloon.rect.y + priv->balloon.rect.h)); |
(y < priv->balloon.rect.y + priv->balloon.rect.h)); |
861 |
} |
} |
862 |
|
#endif // ENABLE_BALLOON |
863 |
|
|
864 |
static void |
static void |
865 |
osm_gps_map_blit_tile(OsmGpsMap *map, GdkPixbuf *pixbuf, int offset_x, int offset_y) |
osm_gps_map_blit_tile(OsmGpsMap *map, GdkPixbuf *pixbuf, int offset_x, int offset_y) |
1417 |
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); |
1418 |
} |
} |
1419 |
|
|
|
#ifdef ENABLE_OSD |
|
|
/* position and extent of bounding box */ |
|
|
#define OSD_X (10) |
|
|
#define OSD_Y (10) |
|
|
#define OSD_W (80+5) |
|
|
#define OSD_H (120+5) |
|
|
|
|
|
static void |
|
|
osm_gps_map_draw_osd_controls (OsmGpsMap *map, gint xoffset, gint yoffset) |
|
|
{ |
|
|
/* xyz */ |
|
|
OsmGpsMapPrivate *priv = map->priv; |
|
|
|
|
|
/* backup previous contents */ |
|
|
if(!priv->osd.backup) |
|
|
priv->osd.backup = gdk_pixmap_new(priv->pixmap, OSD_W+2, OSD_H+2, -1); |
|
|
|
|
|
gint x = OSD_X + EXTRA_BORDER + xoffset; |
|
|
gint y = OSD_Y + EXTRA_BORDER + yoffset; |
|
|
|
|
|
/* create backup of background */ |
|
|
gdk_draw_drawable(priv->osd.backup, |
|
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
|
|
priv->pixmap, x-1, y-1, 0, 0, OSD_W+2, OSD_H+2); |
|
|
priv->osd.backup_x = x-1; |
|
|
priv->osd.backup_y = y-1; |
|
|
|
|
|
#if 0 |
|
|
/* create pixbuf for osd */ |
|
|
if(!priv->osd.pixbuf) |
|
|
priv->osd.pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, |
|
|
TRUE, 8, OSD_W, OSD_H); |
|
|
cairo_surface_t *surface = |
|
|
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, OSD_W, OSD_H); |
|
|
|
|
|
/* fill with transparency */ |
|
|
{ |
|
|
cairo_t *cr = cairo_create(surface); |
|
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
|
|
cairo_set_source_rgba(cr, 1.0, 0.0, 0.0, 0.0); |
|
|
cairo_paint(cr); |
|
|
cairo_destroy(cr); |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
|
#ifdef USE_CAIRO |
|
|
// cairo_t *cr = cairo_create(surface); |
|
|
cairo_t *cr = gdk_cairo_create(priv->pixmap); |
|
|
|
|
|
#define RAD 40 |
|
|
#define TIP 35 |
|
|
#define LEN 15 |
|
|
#define WID 15 |
|
|
|
|
|
#define Z_STEP -5 |
|
|
#define Z_RAD 15 |
|
|
#define Z_TOP 2*RAD+Z_STEP |
|
|
#define Z_MID Z_TOP+Z_RAD |
|
|
#define Z_BOT Z_MID+Z_RAD |
|
|
#define Z_LEFT Z_RAD |
|
|
#define Z_RIGHT 2*RAD-Z_RAD |
|
|
|
|
|
/* --------- the direction "pad" shape and shadow ----------- */ |
|
|
|
|
|
cairo_move_to (cr, x+Z_LEFT+5, y+Z_TOP+5); |
|
|
cairo_line_to (cr, x+Z_RIGHT+5, y+Z_TOP+5); |
|
|
cairo_arc (cr, x+Z_RIGHT+5, y+Z_MID+5, Z_RAD, -M_PI/2, M_PI/2); |
|
|
cairo_line_to (cr, x+Z_LEFT+5, y+Z_BOT+5); |
|
|
cairo_arc (cr, x+Z_LEFT+5, y+Z_MID+5, Z_RAD, M_PI/2, -M_PI/2); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
|
|
cairo_fill (cr); |
|
|
cairo_stroke (cr); |
|
|
|
|
|
cairo_arc (cr, x+RAD+5, y+RAD+5, RAD, 0, 2 * M_PI); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
cairo_set_source_rgba (cr, 0, 0, 0, 0.2); |
|
|
cairo_fill (cr); |
|
|
cairo_stroke (cr); |
|
|
|
|
|
|
|
|
cairo_move_to (cr, x+Z_LEFT, y+Z_TOP); |
|
|
cairo_line_to (cr, x+Z_RIGHT, y+Z_TOP); |
|
|
cairo_arc (cr, x+Z_RIGHT, y+Z_MID, Z_RAD, -M_PI/2, M_PI/2); |
|
|
cairo_line_to (cr, x+Z_LEFT, y+Z_BOT); |
|
|
cairo_arc (cr, x+Z_LEFT, y+Z_MID, Z_RAD, M_PI/2, -M_PI/2); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1); |
|
|
cairo_fill_preserve (cr); |
|
|
cairo_set_source_rgb (cr, 0.6, 0.6, 1); |
|
|
cairo_set_line_width (cr, 1); |
|
|
cairo_stroke (cr); |
|
|
|
|
|
cairo_arc (cr, x+RAD, y+RAD, RAD, 0, 2 * M_PI); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1); |
|
|
cairo_fill_preserve (cr); |
|
|
cairo_set_source_rgb (cr, 0.6, 0.6, 1); |
|
|
cairo_set_line_width (cr, 1); |
|
|
cairo_stroke (cr); |
|
|
|
|
|
/* ---------- the zoom pad shape and shadow -------------- */ |
|
|
|
|
|
|
|
|
|
|
|
/* left arrow/triangle */ |
|
|
cairo_move_to (cr, x+RAD-TIP, y+RAD); |
|
|
cairo_rel_line_to (cr, +LEN, -WID/2); |
|
|
cairo_rel_line_to (cr, 0, +WID); |
|
|
cairo_rel_line_to (cr, -LEN, -WID/2); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
/* right arrow/triangle */ |
|
|
cairo_move_to (cr, x+RAD+TIP, y+RAD); |
|
|
cairo_rel_line_to (cr, -LEN, -WID/2); |
|
|
cairo_rel_line_to (cr, 0, +WID); |
|
|
cairo_rel_line_to (cr, +LEN, -WID/2); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
/* top arrow/triangle */ |
|
|
cairo_move_to (cr, x+RAD, y+RAD-TIP); |
|
|
cairo_rel_line_to (cr, -WID/2, +LEN); |
|
|
cairo_rel_line_to (cr, +WID, 0); |
|
|
cairo_rel_line_to (cr, -WID/2, -LEN); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
/* bottom arrow/triangle */ |
|
|
cairo_move_to (cr, x+RAD, y+RAD+TIP); |
|
|
cairo_rel_line_to (cr, -WID/2, -LEN); |
|
|
cairo_rel_line_to (cr, +WID, 0); |
|
|
cairo_rel_line_to (cr, -WID/2, +LEN); |
|
|
cairo_close_path (cr); |
|
|
|
|
|
cairo_set_source_rgb (cr, 0.6, 0.6, 1); |
|
|
cairo_fill_preserve (cr); |
|
|
cairo_set_line_width (cr, 0); |
|
|
cairo_set_source_rgba (cr, 0, 0, 0, 1); |
|
|
cairo_stroke (cr); |
|
|
|
|
|
|
|
|
cairo_destroy(cr); |
|
|
|
|
|
#else |
|
|
#warning "OSD control display lacks a non-cairo implementation!" |
|
|
#endif |
|
|
} |
|
|
|
|
|
static void |
|
|
osm_gps_map_osd_restore (OsmGpsMap *map) |
|
|
{ |
|
|
OsmGpsMapPrivate *priv = map->priv; |
|
|
|
|
|
/* restore backup of previous contents */ |
|
|
if(priv->osd.backup) { |
|
|
/* create backup of background */ |
|
|
gdk_draw_drawable(priv->pixmap, |
|
|
GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))], |
|
|
priv->osd.backup, 0, 0, |
|
|
priv->osd.backup_x, priv->osd.backup_y, OSD_W+2, OSD_H+2); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
1420 |
static gboolean |
static gboolean |
1421 |
osm_gps_map_map_redraw (OsmGpsMap *map) |
osm_gps_map_map_redraw (OsmGpsMap *map) |
1422 |
{ |
{ |
1447 |
osm_gps_map_print_tracks(map); |
osm_gps_map_print_tracks(map); |
1448 |
osm_gps_map_draw_gps_point(map); |
osm_gps_map_draw_gps_point(map); |
1449 |
osm_gps_map_print_images(map); |
osm_gps_map_print_images(map); |
1450 |
|
#ifdef ENABLE_BALLOON |
1451 |
osm_gps_map_draw_balloon_int(map); |
osm_gps_map_draw_balloon_int(map); |
1452 |
|
#endif |
1453 |
|
|
1454 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1455 |
osm_gps_map_draw_osd_controls(map, 0, 0); |
if(priv->osd) |
1456 |
|
priv->osd->draw(priv->osd, EXTRA_BORDER, EXTRA_BORDER); |
1457 |
#endif |
#endif |
1458 |
|
|
1459 |
//osm_gps_map_osd_speed(map, 1.5); |
//osm_gps_map_osd_speed(map, 1.5); |
1486 |
priv->gps = g_new0(coord_t, 1); |
priv->gps = g_new0(coord_t, 1); |
1487 |
priv->gps_valid = FALSE; |
priv->gps_valid = FALSE; |
1488 |
|
|
1489 |
|
#ifdef ENABLE_BALLOON |
1490 |
priv->balloon.coo = g_new0(coord_t, 1); |
priv->balloon.coo = g_new0(coord_t, 1); |
1491 |
priv->balloon.valid = FALSE; |
priv->balloon.valid = FALSE; |
1492 |
priv->balloon.cb = NULL; |
priv->balloon.cb = NULL; |
1493 |
|
#endif |
1494 |
|
|
1495 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1496 |
priv->osd.backup = NULL; |
priv->osd = NULL; |
1497 |
#endif |
#endif |
1498 |
|
|
1499 |
priv->tracks = NULL; |
priv->tracks = NULL; |
1654 |
g_source_remove (priv->idle_map_redraw); |
g_source_remove (priv->idle_map_redraw); |
1655 |
|
|
1656 |
g_free(priv->gps); |
g_free(priv->gps); |
1657 |
|
|
1658 |
|
#ifdef ENABLE_BALLOON |
1659 |
g_free(priv->balloon.coo); |
g_free(priv->balloon.coo); |
1660 |
|
#endif |
1661 |
|
|
1662 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1663 |
if (priv->osd.backup) |
if(priv->osd) |
1664 |
g_object_unref(priv->osd.backup); |
priv->osd->free(priv->osd); |
1665 |
#endif |
#endif |
1666 |
|
|
1667 |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object); |
1879 |
{ |
{ |
1880 |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
1881 |
|
|
1882 |
|
#ifdef ENABLE_BALLOON |
1883 |
/* don't drag if the user clicked within the balloon */ |
/* don't drag if the user clicked within the balloon */ |
1884 |
if (osm_gps_map_in_balloon(priv, |
if (osm_gps_map_in_balloon(priv, |
1885 |
event->x + EXTRA_BORDER, |
event->x + EXTRA_BORDER, |
1888 |
priv->drag_counter = -1; |
priv->drag_counter = -1; |
1889 |
return FALSE; |
return FALSE; |
1890 |
} |
} |
1891 |
|
#endif |
1892 |
|
|
1893 |
|
#ifdef ENABLE_OSD |
1894 |
|
#define SCROLL_STEP 10 |
1895 |
|
|
1896 |
|
/* pressed inside OSD control? */ |
1897 |
|
if(priv->osd) { |
1898 |
|
osd_button_t but = priv->osd->check(event->x, event->y); |
1899 |
|
if(but != OSD_NONE) |
1900 |
|
{ |
1901 |
|
priv->drag_counter = -1; |
1902 |
|
|
1903 |
|
switch(but) { |
1904 |
|
case OSD_UP: |
1905 |
|
priv->map_y -= GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; |
1906 |
|
priv->center_coord_set = FALSE; |
1907 |
|
break; |
1908 |
|
|
1909 |
|
case OSD_DOWN: |
1910 |
|
priv->map_y += GTK_WIDGET(widget)->allocation.height/SCROLL_STEP; |
1911 |
|
priv->center_coord_set = FALSE; |
1912 |
|
break; |
1913 |
|
|
1914 |
|
case OSD_LEFT: |
1915 |
|
priv->map_x -= GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; |
1916 |
|
priv->center_coord_set = FALSE; |
1917 |
|
break; |
1918 |
|
|
1919 |
|
case OSD_RIGHT: |
1920 |
|
priv->map_x += GTK_WIDGET(widget)->allocation.width/SCROLL_STEP; |
1921 |
|
priv->center_coord_set = FALSE; |
1922 |
|
break; |
1923 |
|
|
1924 |
|
case OSD_IN: |
1925 |
|
osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom+1); |
1926 |
|
break; |
1927 |
|
|
1928 |
|
case OSD_OUT: |
1929 |
|
osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom-1); |
1930 |
|
break; |
1931 |
|
|
1932 |
|
default: |
1933 |
|
/* all custom buttons are forwarded to the application */ |
1934 |
|
if(priv->osd->cb) |
1935 |
|
priv->osd->cb(but, priv->osd->data); |
1936 |
|
break; |
1937 |
|
} |
1938 |
|
|
1939 |
|
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
1940 |
|
|
1941 |
|
return FALSE; |
1942 |
|
} |
1943 |
|
} |
1944 |
|
#endif |
1945 |
|
|
1946 |
priv->drag_counter = 0; |
priv->drag_counter = 0; |
1947 |
priv->drag_start_mouse_x = (int) event->x; |
priv->drag_start_mouse_x = (int) event->x; |
1957 |
{ |
{ |
1958 |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
1959 |
|
|
1960 |
|
#ifdef ENABLE_BALLOON |
1961 |
/* released inside the balloon? */ |
/* released inside the balloon? */ |
1962 |
if (osm_gps_map_in_balloon(priv, |
if (osm_gps_map_in_balloon(priv, |
1963 |
event->x + EXTRA_BORDER, |
event->x + EXTRA_BORDER, |
1966 |
osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget), |
osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget), |
1967 |
event->x - priv->balloon.rect.x + EXTRA_BORDER, |
event->x - priv->balloon.rect.x + EXTRA_BORDER, |
1968 |
event->y - priv->balloon.rect.y + EXTRA_BORDER); |
event->y - priv->balloon.rect.y + EXTRA_BORDER); |
|
return FALSE; |
|
1969 |
} |
} |
1970 |
|
#endif |
|
if (priv->drag_counter < 0) |
|
|
return FALSE; |
|
1971 |
|
|
1972 |
if (priv->dragging) |
if (priv->dragging) |
1973 |
{ |
{ |
1992 |
} |
} |
1993 |
|
|
1994 |
static gboolean |
static gboolean |
1995 |
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
1996 |
|
|
1997 |
|
static gboolean |
1998 |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
1999 |
{ |
{ |
2000 |
int x, y; |
int x, y; |
2023 |
if (priv->drag_counter < 6) |
if (priv->drag_counter < 6) |
2024 |
return FALSE; |
return FALSE; |
2025 |
|
|
2026 |
|
#ifdef USE_MAEMO |
2027 |
|
/* reduce update frequency on maemo to keep screen update fluid */ |
2028 |
|
static guint32 last_time = 0; |
2029 |
|
|
2030 |
|
if(event->time - last_time < 100) return FALSE; |
2031 |
|
last_time = event->time; |
2032 |
|
#endif |
2033 |
|
|
2034 |
priv->dragging = TRUE; |
priv->dragging = TRUE; |
2035 |
|
|
2036 |
if (priv->map_auto_center) |
if (priv->map_auto_center) |
2040 |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
2041 |
|
|
2042 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
2043 |
/* undo OSD */ |
if(priv->osd) { |
2044 |
osm_gps_map_osd_restore (OSM_GPS_MAP(widget)); |
/* undo OSD */ |
2045 |
|
priv->osd->restore (priv->osd); |
2046 |
|
|
2047 |
|
/* draw new OSD */ |
2048 |
|
priv->osd->draw (priv->osd, |
2049 |
|
EXTRA_BORDER - priv->drag_mouse_dx, |
2050 |
|
EXTRA_BORDER - priv->drag_mouse_dy); |
2051 |
|
} |
2052 |
|
#endif |
2053 |
|
|
2054 |
|
osm_gps_map_expose (widget, NULL); |
2055 |
|
|
2056 |
|
|
2057 |
|
return FALSE; |
2058 |
|
} |
2059 |
|
|
2060 |
|
static gboolean |
2061 |
|
osm_gps_map_configure (GtkWidget *widget, GdkEventConfigure *event) |
2062 |
|
{ |
2063 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2064 |
|
|
2065 |
/* draw new OSD */ |
/* create pixmap */ |
2066 |
osm_gps_map_draw_osd_controls (OSM_GPS_MAP(widget), |
if (priv->pixmap) |
2067 |
-priv->drag_mouse_dx, |
g_object_unref (priv->pixmap); |
2068 |
-priv->drag_mouse_dy); |
|
2069 |
|
priv->pixmap = gdk_pixmap_new ( |
2070 |
|
widget->window, |
2071 |
|
widget->allocation.width + EXTRA_BORDER * 2, |
2072 |
|
widget->allocation.height + EXTRA_BORDER * 2, |
2073 |
|
-1); |
2074 |
|
|
2075 |
|
#ifdef ENABLE_OSD |
2076 |
|
/* the osd needs some references to map internal objects */ |
2077 |
|
if(priv->osd) |
2078 |
|
{ |
2079 |
|
priv->osd->pixmap = priv->pixmap; |
2080 |
|
priv->osd->widget = widget; |
2081 |
|
} |
2082 |
#endif |
#endif |
2083 |
|
|
2084 |
|
/* and gc, used for clipping (I think......) */ |
2085 |
|
if(priv->gc_map) |
2086 |
|
g_object_unref(priv->gc_map); |
2087 |
|
|
2088 |
|
priv->gc_map = gdk_gc_new(priv->pixmap); |
2089 |
|
|
2090 |
|
osm_gps_map_map_redraw(OSM_GPS_MAP(widget)); |
2091 |
|
|
2092 |
|
return FALSE; |
2093 |
|
} |
2094 |
|
|
2095 |
|
static gboolean |
2096 |
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event) |
2097 |
|
{ |
2098 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
2099 |
|
|
2100 |
gdk_draw_drawable ( |
gdk_draw_drawable ( |
2101 |
widget->window, |
widget->window, |
2102 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2103 |
priv->pixmap, |
priv->pixmap, |
2104 |
0,0, |
0,0, |
2105 |
priv->drag_mouse_dx - EXTRA_BORDER, priv->drag_mouse_dy - EXTRA_BORDER, |
priv->drag_mouse_dx - EXTRA_BORDER, |
2106 |
|
priv->drag_mouse_dy - EXTRA_BORDER, |
2107 |
-1,-1); |
-1,-1); |
2108 |
|
|
2109 |
//Paint white outside of the map if dragging. Its less |
//Paint white outside of the map if dragging. Its less |
2147 |
widget->allocation.width, |
widget->allocation.width, |
2148 |
-priv->drag_mouse_dy - EXTRA_BORDER); |
-priv->drag_mouse_dy - EXTRA_BORDER); |
2149 |
} |
} |
2150 |
|
#if 0 |
2151 |
return FALSE; |
if(!priv->dragging) |
2152 |
} |
gdk_draw_drawable ( |
|
|
|
|
static gboolean |
|
|
osm_gps_map_configure (GtkWidget *widget, GdkEventConfigure *event) |
|
|
{ |
|
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
|
|
|
|
|
/* create pixmap */ |
|
|
if (priv->pixmap) |
|
|
g_object_unref (priv->pixmap); |
|
|
|
|
|
priv->pixmap = gdk_pixmap_new ( |
|
|
widget->window, |
|
|
widget->allocation.width + EXTRA_BORDER * 2, |
|
|
widget->allocation.height + EXTRA_BORDER * 2, |
|
|
-1); |
|
|
|
|
|
/* and gc, used for clipping (I think......) */ |
|
|
if(priv->gc_map) |
|
|
g_object_unref(priv->gc_map); |
|
|
|
|
|
priv->gc_map = gdk_gc_new(priv->pixmap); |
|
|
|
|
|
osm_gps_map_map_redraw(OSM_GPS_MAP(widget)); |
|
|
|
|
|
return FALSE; |
|
|
} |
|
|
|
|
|
static gboolean |
|
|
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event) |
|
|
{ |
|
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget); |
|
|
|
|
|
gdk_draw_drawable ( |
|
2153 |
widget->window, |
widget->window, |
2154 |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
2155 |
priv->pixmap, |
priv->pixmap, |
2157 |
event->area.y + EXTRA_BORDER, |
event->area.y + EXTRA_BORDER, |
2158 |
event->area.x, event->area.y, |
event->area.x, event->area.y, |
2159 |
event->area.width, event->area.height); |
event->area.width, event->area.height); |
|
|
|
|
#ifdef ENABLE_OSD_OVL |
|
|
/* TODO: intersect with area */ |
|
|
if (priv->osd.pixbuf) |
|
|
{ |
|
|
// gdk_draw_drawable (widget->window, |
|
|
// widget->style->fg_gc[GTK_WIDGET_STATE (widget)], |
|
|
// priv->osd.pixbuf, 0, 0, |
|
|
// OSD_X, OSD_Y, OSD_W, OSD_H); |
|
|
} |
|
2160 |
#endif |
#endif |
|
|
|
2161 |
return FALSE; |
return FALSE; |
2162 |
} |
} |
2163 |
|
|
2343 |
"radius of the gps point inner circle", |
"radius of the gps point inner circle", |
2344 |
0, /* minimum property value */ |
0, /* minimum property value */ |
2345 |
G_MAXINT, /* maximum property value */ |
G_MAXINT, /* maximum property value */ |
2346 |
5, |
10, |
2347 |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); |
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); |
2348 |
|
|
2349 |
g_object_class_install_property (object_class, |
g_object_class_install_property (object_class, |
2929 |
return osm_gps_map_get_scale_at_point(priv->map_zoom, priv->center_rlat, priv->center_rlon); |
return osm_gps_map_get_scale_at_point(priv->map_zoom, priv->center_rlat, priv->center_rlon); |
2930 |
} |
} |
2931 |
|
|
2932 |
|
#ifdef ENABLE_BALLOON |
2933 |
void |
void |
2934 |
osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude, |
osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude, |
2935 |
OsmGpsMapBalloonCallback cb, gpointer data) |
OsmGpsMapBalloonCallback cb, gpointer data) |
2965 |
|
|
2966 |
osm_gps_map_map_redraw_idle(map); |
osm_gps_map_map_redraw_idle(map); |
2967 |
} |
} |
2968 |
|
#endif |
2969 |
|
|
2970 |
|
#ifdef ENABLE_OSD |
2971 |
|
|
2972 |
|
void |
2973 |
|
osm_gps_map_redraw (OsmGpsMap *map) |
2974 |
|
{ |
2975 |
|
osm_gps_map_map_redraw_idle(map); |
2976 |
|
} |
2977 |
|
|
2978 |
|
osm_gps_map_osd_t *osm_gps_map_osd_get(OsmGpsMap *map) { |
2979 |
|
g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL); |
2980 |
|
return map->priv->osd; |
2981 |
|
} |
2982 |
|
|
2983 |
|
void osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd) { |
2984 |
|
OsmGpsMapPrivate *priv; |
2985 |
|
|
2986 |
|
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
2987 |
|
|
2988 |
|
priv = map->priv; |
2989 |
|
g_return_if_fail (!priv->osd); |
2990 |
|
|
2991 |
|
priv->osd = osd; |
2992 |
|
} |
2993 |
|
|
2994 |
|
#endif |