#include "settings.h"
#include "latlon.h"
#include "gpx.h"
+#include "speak.h"
#include "map-poi.h"
#include "map-download.h"
static gint zoom_timeout_sid=0;
static gint map_mode=0;
+static gboolean map_data_needs_refresh=FALSE;
static osm_location map_loc = {NULL, NULL, NULL, FALSE, FALSE, 0, 0, 0.0, 0.0, 0 };
*
*/
static gboolean
-map_follow_move_cb(GtkWidget *widget, GdkEventMotion *event)
+map_follow_move_cb(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
GdkModifierType state;
gint xx, yy;
guint unitx, unity;
guint cx, cy;
+if (!(event->state & GDK_BUTTON1_MASK))
+ return FALSE;
+
if (event->is_hint) {
gdk_window_get_pointer(event->window, &xx, &yy, &state);
state = event->state;
cy = unit2y(_center.unity);
map_center_unit(x2unit((gint) (cx - (xx - before[0]))), y2unit((gint) (cy - (yy - before[1]))));
+map_data_needs_refresh=TRUE;
before[0] = xx;
before[1] = yy;
return FALSE;
}
-/* We can zoom more - tell them how much they're zooming. */
-{
- gchar buffer[32];
- snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), _key_zoom_new);
- MACRO_BANNER_SHOW_INFO(_window, buffer);
-}
return TRUE;
}
distance = calculate_distance(lat1, lon1, lat2, lon2) * UNITS_CONVERT[_units];
if (distance < 1.f)
- snprintf(buffer, sizeof(buffer),
- "%0.2f %s", distance,
- UNITS_TEXT[_units]);
+ snprintf(buffer, sizeof(buffer), "%0.2f %s", distance, UNITS_TEXT[_units]);
else if (distance < 10.f)
- snprintf(buffer, sizeof(buffer),
- "%0.1f %s", distance,
- UNITS_TEXT[_units]);
+ snprintf(buffer, sizeof(buffer), "%0.1f %s", distance, UNITS_TEXT[_units]);
else
- snprintf(buffer, sizeof(buffer),
- "%0.f %s", distance,
- UNITS_TEXT[_units]);
+ snprintf(buffer, sizeof(buffer), "%0.f %s", distance, UNITS_TEXT[_units]);
pango_layout_set_text(_scale_layout, buffer, -1);
pango_layout_get_pixel_size(_scale_layout, &width, NULL);
nzoom = _zoom + zdir;
if ((nzoom > 0) && (nzoom < MAX_ZOOM - 1)) {
- snprintf(buffer, sizeof(buffer), "%s %d", _("Zoom to Level"), nzoom);
- MACRO_BANNER_SHOW_INFO(_window, buffer);
map_set_zoom(nzoom);
}
before[0] = press[0];
before[1] = press[1];
_center_mode=CENTER_MANUAL;
+if (map_drag_id!=0)
+ g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
+
map_drag_id=g_signal_connect(G_OBJECT(_map_widget), "motion_notify_event", G_CALLBACK(map_follow_move_cb), NULL);
}
if (map_drag_id==0)
return;
+g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
+
release[0]=x;
release[1]=y;
-g_signal_handler_disconnect(G_OBJECT(_map_widget), map_drag_id);
press[0]=0;
press[1]=0;
release[0]=0;
_cmenu_position_x = event->x + 0.5;
_cmenu_position_y = event->y + 0.5;
+g_printf("BtnPress\n");
switch (event->button) {
case 1:
if (event->type==GDK_2BUTTON_PRESS) {
map_center_unit(x2unit((gint) (event->x + 0.5)), y2unit((gint) (event->y + 0.5)));
- map_set_zoom(_zoom - 1);
+ map_set_zoom(_zoom-1);
+ map_data_needs_refresh=TRUE;
return FALSE;
}
- if (event->type==GDK_3BUTTON_PRESS)
+ if (event->type==GDK_3BUTTON_PRESS) {
return FALSE;
+ }
ux=x2unit(_cmenu_position_x);
uy=y2unit(_cmenu_position_y);
gboolean
map_cb_button_release(GtkWidget *widget, GdkEventButton *event)
{
+g_printf("BtnRelease\n");
switch (event->button) {
case 1:
if (_center_mode>0)
break;
default:
map_drag_stop(event->x, event->y);
- /* map_render_data(); */
- g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
+ if (map_data_needs_refresh==TRUE) {
+ map_data_needs_refresh=FALSE;
+ map_render_data();
+ g_idle_add_full(G_PRIORITY_HIGH_IDLE,(GSourceFunc)map_update_location_from_center, NULL, NULL);
+ }
break;
}
break;