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

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

revision 114 by harbaum, Wed Sep 16 20:04:38 2009 UTC revision 147 by harbaum, Wed Oct 28 11:50:37 2009 UTC
# Line 149  struct _OsmGpsMapPrivate Line 149  struct _OsmGpsMapPrivate
149      int drag_start_mouse_y;      int drag_start_mouse_y;
150      int drag_start_map_x;      int drag_start_map_x;
151      int drag_start_map_y;      int drag_start_map_y;
152        guint drag_expose;
153    
154      //for customizing the redering of the gps track      //for customizing the redering of the gps track
155      int ui_gps_track_width;      int ui_gps_track_width;
# Line 1247  osm_gps_map_map_redraw (OsmGpsMap *map) Line 1248  osm_gps_map_map_redraw (OsmGpsMap *map)
1248  {  {
1249      OsmGpsMapPrivate *priv = map->priv;      OsmGpsMapPrivate *priv = map->priv;
1250    
1251        /* on diablo the map comes up at 1x1 pixel size and */
1252        /* isn't really usable. ignore this */
1253        if((GTK_WIDGET(map)->allocation.width < 10) ||
1254           (GTK_WIDGET(map)->allocation.height < 10))
1255            return FALSE;
1256    
1257      priv->idle_map_redraw = 0;      priv->idle_map_redraw = 0;
1258    
1259      /* don't redraw the entire map while the OSD is doing */      /* don't redraw the entire map while the OSD is doing */
# Line 1546  osm_gps_map_dispose (GObject *object) Line 1553  osm_gps_map_dispose (GObject *object)
1553      if (priv->idle_map_redraw != 0)      if (priv->idle_map_redraw != 0)
1554          g_source_remove (priv->idle_map_redraw);          g_source_remove (priv->idle_map_redraw);
1555    
1556        if (priv->drag_expose != 0)
1557            g_source_remove (priv->drag_expose);
1558    
1559      g_free(priv->gps);      g_free(priv->gps);
1560    
1561  #ifdef ENABLE_OSD  #ifdef ENABLE_OSD
# Line 1889  osm_gps_map_button_release (GtkWidget *w Line 1899  osm_gps_map_button_release (GtkWidget *w
1899          priv->osd->check(priv->osd, FALSE, event->x, event->y);          priv->osd->check(priv->osd, FALSE, event->x, event->y);
1900  #endif  #endif
1901    
   
1902  #ifdef DRAG_DEBUG  #ifdef DRAG_DEBUG
1903      printf("dragging done\n");      printf("dragging done\n");
1904  #endif  #endif
# Line 1903  static gboolean Line 1912  static gboolean
1912  osm_gps_map_expose (GtkWidget *widget, GdkEventExpose  *event);  osm_gps_map_expose (GtkWidget *widget, GdkEventExpose  *event);
1913    
1914  static gboolean  static gboolean
1915    osm_gps_map_map_expose (GtkWidget *widget)
1916    {
1917        OsmGpsMapPrivate *priv = OSM_GPS_MAP(widget)->priv;
1918    
1919        priv->drag_expose = 0;
1920        osm_gps_map_expose (widget, NULL);
1921        return FALSE;
1922    }
1923    
1924    static gboolean
1925  osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion  *event)  osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion  *event)
1926  {  {
1927      int x, y;      int x, y;
# Line 1925  osm_gps_map_motion_notify (GtkWidget *wi Line 1944  osm_gps_map_motion_notify (GtkWidget *wi
1944      if (priv->drag_counter < 0)      if (priv->drag_counter < 0)
1945          return FALSE;          return FALSE;
1946    
1947      priv->drag_counter++;      /* not yet dragged far enough? */
1948        if(!priv->drag_counter &&
1949      // we havent dragged more than 6 pixels         ( (x - priv->drag_start_mouse_x) * (x - priv->drag_start_mouse_x) +
1950      if (priv->drag_counter < 6)           (y - priv->drag_start_mouse_y) * (y - priv->drag_start_mouse_y) <
1951             10*10))
1952          return FALSE;          return FALSE;
1953    
1954  #ifdef OSM_GPS_MAP_REFRESH      priv->drag_counter++;
     /* reduce update frequency on maemo to keep screen update fluid */  
     static guint32 last_time = 0;  
   
     if(event->time - last_time < (1000/OSM_GPS_MAP_REFRESH)) return FALSE;  
     last_time = event->time;  
 #endif  
1955    
1956      priv->dragging = TRUE;      priv->dragging = TRUE;
1957    
# Line 1947  osm_gps_map_motion_notify (GtkWidget *wi Line 1961  osm_gps_map_motion_notify (GtkWidget *wi
1961      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;      priv->drag_mouse_dx = x - priv->drag_start_mouse_x;
1962      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;      priv->drag_mouse_dy = y - priv->drag_start_mouse_y;
1963    
1964      osm_gps_map_expose (widget, NULL);      /* instead of redrawing directly just add an idle function */
1965        if (!priv->drag_expose)
1966            priv->drag_expose =
1967                g_idle_add ((GSourceFunc)osm_gps_map_map_expose, widget);
1968    
1969      return FALSE;      return FALSE;
1970  }  }
# Line 2825  osm_gps_map_redraw (OsmGpsMap *map) Line 2842  osm_gps_map_redraw (OsmGpsMap *map)
2842      osm_gps_map_map_redraw_idle(map);      osm_gps_map_map_redraw_idle(map);
2843  }  }
2844    
2845  osm_gps_map_osd_t *osm_gps_map_osd_get(OsmGpsMap *map) {  osm_gps_map_osd_t *
2846    osm_gps_map_osd_get(OsmGpsMap *map)
2847    {
2848      g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL);      g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL);
2849      return map->priv->osd;      return map->priv->osd;
2850  }  }
2851    
2852  void osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd) {  void
2853    osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd)
2854    {
2855      OsmGpsMapPrivate *priv;      OsmGpsMapPrivate *priv;
2856    
2857      g_return_if_fail (OSM_IS_GPS_MAP (map));      g_return_if_fail (OSM_IS_GPS_MAP (map));
# Line 2842  void osm_gps_map_register_osd(OsmGpsMap Line 2863  void osm_gps_map_register_osd(OsmGpsMap
2863  }  }
2864    
2865  void  void
2866  osm_gps_map_repaint (OsmGpsMap *map) {  osm_gps_map_repaint (OsmGpsMap *map)
2867    {
2868      osm_gps_map_expose (GTK_WIDGET(map), NULL);      osm_gps_map_expose (GTK_WIDGET(map), NULL);
2869  }  }
2870    
2871    coord_t *
2872    osm_gps_map_get_gps (OsmGpsMap *map)
2873    {
2874        g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL);
2875    
2876        if(!map->priv->gps_valid)
2877            return NULL;
2878    
2879        return map->priv->gps;
2880    }
2881    
2882  #endif  #endif

Legend:
Removed from v.114  
changed lines
  Added in v.147