2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
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
|
|
|
|
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"
|
|
|
|
|
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
|
|
|
|
2008-03-09 23:38:25 +08:00
|
|
|
static void gimp_ellipse_select_tool_draw (GimpDrawTool *draw_tool);
|
2001-03-08 12:15:32 +08:00
|
|
|
|
2008-03-09 23:38:25 +08:00
|
|
|
static void gimp_ellipse_select_tool_select (GimpRectangleSelectTool *rect_tool,
|
|
|
|
GimpChannelOps 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,
|
2008-03-09 23:38:25 +08:00
|
|
|
GIMP_TYPE_RECTANGLE_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,
|
2008-03-09 23:38:25 +08:00
|
|
|
GIMP_TYPE_RECTANGLE_SELECT_OPTIONS,
|
|
|
|
gimp_rectangle_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"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Ellipse Select Tool: Select an elliptical region"),
|
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
|
|
|
{
|
2008-03-09 23:38:25 +08:00
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
|
|
|
GimpRectangleSelectToolClass *rect_tool_class = GIMP_RECTANGLE_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-11-05 20:35:59 +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)
|
|
|
|
{
|
2007-04-01 00:22:57 +08:00
|
|
|
gint x1, y1, x2, y2;
|
2006-03-26 21:50:13 +08:00
|
|
|
|
2007-04-01 00:22:57 +08:00
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
|
|
|
|
|
|
|
g_object_get (draw_tool,
|
2006-03-26 21:50:13 +08:00
|
|
|
"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,
|
2006-10-19 02:54:28 +08:00
|
|
|
0, 360 * 64,
|
2001-11-12 22:45:58 +08:00
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-08 12:15:32 +08:00
|
|
|
static void
|
2008-03-09 23:38:25 +08:00
|
|
|
gimp_ellipse_select_tool_select (GimpRectangleSelectTool *rect_tool,
|
|
|
|
GimpChannelOps 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);
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (tool->display);
|
2001-03-08 12:15:32 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
gimp_channel_select_ellipse (gimp_image_get_mask (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
|
|
|
}
|