mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-22 20:41:43 +00:00
227eea67cb
2001-01-29 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/undo_history.h: new file. * app/apptypes.h: removed the "Channel" typedef. * app/channel.[ch]: renamed all functions to gimp_channel_*() * app/channel_ops.c * app/channels_dialog.c * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/gimage_mask.[ch] * app/gimpdnd.c * app/gimphistogram.c * app/gimpimage.[ch] * app/global_edit.c * app/layer.c * app/layers_dialog.c * app/qmask.c * app/scan_convert.c * app/scan_convert.h * app/toolbox.c * app/undo.[ch] * app/undo_history.c * app/xcf.[ch] * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/drawable_cmds.c * app/pdb/image_cmds.c * app/pdb/pdb_glue.h * app/pdb/selection_cmds.c * app/pdb/tools_cmds.c * app/tools/bezier_select.c * app/tools/bezier_selectP.h * app/tools/blend.c * app/tools/bucket_fill.c * app/tools/by_color_select.c * app/tools/crop.c * app/tools/ellipse_select.c * app/tools/free_select.c * app/tools/fuzzy_select.c * app/tools/fuzzy_select.h * app/tools/iscissors.c * app/tools/rect_select.c * app/tools/text_tool.c * app/tools/transform_core.c * tools/pdbgen/pdb.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/drawable.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly.
171 lines
4.6 KiB
C
171 lines
4.6 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 <stdlib.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "apptypes.h"
|
|
|
|
#include "channel.h"
|
|
#include "draw_core.h"
|
|
#include "edit_selection.h"
|
|
#include "gdisplay.h"
|
|
#include "gimage_mask.h"
|
|
#include "gimpimage.h"
|
|
#include "rect_select.h"
|
|
#include "rect_selectP.h"
|
|
|
|
#include "ellipse_select.h"
|
|
#include "selection_options.h"
|
|
#include "tool_options.h"
|
|
#include "tools.h"
|
|
|
|
|
|
/* the ellipse selection tool options */
|
|
SelectionOptions * ellipse_options = NULL;
|
|
|
|
|
|
/*************************************/
|
|
/* Ellipsoidal selection apparatus */
|
|
|
|
void
|
|
ellipse_select (GimpImage *gimage,
|
|
gint x,
|
|
gint y,
|
|
gint w,
|
|
gint h,
|
|
SelectOps op,
|
|
gboolean antialias,
|
|
gboolean feather,
|
|
gdouble feather_radius)
|
|
{
|
|
GimpChannel *new_mask;
|
|
|
|
/* if applicable, replace the current selection */
|
|
if (op == SELECTION_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)
|
|
{
|
|
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
|
|
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
|
|
x, y, w, h, antialias);
|
|
gimp_channel_feather (new_mask, gimp_image_get_mask (gimage),
|
|
feather_radius,
|
|
feather_radius,
|
|
op, 0, 0);
|
|
gtk_object_unref (GTK_OBJECT (new_mask));
|
|
}
|
|
else if (op == SELECTION_INTERSECT)
|
|
{
|
|
new_mask = gimp_channel_new_mask (gimage, gimage->width, gimage->height);
|
|
gimp_channel_combine_ellipse (new_mask, CHANNEL_OP_ADD,
|
|
x, y, w, h, antialias);
|
|
gimp_channel_combine_mask (gimp_image_get_mask (gimage), new_mask,
|
|
op, 0, 0);
|
|
gtk_object_unref (GTK_OBJECT (new_mask));
|
|
}
|
|
else
|
|
{
|
|
gimp_channel_combine_ellipse (gimp_image_get_mask (gimage), op,
|
|
x, y, w, h, antialias);
|
|
}
|
|
}
|
|
|
|
void
|
|
ellipse_select_draw (Tool *tool)
|
|
{
|
|
EllipseSelect *ellipse_sel;
|
|
gint x1, y1;
|
|
gint x2, y2;
|
|
|
|
ellipse_sel = (EllipseSelect *) tool->private;
|
|
|
|
x1 = MIN (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w);
|
|
y1 = MIN (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h);
|
|
x2 = MAX (ellipse_sel->x, ellipse_sel->x + ellipse_sel->w);
|
|
y2 = MAX (ellipse_sel->y, ellipse_sel->y + ellipse_sel->h);
|
|
|
|
gdisplay_transform_coords (tool->gdisp, x1, y1, &x1, &y1, 0);
|
|
gdisplay_transform_coords (tool->gdisp, x2, y2, &x2, &y2, 0);
|
|
|
|
gdk_draw_arc (ellipse_sel->core->win,
|
|
ellipse_sel->core->gc, 0,
|
|
x1, y1, (x2 - x1), (y2 - y1), 0, 23040);
|
|
}
|
|
|
|
static void
|
|
ellipse_select_options_reset (void)
|
|
{
|
|
selection_options_reset (ellipse_options);
|
|
}
|
|
|
|
Tool *
|
|
tools_new_ellipse_select (void)
|
|
{
|
|
Tool *tool;
|
|
EllipseSelect *private;
|
|
|
|
/* The tool options */
|
|
if (!ellipse_options)
|
|
{
|
|
ellipse_options =
|
|
selection_options_new (ELLIPSE_SELECT, ellipse_select_options_reset);
|
|
tools_register (ELLIPSE_SELECT, (ToolOptions *) ellipse_options);
|
|
}
|
|
|
|
tool = tools_new_tool (ELLIPSE_SELECT);
|
|
private = g_new0 (EllipseSelect, 1);
|
|
|
|
private->core = draw_core_new (ellipse_select_draw);
|
|
/* Make the selection static, not blinking */
|
|
private->x = private->y = 0;
|
|
private->w = private->h = 0;
|
|
|
|
tool->private = (void *) private;
|
|
|
|
tool->button_press_func = rect_select_button_press;
|
|
tool->button_release_func = rect_select_button_release;
|
|
tool->motion_func = rect_select_motion;
|
|
tool->modifier_key_func = rect_select_modifier_update;
|
|
tool->cursor_update_func = rect_select_cursor_update;
|
|
tool->oper_update_func = rect_select_oper_update;
|
|
tool->control_func = rect_select_control;
|
|
|
|
return tool;
|
|
}
|
|
|
|
void
|
|
tools_free_ellipse_select (Tool *tool)
|
|
{
|
|
EllipseSelect *ellipse_sel;
|
|
|
|
ellipse_sel = (EllipseSelect *) tool->private;
|
|
|
|
draw_core_free (ellipse_sel->core);
|
|
g_free (ellipse_sel);
|
|
}
|