1997-11-25 06:05:25 +08: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 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
2000-03-29 07:39:32 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-08-06 00:08:19 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpchannel.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2006-06-01 03:45:38 +08:00
|
|
|
#include "gimprectangletool.h"
|
2001-03-08 12:15:32 +08:00
|
|
|
#include "gimpellipseselecttool.h"
|
2006-06-11 05:34:12 +08:00
|
|
|
#include "gimprectangleselectoptions.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1999-04-13 01:55:06 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2006-06-11 00:49:07 +08:00
|
|
|
static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool);
|
2001-03-08 12:15:32 +08:00
|
|
|
|
2006-06-11 02:24:58 +08:00
|
|
|
static void gimp_ellipse_select_tool_select (GimpRectSelectTool *rect_tool,
|
|
|
|
SelectOps operation,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2001-03-08 12:15:32 +08:00
|
|
|
|
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpEllipseSelectTool, gimp_ellipse_select_tool,
|
2006-06-11 02:24:58 +08:00
|
|
|
GIMP_TYPE_RECT_SELECT_TOOL)
|
2005-12-13 17:13:50 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_ellipse_select_tool_parent_class
|
2001-03-08 12:15:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_ellipse_select_tool_register (GimpToolRegisterCallback callback,
|
2003-08-22 09:42:57 +08:00
|
|
|
gpointer data)
|
2001-03-08 12:15:32 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_ELLIPSE_SELECT_TOOL,
|
2006-06-11 02:24:58 +08:00
|
|
|
GIMP_TYPE_RECT_SELECT_OPTIONS,
|
|
|
|
gimp_rect_select_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-ellipse-select-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Ellipse Select"),
|
|
|
|
_("Select elliptical regions"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Ellipse Select"), "E",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_ELLIPSE_SELECT,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_ELLIPSE_SELECT,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-03-08 12:15:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_ellipse_select_tool_class_init (GimpEllipseSelectToolClass *klass)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-06-11 02:24:58 +08:00
|
|
|
GimpDrawToolClass *draw_tool_class;
|
|
|
|
GimpRectSelectToolClass *rect_tool_class;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2006-06-11 02:24:58 +08:00
|
|
|
rect_tool_class = GIMP_RECT_SELECT_TOOL_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-11 00:49:07 +08:00
|
|
|
draw_tool_class->draw = gimp_ellipse_select_tool_draw;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-06-11 00:49:07 +08:00
|
|
|
rect_tool_class->select = gimp_ellipse_select_tool_select;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
static void
|
2001-03-08 12:15:32 +08:00
|
|
|
gimp_ellipse_select_tool_init (GimpEllipseSelectTool *ellipse_select)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2006-06-01 03:45:38 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (ellipse_select);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_ELLIPSE_SELECT);
|
2001-03-08 12:15:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-08 12:15:32 +08:00
|
|
|
static void
|
|
|
|
gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool)
|
|
|
|
{
|
2006-06-11 02:24:58 +08:00
|
|
|
GimpRectSelectTool *rect_sel = GIMP_RECT_SELECT_TOOL (draw_tool);
|
2006-03-26 21:50:13 +08:00
|
|
|
gint x1, y1;
|
|
|
|
gint x2, y2;
|
|
|
|
|
|
|
|
g_object_get (rect_sel,
|
|
|
|
"x1", &x1,
|
|
|
|
"y1", &y1,
|
|
|
|
"x2", &x2,
|
|
|
|
"y2", &y2,
|
|
|
|
NULL);
|
2005-03-08 05:31:22 +08:00
|
|
|
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_draw_arc (draw_tool,
|
|
|
|
FALSE,
|
2006-03-26 21:50:13 +08:00
|
|
|
x1, y1,
|
|
|
|
x2 - x1, y2 - y1,
|
2001-11-12 22:45:58 +08:00
|
|
|
0, 23040,
|
|
|
|
FALSE);
|
2006-06-12 08:36:56 +08:00
|
|
|
|
|
|
|
gimp_rectangle_tool_draw (draw_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-08 12:15:32 +08:00
|
|
|
static void
|
2006-06-11 02:24:58 +08:00
|
|
|
gimp_ellipse_select_tool_select (GimpRectSelectTool *rect_tool,
|
|
|
|
SelectOps operation,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (rect_tool);
|
|
|
|
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (rect_tool);
|
2001-03-08 12:15:32 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_channel_select_ellipse (gimp_image_get_mask (tool->display->image),
|
2003-10-06 20:17:11 +08:00
|
|
|
x, y, w, h,
|
2006-06-11 00:49:07 +08:00
|
|
|
operation,
|
2003-10-06 20:17:11 +08:00
|
|
|
options->antialias,
|
|
|
|
options->feather,
|
|
|
|
options->feather_radius,
|
2006-08-26 01:19:36 +08:00
|
|
|
options->feather_radius,
|
|
|
|
TRUE);
|
2001-03-08 12:15:32 +08:00
|
|
|
}
|