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

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

revision 56 by harbaum, Fri Aug 14 12:19:45 2009 UTC revision 61 by harbaum, Tue Aug 18 14:32:45 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        //a balloon with additional info
102        struct {
103            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;
123      GSList *images;      GSList *images;
# Line 631  osm_gps_map_draw_gps_point (OsmGpsMap *m Line 651  osm_gps_map_draw_gps_point (OsmGpsMap *m
651                                      (mr*2)+lw+lw);                                      (mr*2)+lw+lw);
652  #endif  #endif
653      }      }
654    }
655    
656    /* most visual effects are hardcoded by now, but may be made */
657    /* available via properties later */
658    #define BALLOON_AREA_WIDTH           290
659    #define BALLOON_AREA_HEIGHT           75
660    
661    #define BALLOON_CORNER_RADIUS         20
662    #define BALLOON_BORDER               (BALLOON_CORNER_RADIUS/4)
663    #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
666    #define POINTER_HEIGHT                20
667    #define POINTER_FOOT_WIDTH            20
668    #define POINTER_OFFSET               (BALLOON_CORNER_RADIUS*3/4)
669    #define BALLOON_SHADOW                5
670    #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 */
676    /* for the shadow */
677    static void
678    osm_gps_map_draw_balloon_shape (cairo_t *cr, int x0, int y0, int x1, int y1,
679           gboolean bottom, int px, int py, int px0, int px1) {
680    
681        cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS);
682        cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + BALLOON_CORNER_RADIUS, y0);
683        if(!bottom) {
684            /* insert top pointer */
685            cairo_line_to (cr, px1, y0);
686            cairo_line_to (cr, px, py);
687            cairo_line_to (cr, px0, y0);
688        }
689    
690        cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0);
691        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + BALLOON_CORNER_RADIUS);
692        cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS);
693        cairo_curve_to (cr, x1, y1, x1, y1, x1 - BALLOON_CORNER_RADIUS, y1);
694        if(bottom) {
695            /* insert bottom pointer */
696            cairo_line_to (cr, px0, y1);
697            cairo_line_to (cr, px, py);
698            cairo_line_to (cr, px1, y1);
699        }
700    
701        cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1);
702        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - BALLOON_CORNER_RADIUS);
703    
704        cairo_close_path (cr);
705  }  }
706    
 /* http://cairographics.org/samples/ */  
707  static void  static void
708  osm_gps_map_draw_balloon (OsmGpsMap *map)  osm_gps_map_draw_balloon_int (OsmGpsMap *map)
709  {  {
710      OsmGpsMapPrivate *priv = map->priv;      OsmGpsMapPrivate *priv = map->priv;
711    
712      /* xyz */      if (priv->balloon.valid) {
 #define X 100  
 #define Y 100  
 #define RADIUS 20  
 #define WIDTH  150  
 #define HEIGHT 75  
 #define TRANSPARENCY  0.7  
 #define PIN_HEIGHT 20  
 #define PIN_FOOT_WIDTH 20  
 #define PIN_X  (X + EXTRA_BORDER)  
 #define PIN_X0 (X + EXTRA_BORDER + RADIUS + PIN_FOOT_WIDTH)  
 #define PIN_X1 (X + EXTRA_BORDER + RADIUS)  
 #define PIN_Y  (Y + EXTRA_BORDER + HEIGHT + PIN_HEIGHT)  
   
 #ifdef USE_CAIRO  
     cairo_t *cr = gdk_cairo_create(priv->pixmap);  
713    
714      int x0 = X + EXTRA_BORDER, y0 = Y + EXTRA_BORDER;          /* ------- convert given coordinate into screen position --------- */
715      int x1 = x0 + WIDTH, y1 = y0 + HEIGHT;          int x0 = lon2pixel(priv->map_zoom, priv->balloon.coo->rlon) -
716                priv->map_x + EXTRA_BORDER;
717            int y0 = lat2pixel(priv->map_zoom, priv->balloon.coo->rlat) -
718                priv->map_y + EXTRA_BORDER;
719    
720      cairo_move_to (cr, x0, y0 + RADIUS);          /* check position of this relative to screen center to determine */
721      cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + RADIUS, y0);          /* pointer direction ... */
722      cairo_line_to (cr, x1 - RADIUS, y0);          int pointer_x = x0, pointer_x0, pointer_x1;
723      cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + RADIUS);          int pointer_y = y0;
     cairo_line_to (cr, x1 , y1 - RADIUS);  
     cairo_curve_to (cr, x1, y1, x1, y1, x1 - RADIUS, y1);  
   
     /* insert pin */  
     cairo_line_to (cr, PIN_X0, y1);  
     cairo_line_to (cr, PIN_X, PIN_Y);  
     cairo_line_to (cr, PIN_X1, y1);  
   
724    
725      cairo_line_to (cr, x0 + RADIUS, y1);          /* ... and calculate position */
726      cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - RADIUS);          if((x0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.width/2) {
727                x0 -= BALLOON_WIDTH - POINTER_OFFSET;
728                pointer_x0 = pointer_x - (BALLOON_CORNER_RADIUS - POINTER_OFFSET);
729                pointer_x1 = pointer_x0 - POINTER_FOOT_WIDTH;
730            } else {
731                x0 -= POINTER_OFFSET;
732                pointer_x1 = pointer_x + (BALLOON_CORNER_RADIUS - POINTER_OFFSET);
733                pointer_x0 = pointer_x1 + POINTER_FOOT_WIDTH;
734            }
735    
736            gboolean bottom = FALSE;
737            if((y0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.height/2) {
738                bottom = TRUE;
739                y0 -= BALLOON_HEIGHT + POINTER_HEIGHT;
740            } else
741                y0 += POINTER_HEIGHT;
742    
743            /* calculate bottom/right of box */
744            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      cairo_close_path (cr);  #ifdef USE_CAIRO
753      cairo_set_source_rgba (cr, 1, 1, 1, TRANSPARENCY);          cairo_t *cr = gdk_cairo_create(priv->pixmap);
754      cairo_fill_preserve (cr);  
755      cairo_set_source_rgba (cr, 0, 0, 0, TRANSPARENCY);          /* --------- draw shadow --------------- */
756      cairo_set_line_width (cr, 1);          osm_gps_map_draw_balloon_shape (cr,
757      cairo_stroke (cr);                      x0 + BALLOON_SHADOW, y0 + BALLOON_SHADOW,
758                        x1 + BALLOON_SHADOW, y1 + BALLOON_SHADOW,
759      gtk_widget_queue_draw_area (GTK_WIDGET(map),                      bottom, pointer_x, pointer_y,
760                                  x0,                      pointer_x0 + BALLOON_SHADOW, pointer_x1 + BALLOON_SHADOW);
761                                  y0,  
762                                  WIDTH,          cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_SHADOW_TRANSPARENCY);
763                                  HEIGHT + PIN_HEIGHT);          cairo_fill_preserve (cr);
764            cairo_set_source_rgba (cr, 1, 0, 0, 1.0);
765            cairo_set_line_width (cr, 0);
766            cairo_stroke (cr);
767    
768            /* --------- draw main shape ----------- */
769            osm_gps_map_draw_balloon_shape (cr, x0, y0, x1, y1,
770                        bottom, pointer_x, pointer_y, pointer_x0, pointer_x1);
771    
772            cairo_set_source_rgba (cr, 1, 1, 1, BALLOON_TRANSPARENCY);
773            cairo_fill_preserve (cr);
774            cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_TRANSPARENCY);
775            cairo_set_line_width (cr, 1);
776            cairo_stroke (cr);
777    
778    
779            /* ---------- draw close button --------- */
780    
781            int cx = x1 - BALLOON_BORDER - CLOSE_BUTTON_RADIUS;
782            int cy = y0 + BALLOON_BORDER + CLOSE_BUTTON_RADIUS;
783            int crad = CLOSE_BUTTON_RADIUS;
784    
785            cairo_arc (cr, cx, cy, crad, 0, 2 * M_PI);
786            cairo_set_source_rgba (cr, 0.8, 0, 0, 1.0);
787            cairo_fill_preserve (cr);
788            cairo_set_source_rgba (cr, 0.3, 0, 0, 1.0);
789            cairo_set_line_width (cr, 2);
790            cairo_stroke(cr);
791    
792            cairo_set_source_rgba (cr, 1, 1, 1, 1.0);
793            cairo_set_line_width (cr, 3);
794            cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
795            cairo_move_to (cr, cx - crad/2, cy - crad/2);
796            cairo_line_to (cr, cx + crad/2, cy + crad/2);
797            cairo_stroke (cr);
798            cairo_move_to (cr, cx + crad/2, cy - crad/2);
799            cairo_line_to (cr, cx - crad/2, cy + crad/2);
800            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),
817                                        x0, y0, BALLOON_WIDTH,
818                                        BALLOON_HEIGHT + POINTER_HEIGHT);
819    #else
820    #warning "Balloon display lacks a non-cairo implementation!"
821  #endif  #endif
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
# Line 1244  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 1274  osm_gps_map_map_redraw (OsmGpsMap *map) Line 1578  osm_gps_map_map_redraw (OsmGpsMap *map)
1578      osm_gps_map_print_tracks(map);      osm_gps_map_print_tracks(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);
1582      osm_gps_map_draw_balloon(map);  #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 1307  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.coo = g_new0(coord_t, 1);
1617        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;
1626    
# Line 1464  osm_gps_map_dispose (GObject *object) Line 1778  osm_gps_map_dispose (GObject *object)
1778      if (priv->idle_map_redraw != 0)      if (priv->idle_map_redraw != 0)
1779          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1780    
1781        g_free(priv->gps);
1782        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    
# Line 1679  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 1693  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 1710  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 1735  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 1749  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 1837  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 2612  osm_gps_map_get_scale(OsmGpsMap *map) Line 2982  osm_gps_map_get_scale(OsmGpsMap *map)
2982      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);
2983  }  }
2984    
2985    void
2986    osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude,
2987                              OsmGpsMapBalloonCallback cb, gpointer data)
2988    {
2989        OsmGpsMapPrivate *priv;
2990    
2991        /* remove and previously installed balloon */
2992        osm_gps_map_clear_balloon (map);
2993    
2994        g_return_if_fail (OSM_IS_GPS_MAP (map));
2995        priv = map->priv;
2996    
2997        priv->balloon.coo->rlat = deg2rad(latitude);
2998        priv->balloon.coo->rlon = deg2rad(longitude);
2999        priv->balloon.valid = TRUE;
3000    
3001        priv->balloon.cb = cb;
3002        priv->balloon.data = data;
3003    
3004        // this redraws the map
3005        osm_gps_map_map_redraw_idle(map);
3006    }
3007    
3008    void
3009    osm_gps_map_clear_balloon (OsmGpsMap *map)
3010    {
3011        OsmGpsMapPrivate *priv;
3012    
3013        g_return_if_fail (OSM_IS_GPS_MAP (map));
3014        priv = map->priv;
3015    
3016        priv->balloon.valid = FALSE;
3017    
3018        osm_gps_map_map_redraw_idle(map);
3019    }

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