Commit affc3100 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

changed gimp_image_mask_select_channel() to not take "drawable" and

2002-03-03  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-mask-select.[ch]: changed
	gimp_image_mask_select_channel() to not take "drawable" and
	"sample_merged" parameters (which are silly in some contexts) but
	simply the offsets of the passed channel.

	* app/gui/channels-commands.c
	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpiscissorstool.c: changed accordingly.

	* app/tools/gimpdrawtool.[ch]: chaged gimp_draw_tool_draw_lines()
	and _draw_strokes() to take an additional "use_offsets" parameter
	like the other drawing functions.

	* app/path_curves.c
	* app/tools/gimpvectortool.c: changed accordingly.

	* app/paint/gimppaintcore.c: removed #if 0'ed code which was
	identical to other functions.

	* app/tools/gimpselectiontool.c: use the GimpEditSelectionTool's
	"arrow_key_func" so it's now possible to keyboad-move the current
	layer and selection with all selection tool. Needs some more
	tweaking...

	* app/tools/gimpiscissorstool.[ch]
	* app/tools/gimpvectortool.[ch]: derive them from GimpSelectionTool
	to make the modifier key <-> tool options interaction work. Ported
	IScissors to the new way the draw_tool works.
parent 9ea943e0
2002-03-03 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-mask-select.[ch]: changed
gimp_image_mask_select_channel() to not take "drawable" and
"sample_merged" parameters (which are silly in some contexts) but
simply the offsets of the passed channel.
* app/gui/channels-commands.c
* app/tools/gimpbezierselecttool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimpiscissorstool.c: changed accordingly.
* app/tools/gimpdrawtool.[ch]: chaged gimp_draw_tool_draw_lines()
and _draw_strokes() to take an additional "use_offsets" parameter
like the other drawing functions.
* app/path_curves.c
* app/tools/gimpvectortool.c: changed accordingly.
* app/paint/gimppaintcore.c: removed #if 0'ed code which was
identical to other functions.
* app/tools/gimpselectiontool.c: use the GimpEditSelectionTool's
"arrow_key_func" so it's now possible to keyboad-move the current
layer and selection with all selection tool. Needs some more
tweaking...
* app/tools/gimpiscissorstool.[ch]
* app/tools/gimpvectortool.[ch]: derive them from GimpSelectionTool
to make the modifier key <-> tool options interaction work. Ported
IScissors to the new way the draw_tool works.
2002-03-02 Sven Neumann <sven@gimp.org>
* autogen.sh: require intltool-0.17.
......@@ -31,7 +63,6 @@
* themes/Default/images/preferences/folders-gradients.png
* themes/Default/images/preferences/folders-palettes.png
* themes/Default/images/preferences/folders-patterns.png
* themes/Default/images/preferences/folders-plug-ins.png: some new
icons made from Jimmac's new tool icons and Tigert's abstract
palette icon.
......
......@@ -142,8 +142,8 @@ channels_channel_to_sel (GtkWidget *widget,
return_if_no_channel (gimage, active_channel);
gimp_image_mask_select_channel (gimage,
NULL, FALSE,
active_channel,
0, 0,
op,
FALSE, 0, 0);
gdisplays_flush ();
......
......@@ -231,18 +231,15 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
void
gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
gint offset_x,
gint offset_y,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
gint off_x, off_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail ((! drawable && ! sample_merged) || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
/* if applicable, replace the current selection */
......@@ -251,15 +248,6 @@ gimp_image_mask_select_channel (GimpImage *gimage,
else
gimp_image_mask_undo (gimage);
if (sample_merged)
{
off_x = off_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
if (feather)
gimp_channel_feather (channel,
feather_radius_x,
......@@ -267,7 +255,7 @@ gimp_image_mask_select_channel (GimpImage *gimage,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), channel,
op, off_x, off_y);
op, offset_x, offset_y);
}
void
......@@ -285,6 +273,8 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
gdouble feather_radius_y)
{
GimpChannel *mask;
gint mask_x;
gint mask_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
......@@ -296,10 +286,20 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
select_transparent,
x, y);
if (sample_merged)
{
mask_x = 0;
mask_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &mask_x, &mask_y);
}
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
mask_x,
mask_y,
op,
feather,
feather_radius_x,
......@@ -322,6 +322,8 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
gdouble feather_radius_y)
{
GimpChannel *mask;
gint mask_x;
gint mask_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
......@@ -334,10 +336,20 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
select_transparent,
color);
if (sample_merged)
{
mask_x = 0;
mask_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &mask_x, &mask_y);
}
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
mask_x,
mask_y,
op,
feather,
feather_radius_x,
......
......@@ -59,9 +59,9 @@ void gimp_image_mask_select_vectors (GimpImage *gimage,
gdouble feather_radius_y);
void gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
gint offset_x,
gint offset_y,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
......
......@@ -231,18 +231,15 @@ gimp_image_mask_select_vectors (GimpImage *gimage,
void
gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
gint offset_x,
gint offset_y,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
gdouble feather_radius_y)
{
gint off_x, off_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail ((! drawable && ! sample_merged) || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (GIMP_IS_CHANNEL (channel));
/* if applicable, replace the current selection */
......@@ -251,15 +248,6 @@ gimp_image_mask_select_channel (GimpImage *gimage,
else
gimp_image_mask_undo (gimage);
if (sample_merged)
{
off_x = off_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
if (feather)
gimp_channel_feather (channel,
feather_radius_x,
......@@ -267,7 +255,7 @@ gimp_image_mask_select_channel (GimpImage *gimage,
FALSE /* no undo */);
gimp_channel_combine_mask (gimp_image_get_mask (gimage), channel,
op, off_x, off_y);
op, offset_x, offset_y);
}
void
......@@ -285,6 +273,8 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
gdouble feather_radius_y)
{
GimpChannel *mask;
gint mask_x;
gint mask_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
......@@ -296,10 +286,20 @@ gimp_image_mask_select_fuzzy (GimpImage *gimage,
select_transparent,
x, y);
if (sample_merged)
{
mask_x = 0;
mask_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &mask_x, &mask_y);
}
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
mask_x,
mask_y,
op,
feather,
feather_radius_x,
......@@ -322,6 +322,8 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
gdouble feather_radius_y)
{
GimpChannel *mask;
gint mask_x;
gint mask_y;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
......@@ -334,10 +336,20 @@ gimp_image_mask_select_by_color (GimpImage *gimage,
select_transparent,
color);
if (sample_merged)
{
mask_x = 0;
mask_y = 0;
}
else
{
gimp_drawable_offsets (drawable, &mask_x, &mask_y);
}
gimp_image_mask_select_channel (gimage,
drawable,
sample_merged,
mask,
mask_x,
mask_y,
op,
feather,
feather_radius_x,
......
......@@ -59,9 +59,9 @@ void gimp_image_mask_select_vectors (GimpImage *gimage,
gdouble feather_radius_y);
void gimp_image_mask_select_channel (GimpImage *gimage,
GimpDrawable *drawable,
gboolean sample_merged,
GimpChannel *channel,
gint offset_x,
gint offset_y,
ChannelOps op,
gboolean feather,
gdouble feather_radius_x,
......
......@@ -142,8 +142,8 @@ channels_channel_to_sel (GtkWidget *widget,
return_if_no_channel (gimage, active_channel);
gimp_image_mask_select_channel (gimage,
NULL, FALSE,
active_channel,
0, 0,
op,
FALSE, 0, 0);
gdisplays_flush ();
......
......@@ -1526,104 +1526,6 @@ brush_to_canvas_buf (GimpPaintCore *core,
apply_mask_to_region (&srcPR, &maskPR, brush_opacity);
}
#if 0
static void
paint_to_canvas_tiles (GimpPaintCore *core,
Maskbuf *brush_mask,
gint brush_opacity)
{
PixelRegion srcPR;
PixelRegion maskPR;
gint x;
gint y;
gint xoff;
gint yoff;
/* combine the brush mask and the canvas tiles */
pixel_region_init (&srcPR, core->canvas_tiles,
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
core->canvas_buf->height,
TRUE);
x = (gint) floor (core->cur_coords.x) - (brush_mask->width >> 1);
y = (gint) floor (core->cur_coords.y) - (brush_mask->height >> 1);
xoff = (x < 0) ? -x : 0;
yoff = (y < 0) ? -y : 0;
maskPR.bytes = 1;
maskPR.x = 0;
maskPR.y = 0;
maskPR.w = srcPR.w;
maskPR.h = srcPR.h;
maskPR.rowstride = maskPR.bytes * brush_mask->width;
maskPR.data = mask_buf_data (brush_mask) + (yoff * maskPR.rowstride +
xoff * maskPR.bytes);
/* combine the mask and canvas tiles */
combine_mask_and_region (&srcPR, &maskPR, brush_opacity);
/* combine the canvas tiles and the canvas buf */
srcPR.bytes = core->canvas_buf->bytes;
srcPR.x = 0;
srcPR.y = 0;
srcPR.w = core->canvas_buf->width;
srcPR.h = core->canvas_buf->height;
srcPR.rowstride = core->canvas_buf->width * core->canvas_buf->bytes;
srcPR.data = temp_buf_data (core->canvas_buf);
pixel_region_init (&maskPR, core->canvas_tiles,
core->canvas_buf->x,
core->canvas_buf->y,
core->canvas_buf->width,
core->canvas_buf->height,
FALSE);
/* apply the canvas tiles to the canvas buf */
apply_mask_to_region (&srcPR, &maskPR, OPAQUE_OPACITY);
}
static void
paint_to_canvas_buf (GimpPaintCore *core,
MaskBuf *brush_mask,
gint brush_opacity)
{
PixelRegion srcPR;
PixelRegion maskPR;
gint x;
gint y;
gint xoff;
gint yoff;
x = (gint) floor (core->cur_coords.x) - (brush_mask->width >> 1);
y = (gint) floor (core->cur_coords.y) - (brush_mask->height >> 1);
xoff = (x < 0) ? -x : 0;
yoff = (y < 0) ? -y : 0;
/* combine the canvas buf and the brush mask to the canvas buf */
srcPR.bytes = core->canvas_buf->bytes;
srcPR.x = 0;
srcPR.y = 0;
srcPR.w = core->canvas_buf->width;
srcPR.h = core->canvas_buf->height;
srcPR.rowstride = core->canvas_buf->width * canvas_buf->bytes;
srcPR.data = temp_buf_data (core->canvas_buf);
maskPR.bytes = 1;
maskPR.x = 0;
maskPR.y = 0;
maskPR.w = srcPR.w;
maskPR.h = srcPR.h;
maskPR.rowstride = maskPR.bytes * brush_mask->width;
maskPR.data = mask_buf_data (brush_mask) + yoff * maskPR.rowstride + xoff * maskPR.bytes;
/* apply the mask */
apply_mask_to_region (&srcPR, &maskPR, brush_opacity);
}
#endif
static void
set_undo_tiles (GimpPaintCore *core,
GimpDrawable *drawable,
......
......@@ -163,7 +163,7 @@ path_curve_draw_segment (GimpDrawTool *tool,
} else {
gdouble *coordinates = g_new (gdouble, 200);
num_pts = path_curve_get_points (segment, coordinates, 100, 0, 1);
gimp_draw_tool_draw_lines (tool, coordinates, num_pts, FALSE);
gimp_draw_tool_draw_lines (tool, coordinates, num_pts, FALSE, FALSE);
g_free (coordinates);
}
......
......@@ -2901,8 +2901,8 @@ bezier_to_sel_internal (GimpBezierSelectTool *bezier_sel,
bezier_convert (bezier_sel, tool->gdisp, SUBDIVIDE, TRUE);
gimp_image_mask_select_channel (gdisp->gimage,
NULL, FALSE,
bezier_sel->mask,
0, 0,
op,
sel_options->feather,
sel_options->feather_radius,
......
......@@ -683,8 +683,9 @@ gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
void
gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
gdouble *points,
gint npoints,
gint filled)
gint n_points,
gboolean filled,
gboolean use_offsets)
{
GimpDisplayShell *shell;
GdkPoint *coords;
......@@ -693,14 +694,14 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
shell = GIMP_DISPLAY_SHELL (draw_tool->gdisp->shell);
coords = g_new (GdkPoint, npoints);
coords = g_new (GdkPoint, n_points);
for (i = 0; i < npoints ; i++)
for (i = 0; i < n_points ; i++)
{
gdisplay_transform_coords_f (draw_tool->gdisp,
points[i*2], points[i*2+1],
&sx, &sy,
TRUE);
use_offsets);
coords[i].x = ROUND (sx);
coords[i].y = ROUND (sy);
}
......@@ -709,13 +710,13 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
{
gdk_draw_polygon (draw_tool->win,
draw_tool->gc, TRUE,
coords, npoints);
coords, n_points);
}
else
{
gdk_draw_lines (draw_tool->win,
draw_tool->gc,
coords, npoints);
coords, n_points);
}
g_free (coords);
......@@ -724,8 +725,9 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
void
gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
GimpCoords *points,
gint npoints,
gint filled)
gint n_points,
gboolean filled,
gboolean use_offsets)
{
GimpDisplayShell *shell;
GdkPoint *coords;
......@@ -734,14 +736,14 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
shell = GIMP_DISPLAY_SHELL (draw_tool->gdisp->shell);
coords = g_new (GdkPoint, npoints);
coords = g_new (GdkPoint, n_points);
for (i = 0; i < npoints ; i++)
for (i = 0; i < n_points ; i++)
{
gdisplay_transform_coords_f (draw_tool->gdisp,
points[i].x, points[i].y,
&sx, &sy,
TRUE);
use_offsets);
coords[i].x = ROUND (sx);
coords[i].y = ROUND (sy);
}
......@@ -750,13 +752,13 @@ gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
{
gdk_draw_polygon (draw_tool->win,
draw_tool->gc, TRUE,
coords, npoints);
coords, n_points);
}
else
{
gdk_draw_lines (draw_tool->win,
draw_tool->gc,
coords, npoints);
coords, n_points);
}
g_free (coords);
......
......@@ -171,13 +171,15 @@ gboolean gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
void gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
gdouble *points,
gint npoints,
gint filled);
gint n_points,
gboolean filled,
gboolean use_offsets);
void gimp_draw_tool_draw_strokes (GimpDrawTool *draw_tool,
GimpCoords *points,
gint npoints,
gint filled);
gint n_points,
gboolean filled,
gboolean use_offsets);
#endif /* __GIMP_DRAW_TOOL_H__ */
......@@ -242,7 +242,6 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool,
{
GimpFuzzySelectTool *fuzzy_sel;
SelectionOptions *sel_options;
GimpDrawable *drawable;
fuzzy_sel = GIMP_FUZZY_SELECT_TOOL (tool);
......@@ -255,12 +254,26 @@ gimp_fuzzy_select_tool_button_release (GimpTool *tool,
/* First take care of the case where the user "cancels" the action */
if (! (state & GDK_BUTTON3_MASK))
{
drawable = gimp_image_active_drawable (gdisp->gimage);
gint off_x, off_y;
if (sel_options->sample_merged)
{
off_x = 0;
off_y = 0;
}
else
{
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (gdisp->gimage);
gimp_drawable_offsets (drawable, &off_x, &off_y);
}
gimp_image_mask_select_channel (gdisp->gimage,
drawable,
sel_options->sample_merged,
fuzzy_sel->fuzzy_mask,
off_x,
off_y,
GIMP_SELECTION_TOOL (tool)->op,
sel_options->feather,
sel_options->feather_radius,
......
......@@ -252,7 +252,8 @@ static gint direction_value[256][4];
static gboolean initialized = FALSE;
static Tile *cur_tile = NULL;
static GimpDrawTool *parent_class = NULL;
static GimpSelectionToolClass *parent_class = NULL;
void
......@@ -292,7 +293,7 @@ gimp_iscissors_tool_get_type (void)
(GInstanceInitFunc) gimp_iscissors_tool_init,
};
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
tool_type = g_type_register_static (GIMP_TYPE_SELECTION_TOOL,
"GimpIscissorsTool",
&tool_info, 0);
}
......@@ -332,9 +333,10 @@ gimp_iscissors_tool_init (GimpIscissorsTool *iscissors)
tool = GIMP_TOOL (iscissors);
iscissors->op = -1;
iscissors->curves = NULL;
iscissors->op = ISCISSORS_OP_NONE;
iscissors->dp_buf = NULL;
iscissors->curves = NULL;
iscissors->draw = DRAW_NOTHING;
iscissors->state = NO_ACTION;
iscissors->mask = NULL;
iscissors->gradient_map = NULL;
......@@ -365,7 +367,7 @@ gimp_iscissors_tool_control (GimpTool *tool,
GimpDisplay *gdisp)
{
GimpIscissorsTool *iscissors;
Iscissors_draw draw;
IscissorsDraw draw;
iscissors = GIMP_ISCISSORS_TOOL (tool);
......@@ -414,14 +416,11 @@ gimp_iscissors_tool_button_press (GimpTool *tool,
{
GimpIscissorsTool *iscissors;
SelectionOptions *sel_options;
GimpDrawable *drawable;
iscissors = GIMP_ISCISSORS_TOOL (tool);