[goffice] Axis: improve padding.



commit 2f06c51a6ee1d918ed9116a7f09f72f09a274bc5
Author: Morten Welinder <terra gnome org>
Date:   Sat Oct 27 16:22:11 2012 -0400

    Axis: improve padding.
    
    Replace .5pt with 15% of a zero's height.  That ought to scale better
    with resolution.

 ChangeLog                     |    5 +++++
 NEWS                          |    1 +
 goffice/graph/gog-axis-line.c |   20 ++++++++------------
 3 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fd280e4..57b6dfc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-27  Morten Welinder  <terra gnome org>
+
+	* goffice/graph/gog-axis-line.c (axis_line_get_bbox): Improve
+	padding.  Fixes #686473.  Patch by Jean.
+
 2012-10-20  Jean Brefort  <jean brefort normalesup org>
 
 	* goffice/canvas/goc-image.c (goc_image_draw): fix image clipping. [#686490]
diff --git a/NEWS b/NEWS
index 60ebc06..817f564 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ Jean:
 	* Restore pixel aligned lines. [#686476]
 	* Fixed position of rotated label frame. [#686478]
 	* Fixed image clipping. [#686490]
+	* Improve padding between axis ticks and labels.  [#686473]
 
 Morten:
 	* Namespace cleanup.  [#686501]
diff --git a/goffice/graph/gog-axis-line.c b/goffice/graph/gog-axis-line.c
index c7bf6c6..1863320 100644
--- a/goffice/graph/gog-axis-line.c
+++ b/goffice/graph/gog-axis-line.c
@@ -1021,7 +1021,7 @@ axis_line_get_bbox (GogAxisBase *axis_base, GogRenderer *renderer,
 	tick_len = axis_base->major.tick_out ? major_tick_len :
 		(axis_base->minor.tick_out ? minor_tick_len : 0.);
 	gog_renderer_get_text_OBR (renderer, "0", TRUE, &txt_obr, -1.);
-	label_padding = txt_obr.w;
+	label_padding = txt_obr.h * .15;
 
 	total_bbox.x = x; total_bbox.y = y;
 	total_bbox.w = w; total_bbox.h = h;
@@ -1079,8 +1079,7 @@ axis_line_get_bbox (GogAxisBase *axis_base, GogRenderer *renderer,
 		if (ticks[i].str != NULL) {
 			GOGeometryOBR *obr = obrs + i;
 			pos = gog_axis_map_to_view (map, ticks[i].position);
-			obr->w += label_padding;
-			go_geometry_calc_label_position (obr, axis_angle, tick_len,
+			go_geometry_calc_label_position (obr, axis_angle, tick_len + label_padding,
 							 side, label_anchor);
 			obr->x += x + pos * cos (axis_angle);
 			obr->y += y + pos * sin (axis_angle);
@@ -1171,7 +1170,7 @@ axis_line_render (GogAxisBase *axis_base,
 	tick_len = axis_base->major.tick_out ? major_tick_len :
 		(axis_base->minor.tick_out ? minor_tick_len : 0.);
 	gog_renderer_get_text_OBR (renderer, "0", TRUE, &zero_obr, -1.);
-	label_padding = zero_obr.w;
+	label_padding = zero_obr.h * .15;
 
 	tick_nbr = gog_axis_get_ticks (axis_base->axis, &ticks);
 	if (draw_labels) {
@@ -1230,8 +1229,7 @@ axis_line_render (GogAxisBase *axis_base,
 
 		if (ticks[i].str != NULL && draw_labels) {
 			GOGeometryOBR *obr = obrs + i;
-			obr->w += label_padding;
-			go_geometry_calc_label_position (obr, axis_angle, tick_len,
+			go_geometry_calc_label_position (obr, axis_angle, tick_len + label_padding,
 							 side, label_anchor);
 			if (ticks_pos) {
 				obr->x += ticks_pos[2 * i];
@@ -1337,7 +1335,7 @@ axis_circle_get_bbox (GogAxisBase *axis_base, GogRenderer *renderer,
 	tick_len = axis_base->major.tick_out ? major_tick_len :
 		(axis_base->minor.tick_out ? minor_tick_len : 0.);
 	gog_renderer_get_text_OBR (renderer, "0", TRUE, &txt_obr, -1.);
-	label_padding = txt_obr.w;
+	label_padding = txt_obr.h * .15;
 
 	draw_ticks = go_style_is_line_visible (axis_base->base.style) &&
 		(axis_base->major.tick_out || axis_base->minor.tick_out);
@@ -1352,8 +1350,7 @@ axis_circle_get_bbox (GogAxisBase *axis_base, GogRenderer *renderer,
 
 		if (ticks[i].str != NULL && draw_labels) {
 			gog_renderer_get_gostring_OBR (renderer, ticks[i].str, &txt_obr, -1.);
-			txt_obr.w += label_padding;
-			go_geometry_calc_label_position (&txt_obr, angle + M_PI / 2.0, tick_len,
+			go_geometry_calc_label_position (&txt_obr, angle + M_PI / 2.0, tick_len + label_padding,
 							 GO_SIDE_LEFT, GO_SIDE_AUTO);
 			txt_obr.x += x;
 			txt_obr.y += y;
@@ -1420,7 +1417,7 @@ axis_circle_render (GogAxisBase *axis_base, GogRenderer *renderer,
 	tick_len = axis_base->major.tick_out ? major_tick_len :
 		(axis_base->minor.tick_out ? minor_tick_len : 0.);
 	gog_renderer_get_text_OBR (renderer, "0", TRUE, &txt_obr, -1.);
-	label_padding = txt_obr.w;
+	label_padding = txt_obr.h * .15;
 
 	tick_nbr = gog_axis_get_ticks (axis_base->axis, &ticks);
 	for (i = 0; i < tick_nbr; i++) {
@@ -1476,8 +1473,7 @@ axis_circle_render (GogAxisBase *axis_base, GogRenderer *renderer,
 			gog_chart_map_2D_to_view (c_map, ticks[i].position, position,
 						  &label_pos.x, &label_pos.y);
 			gog_renderer_get_gostring_OBR (renderer, ticks[i].str, &txt_obr, -1.);
-			txt_obr.w += label_padding;
-			go_geometry_calc_label_position (&txt_obr, angle + M_PI / 2.0, tick_len,
+			go_geometry_calc_label_position (&txt_obr, angle + M_PI / 2.0, tick_len + label_padding,
 							 GO_SIDE_LEFT, GO_SIDE_AUTO);
 			label_pos.x += txt_obr.x;
 			label_pos.y += txt_obr.y;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]