1997-11-24 22:05:25 +00:00
|
|
|
/* 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
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
#include <stdlib.h>
|
2000-03-28 23:39:32 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-08-05 16:08:19 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "tools-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpchannel.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
#include "core/gimpimage-mask.h"
|
2001-10-22 12:13:44 +00:00
|
|
|
#include "core/gimpimage-mask-select.h"
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
#include "gimpellipseselecttool.h"
|
2003-02-08 21:12:03 +00:00
|
|
|
#include "gimpselectionoptions.h"
|
2003-04-15 16:05:52 +00:00
|
|
|
#include "gimptoolcontrol.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
1999-04-12 17:55:06 +00:00
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
static void gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass);
|
|
|
|
static void gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select);
|
|
|
|
|
|
|
|
static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
|
|
|
static void gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
|
|
|
|
|
|
|
|
static GimpRectSelectToolClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-03-08 04:15:32 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_ELLIPSE_SELECT_TOOL,
|
2003-02-05 14:39:40 +00:00
|
|
|
GIMP_TYPE_SELECTION_OPTIONS,
|
|
|
|
gimp_selection_options_gui,
|
2003-06-28 11:20:37 +00:00
|
|
|
0,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-ellipse-select-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Ellipse Select"),
|
|
|
|
_("Select elliptical regions"),
|
2003-07-01 16:22:03 +00:00
|
|
|
N_("/Tools/Selection Tools/_Ellipse Select"), "E",
|
2001-11-20 23:00:47 +00:00
|
|
|
NULL, "tools/ellipse_select.html",
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_ELLIPSE_SELECT,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-03-08 04:15:32 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-03-08 04:15:32 +00:00
|
|
|
gimp_ellipse_select_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
2001-03-08 04:15:32 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
if (! tool_type)
|
2001-03-08 04:15:32 +00:00
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-08 04:15:32 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpEllipseSelectToolClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_ellipse_select_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpEllipseSelectTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_ellipse_select_tool_init,
|
2001-03-08 04:15:32 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_RECT_SELECT_TOOL,
|
|
|
|
"GimpEllipseSelectTool",
|
|
|
|
&tool_info, 0);
|
2001-03-08 04:15:32 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
return tool_type;
|
2001-03-08 04:15:32 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-03-08 04:15:32 +00:00
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
GimpRectSelectToolClass *rect_tool_class;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
|
|
|
rect_tool_class = GIMP_RECT_SELECT_TOOL_CLASS (klass);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-03-08 04:15:32 +00:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_ellipse_select_tool_draw;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
rect_tool_class->rect_select = gimp_ellipse_select_tool_rect_select;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1999-04-08 22:25:54 +00:00
|
|
|
static void
|
2001-03-08 04:15:32 +00:00
|
|
|
gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select)
|
1999-04-08 22:25:54 +00:00
|
|
|
{
|
2002-06-16 17:13:39 +00:00
|
|
|
GimpTool *tool;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2002-06-16 17:13:39 +00:00
|
|
|
tool = GIMP_TOOL (ellipse_select);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-06-16 17:13:39 +00:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_ELLIPSE_SELECT_TOOL_CURSOR);
|
2001-03-08 04:15:32 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
static void
|
|
|
|
gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool)
|
|
|
|
{
|
|
|
|
GimpRectSelectTool *rect_sel;
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
|
|
|
|
2001-11-12 14:45:58 +00:00
|
|
|
gimp_draw_tool_draw_arc (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
rect_sel->x,
|
|
|
|
rect_sel->y,
|
|
|
|
rect_sel->w,
|
|
|
|
rect_sel->h,
|
|
|
|
0, 23040,
|
|
|
|
FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
static void
|
|
|
|
gimp_ellipse_select_tool_rect_select (GimpRectSelectTool *rect_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-02-05 14:39:40 +00:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpSelectionTool *sel_tool;
|
|
|
|
GimpSelectionOptions *options;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-08 04:15:32 +00:00
|
|
|
tool = GIMP_TOOL (rect_tool);
|
|
|
|
sel_tool = GIMP_SELECTION_TOOL (rect_tool);
|
2003-02-05 14:39:40 +00:00
|
|
|
options = GIMP_SELECTION_OPTIONS (tool->tool_info->tool_options);
|
2001-03-08 04:15:32 +00:00
|
|
|
|
2001-10-22 12:13:44 +00:00
|
|
|
gimp_image_mask_select_ellipse (tool->gdisp->gimage,
|
|
|
|
x, y, w, h,
|
|
|
|
sel_tool->op,
|
2003-02-05 14:39:40 +00:00
|
|
|
options->antialias,
|
|
|
|
options->feather,
|
|
|
|
options->feather_radius,
|
|
|
|
options->feather_radius);
|
2001-03-08 04:15:32 +00:00
|
|
|
}
|