]> err.no Git - mapper/commitdiff
For tablets, add map panning using thumbs.
authorKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 15:32:56 +0000 (18:32 +0300)
committerKaj-Michael Lang <milang@tal.org>
Thu, 10 Apr 2008 15:32:56 +0000 (18:32 +0300)
src/map.c

index 3f5ec9d9e4e55b66fa9d4dd52bfb7adfe14be4e2..61036013f4dbd668fcdaa22fbfc8911c537c4934 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -64,6 +64,8 @@
 
 #define DEBUG_MAP_TIME 1
 
+#define MAP_THUMB_MARGIN (20)
+
 /* Initial size */
 #define BUF_WIDTH_TILES (4)
 #define BUF_HEIGHT_TILES (3)
@@ -225,6 +227,9 @@ g_signal_connect(G_OBJECT(map_widget), "scroll_event",  G_CALLBACK(map_cb_scroll
 
 gtk_widget_add_events(map_widget, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
        | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
+#ifdef WITH_HILDON
+gtk_widget_set_extension_events(GTK_WIDGET(map_widget), GDK_EXTENSION_EVENTS_ALL);
+#endif
 
 map_poi_init(map_widget);
 
@@ -1427,11 +1432,30 @@ return FALSE;
 }
 
 static gboolean 
-map_cb_button_press(GtkWidget * widget, GdkEventButton * event)
+map_cb_button_press(GtkWidget *widget, GdkEventButton *event)
 {
 _cmenu_position_x = event->x + 0.5;
 _cmenu_position_y = event->y + 0.5;
 
+#if defined(WITH_HILDON_NEW)
+if (hildon_helper_event_button_is_finger(event)) {
+       if (event->x<MAP_THUMB_MARGIN)
+               map_pan(-PAN_UNITS, 0);
+
+       if (event->x>(_screen_width_pixels-MAP_THUMB_MARGIN))
+               map_pan(PAN_UNITS, 0);
+
+       if (event->y<MAP_THUMB_MARGIN)
+               map_pan(0, -PAN_UNITS);
+
+       if (event->y>(_screen_height_pixels-MAP_THUMB_MARGIN))
+               map_pan(0, PAN_UNITS);
+
+       return FALSE;
+}
+#endif
+
+
 switch (event->button) {
 case 1:
        if (event->type==GDK_2BUTTON_PRESS) {