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

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

revision 55 by harbaum, Thu Aug 13 12:01:52 2009 UTC revision 62 by harbaum, Tue Aug 18 20:33:08 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            //        GdkPixbuf *pixbuf;
116        } osd;
117    #endif
118    
119      //additional images or tracks added to the map      //additional images or tracks added to the map
120      GSList *tracks;      GSList *tracks;
121      GSList *images;      GSList *images;
# Line 631  osm_gps_map_draw_gps_point (OsmGpsMap *m Line 649  osm_gps_map_draw_gps_point (OsmGpsMap *m
649                                      (mr*2)+lw+lw);                                      (mr*2)+lw+lw);
650  #endif  #endif
651      }      }
652    }
653    
654    /* most visual effects are hardcoded by now, but may be made */
655    /* available via properties later */
656    #define BALLOON_AREA_WIDTH           290
657    #define BALLOON_AREA_HEIGHT           75
658    
659    #define BALLOON_CORNER_RADIUS         20
660    #define BALLOON_BORDER               (BALLOON_CORNER_RADIUS/4)
661    #define BALLOON_WIDTH                (BALLOON_AREA_WIDTH + 2 * BALLOON_BORDER)
662    #define BALLOON_HEIGHT               (BALLOON_AREA_HEIGHT + 2 * BALLOON_BORDER)
663    #define BALLOON_TRANSPARENCY         0.8
664    #define POINTER_HEIGHT                20
665    #define POINTER_FOOT_WIDTH            20
666    #define POINTER_OFFSET               (BALLOON_CORNER_RADIUS*3/4)
667    #define BALLOON_SHADOW                5
668    #define BALLOON_SHADOW_TRANSPARENCY  0.2
669    
670    #define CLOSE_BUTTON_RADIUS   (BALLOON_CORNER_RADIUS/3)
671    
672    
673    /* draw the bubble shape. this is used twice, once for the shape and once */
674    /* for the shadow */
675    static void
676    osm_gps_map_draw_balloon_shape (cairo_t *cr, int x0, int y0, int x1, int y1,
677           gboolean bottom, int px, int py, int px0, int px1) {
678    
679        cairo_move_to (cr, x0, y0 + BALLOON_CORNER_RADIUS);
680        cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + BALLOON_CORNER_RADIUS, y0);
681        if(!bottom) {
682            /* insert top pointer */
683            cairo_line_to (cr, px1, y0);
684            cairo_line_to (cr, px, py);
685            cairo_line_to (cr, px0, y0);
686        }
687    
688        cairo_line_to (cr, x1 - BALLOON_CORNER_RADIUS, y0);
689        cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + BALLOON_CORNER_RADIUS);
690        cairo_line_to (cr, x1 , y1 - BALLOON_CORNER_RADIUS);
691        cairo_curve_to (cr, x1, y1, x1, y1, x1 - BALLOON_CORNER_RADIUS, y1);
692        if(bottom) {
693            /* insert bottom pointer */
694            cairo_line_to (cr, px0, y1);
695            cairo_line_to (cr, px, py);
696            cairo_line_to (cr, px1, y1);
697        }
698    
699        cairo_line_to (cr, x0 + BALLOON_CORNER_RADIUS, y1);
700        cairo_curve_to (cr, x0, y1, x0, y1, x0, y1 - BALLOON_CORNER_RADIUS);
701    
702        cairo_close_path (cr);
703    }
704    
705    static void
706    osm_gps_map_draw_balloon_int (OsmGpsMap *map)
707    {
708        OsmGpsMapPrivate *priv = map->priv;
709    
710        if (priv->balloon.valid) {
711    
712            /* ------- convert given coordinate into screen position --------- */
713            int x0 = lon2pixel(priv->map_zoom, priv->balloon.coo->rlon) -
714                priv->map_x + EXTRA_BORDER;
715            int y0 = lat2pixel(priv->map_zoom, priv->balloon.coo->rlat) -
716                priv->map_y + EXTRA_BORDER;
717    
718            /* check position of this relative to screen center to determine */
719            /* pointer direction ... */
720            int pointer_x = x0, pointer_x0, pointer_x1;
721            int pointer_y = y0;
722    
723            /* ... and calculate position */
724            if((x0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.width/2) {
725                x0 -= BALLOON_WIDTH - POINTER_OFFSET;
726                pointer_x0 = pointer_x - (BALLOON_CORNER_RADIUS - POINTER_OFFSET);
727                pointer_x1 = pointer_x0 - POINTER_FOOT_WIDTH;
728            } else {
729                x0 -= POINTER_OFFSET;
730                pointer_x1 = pointer_x + (BALLOON_CORNER_RADIUS - POINTER_OFFSET);
731                pointer_x0 = pointer_x1 + POINTER_FOOT_WIDTH;
732            }
733    
734            gboolean bottom = FALSE;
735            if((y0 - EXTRA_BORDER) > GTK_WIDGET(map)->allocation.height/2) {
736                bottom = TRUE;
737                y0 -= BALLOON_HEIGHT + POINTER_HEIGHT;
738            } else
739                y0 += POINTER_HEIGHT;
740    
741            /* calculate bottom/right of box */
742            int x1 = x0 + BALLOON_WIDTH, y1 = y0 + BALLOON_HEIGHT;
743    
744            /* save balloon screen coordinates for later use */
745            priv->balloon.rect.x = x0 + BALLOON_BORDER;
746            priv->balloon.rect.y = y0 + BALLOON_BORDER;
747            priv->balloon.rect.w = x1 - x0 - 2*BALLOON_BORDER;
748            priv->balloon.rect.h = y1 - y0 - 2*BALLOON_BORDER;
749    
750    #ifdef USE_CAIRO
751            cairo_t *cr = gdk_cairo_create(priv->pixmap);
752    
753            /* --------- draw shadow --------------- */
754            osm_gps_map_draw_balloon_shape (cr,
755                        x0 + BALLOON_SHADOW, y0 + BALLOON_SHADOW,
756                        x1 + BALLOON_SHADOW, y1 + BALLOON_SHADOW,
757                        bottom, pointer_x, pointer_y,
758                        pointer_x0 + BALLOON_SHADOW, pointer_x1 + BALLOON_SHADOW);
759    
760            cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_SHADOW_TRANSPARENCY);
761            cairo_fill_preserve (cr);
762            cairo_set_source_rgba (cr, 1, 0, 0, 1.0);
763            cairo_set_line_width (cr, 0);
764            cairo_stroke (cr);
765    
766            /* --------- draw main shape ----------- */
767            osm_gps_map_draw_balloon_shape (cr, x0, y0, x1, y1,
768                        bottom, pointer_x, pointer_y, pointer_x0, pointer_x1);
769    
770            cairo_set_source_rgba (cr, 1, 1, 1, BALLOON_TRANSPARENCY);
771            cairo_fill_preserve (cr);
772            cairo_set_source_rgba (cr, 0, 0, 0, BALLOON_TRANSPARENCY);
773            cairo_set_line_width (cr, 1);
774            cairo_stroke (cr);
775    
776    
777            /* ---------- draw close button --------- */
778    
779            int cx = x1 - BALLOON_BORDER - CLOSE_BUTTON_RADIUS;
780            int cy = y0 + BALLOON_BORDER + CLOSE_BUTTON_RADIUS;
781            int crad = CLOSE_BUTTON_RADIUS;
782    
783            cairo_arc (cr, cx, cy, crad, 0, 2 * M_PI);
784            cairo_set_source_rgba (cr, 0.8, 0, 0, 1.0);
785            cairo_fill_preserve (cr);
786            cairo_set_source_rgba (cr, 0.3, 0, 0, 1.0);
787            cairo_set_line_width (cr, 2);
788            cairo_stroke(cr);
789    
790            cairo_set_source_rgba (cr, 1, 1, 1, 1.0);
791            cairo_set_line_width (cr, 3);
792            cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
793            cairo_move_to (cr, cx - crad/2, cy - crad/2);
794            cairo_line_to (cr, cx + crad/2, cy + crad/2);
795            cairo_stroke (cr);
796            cairo_move_to (cr, cx + crad/2, cy - crad/2);
797            cairo_line_to (cr, cx - crad/2, cy + crad/2);
798            cairo_stroke (cr);
799    
800            if (priv->balloon.cb) {
801                /* clip in case application tries to draw in */
802                /* exceed of the balloon */
803                cairo_rectangle (cr, priv->balloon.rect.x, priv->balloon.rect.y,
804                                 priv->balloon.rect.w, priv->balloon.rect.h);
805                cairo_clip (cr);
806                cairo_new_path (cr);  /* current path is not
807                                         consumed by cairo_clip() */
808    
809                priv->balloon.cb(cr, &priv->balloon.rect, priv->balloon.data);
810            }
811    
812            cairo_destroy(cr);
813    
814            gtk_widget_queue_draw_area (GTK_WIDGET(map),
815                                        x0, y0, BALLOON_WIDTH,
816                                        BALLOON_HEIGHT + POINTER_HEIGHT);
817    #else
818    #warning "Balloon display lacks a non-cairo implementation!"
819    #endif
820        }
821    }
822    
823    /* the user clicked into the balloons main area. handle this */
824    static void
825    osm_gps_map_handle_balloon_click(OsmGpsMap *map, gint x, gint y)
826    {
827        OsmGpsMapPrivate *priv = map->priv;
828    
829        if (!priv->balloon.valid)
830            return;
831    
832        /* check if the close button was clicked */
833        if ((x > priv->balloon.rect.w - 2*CLOSE_BUTTON_RADIUS) &&
834            (x < priv->balloon.rect.w) &&
835            (y > 0) && (y < 2*CLOSE_BUTTON_RADIUS)) {
836    
837            priv->balloon.valid = FALSE;
838            osm_gps_map_map_redraw_idle(map);
839        }
840    }
841    
842    /* return true if balloon is being displayed and if */
843    /* the given coordinate is within this balloon */
844    static gboolean
845    osm_gps_map_in_balloon(OsmGpsMapPrivate *priv, gint x, gint y)
846    {
847        return (priv->balloon.valid &&
848                (x > priv->balloon.rect.x) &&
849                (x < priv->balloon.rect.x + priv->balloon.rect.w) &&
850                (y > priv->balloon.rect.y) &&
851                (y < priv->balloon.rect.y + priv->balloon.rect.h));
852  }  }
853    
854  static void  static void
# Line 695  osm_gps_map_tile_download_complete (Soup Line 913  osm_gps_map_tile_download_complete (Soup
913              }              }
914              else              else
915              {              {
916                  g_warning("Error creating tile download directory: %s", dl->folder);                  g_warning("Error creating tile download directory: %s",
917                              dl->folder);
918                    perror("perror:");
919              }              }
920          }          }
921    
# Line 1187  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+2, OSD_H+2, -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-1, y-1, 0, 0, OSD_W+2, OSD_H+2);
1434        priv->osd.backup_x = x-1;
1435        priv->osd.backup_y = y-1;
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    #define Z_STEP   -5
1466    #define Z_RAD    15
1467    #define Z_TOP    2*RAD+Z_STEP
1468    #define Z_MID    Z_TOP+Z_RAD
1469    #define Z_BOT    Z_MID+Z_RAD
1470    #define Z_LEFT   Z_RAD
1471    #define Z_RIGHT  2*RAD-Z_RAD
1472    
1473        /* --------- the direction "pad" shape and shadow ----------- */
1474    
1475        cairo_move_to (cr, x+Z_LEFT+5,    y+Z_TOP+5);
1476        cairo_line_to (cr, x+Z_RIGHT+5,   y+Z_TOP+5);
1477        cairo_arc     (cr, x+Z_RIGHT+5,   y+Z_MID+5, Z_RAD, -M_PI/2,  M_PI/2);
1478        cairo_line_to (cr, x+Z_LEFT+5,    y+Z_BOT+5);
1479        cairo_arc     (cr, x+Z_LEFT+5,    y+Z_MID+5, Z_RAD,  M_PI/2, -M_PI/2);
1480        cairo_close_path (cr);
1481    
1482        cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
1483        cairo_fill (cr);
1484        cairo_stroke (cr);
1485    
1486        cairo_arc (cr, x+RAD+5, y+RAD+5, RAD, 0, 2 * M_PI);
1487        cairo_close_path (cr);
1488    
1489        cairo_set_source_rgba (cr, 0, 0, 0, 0.2);
1490        cairo_fill (cr);
1491        cairo_stroke (cr);
1492    
1493    
1494        cairo_move_to (cr, x+Z_LEFT,    y+Z_TOP);
1495        cairo_line_to (cr, x+Z_RIGHT,   y+Z_TOP);
1496        cairo_arc     (cr, x+Z_RIGHT,   y+Z_MID, Z_RAD, -M_PI/2,  M_PI/2);
1497        cairo_line_to (cr, x+Z_LEFT,    y+Z_BOT);
1498        cairo_arc     (cr, x+Z_LEFT,    y+Z_MID, Z_RAD,  M_PI/2, -M_PI/2);
1499        cairo_close_path (cr);
1500    
1501        cairo_set_source_rgb (cr, 1, 1, 1);
1502        cairo_fill_preserve (cr);
1503        cairo_set_source_rgb (cr, 0.6, 0.6, 1);
1504        cairo_set_line_width (cr, 1);
1505        cairo_stroke (cr);
1506    
1507        cairo_arc (cr, x+RAD, y+RAD, RAD, 0, 2 * M_PI);
1508        cairo_close_path (cr);
1509    
1510        cairo_set_source_rgb (cr, 1, 1, 1);
1511        cairo_fill_preserve (cr);
1512        cairo_set_source_rgb (cr, 0.6, 0.6, 1);
1513        cairo_set_line_width (cr, 1);
1514        cairo_stroke (cr);
1515    
1516        /* ---------- the zoom pad shape and shadow  -------------- */
1517    
1518    
1519    
1520        /* left arrow/triangle */
1521        cairo_move_to (cr, x+RAD-TIP, y+RAD);
1522        cairo_rel_line_to (cr, +LEN, -WID/2);
1523        cairo_rel_line_to (cr,    0,   +WID);
1524        cairo_rel_line_to (cr, -LEN, -WID/2);
1525        cairo_close_path (cr);
1526    
1527        /* right arrow/triangle */
1528        cairo_move_to (cr, x+RAD+TIP, y+RAD);
1529        cairo_rel_line_to (cr, -LEN, -WID/2);
1530        cairo_rel_line_to (cr,    0,   +WID);
1531        cairo_rel_line_to (cr, +LEN, -WID/2);
1532        cairo_close_path (cr);
1533    
1534        /* top arrow/triangle */
1535        cairo_move_to (cr, x+RAD, y+RAD-TIP);
1536        cairo_rel_line_to (cr, -WID/2, +LEN);
1537        cairo_rel_line_to (cr,   +WID,    0);
1538        cairo_rel_line_to (cr, -WID/2, -LEN);
1539        cairo_close_path (cr);
1540    
1541        /* bottom arrow/triangle */
1542        cairo_move_to (cr, x+RAD, y+RAD+TIP);
1543        cairo_rel_line_to (cr, -WID/2, -LEN);
1544        cairo_rel_line_to (cr,   +WID,    0);
1545        cairo_rel_line_to (cr, -WID/2, +LEN);
1546        cairo_close_path (cr);
1547    
1548        cairo_set_source_rgb (cr, 0.6, 0.6, 1);
1549        cairo_fill_preserve (cr);
1550        cairo_set_line_width (cr, 0);
1551        cairo_set_source_rgba (cr, 0, 0, 0, 1);
1552        cairo_stroke (cr);
1553    
1554    
1555        cairo_destroy(cr);
1556    
1557    #else
1558    #warning "OSD control display lacks a non-cairo implementation!"
1559    #endif
1560    }
1561    
1562    static void
1563    osm_gps_map_osd_restore (OsmGpsMap *map)
1564    {
1565        OsmGpsMapPrivate *priv = map->priv;
1566    
1567        /* restore backup of previous contents */
1568        if(priv->osd.backup) {
1569            /* create backup of background */
1570            gdk_draw_drawable(priv->pixmap,
1571                GTK_WIDGET(map)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(map))],
1572                          priv->osd.backup, 0, 0,
1573                          priv->osd.backup_x, priv->osd.backup_y, OSD_W+2, OSD_H+2);
1574        }
1575    }
1576    
1577    #endif
1578    
1579  static gboolean  static gboolean
1580  osm_gps_map_map_redraw (OsmGpsMap *map)  osm_gps_map_map_redraw (OsmGpsMap *map)
1581  {  {
# Line 1217  osm_gps_map_map_redraw (OsmGpsMap *map) Line 1606  osm_gps_map_map_redraw (OsmGpsMap *map)
1606      osm_gps_map_print_tracks(map);      osm_gps_map_print_tracks(map);
1607      osm_gps_map_draw_gps_point(map);      osm_gps_map_draw_gps_point(map);
1608      osm_gps_map_print_images(map);      osm_gps_map_print_images(map);
1609        osm_gps_map_draw_balloon_int(map);
1610    #ifdef ENABLE_OSD
1611        osm_gps_map_draw_osd_controls(map, 0, 0);
1612    #endif
1613    
1614      //osm_gps_map_osd_speed(map, 1.5);      //osm_gps_map_osd_speed(map, 1.5);
1615      osm_gps_map_purge_cache(map);      osm_gps_map_purge_cache(map);
# Line 1248  osm_gps_map_init (OsmGpsMap *object) Line 1641  osm_gps_map_init (OsmGpsMap *object)
1641      priv->gps = g_new0(coord_t, 1);      priv->gps = g_new0(coord_t, 1);
1642      priv->gps_valid = FALSE;      priv->gps_valid = FALSE;
1643    
1644        priv->balloon.coo = g_new0(coord_t, 1);
1645        priv->balloon.valid = FALSE;
1646        priv->balloon.cb = NULL;
1647    
1648    #ifdef ENABLE_OSD
1649        priv->osd.backup = NULL;
1650    #endif
1651    
1652      priv->tracks = NULL;      priv->tracks = NULL;
1653      priv->images = NULL;      priv->images = NULL;
1654    
# Line 1405  osm_gps_map_dispose (GObject *object) Line 1806  osm_gps_map_dispose (GObject *object)
1806      if (priv->idle_map_redraw != 0)      if (priv->idle_map_redraw != 0)
1807          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1808    
1809        g_free(priv->gps);
1810        g_free(priv->balloon.coo);
1811    
1812    #ifdef ENABLE_OSD
1813        if (priv->osd.backup)
1814            g_object_unref(priv->osd.backup);
1815    #endif
1816    
1817      G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object);      G_OBJECT_CLASS (osm_gps_map_parent_class)->dispose (object);
1818  }  }
1819    
# Line 1620  osm_gps_map_button_press (GtkWidget *wid Line 2029  osm_gps_map_button_press (GtkWidget *wid
2029  {  {
2030      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2031    
2032        /* don't drag if the user clicked within the balloon */
2033        if (osm_gps_map_in_balloon(priv,
2034                       event->x + EXTRA_BORDER,
2035                       event->y + EXTRA_BORDER))
2036        {
2037            priv->drag_counter = -1;
2038            return FALSE;
2039        }
2040    
2041      priv->drag_counter = 0;      priv->drag_counter = 0;
2042      priv->drag_start_mouse_x = (int) event->x;      priv->drag_start_mouse_x = (int) event->x;
2043      priv->drag_start_mouse_y = (int) event->y;      priv->drag_start_mouse_y = (int) event->y;
# Line 1634  osm_gps_map_button_release (GtkWidget *w Line 2052  osm_gps_map_button_release (GtkWidget *w
2052  {  {
2053      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);      OsmGpsMapPrivate *priv = OSM_GPS_MAP_PRIVATE(widget);
2054    
2055        /* released inside the balloon? */
2056        if (osm_gps_map_in_balloon(priv,
2057                       event->x + EXTRA_BORDER,
2058                       event->y + EXTRA_BORDER))
2059        {
2060            osm_gps_map_handle_balloon_click(OSM_GPS_MAP(widget),
2061                 event->x - priv->balloon.rect.x + EXTRA_BORDER,
2062                 event->y - priv->balloon.rect.y + EXTRA_BORDER);
2063            return FALSE;
2064        }
2065    
2066        if (priv->drag_counter < 0)
2067            return FALSE;
2068    
2069      if (priv->dragging)      if (priv->dragging)
2070      {      {
2071          priv->dragging = FALSE;          priv->dragging = FALSE;
# Line 1651  osm_gps_map_button_release (GtkWidget *w Line 2083  osm_gps_map_button_release (GtkWidget *w
2083    
2084      priv->drag_mouse_dx = 0;      priv->drag_mouse_dx = 0;
2085      priv->drag_mouse_dy = 0;      priv->drag_mouse_dy = 0;
2086      priv->drag_counter = 0;      priv->drag_counter = -1;
2087    
2088      return FALSE;      return FALSE;
2089  }  }
# Line 1676  osm_gps_map_motion_notify (GtkWidget *wi Line 2108  osm_gps_map_motion_notify (GtkWidget *wi
2108      if (!(state & GDK_BUTTON1_MASK))      if (!(state & GDK_BUTTON1_MASK))
2109          return FALSE;          return FALSE;
2110    
2111        if (priv->drag_counter < 0)
2112            return FALSE;
2113    
2114      priv->drag_counter++;      priv->drag_counter++;
2115    
2116      // we havent dragged more than 6 pixels      // we havent dragged more than 6 pixels
# Line 1690  osm_gps_map_motion_notify (GtkWidget *wi Line 2125  osm_gps_map_motion_notify (GtkWidget *wi
2125      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;
2126      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;
2127    
2128    #ifdef ENABLE_OSD
2129        /* undo OSD */
2130        osm_gps_map_osd_restore (OSM_GPS_MAP(widget));
2131    
2132        /* draw new OSD */
2133        osm_gps_map_draw_osd_controls (OSM_GPS_MAP(widget),
2134                                       -priv->drag_mouse_dx,
2135                                       -priv->drag_mouse_dy);
2136    #endif
2137    
2138      gdk_draw_drawable (      gdk_draw_drawable (
2139                         widget->window,                         widget->window,
2140                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
# Line 1778  osm_gps_map_expose (GtkWidget *widget, G Line 2223  osm_gps_map_expose (GtkWidget *widget, G
2223                         widget->window,                         widget->window,
2224                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],                         widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
2225                         priv->pixmap,                         priv->pixmap,
2226                         event->area.x + EXTRA_BORDER, event->area.y + EXTRA_BORDER,                         event->area.x + EXTRA_BORDER,
2227                           event->area.y + EXTRA_BORDER,
2228                         event->area.x, event->area.y,                         event->area.x, event->area.y,
2229                         event->area.width, event->area.height);                         event->area.width, event->area.height);
2230    
2231    #ifdef ENABLE_OSD_OVL
2232        /* TODO: intersect with area */
2233        if (priv->osd.pixbuf)
2234        {
2235            //        gdk_draw_drawable (widget->window,
2236            //            widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
2237            //            priv->osd.pixbuf, 0, 0,
2238            //            OSD_X, OSD_Y, OSD_W, OSD_H);
2239        }
2240    #endif
2241    
2242      return FALSE;      return FALSE;
2243  }  }
2244    
# Line 2553  osm_gps_map_get_scale(OsmGpsMap *map) Line 3010  osm_gps_map_get_scale(OsmGpsMap *map)
3010      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);
3011  }  }
3012    
3013    void
3014    osm_gps_map_draw_balloon (OsmGpsMap *map, float latitude, float longitude,
3015                              OsmGpsMapBalloonCallback cb, gpointer data)
3016    {
3017        OsmGpsMapPrivate *priv;
3018    
3019        /* remove and previously installed balloon */
3020        osm_gps_map_clear_balloon (map);
3021    
3022        g_return_if_fail (OSM_IS_GPS_MAP (map));
3023        priv = map->priv;
3024    
3025        priv->balloon.coo->rlat = deg2rad(latitude);
3026        priv->balloon.coo->rlon = deg2rad(longitude);
3027        priv->balloon.valid = TRUE;
3028    
3029        priv->balloon.cb = cb;
3030        priv->balloon.data = data;
3031    
3032        // this redraws the map
3033        osm_gps_map_map_redraw_idle(map);
3034    }
3035    
3036    void
3037    osm_gps_map_clear_balloon (OsmGpsMap *map)
3038    {
3039        OsmGpsMapPrivate *priv;
3040    
3041        g_return_if_fail (OSM_IS_GPS_MAP (map));
3042        priv = map->priv;
3043    
3044        priv->balloon.valid = FALSE;
3045    
3046        osm_gps_map_map_redraw_idle(map);
3047    }

Legend:
Removed from v.55  
changed lines
  Added in v.62