]> err.no Git - mapper/commitdiff
Scale heading number with size. Fix copy&paste typo.
authorKaj-Michael Lang <milang@onion.tal.org>
Fri, 5 Oct 2007 08:45:55 +0000 (11:45 +0300)
committerKaj-Michael Lang <milang@onion.tal.org>
Fri, 5 Oct 2007 08:45:55 +0000 (11:45 +0300)
src/gtkcompass.c

index d041197bb10eed47490e9b736a60cf8dfd5e31a4..25e08b079d9ea70f55845ba6a2c132f5971c3967 100644 (file)
@@ -257,7 +257,7 @@ if (!compass->gc_w) {
 }
 
 static void
-gtk_compass_draw_mark(GtkCompass *compass, GdkGC *gc, gdouble t)
+gtk_compass_draw_mark(GtkCompass *compass, GdkGC *gc, gdouble angle, gint size)
 {
 GtkWidget *widget;
 gint hs;
@@ -267,10 +267,10 @@ widget=GTK_WIDGET(compass);
 hs=compass->size/2;
 
 gdk_draw_line(widget->window,gc,
-       compass->xoffset+hs+((hs-5)*sin(t)),
-       compass->yoffset+compass->size-((hs-5)*cos(t)),
-       compass->xoffset+hs+((hs+5)*sin(t)),
-       compass->yoffset+compass->size-((hs+5)*cos(t)));
+       compass->xoffset+hs+((hs-size)*sin(angle)),
+       compass->yoffset+compass->size-((hs-size)*cos(angle)),
+       compass->xoffset+hs+((hs+size)*sin(angle)),
+       compass->yoffset+compass->size-((hs+size)*cos(angle)));
 }
 
 static void
@@ -295,6 +295,8 @@ BOUND(fs, 1, 16);
 pango_context_set_matrix (compass->context, NULL);
 
 g_snprintf(htext, 8, "%3.0f°", compass->data->heading);
+pango_font_description_set_size(compass->fontdesc, (10+fs) * PANGO_SCALE);
+pango_layout_set_font_description(compass->layout, compass->fontdesc);
 pango_layout_set_text(compass->layout, htext, -1);
 pango_layout_get_pixel_size(compass->layout, &x, &y);
 
@@ -378,12 +380,8 @@ for (i = 0; i < 5; i++) {
        }
 
        tmp = ((dir - compass->data->heading) * (1.f / 180.f)) * G_PI;
-       gdk_draw_line(widget->window,
-             widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
-             compass->xoffset + size / 2 + ((size / 2 - 5) * sinf(tmp)),
-             compass->yoffset + size - ((size / 2 - 5) * cosf(tmp)),
-             compass->xoffset + size / 2 + ((size / 2 + 5) * sinf(tmp)),
-             compass->yoffset + size - ((size / 2 + 5) * cosf(tmp)));
+
+       gtk_compass_draw_mark(compass, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], tmp, 6);
 
        x = fsize[i];
        if (abs((guint) (compass->data->heading / 45) * 45 - compass->data->heading)
@@ -398,23 +396,18 @@ for (i = 0; i < 5; i++) {
        pango_layout_get_pixel_size(compass->layout, &x, &y);
        x = compass->xoffset + size / 2 + ((size / 2 + 15) * sinf(tmp)) - x / 2,
     y = compass->yoffset + size - ((size / 2 + 15) * cosf(tmp)) - y / 2,
-    gdk_draw_layout(widget->window,
-           widget->style->fg_gc[GTK_STATE_NORMAL],
-           x, y, compass->layout);
+    gdk_draw_layout(widget->window, widget->style->fg_gc[GTK_STATE_NORMAL], x, y, compass->layout);
+}
 
-       if (compass->dest_valid) {
-               gtk_compass_draw_mark(compass, compass->gc_d, compass->dest_heading);
-       }
+if (compass->dest_valid)
+       gtk_compass_draw_mark(compass, compass->gc_d, compass->dest_heading, 10);
 
-       if (compass->way_valid) {
-               gtk_compass_draw_mark(compass, compass->gc_w, compass->way_heading);
-       }
-}
+if (compass->way_valid)
+       gtk_compass_draw_mark(compass, compass->gc_w, compass->way_heading, 10);
 
 return;
 }
 
-
 static gboolean
 gtk_compass_expose(GtkWidget *widget, GdkEventExpose *event)
 {
@@ -455,8 +448,11 @@ gtk_compass_paint(compass);
 void 
 gtk_compass_set_dest_heading(GtkWidget *widget, gboolean valid, gfloat heading)
 {
+GtkCompass *compass;
 g_return_if_fail(GTK_IS_COMPASS(widget));
 
+compass=GTK_COMPASS(widget);
+
 compass->dest_valid=valid;
 compass->dest_heading=heading;