patch for drawing left frame in usage row bars

Lee Baylis <lee-gZngeWTYz/[email protected]> Mon, 25 Aug 2008 03:38:20 +0100
Newsgroups gmane.comp.gnome.apps.planner.devel
Message-ID <[email protected]>
Hi all,

My first planner patch - whilst tinkering around in planner-usage-row.c 
I found a FIXME line which was near to what I happened to be playing 
with, so I have fixed it.

I don't think this is a registered bug in bugzilla, just something a 
developer noticed and made a note of.

As far as I could tell, the problem wasn't exactly as described in the 
FIXME - my observation was that, rather than being a bug for *any* task 
which started at the same time as the project, usage row bars for 
resources were actually rendered OK in general, unless the resource had 
either:

- *no* tasks assigned, or
- a single task assigned which ran the full length of the project.

In these two cases, the left side of the usage bar was drawn and then 
overwritten by a white separator bar.

If anyone wants to reproduce the problem, the attached planner file 
should demonstrate the issue (look on the Sarah and Jimmy resources). 
The attached svn diff is my patch for this issue, and causes the example 
to render correctly.

If people are happy with this after a week or so, I can add to the 
changelog and upload it to the svn repository - do I need some sort of 
credentials to do so?

Thanks,
lee

_______________________________________________
Planner-dev-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/planner-dev-list
planner-usage-row-left-frame-bug.planner (application/x-planner, 2.6 KB) - not displayed
planner-usage-row.patch (text/x-diff, 3.3 KB)
Index: src/planner-usage-row.c
===================================================================
--- src/planner-usage-row.c	(revision 931)
+++ src/planner-usage-row.c	(working copy)
@@ -4,6 +4,7 @@
  * Copyright (C) 2003 Benjamin BAYART <[email protected]>
  * Copyright (C) 2003 Xavier Ordoquy <[email protected]>
  * Copyright (C) 2006 Alvaro del Castillo <[email protected]>
+ * Copyright (C) 2008 Lee Baylis <http://leebaylis.co.uk>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -869,6 +870,7 @@
 typedef enum {
         ROW_START,
         ROW_MIDDLE,
+	ROW_WHOLE,
         ROW_END
 } RowChunk;
 
@@ -1012,7 +1014,7 @@
         }
 	
         /* Left of the shadow. */
-        if (chunk == ROW_START && cs_xstart == rs_xstart) {
+        if ((chunk == ROW_START || chunk == ROW_WHOLE) && cs_xstart == rs_xstart) {
                 gdk_draw_line (drawable, priv->fill_gc, rs_xstart, rs_ystart,
                                rs_xstart, cs_yend);
         }
@@ -1038,13 +1040,13 @@
         }
 	
         /* Right of the shadow. */
-        if (chunk == ROW_END && cs_xend == rs_xend) {
+        if ((chunk == ROW_END || chunk == ROW_WHOLE) && cs_xend == rs_xend) {
                 gdk_draw_line (drawable, priv->fill_gc, rs_xend, rs_ystart,
                                rs_xend, cs_yend);
         }
 
 	/* Interval separator. */
-	if (chunk != ROW_START) {
+	if (chunk != ROW_START && chunk != ROW_WHOLE) {
 		gdk_gc_set_foreground (priv->fill_gc, &GTK_WIDGET (item->canvas)->style->white);
 		gdk_draw_line (drawable, priv->fill_gc, c_xstart, rs_ystart, c_xstart,
                                rr_yend);
@@ -1063,13 +1065,13 @@
 	}
 	
         /* Left frame. */
-        if (chunk == ROW_START && c_xstart == r_xstart) {
+        if ((chunk == ROW_START || chunk == ROW_WHOLE) && c_xstart == r_xstart) {
                 gdk_draw_line (drawable, priv->frame_gc, r_xstart, r_ystart,
                                r_xstart, r_yend);
 	}
 	
         /* Right frame. */
-        if (chunk == ROW_END && c_xend == r_xend) {
+        if ((chunk == ROW_END || chunk == ROW_WHOLE) && c_xend == r_xend) {
                 gdk_draw_line (drawable, priv->frame_gc, r_xend, r_ystart, r_xend,
                                r_yend);
 	}
@@ -1145,12 +1147,13 @@
         for (d = dates; d; d = d->next) {
                 date = d->data;
 
-		/* FIXME: This code is broken, it never paints the leftmost part
-		 * of the frame for bars that start at the project start.
-		 */
                 if (date->time != previous_time) {
                         if (date->time == finish) {
-                                chunk = ROW_END;
+                                if (chunk == ROW_START){
+					chunk = ROW_WHOLE;
+				} else {
+					chunk = ROW_END;
+				}
 			}
 
                         usage_row_draw_resource_ival (previous_time,
@@ -1175,7 +1178,11 @@
         g_list_free (dates);
 
         if (chunk != ROW_END) {
-                chunk = ROW_END;
+                if (chunk == ROW_START) {
+			chunk = ROW_WHOLE;
+		} else {
+			chunk = ROW_END;
+		}
                 usage_row_draw_resource_ival (previous_time,
                                                finish,
                                                units,