[cairo-commit] roadster/src mainwindow.c, 1.17, 1.18 mainwindow.h,
1.6, 1.7 map_draw_cairo.c, 1.3, 1.4
Ian McIntosh
commit at pdx.freedesktop.org
Sun Mar 6 15:38:22 PST 2005
Committed by: ian
Update of /cvs/cairo/roadster/src
In directory gabe:/tmp/cvs-serv1843/src
Modified Files:
mainwindow.c mainwindow.h map_draw_cairo.c
Log Message:
* mainwindow.c: Scroll once when user clicks map border. Change map drag mouse cursor.
* map_draw_cairo.c: Fix halo drawing.
Index: mainwindow.c
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mainwindow.c 5 Mar 2005 05:47:51 -0000 1.17
+++ mainwindow.c 6 Mar 2005 23:38:19 -0000 1.18
@@ -55,6 +55,11 @@
#define PROGRAM_COPYRIGHT "Copyright (c) 2005 Ian McIntosh"
#define PROGRAM_DESCRIPTION "Mapping for everyone!"
+#define DRAW_PRETTY_TIMEOUT_MS (110) // how long after stopping various movements should we redraw in high-quality mode
+#define SCROLL_TIMEOUT_MS (100) // how often (in MS) to move (SHORTER THAN ABOVE TIME)
+#define SCROLL_DISTANCE_IN_PIXELS (100) // how far to move every (above) MS
+#define BORDER_SCROLL_CLICK_TARGET_SIZE (17) // the size of the click target (distance from edge of map view) to begin scrolling
+
// Layerlist columns
#define LAYERLIST_COLUMN_ENABLED (0)
#define LAYERLIST_COLUMN_NAME (1)
@@ -91,15 +96,6 @@
static gboolean mainwindow_callback_on_gps_redraw_timeout(gpointer pData);
static void mainwindow_setup_selected_tool(void);
-#define DRAW_PRETTY_TIMEOUT_MS (110) // how long after stopping various movements should we redraw in high-quality mode
-#define SCROLL_TIMEOUT_MS (100) // how often (in MS) to move (SHORTER THAN ABOVE TIME)
-#define SCROLL_DISTANCE_IN_PIXELS (100) // how far to move every (above) MS
-#define BORDER_SCROLL_CLICK_TARGET_SIZE (17) // the size of the click target (distance from edge of map view) to begin scrolling
-
-typedef enum {
- DIRECTION_NONE, DIRECTION_N, DIRECTION_NE, DIRECTION_E, DIRECTION_SE, DIRECTION_S, DIRECTION_SW, DIRECTION_W, DIRECTION_NW
-} EDirection;
-
struct {
gint m_nX;
gint m_nY;
@@ -180,7 +176,7 @@
{
GdkPixbuf* pPixbuf = gtk_widget_render_icon(GTK_WIDGET(g_MainWindow.m_pStatusbarGPSIcon),pszStockIconID, nSize, "name");
gtk_image_set_from_pixbuf(pImage, pPixbuf);
- gdk_pixbuf_unref(pPixbuf);
+ g_object_unref(pPixbuf);
}
static void mainwindow_set_statusbar_position(gchar* pMessage)
@@ -391,15 +387,15 @@
//
// the "scroll" timeout
//
-gboolean mainwindow_on_scroll_timeout(gpointer _unused)
+void mainwindow_scroll_direction(EDirection eScrollDirection, gint nPixels)
{
- if(g_MainWindow.m_eScrollDirection != DIRECTION_NONE) {
+ if(eScrollDirection != DIRECTION_NONE) {
gint nWidth = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.width;
gint nHeight = GTK_WIDGET(g_MainWindow.m_pDrawingArea)->allocation.height;
- gint nDeltaX = SCROLL_DISTANCE_IN_PIXELS * g_aDirectionMultipliers[g_MainWindow.m_eScrollDirection].m_nX;
- gint nDeltaY = SCROLL_DISTANCE_IN_PIXELS * g_aDirectionMultipliers[g_MainWindow.m_eScrollDirection].m_nY;
-
+ gint nDeltaX = nPixels * g_aDirectionMultipliers[eScrollDirection].m_nX;
+ gint nDeltaY = nPixels * g_aDirectionMultipliers[eScrollDirection].m_nY;
+
map_center_on_windowpoint(g_MainWindow.m_pMap,
(nWidth / 2) + nDeltaX,
(nHeight / 2) + nDeltaY);
@@ -407,6 +403,11 @@
mainwindow_draw_map(DRAWFLAG_GEOMETRY);
mainwindow_set_draw_pretty_timeout();
}
+}
+
+gboolean mainwindow_on_scroll_timeout(gpointer _unused)
+{
+ mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
return TRUE; // more events, please
}
void mainwindow_cancel_scroll_timeout()
@@ -692,6 +693,7 @@
eScrollDirection = match_border(nX, nY, nWidth, nHeight, BORDER_SCROLL_CLICK_TARGET_SIZE);
if(eScrollDirection != DIRECTION_NONE) {
// begin a scroll
+
//GdkCursor* pCursor = gdk_cursor_new(g_aDirectionCursors[eScrollDirection].m_nCursor);
//if(GDK_GRAB_SUCCESS == gdk_pointer_grab(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, FALSE, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK, NULL, pCursor, GDK_CURRENT_TIME)) {
GdkCursor* pCursor = gdk_cursor_new(g_aDirectionCursors[eScrollDirection].m_nCursor);
@@ -701,6 +703,7 @@
g_MainWindow.m_bScrolling = TRUE;
g_MainWindow.m_eScrollDirection = eScrollDirection;
+ mainwindow_scroll_direction(g_MainWindow.m_eScrollDirection, SCROLL_DISTANCE_IN_PIXELS);
mainwindow_set_scroll_timeout();
//}
//gdk_cursor_unref(pCursor);
@@ -710,7 +713,7 @@
// else begin a drag
// GdkCursor* pCursor = gdk_cursor_new(GDK_HAND2);
// if(GDK_GRAB_SUCCESS == gdk_pointer_grab(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, FALSE, GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK, NULL, pCursor, GDK_CURRENT_TIME)) {
- GdkCursor* pCursor = gdk_cursor_new(GDK_HAND2);
+ GdkCursor* pCursor = gdk_cursor_new(GDK_FLEUR);
gdk_window_set_cursor(GTK_WIDGET(g_MainWindow.m_pDrawingArea)->window, pCursor);
gdk_cursor_unref(pCursor);
@@ -760,6 +763,7 @@
// return TRUE;
// }
// map_redraw_if_needed();
+
return TRUE;
}
Index: mainwindow.h
===================================================================
RCS file: /cvs/cairo/roadster/src/mainwindow.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- mainwindow.h 4 Mar 2005 21:08:23 -0000 1.6
+++ mainwindow.h 6 Mar 2005 23:38:19 -0000 1.7
@@ -70,6 +70,12 @@
// Map
void mainwindow_set_centerpoint(mappoint_t* pPoint);
+typedef enum {
+ DIRECTION_NONE, DIRECTION_N, DIRECTION_NE, DIRECTION_E, DIRECTION_SE, DIRECTION_S, DIRECTION_SW, DIRECTION_W, DIRECTION_NW
+} EDirection;
+
+void mainwindow_scroll_direction(EDirection eScrollDirection, gint nPixels);
+
#define SIDEBAR_TAB_SEARCH_RESULTS 0
#define SIDEBAR_TAB_GPS 1
#define SIDEBAR_TAB_LOCATIONSETS 2
Index: map_draw_cairo.c
===================================================================
RCS file: /cvs/cairo/roadster/src/map_draw_cairo.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- map_draw_cairo.c 4 Mar 2005 21:08:23 -0000 1.3
+++ map_draw_cairo.c 6 Mar 2005 23:38:19 -0000 1.4
@@ -145,7 +145,7 @@
if(pPointString->m_pPointsArray->len < 2) return;
#define ROAD_MAX_SEGMENTS 100
- if(pPointString->m_pPointsArray->len > ROAD_MAX_SEGMENTS) { g_warning("road %s has > %d segments!\n", pszLabel, ROAD_MAX_SEGMENTS); return; }
+ if(pPointString->m_pPointsArray->len > ROAD_MAX_SEGMENTS) { g_warning("not drawing label for road '%s' with > %d segments.\n", pszLabel, ROAD_MAX_SEGMENTS); return; }
gfloat fFontSize = pLabelStyle->m_afFontSizeAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
if(fFontSize == 0) return;
@@ -376,11 +376,11 @@
cairo_set_rgb_color(pCairo, 0.0,0.0,0.0);
cairo_set_alpha(pCairo, 1.0);
cairo_rotate(pCairo, fAngleInRadians);
- //cairo_text_path(pCairo, azLabelSegment);
gdouble fHaloSize = pLabelStyle->m_afHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
if(fHaloSize >= 0) {
cairo_save(pCairo);
+ cairo_text_path(pCairo, azLabelSegment);
cairo_set_line_width(pCairo, fHaloSize);
cairo_set_rgb_color(pCairo, 1.0,1.0,1.0);
cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_BEVEL);
@@ -476,11 +476,11 @@
cairo_move_to(pCairo, fDrawX, fDrawY);
cairo_set_rgb_color(pCairo, pLabelStyle->m_clrColor.m_fRed, pLabelStyle->m_clrColor.m_fGreen, pLabelStyle->m_clrColor.m_fBlue);
cairo_set_alpha(pCairo, fAlpha);
- //cairo_text_path(pCairo, pszLabel);
gdouble fHaloSize = pLabelStyle->m_afHaloAtZoomLevel[pRenderMetrics->m_nZoomLevel-1];
if(fHaloSize >= 0) {
cairo_save(pCairo);
+ cairo_text_path(pCairo, pszLabel);
cairo_set_line_width(pCairo, fHaloSize);
cairo_set_rgb_color(pCairo, 1.0,1.0,1.0);
cairo_set_line_join(pCairo, CAIRO_LINE_JOIN_BEVEL);
More information about the cairo-commit
mailing list