From: Carl Worth <cworth@cworth.org>
Date: Tue, 27 Jan 2009 15:10:50 +0000 (-0800)
Subject: Account for space between tick values and frames
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=3c7d4a2c642dea29982dadd700542549ac09be14;p=acre

Account for space between tick values and frames

With this correctly accounted for the axis labels now have consistent
padding above and below.
---

diff --git a/acre.c b/acre.c
index 908bebd..cec8a2f 100644
--- 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);