Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gimp/ChangeLog,v
retrieving revision 1.11180
diff -p -u -2 -r1.11180 ChangeLog
--- ChangeLog	22 Jun 2005 21:19:10 -0000	1.11180
+++ ChangeLog	23 Jun 2005 00:58:21 -0000
@@ -1,2 +1,22 @@
+2005-06-23  Tor Lillqvist  <tml@novell.com>
+
+	* app/display/gimpcanvas.h: Add new GimpCanvasStyle value,
+	GIMP_CANVAS_STYLE_XOR_DOTTED.
+
+	* app/display/gimpcanvas.c (gimp_canvas_gc_new): Implement it like
+	GIMP_CANVAS_STYLE_XOR_DASHED, except that we set the dash pattern
+	to a single-pixel on-off one.
+
+	* app/tools/gimpdrawtool.c (gimp_draw_tool_draw_boundary): Sort
+	the boundary so that drawig it using XOR and GDK_CAP_NOT_LAST
+	actually has the desired effect. Use GIMP_CANVAS_STYLE_XOR_DOTTED
+	so the outline doesn't look too heavy. Draw using
+	gimp_canvas_draw_lines(), not gimp_canvas_draw_segments(), so that
+	the dashes don't start anew for each boundary segment. Remove the
+	dubious code snippet that offset some segments by one pixel. It
+	didn't do what the comment said, and why one would need to to what
+	the comment said, or what it actually did, is unclear. Now brush
+	outlines don't have gaps any longer.
+
 2005-06-22  Sven Neumann  <sven@gimp.org>
 
Index: app/display/gimpcanvas.c
===================================================================
RCS file: /cvs/gnome/gimp/app/display/gimpcanvas.c,v
retrieving revision 1.15
diff -p -u -2 -r1.15 gimpcanvas.c
--- app/display/gimpcanvas.c	23 Mar 2005 13:53:31 -0000	1.15
+++ app/display/gimpcanvas.c	23 Jun 2005 00:58:21 -0000
@@ -247,4 +247,5 @@ gimp_canvas_gc_new (GimpCanvas      *can
       break;
 
+    case GIMP_CANVAS_STYLE_XOR_DOTTED:
     case GIMP_CANVAS_STYLE_XOR_DASHED:
       mask |= GDK_GC_LINE_STYLE;
@@ -276,4 +277,10 @@ gimp_canvas_gc_new (GimpCanvas      *can
 
   gc = gdk_gc_new_with_values (GTK_WIDGET (canvas)->window, &values, mask);
+
+  if (style == GIMP_CANVAS_STYLE_XOR_DOTTED)
+    {
+      gint8 one = 1;
+      gdk_gc_set_dashes (gc, 0, &one, 1);
+    }
 
   switch (style)
Index: app/display/gimpcanvas.h
===================================================================
RCS file: /cvs/gnome/gimp/app/display/gimpcanvas.h,v
retrieving revision 1.7
diff -p -u -2 -r1.7 gimpcanvas.h
--- app/display/gimpcanvas.h	23 Mar 2005 13:53:31 -0000	1.7
+++ app/display/gimpcanvas.h	23 Jun 2005 00:58:21 -0000
@@ -31,4 +31,5 @@ typedef enum
   GIMP_CANVAS_STYLE_XOR,
   GIMP_CANVAS_STYLE_XOR_DASHED,
+  GIMP_CANVAS_STYLE_XOR_DOTTED,
   GIMP_CANVAS_STYLE_SELECTION_IN,
   GIMP_CANVAS_STYLE_SELECTION_OUT,
Index: app/tools/gimpdrawtool.c
===================================================================
RCS file: /cvs/gnome/gimp/app/tools/gimpdrawtool.c,v
retrieving revision 1.56
diff -p -u -2 -r1.56 gimpdrawtool.c
--- app/tools/gimpdrawtool.c	14 Nov 2004 02:50:14 -0000	1.56
+++ app/tools/gimpdrawtool.c	23 Jun 2005 00:58:22 -0000
@@ -1283,9 +1283,11 @@ gimp_draw_tool_draw_boundary (GimpDrawTo
 {
   GimpDisplayShell *shell;
-  GdkSegment       *gdk_segs;
-  gint              n_gdk_segs;
+  GdkPoint         *gdk_points;
+  gint              n_gdk_points;
   gint              xmax, ymax;
   gint              x, y;
   gint              i;
+  gint              num_groups;
+  BoundSeg	   *sorted_segs;
 
   g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
@@ -1294,61 +1296,59 @@ gimp_draw_tool_draw_boundary (GimpDrawTo
   shell = GIMP_DISPLAY_SHELL (draw_tool->gdisp->shell);
 
-  gdk_segs   = g_new0 (GdkSegment, n_bound_segs);
-  n_gdk_segs = 0;
+  sorted_segs = sort_boundary (bound_segs, n_bound_segs, &num_groups);
+
+  gdk_points = g_new0 (GdkPoint, n_bound_segs + 1);
+  n_gdk_points = 0;
 
   xmax = shell->disp_width  + 1;
   ymax = shell->disp_height + 1;
 
-  for (i = 0; i < n_bound_segs; i++)
+  /* The sorted boundary has sentinel segments inserted at the end of
+   * each group.
+   */
+  for (i = 0; i < n_bound_segs + num_groups; i++)
     {
-      gimp_display_shell_transform_xy (shell,
-                                       bound_segs[i].x1 + offset_x,
-                                       bound_segs[i].y1 + offset_y,
-                                       &x, &y,
-                                       use_offsets);
+      if (sorted_segs[i].x1 == -1 &&
+	  sorted_segs[i].y1 == -1 &&
+	  sorted_segs[i].x2 == -1 &&
+	  sorted_segs[i].y2 == -1)
+	{
+	  /* Group ends */
+	  gimp_canvas_draw_lines (GIMP_CANVAS (shell->canvas),
+				  GIMP_CANVAS_STYLE_XOR_DOTTED,
+				  gdk_points, n_gdk_points);
+	  n_gdk_points = 0;
+	  continue;
+	}
+
+      if (n_gdk_points == 0)
+	{
+	  gimp_display_shell_transform_xy (shell,
+					   sorted_segs[i].x1 + offset_x,
+					   sorted_segs[i].y1 + offset_y,
+					   &x, &y,
+					   use_offsets);
 
-      gdk_segs[n_gdk_segs].x1 = CLAMP (x, -1, xmax);
-      gdk_segs[n_gdk_segs].y1 = CLAMP (y, -1, ymax);
+	  gdk_points[0].x = CLAMP (x, -1, xmax);
+	  gdk_points[0].y = CLAMP (y, -1, ymax);
+
+	  n_gdk_points++;
+	}
+
+      g_assert (n_gdk_points < n_bound_segs + 1);
 
       gimp_display_shell_transform_xy (shell,
-                                       bound_segs[i].x2 + offset_x,
-                                       bound_segs[i].y2 + offset_y,
+                                       sorted_segs[i].x2 + offset_x,
+                                       sorted_segs[i].y2 + offset_y,
                                        &x, &y,
                                        use_offsets);
 
-      gdk_segs[n_gdk_segs].x2 = CLAMP (x, -1, xmax);
-      gdk_segs[n_gdk_segs].y2 = CLAMP (y, -1, ymax);
+      gdk_points[n_gdk_points].x = CLAMP (x, -1, xmax);
+      gdk_points[n_gdk_points].y = CLAMP (y, -1, ymax);
 
-      if (gdk_segs[n_gdk_segs].x1 == gdk_segs[n_gdk_segs].x2 &&
-          gdk_segs[n_gdk_segs].y1 == gdk_segs[n_gdk_segs].y2)
-        continue;
-
-      /*  If this segment is a closing segment && the segments lie inside
-       *  the region, OR if this is an opening segment and the segments
-       *  lie outside the region...
-       *  we need to transform it by one display pixel
-       */
-      if (! bound_segs[i].open)
-        {
-          /*  If it is vertical  */
-          if (gdk_segs[n_gdk_segs].x1 == gdk_segs[n_gdk_segs].x2)
-            {
-              gdk_segs[n_gdk_segs].x1 -= 1;
-              gdk_segs[n_gdk_segs].x2 -= 1;
-            }
-          else
-            {
-              gdk_segs[n_gdk_segs].y1 -= 1;
-              gdk_segs[n_gdk_segs].y2 -= 1;
-            }
-        }
-
-      n_gdk_segs++;
+      n_gdk_points++;
     }
 
-  gimp_canvas_draw_segments (GIMP_CANVAS (shell->canvas),
-                             GIMP_CANVAS_STYLE_XOR,
-                             gdk_segs, n_gdk_segs);
-
-  g_free (gdk_segs);
+  g_free (gdk_points);
+  g_free (sorted_segs);
 }
