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

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

revision 57 by harbaum, Sun Aug 16 19:29:01 2009 UTC revision 61 by harbaum, Tue Aug 18 14:32:45 2009 UTC
# Line 99  struct _OsmGpsMapPrivate Line 99  struct _OsmGpsMapPrivate
99      gboolean gps_valid;      gboolean gps_valid;
100    
101      //a balloon with additional info      //a balloon with additional info
102      coord_t *balloon;      struct {
103      gboolean balloon_valid;          coord_t *coo;
104            gboolean valid;
105            OsmGpsMapRect_t rect;
106            OsmGpsMapBalloonCallback cb;
107            gpointer data;
108        } 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;
# Line 639  osm_gps_map_draw_gps_point (OsmGpsMap *m Line 655  osm_gps_map_draw_gps_point (OsmGpsMap *m
655    
656  /* most visual effects are hardcoded by now, but may be made */  /* most visual effects are hardcoded by now, but may be made */
657  /* available via properties later */  /* available via properties later */
658    #define BALLOON_AREA_WIDTH           290
659    #define BALLOON_AREA_HEIGHT           75
660    
661  #define BALLOON_CORNER_RADIUS         20  #define BALLOON_CORNER_RADIUS         20
662  #define BALLOON_WIDTH                150  #define BALLOON_BORDER               (BALLOON_CORNER_RADIUS/4)
663  #define BALLOON_HEIGHT                75  #define BALLOON_WIDTH                (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER)
664    #define BALLOON_HEIGHT               (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER)
665  #define BALLOON_TRANSPARENCY         0.8  #define BALLOON_TRANSPARENCY         0.8
666  #define POINTER_HEIGHT                20  #define POINTER_HEIGHT                20
667  #define POINTER_FOOT_WIDTH            20  #define POINTER_FOOT_WIDTH            20
# Line 649  osm_gps_map_draw_gps_point (OsmGpsMap *m Line 669  osm_gps_map_draw_gps_point (OsmGpsMap *m
669  #define BALLOON_SHADOW                5  #define BALLOON_SHADOW                5
670  #define BALLOON_SHADOW_TRANSPARENCY  0.2  #define BALLOON_SHADOW_TRANSPARENCY  0.2
671    
672    #define CLOSE_BUTTON_RADIUS   (BALLOON_CORNER_RADIUS/3)
673    
674    
675  /* 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 */
676  /* for the shadow */  /* for the shadow */
677  static void  static void
# Line 658  osm_gps_map_draw_balloon_shape (cairo_t Line 681  osm_gps_map_draw_balloon_shape (cairo_t
681      cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS);      cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS);
682      cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + BALLOON_CORNER_RADIUS, y0);      cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + BALLOON_CORNER_RADIUS, y0);
683      if(!bottom) {      if(!bottom) {
684          /* insert bottom/left pointer */          /* insert top pointer */
685          cairo_line_to (cr, px1, y0);          cairo_line_to (cr, px1, y0);
686          cairo_line_to (cr, px, py);          cairo_line_to (cr, px, py);
687          cairo_line_to (cr, px0, y0);          cairo_line_to (cr, px0, y0);
# Line 669  osm_gps_map_draw_balloon_shape (cairo_t Line 692  osm_gps_map_draw_balloon_shape (cairo_t
692      cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS);      cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS);
693      cairo_curve_to (cr, x1, y1, x1, y1, x1 - BALLOON_CORNER_RADIUS, y1);      cairo_curve_to (cr, x1, y1, x1, y1, x1 - BALLOON_CORNER_RADIUS, y1);
694      if(bottom) {      if(bottom) {
695          /* insert bottom/left pointer */          /* insert bottom pointer */
696          cairo_line_to (cr, px0, y1);          cairo_line_to (cr, px0, y1);
697          cairo_line_to (cr, px, py);          cairo_line_to (cr, px, py);
698          cairo_line_to (cr, px1, y1);          cairo_line_to (cr, px1, y1);
# Line 681  osm_gps_map_draw_balloon_shape (cairo_t Line 704  osm_gps_map_draw_balloon_shape (cairo_t
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  {  {
710      OsmGpsMapPrivate *priv = map->priv;      OsmGpsMapPrivate *priv = map->priv;
711    
712      if (priv->balloon_valid) {      if (priv->balloon.valid) {
713    
714          /* ------- convert given coordinate into screen position --------- */          /* ------- convert given coordinate into screen position --------- */
715          int x0 = lon2pixel(priv->map_zoom, priv->balloon->rlon) -          int x0 = lon2pixel(priv->map_zoom, priv->balloon.coo->rlon) -
716              priv->map_x + EXTRA_BORDER;              priv->map_x + EXTRA_BORDER;
717          int y0 = lat2pixel(priv->map_zoom, priv->balloon->rlat) -          int y0 = lat2pixel(priv->map_zoom, priv->balloon.coo->rlat) -
718              priv->map_y + EXTRA_BORDER;              priv->map_y + EXTRA_BORDER;
719    
720          /* check position of this relative to screen center to determine */          /* check position of this relative to screen center to determine */
# Line 721  osm_gps_map_draw_balloon_int (OsmGpsMap Line 743  osm_gps_map_draw_balloon_int (OsmGpsMap
743          /* calculate bottom/right of box */          /* calculate bottom/right of box */
744          int x1 = x0 + BALLOON_WIDTH, y1 = y0 + BALLOON_HEIGHT;          int x1 = x0 + BALLOON_WIDTH, y1 = y0 + BALLOON_HEIGHT;
745    
746            /* save balloon screen coordinates for later use */
747            priv->balloon.rect.x = x0 + BALLOON_BORDER;
748            priv->balloon.rect.y = y0 + BALLOON_BORDER;
749            priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER;
750            priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER;
751    
752  #ifdef USE_CAIRO  #ifdef USE_CAIRO
753          cairo_t *cr = gdk_cairo_create(priv->pixmap);          cairo_t *cr = gdk_cairo_create(priv->pixmap);
754    
# Line 750  osm_gps_map_draw_balloon_int (OsmGpsMap Line 778  osm_gps_map_draw_balloon_int (OsmGpsMap
778    
779          /* ---------- draw close button --------- */          /* ---------- draw close button --------- */
780    
781          int cx = x1 - BALLOON_CORNER_RADIUS*3/4;          int cx = x1 - BALLOON_BORDER - CLOSE_BUTTON_RADIUS;
782          int cy = y0 + BALLOON_CORNER_RADIUS*3/4;          int cy = y0 + BALLOON_BORDER + CLOSE_BUTTON_RADIUS;
783          int crad = BALLOON_CORNER_RADIUS/3;          int crad = CLOSE_BUTTON_RADIUS;
784    
785          cairo_arc (cr, cx, cy, crad, 0, 2 * M_PI);          cairo_arc (cr, cx, cy, crad, 0, 2 * M_PI);
786          cairo_set_source_rgba (cr, 0.8, 0, 0, 1.0);          cairo_set_source_rgba (cr, 0.8, 0, 0, 1.0);
787          cairo_fill_preserve (cr);          cairo_fill_preserve (cr);
788          cairo_set_source_rgba (cr, 0.3, 0, 0, 1.0);          cairo_set_source_rgba (cr, 0.3, 0, 0, 1.0);
789          cairo_set_line_width (cr, 1);          cairo_set_line_width (cr, 2);
790          cairo_stroke(cr);          cairo_stroke(cr);
791    
         int cs = crad/2;  
792          cairo_set_source_rgba (cr, 1, 1, 1, 1.0);          cairo_set_source_rgba (cr, 1, 1, 1, 1.0);
793          cairo_set_line_width (cr, 3);          cairo_set_line_width (cr, 3);
794          cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);          cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
795          cairo_move_to (cr, cx - cs, cy - cs);          cairo_move_to (cr, cx - crad/2, cy - crad/2);
796          cairo_line_to (cr, cx + cs, cy + cs);          cairo_line_to (cr, cx + crad/2, cy + crad/2);
797          cairo_stroke (cr);          cairo_stroke (cr);
798          cairo_move_to (cr, cx + cs, cy - cs);          cairo_move_to (cr, cx + crad/2, cy - crad/2);
799          cairo_line_to (cr, cx - cs, cy + cs);          cairo_line_to (cr, cx - crad/2, cy + crad/2);
800          cairo_stroke (cr);          cairo_stroke (cr);
801    
802            if (priv->balloon.cb) {
803                /* clip in case application tries to draw in */
804                /* exceed of the balloon */
805                cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y,
806                                 priv->balloon.rect.w, priv->balloon.rect.h);
807                cairo_clip (cr);
808                cairo_new_path (cr);  /* current path is not
809                                         consumed by cairo_clip() */
810    
811                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);
# Line 782  osm_gps_map_draw_balloon_int (OsmGpsMap Line 822  osm_gps_map_draw_balloon_int (OsmGpsMap
822      }      }
823  }  }
824    
825    /* the user clicked into the balloons main area. handle this */
826    static void
827    osm_gps_map_handle_balloon_click(OsmGpsMap *map, gint x, gint y)
828    {
829        OsmGpsMapPrivate *priv = map->priv;
830    
831        if (!priv->balloon.valid)
832            return;
833    
834        /* check if the close button was clicked */
835        if ((x > priv->balloon.rect.w - 2*CLOSE_BUTTON_RADIUS) &&
836            (x < priv->balloon.rect.w) &&
837            (y > 0) && (y < 2*CLOSE_BUTTON_RADIUS)) {
838    
839            priv->balloon.valid = FALSE;
840            osm_gps_map_map_redraw_idle(map);
841        }
842    }
843    
844    /* return true if balloon is being displayed and if */
845    /* the given coordinate is within this balloon */
846    static gboolean
847    osm_gps_map_in_balloon(OsmGpsMapPrivate *priv, gint x, gint y)
848    {
849        return (priv->balloon.valid &&
850                (x > priv->balloon.rect.x) &&
851                (x < priv->balloon.rect.x + priv->balloon.rect.w) &&
852                (y > priv->balloon.rect.y) &&
853                (y < priv->balloon.rect.y + priv->balloon.rect.h));
854    }
855    
856  static void  static void
857  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)
858  {  {
# Line 1336  osm_gps_map_purge_cache (OsmGpsMap *map) Line 1407  osm_gps_map_purge_cache (OsmGpsMap *map)
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  {  {
# Line 1367  osm_gps_map_map_redraw (OsmGpsMap *map) Line 1579  osm_gps_map_map_redraw (OsmGpsMap *map)
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);
# Line 1398  osm_gps_map_init (OsmGpsMap *object) Line 1613  osm_gps_map_init (OsmGpsMap *object)
1613      priv->gps = g_new0(coord_t, 1);      priv->gps = g_new0(coord_t, 1);
1614      priv->gps_valid = FALSE;      priv->gps_valid = FALSE;
1615    
1616      priv->balloon = g_new0(coord_t, 1);      priv->balloon.coo = g_new0(coord_t, 1);
1617      priv->balloon_valid = FALSE;      priv->balloon.valid = FALSE;
1618        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;
# Line 1559  osm_gps_map_dispose (GObject *object) Line 1779  osm_gps_map_dispose (GObject *object)
1779          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1780    
1781      g_free(priv->gps);      g_free(priv->gps);
1782      g_free(priv->balloon);      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  }  }
# Line 1776  osm_gps_map_button_press (GtkWidget *wid Line 2001  osm_gps_map_button_press (GtkWidget *wid
2001  {  {
2002      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2003    
2004        /* don't drag if the user clicked within the balloon */
2005        if (osm_gps_map_in_balloon(priv,
2006                       event->x + EXTRA_BORDER,
2007                       event->y + EXTRA_BORDER))
2008        {
2009            priv->drag_counter = -1;
2010            return FALSE;
2011        }
2012    
2013      priv->drag_counter = 0;      priv->drag_counter = 0;
2014      priv->drag_start_mouse_x = (int) event->x;      priv->drag_start_mouse_x = (int) event->x;
2015      priv->drag_start_mouse_y = (int) event->y;      priv->drag_start_mouse_y = (int) event->y;
# Line 1790  osm_gps_map_button_release (GtkWidget *w Line 2024  osm_gps_map_button_release (GtkWidget *w
2024  {  {
2025      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2026    
2027        /* released inside the balloon? */
2028        if (osm_gps_map_in_balloon(priv,
2029                       event->x + EXTRA_BORDER,
2030                       event->y + EXTRA_BORDER))
2031        {
2032            osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget),
2033                 event->x - priv->balloon.rect.x + EXTRA_BORDER,
2034                 event->y - priv->balloon.rect.y + EXTRA_BORDER);
2035            return FALSE;
2036        }
2037    
2038        if (priv->drag_counter < 0)
2039            return FALSE;
2040    
2041      if (priv->dragging)      if (priv->dragging)
2042      {      {
2043          priv->dragging = FALSE;          priv->dragging = FALSE;
# Line 1807  osm_gps_map_button_release (GtkWidget *w Line 2055  osm_gps_map_button_release (GtkWidget *w
2055    
2056      priv->drag_mouse_dx = 0;      priv->drag_mouse_dx = 0;
2057      priv->drag_mouse_dy = 0;      priv->drag_mouse_dy = 0;
2058      priv->drag_counter = 0;      priv->drag_counter = -1;
2059    
2060      return FALSE;      return FALSE;
2061  }  }
# Line 1832  osm_gps_map_motion_notify (GtkWidget *wi Line 2080  osm_gps_map_motion_notify (GtkWidget *wi
2080      if (!(state & GDK_BUTTON1_MASK))      if (!(state & GDK_BUTTON1_MASK))
2081          return FALSE;          return FALSE;
2082    
2083        if (priv->drag_counter < 0)
2084            return FALSE;
2085    
2086      priv->drag_counter++;      priv->drag_counter++;
2087    
2088      // we havent dragged more than 6 pixels      // we havent dragged more than 6 pixels
# Line 1846  osm_gps_map_motion_notify (GtkWidget *wi Line 2097  osm_gps_map_motion_notify (GtkWidget *wi
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)],
# Line 1934  osm_gps_map_expose (GtkWidget *widget, G Line 2195  osm_gps_map_expose (GtkWidget *widget, G
2195                         widget->window,                         widget->window,
2196                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
2197                         priv->pixmap,                         priv->pixmap,
2198                         event->area.x + EXTRA_BORDER, event->area.y + EXTRA_BORDER,                         event->area.x + EXTRA_BORDER,
2199                           event->area.y + EXTRA_BORDER,
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    
# Line 2710  osm_gps_map_get_scale(OsmGpsMap *map) Line 2983  osm_gps_map_get_scale(OsmGpsMap *map)
2983  }  }
2984    
2985  void  void
2986  osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude)  osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude,
2987                              OsmGpsMapBalloonCallback cb, gpointer data)
2988  {  {
2989      OsmGpsMapPrivate *priv;      OsmGpsMapPrivate *priv;
2990    
# Line 2720  osm_gps_map_draw_balloon (OsmGpsMap *map Line 2994  osm_gps_map_draw_balloon (OsmGpsMap *map
2994      g_return_if_fail (OSM_IS_GPS_MAP (map));      g_return_if_fail (OSM_IS_GPS_MAP (map));
2995      priv = map->priv;      priv = map->priv;
2996    
2997      priv->balloon->rlat = deg2rad(latitude);      priv->balloon.coo->rlat = deg2rad(latitude);
2998      priv->balloon->rlon = deg2rad(longitude);      priv->balloon.coo->rlon = deg2rad(longitude);
2999      priv->balloon_valid = TRUE;      priv->balloon.valid = TRUE;
3000    
3001        priv->balloon.cb = cb;
3002        priv->balloon.data = data;
3003    
3004      // this redraws the map      // this redraws the map
3005      osm_gps_map_map_redraw_idle(map);      osm_gps_map_map_redraw_idle(map);
# Line 2736  osm_gps_map_clear_balloon (OsmGpsMap *ma Line 3013  osm_gps_map_clear_balloon (OsmGpsMap *ma
3013      g_return_if_fail (OSM_IS_GPS_MAP (map));      g_return_if_fail (OSM_IS_GPS_MAP (map));
3014      priv = map->priv;      priv = map->priv;
3015    
3016      priv->balloon_valid = FALSE;      priv->balloon.valid = FALSE;
3017    
3018      osm_gps_map_map_redraw_idle(map);      osm_gps_map_map_redraw_idle(map);
3019  }  }

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