Commit de642dd1 authored by Tor Lillqvist's avatar Tor Lillqvist Committed by Tor Lillqvist
Browse files

Add new GimpCanvasStyle value, GIMP_CANVAS_STYLE_XOR_DOTTED.

2005-06-24  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 we can draw each connected group of segments
	using gimp_canvas_draw_lines(). (Even if we would still use
	gimp_canvas_draw_segments(), the boundary would have to be sorted
	so that the XOR drawing and GDK_CAP_NOT_LAST cooperate properly.)

	Use GIMP_CANVAS_STYLE_XOR_DOTTED so the outline doesn't look too
	heavy.

	Remove the dubious code snippet that offset some segments by one
	pixel. It didn't do what the comment claimed, and why one would
	need to do what the comment said, or what it actually did, is
	unclear.

	Now brush outlines shouldn't have gaps any longer. (#308710)
parent 6d509631
2005-06-24 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 we can draw each connected group of segments
using gimp_canvas_draw_lines(). (Even if we would still use
gimp_canvas_draw_segments(), the boundary would have to be sorted
so that the XOR drawing and GDK_CAP_NOT_LAST cooperate properly.)
Use GIMP_CANVAS_STYLE_XOR_DOTTED so the outline doesn't look too
heavy.
Remove the dubious code snippet that offset some segments by one
pixel. It didn't do what the comment claimed, and why one would
need to do what the comment said, or what it actually did, is
unclear.
Now brush outlines shouldn't have gaps any longer. (#308710)
2005-06-24 Manish Singh <yosh@gimp.org>
* configure.in: define PYLINK_LIBS on Win32, since DLLs need to have
......@@ -155,17 +180,6 @@
* plug-ins/script-fu/scripts/xach-effect.scm: Reorganize
the Image window's Filters menu, as discussed in bug #116145.
2005-06-23 Tor Lillqvist <tml@novell.com>
* app/tools/gimpdrawtool.c (gimp_draw_tool_draw_boundary): Sort
the boundary so that GIMP_CANVAS_STYLE_XOR drawing (which uses
GDK_CAP_NOT_LAST) works better. 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
so many gaps any longer. (There are still some gaps for
pathological brushes.)
2005-06-23 Sven Neumann <sven@gimp.org>
* app/actions/plug-in-actions.c (plug_in_actions_last_changed): call
......
......@@ -246,6 +246,7 @@ gimp_canvas_gc_new (GimpCanvas *canvas,
values.graphics_exposures = TRUE;
break;
case GIMP_CANVAS_STYLE_XOR_DOTTED:
case GIMP_CANVAS_STYLE_XOR_DASHED:
mask |= GDK_GC_LINE_STYLE;
values.line_style = GDK_LINE_ON_OFF_DASH;
......@@ -276,6 +277,12 @@ gimp_canvas_gc_new (GimpCanvas *canvas,
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)
{
default:
......
......@@ -30,6 +30,7 @@ typedef enum
GIMP_CANVAS_STYLE_RENDER,
GIMP_CANVAS_STYLE_XOR,
GIMP_CANVAS_STYLE_XOR_DASHED,
GIMP_CANVAS_STYLE_XOR_DOTTED,
GIMP_CANVAS_STYLE_SELECTION_IN,
GIMP_CANVAS_STYLE_SELECTION_OUT,
GIMP_CANVAS_STYLE_LAYER_BOUNDARY,
......
......@@ -1282,73 +1282,73 @@ gimp_draw_tool_draw_boundary (GimpDrawTool *draw_tool,
gboolean use_offsets)
{
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));
g_return_if_fail (n_bound_segs > 0 || bound_segs == NULL);
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);
gdk_segs[n_gdk_segs].x1 = CLAMP (x, -1, xmax);
gdk_segs[n_gdk_segs].y1 = CLAMP (y, -1, ymax);
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_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);
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;
gdk_points[n_gdk_points].x = CLAMP (x, -1, xmax);
gdk_points[n_gdk_points].y = CLAMP (y, -1, ymax);
/* 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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment