[cairo-commit] roadster/src mainwindow.c, 1.29, 1.30 map.h, 1.10, 1.11 map_draw_gdk.c, 1.8, 1.9

Ian McIntosh commit at pdx.freedesktop.org
Wed Mar 23 13:15:48 PST 2005


Committed by: ian

Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv9202/src

Modified Files:
	mainwindow.c map.h map_draw_gdk.c 
Log Message:
	* src/mainwindow.c: Single click on the border now does a big jump, instead of a single 80-pixel scroll.


Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mainwindow.c	23 Mar 2005 09:21:49 -0000	1.29
+++ mainwindow.c	23 Mar 2005 21:15:46 -0000	1.30
@@ -65,9 +65,10 @@
 #define DRAW_PRETTY_DRAG_TIMEOUT_MS	(250)
 #define DRAW_PRETTY_RESIZE_TIMEOUT_MS	(180)
 
-#define SCROLL_TIMEOUT_MS		(80)	// how often (in MS) to move
-#define SCROLL_DISTANCE_IN_PIXELS	(70)	// how far to move every (above) MS
-#define BORDER_SCROLL_CLICK_TARGET_SIZE	(20)	// the size of the click target (distance from edge of map view) to begin scrolling
+#define SCROLL_TIMEOUT_MS		(80)		// how often (in MS) to move
+#define SCROLL_DISTANCE_IN_PIXELS	(120)		// how far to move every (above) MS
+#define SCROLL_SINGLE_CLICK_DISTANCE_IN_PIXELS	(500)	// how to move in response to a single border click
+#define BORDER_SCROLL_CLICK_TARGET_SIZE	(20)		// the size of the click target (distance from edge of map view) to begin scrolling
 
 #define SLIDE_TIMEOUT_MS		(50)	// time between frames (in MS) for smooth-sliding (on double click?)
 #define	SLIDE_TIME_IN_SECONDS		(0.7)	// how long the whole slide should take, in seconds
@@ -81,6 +82,8 @@
 #define MAX_SEARCH_TEXT_LENGTH		(100)
 #define SPEED_LABEL_FORMAT		("<span font_desc='32'>%.0f</span>")
 
+#define TOOLTIP_FORMAT			(" %s ")
+
 // Settings
 #define TIMER_GPS_REDRAW_INTERVAL_MS	(2500)		// lower this (to 1000?) when it's faster to redraw track
 
@@ -182,6 +185,7 @@
 
 	gboolean m_bScrolling;
 	EDirection m_eScrollDirection;
+	gboolean m_bScrollMovement;
 	
 	gboolean m_bMouseDragging;
 	gboolean m_bMouseDragMovement;
@@ -469,6 +473,8 @@
 gboolean mainwindow_on_scroll_timeout(gpointer _unused)
 {
 	mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
+	g_MainWindow.m_bScrollMovement = TRUE;
+
 	return TRUE;	// more events, please
 }
 void mainwindow_cancel_scroll_timeout()
@@ -812,10 +818,11 @@
 
 				g_MainWindow.m_bScrolling = TRUE;
 				g_MainWindow.m_eScrollDirection = eScrollDirection;
+				g_MainWindow.m_bScrollMovement = FALSE;	// no movement yet
 
 				// XXX: s.garrity asked for a single click to scroll once, BUT when we added double-click to slide
 				// it resulted in weird behavior
-		//		mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
+				//mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
 				
 				mainwindow_set_scroll_timeout();
 			}
@@ -859,29 +866,36 @@
 			// end scrolling, if active
 			if(g_MainWindow.m_bScrolling == TRUE) {
 				g_MainWindow.m_bScrolling = FALSE;
-				g_MainWindow.m_eScrollDirection = DIRECTION_NONE;
-//                                 gdk_pointer_ungrab(GDK_CURRENT_TIME);
-
 				mainwindow_cancel_draw_pretty_timeout();
-				mainwindow_draw_map(DRAWFLAG_ALL);
 
+				// has there been any movement?
+				if(g_MainWindow.m_bScrollMovement) {
+					g_MainWindow.m_bScrollMovement = FALSE;
+					mainwindow_draw_map(DRAWFLAG_ALL);
+				}
+				else {
+					mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_SINGLE_CLICK_DISTANCE_IN_PIXELS);
+				}
+				g_MainWindow.m_eScrollDirection = DIRECTION_NONE;
 				mainwindow_add_history();
 			}
 		}
 		else if(event->type == GDK_2BUTTON_PRESS) {
-			
-			animator_destroy(g_MainWindow.m_pAnimator);
-
-			g_MainWindow.m_bSliding = TRUE;
-			g_MainWindow.m_pAnimator = animator_new(ANIMATIONTYPE_FAST_THEN_SLIDE, SLIDE_TIME_IN_SECONDS);
-
-			// set startpoint
-			map_get_centerpoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptSlideStartLocation);
-
-			// set endpoint
-			screenpoint_t ptScreenPoint = {nX, nY};
-			map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &ptScreenPoint, &(g_MainWindow.m_ptSlideEndLocation));
-
+			// can only double click in the middle (not on a scroll border)
+			eScrollDirection = match_border(nX, nY, nWidth, nHeight, BORDER_SCROLL_CLICK_TARGET_SIZE);
+			if(eScrollDirection == DIRECTION_NONE) {
+				animator_destroy(g_MainWindow.m_pAnimator);
+	
+				g_MainWindow.m_bSliding = TRUE;
+				g_MainWindow.m_pAnimator = animator_new(ANIMATIONTYPE_FAST_THEN_SLIDE, SLIDE_TIME_IN_SECONDS);
+	
+				// set startpoint
+				map_get_centerpoint(g_MainWindow.m_pMap, &g_MainWindow.m_ptSlideStartLocation);
+	
+				// set endpoint
+				screenpoint_t ptScreenPoint = {nX, nY};
+				map_windowpoint_to_mappoint(g_MainWindow.m_pMap, &ptScreenPoint, &(g_MainWindow.m_ptSlideEndLocation));
+			}
 //			map_center_on_windowpoint(g_MainWindow.m_pMap, nX, nY);
 //			mainwindow_draw_map(DRAWFLAG_ALL);
 		}
@@ -982,7 +996,7 @@
 				// A hit!  Move the tooltip here, format the text, and show it.
 				tooltip_set_upper_left_corner(g_MainWindow.m_pTooltip, (gint)(event->x_root) + TOOLTIP_OFFSET_X, (gint)(event->y_root) + TOOLTIP_OFFSET_Y);
 
-				gchar* pszMarkup = g_strdup_printf(" %s ", pszReturnString);
+				gchar* pszMarkup = g_strdup_printf(TOOLTIP_FORMAT, pszReturnString);
 				tooltip_set_markup(g_MainWindow.m_pTooltip, pszMarkup);
 				g_free(pszMarkup);
 
@@ -1006,7 +1020,6 @@
 
 static gboolean mainwindow_on_enter_notify(GtkWidget* w, GdkEventCrossing *event)
 {
-	tooltip_show(g_MainWindow.m_pTooltip);
 }
 
 static gboolean mainwindow_on_leave_notify(GtkWidget* w, GdkEventCrossing *event)

Index: map.h
===================================================================
RCS file: /cvs/cairo/roadster/src/map.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- map.h	23 Mar 2005 09:21:49 -0000	1.10
+++ map.h	23 Mar 2005 21:15:46 -0000	1.11
@@ -37,9 +37,9 @@
 
 #define INCHES_PER_METER (39.37007)
 
-#define MIN_ZOOMLEVEL (6)	// 1
-#define MAX_ZOOMLEVEL (10)
-#define NUM_ZOOMLEVELS (10)	// 10
+#define NUM_ZOOMLEVELS (10)	// the real total # in the array
+#define MIN_ZOOMLEVEL (6)	// the min/max that we allow, for now
+#define MAX_ZOOMLEVEL (9)
 
 #define WORLD_CIRCUMFERENCE_IN_METERS (40076000)
 #define WORLD_METERS_PER_DEGREE (WORLD_CIRCUMFERENCE_IN_METERS / 360.0)

Index: map_draw_gdk.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_gdk.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- map_draw_gdk.c	20 Mar 2005 10:57:05 -0000	1.8
+++ map_draw_gdk.c	23 Mar 2005 21:15:46 -0000	1.9
@@ -303,9 +303,9 @@
 static void map_draw_gdk_background(map_t* pMap, GdkPixmap* pPixmap)
 {
 	GdkColor clr;
-	clr.red = 239/255.0 * 65535;
-	clr.green = 239/255.0 * 65535;
-	clr.blue = 239/255.0 * 65535;
+	clr.red = 240/255.0 * 65535;
+	clr.green = 235/255.0 * 65535;
+	clr.blue = 230/255.0 * 65535;
 	gdk_gc_set_rgb_fg_color(pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)], &clr);
 	
 	gdk_draw_rectangle(pPixmap, pMap->m_pTargetWidget->style->fg_gc[GTK_WIDGET_STATE(pMap->m_pTargetWidget)],




More information about the cairo-commit mailing list