+2004-03-06 Jim Evins <evins@snaught.com>
+
+ * src/view.c: (draw_grid_layer):
+ For round labels (round and cd) adjust grid so that it lines up with
+ center of label. Also, no longer draw box around label in the grid layer,
+ it is hidden by he fg layer anyway. Feature suggested by
+ nemolivier@free.fr. Although the grid is aligned with the center of the
+ label, the coordinate system is still relative to the upper left corner
+ of the rectangle containing the label.
+
2004-02-25 Jim Evins <evins@snaught.com>
* configure.in:
static void
draw_grid_layer (glView *view)
{
- gdouble w, h, x, y;
- GnomeCanvasPoints *points;
- GnomeCanvasItem *item;
- GnomeCanvasGroup *group;
+ gdouble w, h, x, y, x0, y0;
+ GnomeCanvasPoints *points;
+ GnomeCanvasItem *item;
+ GnomeCanvasGroup *group;
+ glTemplate *template;
+ const glTemplateLabelType *template_type;
gl_debug (DEBUG_VIEW, "START");
g_return_if_fail (view->label && GL_IS_LABEL(view->label));
gl_label_get_size (view->label, &w, &h);
+ template = gl_label_get_template (view->label);
+ template_type = gl_template_get_first_label_type (template);
+
+ if (template_type->shape == GL_TEMPLATE_SHAPE_RECT) {
+ x0 = 0.0;
+ y0 = 0.0;
+ } else {
+ /* for round labels, adjust grid to line up with center of label. */
+ x0 = fmod (w/2.0, view->grid_spacing);
+ y0 = fmod (h/2.0, view->grid_spacing);
+ }
group = gnome_canvas_root (GNOME_CANVAS (view->canvas));
view->grid_group = GNOME_CANVAS_GROUP(
points->coords[1] = 0.0;
points->coords[3] = h;
- for ( x=0.0; x < w; x += view->grid_spacing ) {
+ for ( x=x0+view->grid_spacing; x < w; x += view->grid_spacing ) {
points->coords[0] = points->coords[2] = x;
item = gnome_canvas_item_new (view->grid_group,
gnome_canvas_line_get_type (),
"fill_color_rgba", GRID_COLOR,
NULL);
}
- points->coords[0] = points->coords[2] = w;
- item = gnome_canvas_item_new (view->grid_group,
- gnome_canvas_line_get_type (),
- "points", points,
- "width_pixels", 1,
- "fill_color_rgba", GRID_COLOR,
- NULL);
points->coords[0] = 0.0;
points->coords[2] = w;
- for ( y=0.0; y < h; y += view->grid_spacing ) {
+ for ( y=y0+view->grid_spacing; y < h; y += view->grid_spacing ) {
points->coords[1] = points->coords[3] = y;
item = gnome_canvas_item_new (view->grid_group,
gnome_canvas_line_get_type (),
"fill_color_rgba", GRID_COLOR,
NULL);
}
- points->coords[1] = points->coords[3] = h;
- item = gnome_canvas_item_new (view->grid_group,
- gnome_canvas_line_get_type (),
- "points", points,
- "width_pixels", 1,
- "fill_color_rgba", GRID_COLOR,
- NULL);
gnome_canvas_points_free (points);
+ gl_template_free (template);
gl_debug (DEBUG_VIEW, "END");
}