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

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

revision 61 by harbaum, Tue Aug 18 14:32:45 2009 UTC revision 65 by harbaum, Wed Aug 19 14:21:14 2009 UTC
# Line 98  struct _OsmGpsMapPrivate Line 98  struct _OsmGpsMapPrivate
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;
# Line 106  struct _OsmGpsMapPrivate Line 107  struct _OsmGpsMapPrivate
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
114      struct {      struct {
115          GdkPixmap *backup;          GdkPixmap *backup;
116          gint backup_x, backup_y;          gint backup_x, backup_y;
   
   
117          //        GdkPixbuf *pixbuf;          //        GdkPixbuf *pixbuf;
118      } osd;      } osd;
119  #endif  #endif
# Line 653  osm_gps_map_draw_gps_point (OsmGpsMap *m Line 653  osm_gps_map_draw_gps_point (OsmGpsMap *m
653      }      }
654  }  }
655    
656    #ifdef ENABLE_BALLOON
657  /* most visual effects are hardcoded by now, but may be made */  /* most visual effects are hardcoded by now, but may be made */
658  /* available via properties later */  /* available via properties later */
659    #ifndef BALLOON_AREA_WIDTH
660  #define BALLOON_AREA_WIDTH           290  #define BALLOON_AREA_WIDTH           290
661    #endif
662    #ifndef BALLOON_AREA_HEIGHT
663  #define BALLOON_AREA_HEIGHT           75  #define BALLOON_AREA_HEIGHT           75
664    #endif
665    #ifndef BALLOON_CORNER_RADIUS
666  #define BALLOON_CORNER_RADIUS         20  #define BALLOON_CORNER_RADIUS         20
667    #endif
668    
669  #define BALLOON_BORDER               (BALLOON_CORNER_RADIUS/4)  #define BALLOON_BORDER               (BALLOON_CORNER_RADIUS/4)
670  #define BALLOON_WIDTH                (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER)  #define BALLOON_WIDTH                (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER)
671  #define BALLOON_HEIGHT               (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER)  #define BALLOON_HEIGHT               (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER)
# Line 852  osm_gps_map_in_balloon(OsmGpsMapPrivate Line 859  osm_gps_map_in_balloon(OsmGpsMapPrivate
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)
# Line 915  osm_gps_map_tile_download_complete (Soup Line 923  osm_gps_map_tile_download_complete (Soup
923              }              }
924              else              else
925              {              {
926                  g_warning("Error creating tile download directory: %s", dl->folder);                  g_warning("Error creating tile download directory: %s",
927                              dl->folder);
928                    perror("perror:");
929              }              }
930          }          }
931    
# Line 1409  osm_gps_map_purge_cache (OsmGpsMap *map) Line 1419  osm_gps_map_purge_cache (OsmGpsMap *map)
1419    
1420  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
1421  /* position and extent of bounding box */  /* position and extent of bounding box */
1422  #define OSD_X  (10)  #define OSD_X      (10)
1423  #define OSD_Y  (10)  #define OSD_Y      (10)
1424  #define OSD_W  (80+5)  
1425  #define OSD_H  (120+5)  #define OSD_COLOR  0.5, 0.5, 1
1426    
1427    /* parameters of the direction shape */
1428    #define D_RAD  (20)         // diameter of dpad
1429    #define D_TIP  (4*D_RAD/5)  // distance of arrow tip from dpad center
1430    #define D_LEN  (D_RAD/4)    // length of arrow
1431    #define D_WID  (D_LEN)      // width of arrow
1432    
1433    /* parameters of the "zoom" pad */
1434    #define Z_STEP   (-D_RAD/8) // distance between dpad and zoom
1435    #define Z_RAD    (D_RAD/2)  // radius of "caps" of zoom bar
1436    
1437    /* shadow also depends on control size */
1438    #define OSD_SHADOW (D_RAD/8)
1439    
1440    /* total width and height of controls incl. shadow */
1441    #define OSD_W    (2*D_RAD + OSD_SHADOW)
1442    #define OSD_H    (2*D_RAD + Z_STEP + 2*Z_RAD + OSD_SHADOW)
1443    
1444    #define OSD_LBL_SHADOW (OSD_SHADOW/2)
1445    
1446    #define Z_TOP    (2 * D_RAD + Z_STEP)
1447    #define Z_MID    (Z_TOP + Z_RAD)
1448    #define Z_BOT    (Z_MID + Z_RAD)
1449    #define Z_LEFT   (Z_RAD)
1450    #define Z_RIGHT  (2 * D_RAD - Z_RAD)
1451    
1452    /* create the cairo shape used for the zoom buttons */
1453    static void
1454    osm_gps_map_osd_zoom_shape(cairo_t *cr, gint x, gint y) {
1455        cairo_move_to (cr, x+Z_LEFT,    y+Z_TOP);
1456        cairo_line_to (cr, x+Z_RIGHT,   y+Z_TOP);
1457        cairo_arc     (cr, x+Z_RIGHT,   y+Z_MID, Z_RAD, -M_PI/2,  M_PI/2);
1458        cairo_line_to (cr, x+Z_LEFT,    y+Z_BOT);
1459        cairo_arc     (cr, x+Z_LEFT,    y+Z_MID, Z_RAD,  M_PI/2, -M_PI/2);
1460    }
1461    
1462    /* create the cairo shape used for the dpad */
1463    static void
1464    osm_gps_map_osd_dpad_shape(cairo_t *cr, gint x, gint y) {
1465        cairo_arc (cr, x+D_RAD, y+D_RAD, D_RAD, 0, 2 * M_PI);
1466    }
1467    
1468    typedef enum {
1469        OSD_NONE = 0,
1470        OSD_BG,
1471        OSD_UP,
1472        OSD_DOWN,
1473        OSD_LEFT,
1474        OSD_RIGHT,
1475        OSD_IN,
1476        OSD_OUT,
1477        OSD_GPS
1478    } osd_button_t;
1479    
1480    static gboolean
1481    osm_gps_map_in_circle(gint x, gint y, gint cx, gint cy, gint rad)
1482    {
1483        return( pow(cx - x, 2) + pow(cy - y, 2) < rad * rad);
1484    }
1485    
1486    /* check whether x/y is within the dpad */
1487    static osd_button_t
1488    osm_gps_map_osd_check_dpad(gint x, gint y)
1489    {
1490        /* within entire dpad circle */
1491        if( osm_gps_map_in_circle(x, y, OSD_X + D_RAD, OSD_Y + D_RAD, D_RAD))
1492        {
1493            /* convert into position relative to dpads centre */
1494            x -= (OSD_X + D_RAD);
1495            y -= (OSD_Y + D_RAD);
1496    
1497            /* check for dpad center goes here! */
1498            if( osm_gps_map_in_circle(x, y, OSD_X + D_RAD, OSD_Y + D_RAD, D_RAD/3))
1499                return OSD_GPS;
1500    
1501            if( y < 0 && abs(x) < abs(y))
1502                return OSD_UP;
1503    
1504            if( y > 0 && abs(x) < abs(y))
1505                return OSD_DOWN;
1506    
1507            if( x < 0 && abs(y) < abs(x))
1508                return OSD_LEFT;
1509    
1510            if( x > 0 && abs(y) < abs(x))
1511                return OSD_RIGHT;
1512    
1513            return OSD_BG;
1514        }
1515        return OSD_NONE;
1516    }
1517    
1518    /* check whether x/y is within the zoom pads */
1519    static osd_button_t
1520    osm_gps_map_osd_check_zoom(gint x, gint y) {
1521        if( x > OSD_X && x < (OSD_X + OSD_W) && y > Z_TOP && y < Z_BOT) {
1522    
1523            /* within circle around (-) label */
1524            if( osm_gps_map_in_circle(x, y, OSD_X + Z_LEFT, OSD_Y + Z_MID, Z_RAD))
1525                return OSD_OUT;
1526    
1527            /* between center of (-) button and center of entire zoom control area */
1528            if(x > OSD_LEFT && x < OSD_X + D_RAD)
1529                return OSD_OUT;
1530    
1531            /* within circle around (+) label */
1532            if( osm_gps_map_in_circle(x, y, OSD_X + Z_RIGHT, OSD_Y + Z_MID, Z_RAD))
1533                return OSD_IN;
1534    
1535            /* between center of (+) button and center of entire zoom control area */
1536            if(x < OSD_RIGHT && x > OSD_X + D_RAD)
1537                return OSD_IN;
1538        }
1539    
1540        return OSD_NONE;
1541    }
1542    
1543    static osd_button_t
1544    osm_gps_map_osd_check(gint x, gint y) {
1545        osd_button_t but = OSD_NONE;
1546    
1547        /* first do a rough test for the OSD area. */
1548        /* this is just to avoid an unnecessary detailed test */
1549        if(x > OSD_X && x < OSD_X + OSD_W &&
1550           y > OSD_Y && y < OSD_Y + OSD_H) {
1551    
1552            but = osm_gps_map_osd_check_dpad(x, y);
1553    
1554            if(but == OSD_NONE)
1555                but = osm_gps_map_osd_check_zoom(x, y);
1556        }
1557    
1558        return but;
1559    }
1560    
1561    static void
1562    osm_gps_map_osd_shape_shadow(cairo_t *cr) {
1563        cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
1564        cairo_fill (cr);
1565        cairo_stroke (cr);
1566    }
1567    
1568    static void
1569    osm_gps_map_osd_shape(cairo_t *cr) {
1570        cairo_set_source_rgb (cr, 1, 1, 1);
1571        cairo_fill_preserve (cr);
1572        cairo_set_source_rgb (cr, OSD_COLOR);
1573        cairo_set_line_width (cr, 1);
1574        cairo_stroke (cr);
1575    }
1576    
1577    static void
1578    osm_gps_map_osd_dpad_labels(cairo_t *cr, gint x, gint y) {
1579        /* move reference to dpad center */
1580        x += D_RAD;
1581        y += D_RAD;
1582    
1583        const static gint offset[][3][2] = {
1584            /* left arrow/triangle */
1585            { { -D_TIP+D_LEN, -D_WID }, { -D_LEN, D_WID }, { +D_LEN, D_WID } },
1586            /* right arrow/triangle */
1587            { { +D_TIP-D_LEN, -D_WID }, { +D_LEN, D_WID }, { -D_LEN, D_WID } },
1588            /* top arrow/triangle */
1589            { { -D_WID, -D_TIP+D_LEN }, { D_WID, -D_LEN }, { D_WID, +D_LEN } },
1590            /* bottom arrow/triangle */
1591            { { -D_WID, +D_TIP-D_LEN }, { D_WID, +D_LEN }, { D_WID, -D_LEN } }
1592        };
1593    
1594        int i;
1595        for(i=0;i<4;i++) {
1596            cairo_move_to (cr, x + offset[i][0][0], y + offset[i][0][1]);
1597            cairo_rel_line_to (cr, offset[i][1][0], offset[i][1][1]);
1598            cairo_rel_line_to (cr, offset[i][2][0], offset[i][2][1]);
1599        }
1600    }
1601    
1602    /* draw the sattelite dish icon in the center of the dpad */
1603    #define GPS_V0  (D_RAD/8)
1604    #define GPS_V1  (D_RAD/10)
1605    #define GPS_V2  (D_RAD/5)
1606    
1607    /* draw a satellite receiver dish */
1608    static void
1609    osm_gps_map_osd_dpad_gps(cairo_t *cr, gint x, gint y) {
1610        /* move reference to dpad center */
1611        x += D_RAD;
1612        y += D_RAD + GPS_V0;
1613    
1614        cairo_move_to (cr, x-GPS_V0, y+GPS_V0);
1615        cairo_rel_line_to (cr, +GPS_V0, -GPS_V0);
1616        cairo_rel_line_to (cr, +GPS_V0, +GPS_V0);
1617        cairo_close_path (cr);
1618    
1619        cairo_move_to (cr, x+GPS_V1-GPS_V2, y-2*GPS_V2);
1620        cairo_curve_to (cr, x-GPS_V2, y, x+GPS_V1, y+GPS_V1, x+GPS_V1+GPS_V2, y);
1621        cairo_close_path (cr);
1622    
1623        x += GPS_V1;
1624        cairo_move_to (cr, x, y-GPS_V2);
1625        cairo_rel_line_to (cr, +GPS_V1, -GPS_V1);
1626    }
1627    
1628    #define Z_LEN  (2*Z_RAD/3)
1629    
1630    static void
1631    osm_gps_map_osd_zoom_labels(cairo_t *cr, gint x, gint y) {
1632        cairo_move_to (cr, x + Z_LEFT  - Z_LEN, y + Z_MID);
1633        cairo_line_to (cr, x + Z_LEFT  + Z_LEN, y + Z_MID);
1634    
1635        cairo_move_to (cr, x + Z_RIGHT,         y + Z_MID - Z_LEN);
1636        cairo_line_to (cr, x + Z_RIGHT,         y + Z_MID + Z_LEN);
1637        cairo_move_to (cr, x + Z_RIGHT - Z_LEN, y + Z_MID);
1638        cairo_line_to (cr, x + Z_RIGHT + Z_LEN, y + Z_MID);
1639    }
1640    
1641    static void
1642    osm_gps_map_osd_labels(cairo_t *cr, gint width) {
1643        cairo_set_source_rgb (cr, OSD_COLOR);
1644        cairo_set_line_width (cr, width);
1645        cairo_stroke (cr);
1646    }
1647    
1648    static void
1649    osm_gps_map_osd_labels_shadow(cairo_t *cr, gint width) {
1650        cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
1651        cairo_set_line_width (cr, width);
1652        cairo_stroke (cr);
1653    }
1654    
1655  static void  static void
1656  osm_gps_map_draw_osd_controls (OsmGpsMap *map, gint xoffset, gint yoffset)  osm_gps_map_osd_draw_controls (OsmGpsMap *map, gint xoffset, gint yoffset)
1657  {  {
     /* xyz */  
1658      OsmGpsMapPrivate *priv = map->priv;      OsmGpsMapPrivate *priv = map->priv;
1659    
1660      /* backup previous contents */      /* backup previous contents */
1661      if(!priv->osd.backup)      if(!priv->osd.backup)
1662          priv->osd.backup = gdk_pixmap_new(priv->pixmap, OSD_W, OSD_H, -1);          priv->osd.backup = gdk_pixmap_new(priv->pixmap, OSD_W+2, OSD_H+2, -1);
1663    
1664      gint x = OSD_X + EXTRA_BORDER + xoffset;      gint x = OSD_X + EXTRA_BORDER + xoffset;
1665      gint y = OSD_Y + EXTRA_BORDER + yoffset;      gint y = OSD_Y + EXTRA_BORDER + yoffset;
# Line 1430  osm_gps_map_draw_osd_controls (OsmGpsMap Line 1667  osm_gps_map_draw_osd_controls (OsmGpsMap
1667      /* create backup of background */      /* create backup of background */
1668      gdk_draw_drawable(priv->osd.backup,      gdk_draw_drawable(priv->osd.backup,
1669          GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))],          GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))],
1670                        priv->pixmap, x, y, 0, 0, OSD_W, OSD_H);                        priv->pixmap, x-1, y-1, 0, 0, OSD_W+2, OSD_H+2);
1671      priv->osd.backup_x = x;      priv->osd.backup_x = x-1;
1672      priv->osd.backup_y = y;      priv->osd.backup_y = y-1;
1673    
1674  #if 0  #if 0
1675      /* create pixbuf for osd */      /* create pixbuf for osd */
# Line 1457  osm_gps_map_draw_osd_controls (OsmGpsMap Line 1694  osm_gps_map_draw_osd_controls (OsmGpsMap
1694      //    cairo_t *cr = cairo_create(surface);      //    cairo_t *cr = cairo_create(surface);
1695      cairo_t *cr = gdk_cairo_create(priv->pixmap);      cairo_t *cr = gdk_cairo_create(priv->pixmap);
1696    
1697  #define RAD  40      /* --------- draw zoom and dpad shape shadow ----------- */
 #define TIP  35  
 #define LEN  15  
 #define WID  15  
   
     /* --------- the direction "pad" shape and shadow ----------- */  
     cairo_arc (cr, x+RAD+5, y+RAD+5, RAD, 0, 2 * M_PI);  
     cairo_set_source_rgba (cr, 0, 0, 0, 0.2);  
     cairo_fill (cr);  
     cairo_stroke (cr);  
   
     cairo_arc (cr, x+RAD, y+RAD, RAD, 0, 2 * M_PI);  
     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  -------------- */  
     cairo_move_to (cr, x,       y+2*RAD);  
     cairo_line_to (cr, x+2*RAD-10, y+2*RAD);  
     cairo_curve_to (cr, x+2*RAD, y+2*RAD,  
                         x+2*RAD, y+3*RAD,  
                         x+2*RAD-10, y+3*RAD);  
     cairo_close_path (cr);  
   
   
     cairo_set_source_rgba (cr, 1, 1, 1, 1.0);  
     cairo_fill (cr);  
     cairo_stroke (cr);  
   
   
     /* 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);  
1698    
1699        osm_gps_map_osd_zoom_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW);
1700        osm_gps_map_osd_shape_shadow(cr);
1701        osm_gps_map_osd_dpad_shape(cr, x + OSD_SHADOW, y + OSD_SHADOW);
1702        osm_gps_map_osd_shape_shadow(cr);
1703    
1704        /* --------- draw zoom and dpad shape ----------- */
1705    
1706        osm_gps_map_osd_zoom_shape(cr, x, y);
1707        osm_gps_map_osd_shape(cr);
1708        osm_gps_map_osd_dpad_shape(cr, x, y);
1709        osm_gps_map_osd_shape(cr);
1710    
1711        /* --------- draw zoom and dpad labels --------- */
1712    
1713        osm_gps_map_osd_zoom_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW);
1714        osm_gps_map_osd_dpad_labels(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW);
1715        osm_gps_map_osd_labels_shadow(cr, Z_RAD/3);
1716        osm_gps_map_osd_dpad_gps(cr, x + OSD_LBL_SHADOW, y + OSD_LBL_SHADOW);
1717        osm_gps_map_osd_labels_shadow(cr, Z_RAD/6);
1718    
1719        osm_gps_map_osd_zoom_labels(cr, x, y);
1720        osm_gps_map_osd_dpad_labels(cr, x, y);
1721        osm_gps_map_osd_labels(cr, Z_RAD/3);
1722        osm_gps_map_osd_dpad_gps(cr, x, y);
1723        osm_gps_map_osd_labels(cr, Z_RAD/6);
1724    
1725      cairo_destroy(cr);      cairo_destroy(cr);
1726    
# Line 1542  osm_gps_map_osd_restore (OsmGpsMap *map) Line 1740  osm_gps_map_osd_restore (OsmGpsMap *map)
1740          gdk_draw_drawable(priv->pixmap,          gdk_draw_drawable(priv->pixmap,
1741              GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))],              GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))],
1742                        priv->osd.backup, 0, 0,                        priv->osd.backup, 0, 0,
1743                        priv->osd.backup_x, priv->osd.backup_y, OSD_W, OSD_H);                        priv->osd.backup_x, priv->osd.backup_y, OSD_W+2, OSD_H+2);
1744      }      }
1745  }  }
1746    
# Line 1578  osm_gps_map_map_redraw (OsmGpsMap *map) Line 1776  osm_gps_map_map_redraw (OsmGpsMap *map)
1776      osm_gps_map_print_tracks(map);      osm_gps_map_print_tracks(map);
1777      osm_gps_map_draw_gps_point(map);      osm_gps_map_draw_gps_point(map);
1778      osm_gps_map_print_images(map);      osm_gps_map_print_images(map);
1779    #ifdef ENABLE_BALLOON
1780      osm_gps_map_draw_balloon_int(map);      osm_gps_map_draw_balloon_int(map);
1781    #endif
1782  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
1783      osm_gps_map_draw_osd_controls(map, 0, 0);      osm_gps_map_osd_draw_controls(map, 0, 0);
1784  #endif  #endif
1785    
1786      //osm_gps_map_osd_speed(map, 1.5);      //osm_gps_map_osd_speed(map, 1.5);
# Line 1613  osm_gps_map_init (OsmGpsMap *object) Line 1813  osm_gps_map_init (OsmGpsMap *object)
1813      priv->gps = g_new0(coord_t, 1);      priv->gps = g_new0(coord_t, 1);
1814      priv->gps_valid = FALSE;      priv->gps_valid = FALSE;
1815    
1816    #ifdef ENABLE_BALLOON
1817      priv->balloon.coo = g_new0(coord_t, 1);      priv->balloon.coo = g_new0(coord_t, 1);
1818      priv->balloon.valid = FALSE;      priv->balloon.valid = FALSE;
1819      priv->balloon.cb = NULL;      priv->balloon.cb = NULL;
1820    #endif
1821    
1822  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
1823      priv->osd.backup = NULL;      priv->osd.backup = NULL;
# Line 1779  osm_gps_map_dispose (GObject *object) Line 1981  osm_gps_map_dispose (GObject *object)
1981          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1982    
1983      g_free(priv->gps);      g_free(priv->gps);
1984    
1985    #ifdef ENABLE_BALLOON
1986      g_free(priv->balloon.coo);      g_free(priv->balloon.coo);
1987    #endif
1988    
1989  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
1990      if (priv->osd.backup)      if (priv->osd.backup)
# Line 2001  osm_gps_map_button_press (GtkWidget *wid Line 2206  osm_gps_map_button_press (GtkWidget *wid
2206  {  {
2207      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2208    
2209    #ifdef ENABLE_BALLOON
2210      /* don't drag if the user clicked within the balloon */      /* don't drag if the user clicked within the balloon */
2211      if (osm_gps_map_in_balloon(priv,      if (osm_gps_map_in_balloon(priv,
2212                     event->x + EXTRA_BORDER,                     event->x + EXTRA_BORDER,
# Line 2009  osm_gps_map_button_press (GtkWidget *wid Line 2215  osm_gps_map_button_press (GtkWidget *wid
2215          priv->drag_counter = -1;          priv->drag_counter = -1;
2216          return FALSE;          return FALSE;
2217      }      }
2218    #endif
2219    
2220    #ifdef ENABLE_OSD
2221        /* also don't drag on clicks into the control OSD */
2222        if(osm_gps_map_osd_check(event->x, event->y) != OSD_NONE)
2223        {
2224            priv->drag_counter = -1;
2225            return FALSE;
2226        }
2227    #endif
2228    
2229      priv->drag_counter = 0;      priv->drag_counter = 0;
2230      priv->drag_start_mouse_x = (int) event->x;      priv->drag_start_mouse_x = (int) event->x;
# Line 2024  osm_gps_map_button_release (GtkWidget *w Line 2240  osm_gps_map_button_release (GtkWidget *w
2240  {  {
2241      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2242    
2243    #ifdef ENABLE_OSD
2244        /* released inside OSD control? */
2245        osd_button_t but = osm_gps_map_osd_check(event->x, event->y);
2246        if(but != OSD_NONE)
2247        {
2248            switch(but) {
2249            case OSD_UP:
2250                priv->map_y -= GTK_WIDGET(widget)->allocation.height/4;
2251                priv->center_coord_set = FALSE;
2252                break;
2253    
2254            case OSD_DOWN:
2255                priv->map_y += GTK_WIDGET(widget)->allocation.height/4;
2256                priv->center_coord_set = FALSE;
2257                break;
2258    
2259            case OSD_LEFT:
2260                priv->map_x -= GTK_WIDGET(widget)->allocation.width/4;
2261                priv->center_coord_set = FALSE;
2262                break;
2263    
2264            case OSD_RIGHT:
2265                priv->map_x += GTK_WIDGET(widget)->allocation.width/4;
2266                priv->center_coord_set = FALSE;
2267                break;
2268    
2269            case OSD_IN:
2270                osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom+1);
2271                break;
2272    
2273            case OSD_OUT:
2274                osm_gps_map_set_zoom(OSM_GPS_MAP(widget), priv->map_zoom-1);
2275                break;
2276    
2277            default:
2278                break;
2279            }
2280    
2281            osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget));
2282    
2283            return FALSE;
2284        }
2285    #endif
2286    
2287    #ifdef ENABLE_BALLOON
2288      /* released inside the balloon? */      /* released inside the balloon? */
2289      if (osm_gps_map_in_balloon(priv,      if (osm_gps_map_in_balloon(priv,
2290                     event->x + EXTRA_BORDER,                     event->x + EXTRA_BORDER,
# Line 2032  osm_gps_map_button_release (GtkWidget *w Line 2293  osm_gps_map_button_release (GtkWidget *w
2293          osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget),          osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget),
2294               event->x - priv->balloon.rect.x + EXTRA_BORDER,               event->x - priv->balloon.rect.x + EXTRA_BORDER,
2295               event->y - priv->balloon.rect.y + EXTRA_BORDER);               event->y - priv->balloon.rect.y + EXTRA_BORDER);
         return FALSE;  
2296      }      }
2297    #endif
     if (priv->drag_counter < 0)  
         return FALSE;  
2298    
2299      if (priv->dragging)      if (priv->dragging)
2300      {      {
# Line 2102  osm_gps_map_motion_notify (GtkWidget *wi Line 2360  osm_gps_map_motion_notify (GtkWidget *wi
2360      osm_gps_map_osd_restore (OSM_GPS_MAP(widget));      osm_gps_map_osd_restore (OSM_GPS_MAP(widget));
2361    
2362      /* draw new OSD */      /* draw new OSD */
2363      osm_gps_map_draw_osd_controls (OSM_GPS_MAP(widget),      osm_gps_map_osd_draw_controls (OSM_GPS_MAP(widget),
2364                                     -priv->drag_mouse_dx,                                     -priv->drag_mouse_dx,
2365                                     -priv->drag_mouse_dy);                                     -priv->drag_mouse_dy);
2366  #endif  #endif
# Line 2982  osm_gps_map_get_scale(OsmGpsMap *map) Line 3240  osm_gps_map_get_scale(OsmGpsMap *map)
3240      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);
3241  }  }
3242    
3243    #ifdef ENABLE_BALLOON
3244  void  void
3245  osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude,  osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude,
3246                            OsmGpsMapBalloonCallback cb, gpointer data)                            OsmGpsMapBalloonCallback cb, gpointer data)
# Line 3017  osm_gps_map_clear_balloon (OsmGpsMap *ma Line 3276  osm_gps_map_clear_balloon (OsmGpsMap *ma
3276    
3277      osm_gps_map_map_redraw_idle(map);      osm_gps_map_map_redraw_idle(map);
3278  }  }
3279    #endif

Legend:
Removed from v.61  
changed lines
  Added in v.65