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. 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 */ |
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 |
1807 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1808 |
/* pressed inside OSD control? */ |
/* pressed inside OSD control? */ |
1809 |
if(priv->osd) { |
if(priv->osd) { |
1810 |
osd_button_t but = priv->osd->check(priv->osd, event->x, event->y); |
osd_button_t but = |
1811 |
|
priv->osd->check(priv->osd, TRUE, event->x, event->y); |
1812 |
|
|
1813 |
if(but != OSD_NONE) |
if(but != OSD_NONE) |
1814 |
{ |
{ |
1815 |
int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
int step = |
1816 |
|
GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
1817 |
priv->drag_counter = -1; |
priv->drag_counter = -1; |
1818 |
|
|
1819 |
switch(but) { |
switch(but) { |
1893 |
|
|
1894 |
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
1895 |
} |
} |
1896 |
|
#ifdef ENABLE_OSD |
1897 |
|
/* pressed inside OSD control? */ |
1898 |
|
else if(priv->osd) |
1899 |
|
priv->osd->check(priv->osd, FALSE, event->x, event->y); |
1900 |
|
#endif |
1901 |
|
|
1902 |
#ifdef DRAG_DEBUG |
#ifdef DRAG_DEBUG |
1903 |
printf("dragging done\n"); |
printf("dragging done\n"); |
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; |
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 |
|
|
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 |
} |
} |
2795 |
priv = map->priv; |
priv = map->priv; |
2796 |
|
|
2797 |
if (pixel_x) |
if (pixel_x) |
2798 |
*pixel_x = lon2pixel(priv->map_zoom, deg2rad(longitude)) - priv->map_x; |
*pixel_x = lon2pixel(priv->map_zoom, deg2rad(longitude)) - |
2799 |
|
priv->map_x + priv->drag_mouse_dx; |
2800 |
if (pixel_y) |
if (pixel_y) |
2801 |
*pixel_y = lat2pixel(priv->map_zoom, deg2rad(latitude)) - priv->map_y; |
*pixel_y = lat2pixel(priv->map_zoom, deg2rad(latitude)) - |
2802 |
|
priv->map_y + priv->drag_mouse_dy; |
2803 |
} |
} |
2804 |
|
|
2805 |
void |
void |
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)); |
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 |