From: Kaj-Michael Lang Date: Mon, 15 Oct 2007 12:33:10 +0000 (+0300) Subject: Pre-calc size/2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=67917eb6fc6c38e0067aa2de6b8a04953648208a;p=mapper Pre-calc size/2 --- diff --git a/src/gtkcompass.c b/src/gtkcompass.c index d2936d4..998df74 100644 --- a/src/gtkcompass.c +++ b/src/gtkcompass.c @@ -287,7 +287,11 @@ gint fsize[5] = { 0, 4, 10, 4, 0 }; widget=GTK_WIDGET(compass); size=compass->size; +#if 1 hsize=size/2; +#else +hsize=0; +#endif fs=size/42; BOUND(fs, 1, 16); @@ -302,38 +306,38 @@ pango_layout_get_pixel_size(compass->layout, &x, &y); gdk_draw_layout(widget->window, compass->gc_h, - compass->xoffset+size/2-x/2, + compass->xoffset+hsize-x/2, compass->yoffset+size-y-2, compass->layout); gdk_draw_arc(widget->window, compass->gc_h, FALSE, - compass->xoffset, compass->yoffset+size/2, size, size, 0, 64 * 180); + compass->xoffset, compass->yoffset+hsize, size - fs, size - fs, 0, 64 * 360); /* Simple arrow for heading */ gdk_draw_line(widget->window, compass->gc_h, - compass->xoffset + size / 2 + 3, + compass->xoffset + hsize + 3, compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); + compass->xoffset + hsize, compass->yoffset + hsize + 5); gdk_draw_line(widget->window, compass->gc_h, - compass->xoffset + size / 2 - 3, + compass->xoffset + hsize - 3, compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size / 2 + 5); + compass->xoffset + hsize, compass->yoffset + hsize + 5); gdk_draw_line(widget->window, compass->gc_h, - compass->xoffset + size / 2 - 3, + compass->xoffset + hsize - 3, compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size - y - 8); + compass->xoffset + hsize, compass->yoffset + size - y - 8); gdk_draw_line(widget->window, compass->gc_h, - compass->xoffset + size / 2 + 3, + compass->xoffset + hsize + 3, compass->yoffset + size - y - 5, - compass->xoffset + size / 2, compass->yoffset + size - y - 8); + compass->xoffset + hsize, compass->yoffset + size - y - 8); for (i = 0; i < 5; i++) { PangoMatrix matrix = PANGO_MATRIX_INIT; @@ -388,8 +392,8 @@ for (i = 0; i < 5; i++) { pango_matrix_rotate (&matrix, -(dir-compass->data->heading)); pango_context_set_matrix (compass->context, &matrix); pango_layout_get_pixel_size(compass->layout, &x, &y); - x = compass->xoffset + size / 2 + ((size / 2 + 15 + fs) * sinf(tmp)) - x / 2, - y = compass->yoffset + size - ((size / 2 + 15 + fs) * cosf(tmp)) - y / 2, + x = compass->xoffset + hsize + ((hsize + 15 + fs) * sinf(tmp)) - x / 2, + y = compass->yoffset + size - ((hsize + 15 + fs) * cosf(tmp)) - y / 2, gdk_draw_layout(widget->window, compass->gc_h, x, y, compass->layout); }