From: Kaj-Michael Lang Date: Fri, 5 Oct 2007 08:45:55 +0000 (+0300) Subject: Scale heading number with size. Fix copy&paste typo. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8faedb6e59013ac7df8f3a748bed9ebc4d7d5ff;p=mapper Scale heading number with size. Fix copy&paste typo. --- diff --git a/src/gtkcompass.c b/src/gtkcompass.c index d041197..25e08b0 100644 --- a/src/gtkcompass.c +++ b/src/gtkcompass.c @@ -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;