]> git.cworth.org Git - acre/commitdiff
Account for space between tick values and frames
authorCarl Worth <cworth@cworth.org>
Tue, 27 Jan 2009 15:10:50 +0000 (07:10 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 16 Apr 2009 19:05:13 +0000 (12:05 -0700)
With this correctly accounted for the axis labels now have consistent
padding above and below.

acre.c

diff --git a/acre.c b/acre.c
index 908bebd74fb15a2921205138f20e19100347b4d9..cec8a2f2532a528ffdc32e6b1a9c0c227d1df68d 100644 (file)
--- a/acre.c
+++ b/acre.c
@@ -163,6 +163,8 @@ acre_add_data (acre_t *acre, acre_data_t *data)
 #define ACRE_TITLE_FONT_SIZE 32
 #define ACRE_PAD (ACRE_FONT_SIZE)
 #define ACRE_TICK_SIZE 6
+#define ACRE_X_TICK_VALUE_PAD 2
+#define ACRE_Y_TICK_VALUE_PAD 4
 
 static PangoLayout *
 _create_layout (acre_t *acre, const char *text)
@@ -284,11 +286,13 @@ _draw_title_and_labels (acre_t *acre)
        pango_layout_get_pixel_size (y_axis_layout, &y_axis_width, &y_axis_height);
 
        new_chart.x = ACRE_PAD + y_axis_height +
-           ACRE_PAD + y_axis_value_width;
+           ACRE_PAD + y_axis_value_width + ACRE_Y_TICK_VALUE_PAD;
        new_chart.width = acre->width - acre->chart.x - ACRE_PAD;
 
        new_chart.y = ACRE_PAD + title_height + ACRE_PAD;
-       new_chart.height = acre->height - acre->chart.y - (ACRE_FONT_SIZE + ACRE_PAD + x_axis_height + ACRE_PAD);
+       new_chart.height = acre->height - acre->chart.y - 
+           (ACRE_X_TICK_VALUE_PAD + ACRE_FONT_SIZE +
+            ACRE_PAD + x_axis_height + ACRE_PAD);
 
        if (new_chart.x == acre->chart.x &&
            new_chart.y == acre->chart.y &&
@@ -539,7 +543,7 @@ _draw_frame_and_ticks (acre_t *acre)
                    cairo_move_to (cr, x, acre->y_axis.min);
                    cairo_identity_matrix (cr);
                    pango_layout_get_pixel_size (layout, &width, &height);
-                   cairo_rel_move_to (cr, -width / 2, 2);
+                   cairo_rel_move_to (cr, -width / 2, ACRE_X_TICK_VALUE_PAD);
                    _show_layout (cr, layout);
                }
                cairo_restore (cr);
@@ -574,7 +578,8 @@ _draw_frame_and_ticks (acre_t *acre)
                    cairo_move_to (cr, acre->x_axis.min, y);
                    cairo_identity_matrix (cr);
                    pango_layout_get_pixel_size (layout, &width, &height);
-                   cairo_rel_move_to (cr, -width-4, -height/2);
+                   cairo_rel_move_to (cr, -width - ACRE_Y_TICK_VALUE_PAD,
+                                      -height/2);
                    _show_layout (cr, layout);
                }
                cairo_restore (cr);