
2001-11-08 Michael Natterer <mitch@gimp.org> * app/Makefile.am: build display/ before tools/. * app/devices.c: devices_check_change(): added all events which have a GdkDevice pointer. * app/gimpprogress.c: include "display-types.h" instead of "core-types.h". * app/core/Makefile.am * app/core/gimpdrawable-bucket-fill.[ch]: new files: the bucket_fill stuff taken from tools/gimpbucketfilltool.[ch]. * app/core/core-types.h: added "BucketFillMode". * app/core/gimpimage-mask-select.[ch]: cleanup. * app/core/gimpmarshal.list: added more marshallers for GimpTool's new signal signatures. * app/core/gimpmarshal.[ch]: regenerated. * app/display/Makefile.am * app/display/gimpdisplayshell-dnd.[ch] * app/display/gimpdisplayshell-layer-select.[ch]: new files: the canvas drop callbacks from gimpdisplayshell-callbacks.[ch] and the stuff formerly knows as gui/layer-select.[ch]. * app/display/gimpdisplay.h: don't include "gui/gui-types.h". * app/display/gximage.c: include "display-types.h". * app/display/gimpdisplay-foreach.c * app/display/gimpdisplayshell.[ch]: call gdsplay_delete(), don't destroy the shell widget. * app/gui/Makefile.am * app/gui/layer-select.[ch]: removed. * app/gui/gradients-commands.c: fixed "Save as POV" fprintf()s. * app/gui/preferences-dialog.c: removed the layer_select stuff because it is useless with the new preview system. * app/gui/tool-options-dialog.c: send the correct data to the close_callback. * app/gui/tools-commands.c: changed to follow the new gimp_tool_initialize() semantics (see below). Tool & canvas event handling chainsawing: * app/tools/tools-types.h: new struct GimpCoords which contains x, y, pressure, tilt etc. * app/display/gimpdisplayshell-callbacks.[ch]: added utility functions which transparently retreive the current event's GimpCoords or take it from the device directly if the event has none. Pass GimpCoords _in_image_coordinates_ to all tool functions. Most important: don't pass GdkEvents and display coordinates to tools any more. * app/tools/gimptool.[ch]: changed virtual functions to take GimpCoords, time and state separately instead of GdkEvents. * app/tools/gimpbezierselecttool.c * app/tools/gimpblendtool.c * app/tools/gimpbucketfilltool.[ch] * app/tools/gimpbycolorselecttool.c * app/tools/gimpclonetool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpconvolvetool.c * app/tools/gimpcroptool.[ch] * app/tools/gimpcurvestool.c * app/tools/gimpdodgeburntool.c * app/tools/gimpdrawtool.c * app/tools/gimpeditselectiontool.[ch] * app/tools/gimperasertool.c * app/tools/gimpfliptool.c * app/tools/gimpfreeselecttool.[ch] * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpiscissorstool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.[ch] * app/tools/gimprectselecttool.c * app/tools/gimprotatetool.c * app/tools/gimpselectiontool.[ch] * app/tools/gimpsmudgetool.c * app/tools/gimptexttool.c * app/tools/gimptransformtool.[ch] * app/tools/path_tool.[ch] * app/tools/selection_options.c: tons and tons of changes: - changed to use the new virtual function parameters. - removed zillions of gdisplay_untransform_coords(). - get the active drawable's offsets manually in many cases. (questionable, but IMHO ok because it's obvious and not simply a "TRUE" passed to some function) - reordered some functions to be consistent across tools. - some tools had to be changed to work on image coords, not display ones (esp. crop). - fixed strange rotate tool behaviour which should be backported to stable. - some stuff i came across. - indentation and other paranoia. - rounding of coordinated may be broken in some tools. - new bugs guaranteed. * app/tools/tool_manager.[ch]: new semantic of tool_manager_initialize_active() (looked at the places where it was used from and put common code together). Should be a bit better now :) * app/tools/gimpblendtool.c * app/tools/transform_options.c: use the new GTK+ feature that a widget (toggle button) can be a frame's title for this tools' tool options. * app/widgets/widgets-types.h: stuff. * themes/Default/gtkrc: s/GtkDialog/GimpDialog/. * tools/pdbgen/Makefile.am: don't scan tools/gimpbucketfilltool.h any more. * tools/pdbgen/enums.pl: regenerated. * tools/pdbgen/pdb/tools.pdb: changed bucket_fill wrapper. * app/pdb/tools_cmds.c: regenerated.
284 lines
9.4 KiB
C
284 lines
9.4 KiB
C
/* The GIMP -- an image manipulation program
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
#include <glib-object.h>
|
|
|
|
#include "core-types.h"
|
|
|
|
#include "gimpchannel.h"
|
|
#include "gimpimage.h"
|
|
#include "gimpimage-contiguous-region.h"
|
|
#include "gimpimage-mask.h"
|
|
#include "gimpimage-mask-select.h"
|
|
#include "gimpscanconvert.h"
|
|
|
|
|
|
void
|
|
gimp_image_mask_select_rectangle (GimpImage *gimage,
|
|
gint x,
|
|
gint y,
|
|
gint w,
|
|
gint h,
|
|
ChannelOps op,
|
|
gboolean feather,
|
|
gdouble feather_radius_x,
|
|
gdouble feather_radius_y)
|
|
{
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
/* if applicable, replace the current selection */
|
|
if (op == CHANNEL_OP_REPLACE)
|
|
gimage_mask_clear (gimage);
|
|
else
|
|
gimage_mask_undo (gimage);
|
|
|
|
/* if feathering for rect, make a new mask with the
|
|
* rectangle and feather that with the old mask
|
|
*/
|
|
if (feather || op == CHANNEL_OP_INTERSECT)
|
|
{
|
|
GimpChannel *mask;
|
|
|
|
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
|
|
gimp_channel_combine_rect (mask, CHANNEL_OP_ADD, x, y, w, h);
|
|
|
|
if (feather)
|
|
gimp_channel_feather (mask,
|
|
feather_radius_x,
|
|
feather_radius_y,
|
|
FALSE /* no undo */);
|
|
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage), mask, op, 0, 0);
|
|
g_object_unref (G_OBJECT (mask));
|
|
}
|
|
else
|
|
{
|
|
gimp_channel_combine_rect (gimp_image_get_mask (gimage), op, x, y, w, h);
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_image_mask_select_ellipse (GimpImage *gimage,
|
|
gint x,
|
|
gint y,
|
|
gint w,
|
|
gint h,
|
|
ChannelOps op,
|
|
gboolean antialias,
|
|
gboolean feather,
|
|
gdouble feather_radius_x,
|
|
gdouble feather_radius_y)
|
|
{
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
/* if applicable, replace the current selection */
|
|
if (op == CHANNEL_OP_REPLACE)
|
|
gimage_mask_clear (gimage);
|
|
else
|
|
gimage_mask_undo (gimage);
|
|
|
|
/* if feathering for rect, make a new mask with the
|
|
* rectangle and feather that with the old mask
|
|
*/
|
|
if (feather || op == CHANNEL_OP_INTERSECT)
|
|
{
|
|
GimpChannel *mask;
|
|
|
|
mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
|
|
gimp_channel_combine_ellipse (mask, CHANNEL_OP_ADD, x, y, w, h, antialias);
|
|
|
|
if (feather)
|
|
gimp_channel_feather (mask,
|
|
feather_radius_x,
|
|
feather_radius_y,
|
|
FALSE /* no undo */);
|
|
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage), mask, op, 0, 0);
|
|
g_object_unref (G_OBJECT (mask));
|
|
}
|
|
else
|
|
{
|
|
gimp_channel_combine_ellipse (gimp_image_get_mask (gimage), op,
|
|
x, y, w, h, antialias);
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_image_mask_select_polygon (GimpImage *gimage,
|
|
gint n_points,
|
|
GimpVector2 *points,
|
|
ChannelOps op,
|
|
gboolean antialias,
|
|
gboolean feather,
|
|
gdouble feather_radius_x,
|
|
gdouble feather_radius_y)
|
|
{
|
|
GimpScanConvert *scan_convert;
|
|
GimpChannel *mask;
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
/* if applicable, replace the current selection
|
|
* or insure that a floating selection is anchored down...
|
|
*/
|
|
if (op == CHANNEL_OP_REPLACE)
|
|
gimage_mask_clear (gimage);
|
|
else
|
|
gimage_mask_undo (gimage);
|
|
|
|
#define SUPERSAMPLE 3
|
|
|
|
scan_convert = gimp_scan_convert_new (gimage->width,
|
|
gimage->height,
|
|
antialias ? SUPERSAMPLE : 1);
|
|
gimp_scan_convert_add_points (scan_convert, n_points, points);
|
|
|
|
mask = gimp_scan_convert_to_channel (scan_convert, gimage);
|
|
|
|
gimp_scan_convert_free (scan_convert);
|
|
|
|
#undef SUPERSAMPLE
|
|
|
|
if (mask)
|
|
{
|
|
if (feather)
|
|
gimp_channel_feather (mask,
|
|
feather_radius_x,
|
|
feather_radius_y,
|
|
FALSE /* no undo */);
|
|
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage), mask, op, 0, 0);
|
|
g_object_unref (G_OBJECT (mask));
|
|
}
|
|
}
|
|
|
|
void
|
|
gimp_image_mask_select_channel (GimpImage *gimage,
|
|
GimpDrawable *drawable,
|
|
gboolean sample_merged,
|
|
GimpChannel *channel,
|
|
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 */
|
|
if (op == CHANNEL_OP_REPLACE)
|
|
gimage_mask_clear (gimage);
|
|
else
|
|
gimage_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,
|
|
feather_radius_y,
|
|
FALSE /* no undo */);
|
|
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage), channel,
|
|
op, off_x, off_y);
|
|
}
|
|
|
|
void
|
|
gimp_image_mask_select_fuzzy (GimpImage *gimage,
|
|
GimpDrawable *drawable,
|
|
gboolean sample_merged,
|
|
gint x,
|
|
gint y,
|
|
gint threshold,
|
|
ChannelOps op,
|
|
gboolean antialias,
|
|
gboolean feather,
|
|
gdouble feather_radius_x,
|
|
gdouble feather_radius_y)
|
|
{
|
|
GimpChannel *mask;
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
mask = gimp_image_contiguous_region_by_seed (gimage, drawable,
|
|
sample_merged,
|
|
antialias,
|
|
threshold,
|
|
x, y);
|
|
|
|
gimp_image_mask_select_channel (gimage,
|
|
drawable,
|
|
sample_merged,
|
|
mask,
|
|
op,
|
|
feather,
|
|
feather_radius_x,
|
|
feather_radius_y);
|
|
|
|
g_object_unref (G_OBJECT (mask));
|
|
}
|
|
|
|
void
|
|
gimp_image_mask_select_by_color (GimpImage *gimage,
|
|
GimpDrawable *drawable,
|
|
gboolean sample_merged,
|
|
const GimpRGB *color,
|
|
gint threshold,
|
|
ChannelOps op,
|
|
gboolean antialias,
|
|
gboolean feather,
|
|
gdouble feather_radius_x,
|
|
gdouble feather_radius_y)
|
|
{
|
|
GimpChannel *mask;
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
g_return_if_fail (color != NULL);
|
|
|
|
mask = gimp_image_contiguous_region_by_color (gimage, drawable,
|
|
sample_merged,
|
|
antialias,
|
|
threshold,
|
|
color);
|
|
|
|
gimp_image_mask_select_channel (gimage,
|
|
drawable,
|
|
sample_merged,
|
|
mask,
|
|
op,
|
|
feather,
|
|
feather_radius_x,
|
|
feather_radius_y);
|
|
|
|
g_object_unref (G_OBJECT (mask));
|
|
}
|