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; |
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. we'll just ignore this ... */ |
1253 |
|
if((GTK_WIDGET(map)->allocation.width < 2) || |
1254 |
|
(GTK_WIDGET(map)->allocation.height < 2)) { |
1255 |
|
printf("not a useful sized map yet ...\n"); |
1256 |
|
return FALSE; |
1257 |
|
} |
1258 |
|
|
1259 |
priv->idle_map_redraw = 0; |
priv->idle_map_redraw = 0; |
1260 |
|
|
1261 |
/* don't redraw the entire map while the OSD is doing */ |
/* don't redraw the entire map while the OSD is doing */ |
1555 |
if (priv->idle_map_redraw != 0) |
if (priv->idle_map_redraw != 0) |
1556 |
g_source_remove (priv->idle_map_redraw); |
g_source_remove (priv->idle_map_redraw); |
1557 |
|
|
1558 |
|
if (priv->drag_expose != 0) |
1559 |
|
g_source_remove (priv->drag_expose); |
1560 |
|
|
1561 |
g_free(priv->gps); |
g_free(priv->gps); |
1562 |
|
|
1563 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1901 |
priv->osd->check(priv->osd, FALSE, event->x, event->y); |
priv->osd->check(priv->osd, FALSE, event->x, event->y); |
1902 |
#endif |
#endif |
1903 |
|
|
|
|
|
1904 |
#ifdef DRAG_DEBUG |
#ifdef DRAG_DEBUG |
1905 |
printf("dragging done\n"); |
printf("dragging done\n"); |
1906 |
#endif |
#endif |
1914 |
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
1915 |
|
|
1916 |
static gboolean |
static gboolean |
1917 |
|
osm_gps_map_map_expose (GtkWidget *widget) |
1918 |
|
{ |
1919 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP(widget)->priv; |
1920 |
|
|
1921 |
|
priv->drag_expose = 0; |
1922 |
|
osm_gps_map_expose (widget, NULL); |
1923 |
|
return FALSE; |
1924 |
|
} |
1925 |
|
|
1926 |
|
static gboolean |
1927 |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
1928 |
{ |
{ |
1929 |
int x, y; |
int x, y; |
1946 |
if (priv->drag_counter < 0) |
if (priv->drag_counter < 0) |
1947 |
return FALSE; |
return FALSE; |
1948 |
|
|
1949 |
priv->drag_counter++; |
/* not yet dragged far enough? */ |
1950 |
|
if(!priv->drag_counter && |
1951 |
// we havent dragged more than 6 pixels |
( (x - priv->drag_start_mouse_x) * (x - priv->drag_start_mouse_x) + |
1952 |
if (priv->drag_counter < 6) |
(y - priv->drag_start_mouse_y) * (y - priv->drag_start_mouse_y) < |
1953 |
|
10*10)) |
1954 |
return FALSE; |
return FALSE; |
1955 |
|
|
1956 |
#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 |
|
1957 |
|
|
1958 |
priv->dragging = TRUE; |
priv->dragging = TRUE; |
1959 |
|
|
1963 |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
1964 |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
1965 |
|
|
1966 |
osm_gps_map_expose (widget, NULL); |
/* instead of redrawing directly just add an idle function */ |
1967 |
|
if (!priv->drag_expose) |
1968 |
|
priv->drag_expose = |
1969 |
|
g_idle_add ((GSourceFunc)osm_gps_map_map_expose, widget); |
1970 |
|
|
1971 |
return FALSE; |
return FALSE; |
1972 |
} |
} |
2844 |
osm_gps_map_map_redraw_idle(map); |
osm_gps_map_map_redraw_idle(map); |
2845 |
} |
} |
2846 |
|
|
2847 |
osm_gps_map_osd_t *osm_gps_map_osd_get(OsmGpsMap *map) { |
osm_gps_map_osd_t * |
2848 |
|
osm_gps_map_osd_get(OsmGpsMap *map) |
2849 |
|
{ |
2850 |
g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL); |
g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL); |
2851 |
return map->priv->osd; |
return map->priv->osd; |
2852 |
} |
} |
2853 |
|
|
2854 |
void osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd) { |
void |
2855 |
|
osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd) |
2856 |
|
{ |
2857 |
OsmGpsMapPrivate *priv; |
OsmGpsMapPrivate *priv; |
2858 |
|
|
2859 |
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
g_return_if_fail (OSM_IS_GPS_MAP (map)); |
2865 |
} |
} |
2866 |
|
|
2867 |
void |
void |
2868 |
osm_gps_map_repaint (OsmGpsMap *map) { |
osm_gps_map_repaint (OsmGpsMap *map) |
2869 |
|
{ |
2870 |
osm_gps_map_expose (GTK_WIDGET(map), NULL); |
osm_gps_map_expose (GTK_WIDGET(map), NULL); |
2871 |
} |
} |
2872 |
|
|
2873 |
|
coord_t * |
2874 |
|
osm_gps_map_get_gps (OsmGpsMap *map) |
2875 |
|
{ |
2876 |
|
g_return_val_if_fail (OSM_IS_GPS_MAP (map), NULL); |
2877 |
|
|
2878 |
|
if(!map->priv->gps_valid) |
2879 |
|
return NULL; |
2880 |
|
|
2881 |
|
return map->priv->gps; |
2882 |
|
} |
2883 |
|
|
2884 |
#endif |
#endif |