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; |
1547 |
if (priv->idle_map_redraw != 0) |
if (priv->idle_map_redraw != 0) |
1548 |
g_source_remove (priv->idle_map_redraw); |
g_source_remove (priv->idle_map_redraw); |
1549 |
|
|
1550 |
|
if (priv->drag_expose != 0) |
1551 |
|
g_source_remove (priv->drag_expose); |
1552 |
|
|
1553 |
g_free(priv->gps); |
g_free(priv->gps); |
1554 |
|
|
1555 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1801 |
#ifdef ENABLE_OSD |
#ifdef ENABLE_OSD |
1802 |
/* pressed inside OSD control? */ |
/* pressed inside OSD control? */ |
1803 |
if(priv->osd) { |
if(priv->osd) { |
1804 |
osd_button_t but = priv->osd->check(priv->osd, event->x, event->y); |
osd_button_t but = |
1805 |
|
priv->osd->check(priv->osd, TRUE, event->x, event->y); |
1806 |
|
|
1807 |
if(but != OSD_NONE) |
if(but != OSD_NONE) |
1808 |
{ |
{ |
1809 |
int step = GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
int step = |
1810 |
|
GTK_WIDGET(widget)->allocation.width/OSM_GPS_MAP_SCROLL_STEP; |
1811 |
priv->drag_counter = -1; |
priv->drag_counter = -1; |
1812 |
|
|
1813 |
switch(but) { |
switch(but) { |
1887 |
|
|
1888 |
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
osm_gps_map_map_redraw_idle(OSM_GPS_MAP(widget)); |
1889 |
} |
} |
1890 |
|
#ifdef ENABLE_OSD |
1891 |
|
/* pressed inside OSD control? */ |
1892 |
|
else if(priv->osd) |
1893 |
|
priv->osd->check(priv->osd, FALSE, event->x, event->y); |
1894 |
|
#endif |
1895 |
|
|
1896 |
#ifdef DRAG_DEBUG |
#ifdef DRAG_DEBUG |
1897 |
printf("dragging done\n"); |
printf("dragging done\n"); |
1906 |
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
osm_gps_map_expose (GtkWidget *widget, GdkEventExpose *event); |
1907 |
|
|
1908 |
static gboolean |
static gboolean |
1909 |
|
osm_gps_map_map_expose (GtkWidget *widget) |
1910 |
|
{ |
1911 |
|
OsmGpsMapPrivate *priv = OSM_GPS_MAP(widget)->priv; |
1912 |
|
|
1913 |
|
priv->drag_expose = 0; |
1914 |
|
osm_gps_map_expose (widget, NULL); |
1915 |
|
return FALSE; |
1916 |
|
} |
1917 |
|
|
1918 |
|
static gboolean |
1919 |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
osm_gps_map_motion_notify (GtkWidget *widget, GdkEventMotion *event) |
1920 |
{ |
{ |
1921 |
int x, y; |
int x, y; |
1938 |
if (priv->drag_counter < 0) |
if (priv->drag_counter < 0) |
1939 |
return FALSE; |
return FALSE; |
1940 |
|
|
1941 |
priv->drag_counter++; |
/* not yet dragged far enough? */ |
1942 |
|
if(!priv->drag_counter && |
1943 |
// we havent dragged more than 6 pixels |
( (x - priv->drag_start_mouse_x) * (x - priv->drag_start_mouse_x) + |
1944 |
if (priv->drag_counter < 6) |
(y - priv->drag_start_mouse_y) * (y - priv->drag_start_mouse_y) < |
1945 |
|
10*10)) |
1946 |
return FALSE; |
return FALSE; |
1947 |
|
|
1948 |
#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 |
|
1949 |
|
|
1950 |
priv->dragging = TRUE; |
priv->dragging = TRUE; |
1951 |
|
|
1955 |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
priv->drag_mouse_dx = x - priv->drag_start_mouse_x; |
1956 |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
priv->drag_mouse_dy = y - priv->drag_start_mouse_y; |
1957 |
|
|
1958 |
osm_gps_map_expose (widget, NULL); |
/* instead of redrawing directly just add an idle function */ |
1959 |
|
if (!priv->drag_expose) |
1960 |
|
priv->drag_expose = |
1961 |
|
g_idle_add ((GSourceFunc)osm_gps_map_map_expose, widget); |
1962 |
|
|
1963 |
return FALSE; |
return FALSE; |
1964 |
} |
} |