Re: [PATCH] resource name redraw fix

Maurice van der Pot <griffon26-bCGDfOjggl9Wk0Htik3J/[email protected]>
Newsgroups gmane.comp.gnome.apps.planner.devel
Message-ID <[email protected]>
On Wed, Jul 25, 2007 at 08:52:40PM +0200, Maurice van der Pot wrote:
> Kurt, can you check if this doesn't make things worse for you? You seem
> to have determined the old value empirically.

After trying it out with planner on Windows I can say that my earlier
patch made matters worse there.

I have a new version that works equally well on my Linux and Windows
machines.

As you can see in the following screenshot the resource text is
vertically aligned perfectly with the task names in the task tree.

http://griffon26.kfk4ever.com/~griffon26/planner_text_alignment.png

The only difference is that on Windows there is more space above the
text than there is below it. This may be just how text is rendered on
Windows, I don't know. I don't think that it's worth investigating, do
you?

Best regards,
Maurice.

-- 
Maurice van der Pot

Gentoo Linux Developer   [email protected]     http://www.gentoo.org
Creator of BiteMe!       griffon26-bCGDfOjggl9Wk0Htik3J/[email protected]   http://www.kfk4ever.com

_______________________________________________
Planner-dev-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/planner-dev-list
planner-resource-name-redraw-fix.patch (text/plain, 2.1 KB)
Index: src/planner-gantt-row.c
===================================================================
--- src/planner-gantt-row.c	(revision 846)
+++ src/planner-gantt-row.c	(working copy)
@@ -162,6 +162,7 @@
 	gdouble      bar_top; /* Top y position of the bar. */
 	gdouble      bar_bot; /* Bottom y position of the bar. */
 	gdouble      text_width;
+	gdouble      text_height;
 
 	/* Cached positions of each assigned resource. */
 	GArray      *resource_widths;
@@ -493,7 +494,7 @@
 {
 	PlannerGanttRowPriv *priv;
 	GnomeCanvasItem     *item;
-	gint                 width;
+	gint                 width, height;
 	mrptime              t;
 	MrpTaskType          type;
 	gdouble              old_x, old_x_start, old_width;
@@ -511,13 +512,14 @@
 
 	pango_layout_get_pixel_size (priv->layout,
 				     &width,
-				     NULL);
-		
+				     &height);
+
 	if (width > 0) {
 		width += TEXT_PADDING;
 	}
 
 	priv->text_width = width;
+	priv->text_height = height;
 
 	t = mrp_task_get_work_start (priv->task);
 	priv->x = t * priv->scale;
@@ -742,7 +744,7 @@
 	pango_layout_set_text (priv->layout, ", ", 2);
 	pango_layout_get_extents (priv->layout, NULL, &rect);
 	spacing = rect.width / PANGO_SCALE;
-	
+
 	x = 0;
 	resources = mrp_task_get_assigned_resources (priv->task);
 		
@@ -1955,14 +1957,15 @@
 	rx2 = MIN (cx2 + TEXT_PADDING + priv->text_width, width);
 
 	if (priv->layout != NULL && rx1 < rx2) {
-		/* NOTE: cy1 - priv->bar_top: report to the top of the cell,
-		         + 3: is an empirical value to realign with task-tree result of the
-		         default gtkcellrenderertext ypad property (2) + 1 ??? ;). */
+		/* NOTE: cy1 is the pixel coordinate of the top of the bar. 
+			 subtract round(priv->bar_top) to bring us to the top of the row
+			 add priv->height / 2 to get to the center of the row
+			 subtract priv->text_height / 2 to get to the top of the text */
 		   
 		draw_cut_layout (drawable,
 				 GTK_WIDGET (item->canvas)->style->text_gc[GTK_STATE_NORMAL],
 				 cx2 + TEXT_PADDING,
-				 cy1 - priv->bar_top + 3, 
+				 cy1 - (gint)(priv->bar_top + 0.5) + (priv->height - priv->text_height) / 2,
 				 priv->layout);
 
 		if (priv->mouse_over_index != -1) {
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (GNU/Linux)

iD8DBQFGqkcnMGnpIbeahxwRAqQrAJ4tOu4a2OxrMmT5l99RSTWoxeEgIgCgrT7T
vrxp6q/lhXVcsewHcSSkcJw=
=0O2Y
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.