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-10-27 06:02:44 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-03-29 11:50:29 +08:00
|
|
|
#include "core/core-types.h"
|
|
|
|
#include "libgimptool/gimptooltypes.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui/gui-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
2001-07-07 22:53:42 +08:00
|
|
|
#include "core/gimpimage-crop.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage-mask.h"
|
2001-11-20 21:53:21 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-13 20:52:30 +08:00
|
|
|
#include "display/gimpdisplay-foreach.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
2002-03-20 03:17:31 +08:00
|
|
|
#include "widgets/gimpenummenu.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gimpcroptool.h"
|
|
|
|
#include "tool_manager.h"
|
2001-11-21 07:00:47 +08:00
|
|
|
#include "tool_options.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2001-05-14 05:51:20 +08:00
|
|
|
#include "app_procs.h"
|
2001-11-09 03:14:51 +08:00
|
|
|
#include "gimprc.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
/* speed of key movement */
|
|
|
|
#define ARROW_VELOCITY 25
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
/* possible crop functions */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
CREATING,
|
|
|
|
MOVING,
|
|
|
|
RESIZING_LEFT,
|
|
|
|
RESIZING_RIGHT,
|
|
|
|
CROPPING
|
|
|
|
};
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
typedef struct _CropOptions CropOptions;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
1999-04-09 06:25:54 +08:00
|
|
|
struct _CropOptions
|
|
|
|
{
|
2001-07-18 04:50:01 +08:00
|
|
|
GimpToolOptions tool_options;
|
1999-04-13 01:55:06 +08:00
|
|
|
|
2002-03-20 03:17:31 +08:00
|
|
|
gboolean layer_only;
|
|
|
|
gboolean layer_only_d;
|
|
|
|
GtkWidget *layer_only_w;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-20 03:17:31 +08:00
|
|
|
gboolean allow_enlarge;
|
|
|
|
gboolean allow_enlarge_d;
|
|
|
|
GtkWidget *allow_enlarge_w;
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2002-03-20 03:17:31 +08:00
|
|
|
GimpCropType type;
|
|
|
|
GimpCropType type_d;
|
|
|
|
GtkWidget *type_w;
|
1999-04-09 06:25:54 +08:00
|
|
|
};
|
|
|
|
|
1999-04-27 10:09:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void gimp_crop_tool_class_init (GimpCropToolClass *klass);
|
|
|
|
static void gimp_crop_tool_init (GimpCropTool *crop_tool);
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
static void gimp_crop_tool_finalize (GObject *object);
|
2001-07-18 04:50:01 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static void gimp_crop_tool_control (GimpTool *tool,
|
2002-02-19 01:00:09 +08:00
|
|
|
GimpToolAction action,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_crop_tool_button_press (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_crop_tool_button_release (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_crop_tool_motion (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_crop_tool_arrow_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
static void gimp_crop_tool_modifier_key (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_crop_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp);
|
2001-07-18 04:50:01 +08:00
|
|
|
|
|
|
|
static void gimp_crop_tool_draw (GimpDrawTool *draw_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-26 19:16:47 +08:00
|
|
|
/* Crop helper functions */
|
2001-07-18 04:50:01 +08:00
|
|
|
static void crop_tool_crop_image (GimpImage *gimage,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gboolean layer_only,
|
|
|
|
gboolean crop_layers);
|
|
|
|
|
|
|
|
static void crop_recalc (GimpTool *tool,
|
|
|
|
GimpCropTool *crop);
|
|
|
|
static void crop_start (GimpTool *tool,
|
|
|
|
GimpCropTool *crop);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Crop dialog functions */
|
2001-07-18 04:50:01 +08:00
|
|
|
static void crop_info_update (GimpTool *tool);
|
|
|
|
static void crop_info_create (GimpTool *tool);
|
|
|
|
static void crop_crop_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void crop_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void crop_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void crop_selection_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void crop_automatic_callback (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
static void crop_origin_changed (GtkWidget *widget,
|
2001-07-18 04:50:01 +08:00
|
|
|
gpointer data);
|
|
|
|
static void crop_size_changed (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions * crop_options_new (GimpToolInfo *tool_info);
|
|
|
|
static void crop_options_reset (GimpToolOptions *tool_options);
|
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static InfoDialog *crop_info = NULL;
|
|
|
|
|
|
|
|
static gdouble orig_vals[2];
|
|
|
|
static gdouble size_vals[2];
|
|
|
|
|
|
|
|
static GtkWidget *origin_sizeentry;
|
|
|
|
static GtkWidget *size_sizeentry;
|
2001-03-02 00:57:16 +08:00
|
|
|
|
|
|
|
static GimpDrawToolClass *parent_class = NULL;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
/* public functions */
|
2001-07-07 22:53:42 +08:00
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_crop_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_CROP_TOOL,
|
2001-11-21 07:00:47 +08:00
|
|
|
crop_options_new,
|
|
|
|
FALSE,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-crop-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Crop Tool"),
|
|
|
|
_("Crop or Resize an image"),
|
|
|
|
N_("/Tools/Transform Tools/Crop Tool"), "<shift>C",
|
|
|
|
NULL, "tools/crop_tool.html",
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_CROP,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1998-12-04 14:46:52 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpCropToolClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_crop_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpCropTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_crop_tool_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
|
|
|
"GimpCropTool",
|
|
|
|
&tool_info, 0);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
return tool_type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-04 14:46:52 +08:00
|
|
|
static void
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_class_init (GimpCropToolClass *klass)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
GObjectClass *object_class;
|
2001-07-07 22:53:42 +08:00
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpDrawToolClass *draw_tool_class;
|
2001-04-01 04:41:39 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class->finalize = gimp_crop_tool_finalize;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
|
|
|
tool_class->control = gimp_crop_tool_control;
|
|
|
|
tool_class->button_press = gimp_crop_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_crop_tool_button_release;
|
|
|
|
tool_class->motion = gimp_crop_tool_motion;
|
|
|
|
tool_class->arrow_key = gimp_crop_tool_arrow_key;
|
|
|
|
tool_class->modifier_key = gimp_crop_tool_modifier_key;
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->cursor_update = gimp_crop_tool_cursor_update;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_crop_tool_draw;
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_init (GimpCropTool *crop_tool)
|
1998-12-04 14:46:52 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
GimpTool *tool;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
tool = GIMP_TOOL (crop_tool);
|
2001-04-01 04:41:39 +08:00
|
|
|
|
2002-05-03 05:03:27 +08:00
|
|
|
gimp_tool_control_set_preserve (tool->control, FALSE);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_CROP_TOOL_CURSOR);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1998-12-04 14:46:52 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void
|
2001-08-14 22:53:55 +08:00
|
|
|
gimp_crop_tool_finalize (GObject *object)
|
2001-07-07 22:53:42 +08:00
|
|
|
{
|
|
|
|
if (crop_info)
|
|
|
|
{
|
|
|
|
info_dialog_free (crop_info);
|
|
|
|
crop_info = NULL;
|
2001-08-14 22:53:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-02-19 01:00:09 +08:00
|
|
|
gimp_crop_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp)
|
2001-08-14 22:53:55 +08:00
|
|
|
{
|
|
|
|
GimpCropTool *crop_tool;
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
crop_tool = GIMP_CROP_TOOL (tool);
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case PAUSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME:
|
|
|
|
crop_recalc (tool, crop_tool);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HALT:
|
|
|
|
crop_close_callback (NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1999-04-08 13:20:37 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
1998-12-04 14:46:52 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_crop_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-05 19:35:03 +08:00
|
|
|
GimpCropTool *crop;
|
|
|
|
GimpDrawTool *draw_tool;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-11-16 05:17:36 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
if (!gimp_tool_control_is_active (tool->control) || gdisp != tool->gdisp)
|
1999-06-26 19:16:47 +08:00
|
|
|
{
|
|
|
|
crop->function = CREATING;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If the cursor is in either the upper left or lower right boxes,
|
2001-11-09 03:14:51 +08:00
|
|
|
* The new function will be to resize the current crop area
|
|
|
|
*/
|
2001-11-16 05:17:36 +08:00
|
|
|
if (gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_WEST,
|
|
|
|
FALSE))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
crop->function = RESIZING_LEFT;
|
|
|
|
}
|
2001-11-16 05:17:36 +08:00
|
|
|
else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x2, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_EAST,
|
|
|
|
FALSE))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
crop->function = RESIZING_RIGHT;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
/* If the cursor is in either the upper right or lower left boxes,
|
2001-11-09 03:14:51 +08:00
|
|
|
* The new function will be to translate the current crop area
|
|
|
|
*/
|
2001-11-16 05:17:36 +08:00
|
|
|
else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x2, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_EAST,
|
|
|
|
FALSE) ||
|
|
|
|
gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x1, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_WEST,
|
|
|
|
FALSE))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
crop->function = MOVING;
|
|
|
|
}
|
|
|
|
/* If the pointer is in the rectangular region, crop or resize it!
|
|
|
|
*/
|
|
|
|
else if (coords->x > crop->x1 &&
|
|
|
|
coords->x < crop->x2 &&
|
|
|
|
coords->y > crop->y1 &&
|
|
|
|
coords->y < crop->y2)
|
|
|
|
{
|
|
|
|
crop->function = CROPPING;
|
|
|
|
}
|
|
|
|
/* otherwise, the new function will be creating, since we want
|
|
|
|
* to start a new
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
crop->function = CREATING;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (crop->function == CREATING)
|
|
|
|
{
|
2002-05-03 19:31:08 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
tool->gdisp = gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2 = crop->x1 = ROUND (coords->x);
|
|
|
|
crop->y2 = crop->y1 = ROUND (coords->y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
crop_start (tool, crop);
|
|
|
|
}
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->lastx = crop->startx = ROUND (coords->x);
|
|
|
|
crop->lasty = crop->starty = ROUND (coords->y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_crop_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-05 19:35:03 +08:00
|
|
|
GimpCropTool *crop;
|
|
|
|
CropOptions *options;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-08 10:01:52 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_tool_pop_status (tool);
|
1998-07-27 05:49:42 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (! (state & GDK_BUTTON3_MASK))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-04-29 02:58:01 +08:00
|
|
|
if (crop->function == CROPPING)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-20 03:17:31 +08:00
|
|
|
if (options->type == GIMP_CROP)
|
2001-07-07 22:53:42 +08:00
|
|
|
crop_tool_crop_image (gdisp->gimage,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->x2, crop->y2,
|
2001-11-20 21:53:21 +08:00
|
|
|
options->layer_only,
|
2001-11-09 03:14:51 +08:00
|
|
|
TRUE);
|
1999-04-29 02:58:01 +08:00
|
|
|
else
|
2001-07-07 22:53:42 +08:00
|
|
|
crop_tool_crop_image (gdisp->gimage,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->x2, crop->y2,
|
2001-11-20 21:53:21 +08:00
|
|
|
options->layer_only,
|
2001-11-09 03:14:51 +08:00
|
|
|
FALSE);
|
1999-04-29 02:58:01 +08:00
|
|
|
|
|
|
|
/* Finish the tool */
|
1999-06-26 19:16:47 +08:00
|
|
|
crop_close_callback (NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-04-29 02:58:01 +08:00
|
|
|
else
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
crop_info_update (tool);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_crop_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpCropTool *crop;
|
2001-11-20 21:53:21 +08:00
|
|
|
CropOptions *options;
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint curx, cury;
|
|
|
|
gint inc_x, inc_y;
|
|
|
|
gint min_x, min_y, max_x, max_y;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-03-08 10:01:52 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* This is the only case when the motion events should be ignored--
|
|
|
|
we're just waiting for the button release event to crop the image */
|
1999-04-29 02:58:01 +08:00
|
|
|
if (crop->function == CROPPING)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
curx = ROUND (coords->x);
|
|
|
|
cury = ROUND (coords->y);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
x1 = crop->startx;
|
|
|
|
y1 = crop->starty;
|
|
|
|
x2 = curx;
|
|
|
|
y2 = cury;
|
|
|
|
|
|
|
|
inc_x = (x2 - x1);
|
|
|
|
inc_y = (y2 - y1);
|
|
|
|
|
|
|
|
/* If there have been no changes... return */
|
2001-11-09 03:14:51 +08:00
|
|
|
if (crop->lastx == x2 && crop->lasty == y2)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (options->layer_only)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
layer = gimp_image_get_active_layer (gdisp->gimage);
|
2001-01-15 05:11:52 +08:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &min_x, &min_y);
|
|
|
|
max_x = gimp_drawable_width (GIMP_DRAWABLE (layer)) + min_x;
|
|
|
|
max_y = gimp_drawable_height (GIMP_DRAWABLE (layer)) + min_y;
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
min_x = min_y = 0;
|
|
|
|
max_x = gdisp->gimage->width;
|
|
|
|
max_y = gdisp->gimage->height;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (crop->function)
|
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
case CREATING:
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
x1 = CLAMP (x1, min_x, max_x);
|
|
|
|
y1 = CLAMP (y1, min_y, max_y);
|
|
|
|
x2 = CLAMP (x2, min_x, max_x);
|
|
|
|
y2 = CLAMP (y2, min_y, max_y);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
case RESIZING_LEFT:
|
|
|
|
x1 = crop->x1 + inc_x;
|
|
|
|
y1 = crop->y1 + inc_y;
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
x1 = CLAMP (x1, min_x, max_x);
|
|
|
|
y1 = CLAMP (y1, min_y, max_y);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
x2 = MAX (x1, crop->x2);
|
|
|
|
y2 = MAX (y1, crop->y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
crop->startx = curx;
|
|
|
|
crop->starty = cury;
|
|
|
|
break;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
case RESIZING_RIGHT:
|
|
|
|
x2 = crop->x2 + inc_x;
|
|
|
|
y2 = crop->y2 + inc_y;
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
x2 = CLAMP (x2, min_x, max_x);
|
|
|
|
y2 = CLAMP (y2, min_y, max_y);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
x1 = MIN (crop->x1, x2);
|
|
|
|
y1 = MIN (crop->y1, y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
crop->startx = curx;
|
|
|
|
crop->starty = cury;
|
|
|
|
break;
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
case MOVING:
|
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
inc_x = CLAMP (inc_x, min_x - crop->x1, max_x - crop->x2);
|
|
|
|
inc_y = CLAMP (inc_y, min_y - crop->y1, max_y - crop->y2);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
x1 = crop->x1 + inc_x;
|
|
|
|
x2 = crop->x2 + inc_x;
|
|
|
|
y1 = crop->y1 + inc_y;
|
|
|
|
y2 = crop->y2 + inc_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
crop->startx = curx;
|
|
|
|
crop->starty = cury;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure that the coords are in bounds */
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1 = MIN (x1, x2);
|
|
|
|
crop->y1 = MIN (y1, y2);
|
|
|
|
crop->x2 = MAX (x1, x2);
|
|
|
|
crop->y2 = MAX (y1, y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
crop->lastx = curx;
|
|
|
|
crop->lasty = cury;
|
|
|
|
|
|
|
|
/* recalculate the coordinates for crop_draw based on the new values */
|
|
|
|
crop_recalc (tool, crop);
|
1998-07-27 05:49:42 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (crop->function == CREATING ||
|
|
|
|
crop->function == RESIZING_LEFT ||
|
|
|
|
crop->function == RESIZING_RIGHT)
|
1998-07-27 05:49:42 +08:00
|
|
|
{
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_tool_pop_status (tool);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_tool_push_status_coords (tool,
|
|
|
|
_("Crop: "),
|
|
|
|
crop->x2 - crop->x1,
|
|
|
|
" x ",
|
|
|
|
crop->y2 - crop->y1);
|
1998-07-27 05:49:42 +08:00
|
|
|
}
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_arrow_key (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
GimpCropTool *crop;
|
2001-11-20 21:53:21 +08:00
|
|
|
CropOptions *options;
|
|
|
|
GimpLayer *layer;
|
2001-02-28 11:29:03 +08:00
|
|
|
gint inc_x, inc_y;
|
|
|
|
gint min_x, min_y;
|
|
|
|
gint max_x, max_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-02 00:57:16 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
inc_x = inc_y = 0;
|
|
|
|
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_Up : inc_y = -1; break;
|
|
|
|
case GDK_Left : inc_x = -1; break;
|
|
|
|
case GDK_Right : inc_x = 1; break;
|
|
|
|
case GDK_Down : inc_y = 1; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the shift key is down, move by an accelerated increment */
|
|
|
|
if (kevent->state & GDK_SHIFT_MASK)
|
|
|
|
{
|
|
|
|
inc_y *= ARROW_VELOCITY;
|
|
|
|
inc_x *= ARROW_VELOCITY;
|
|
|
|
}
|
|
|
|
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (options->layer_only)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
layer = gimp_image_get_active_layer (gdisp->gimage);
|
2001-01-15 05:11:52 +08:00
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &min_x, &min_y);
|
|
|
|
max_x = gimp_drawable_width (GIMP_DRAWABLE (layer)) + min_x;
|
|
|
|
max_y = gimp_drawable_height (GIMP_DRAWABLE (layer)) + min_y;
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
min_x = min_y = 0;
|
|
|
|
max_x = gdisp->gimage->width;
|
|
|
|
max_y = gdisp->gimage->height;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (kevent->state & GDK_CONTROL_MASK) /* RESIZING */
|
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2 = crop->x2 + inc_x;
|
|
|
|
crop->y2 = crop->y2 + inc_y;
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2 = CLAMP (crop->x2, min_x, max_x);
|
|
|
|
crop->y2 = CLAMP (crop->y2, min_y, max_y);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1 = MIN (crop->x1, crop->x2);
|
|
|
|
crop->y1 = MIN (crop->y1, crop->y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2000-01-26 07:06:12 +08:00
|
|
|
inc_x = CLAMP (inc_x,
|
2001-11-09 03:14:51 +08:00
|
|
|
-crop->x1, gdisp->gimage->width - crop->x2);
|
2000-01-26 07:06:12 +08:00
|
|
|
inc_y = CLAMP (inc_y,
|
2001-11-09 03:14:51 +08:00
|
|
|
-crop->y1, gdisp->gimage->height - crop->y2);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1 += inc_x;
|
|
|
|
crop->x2 += inc_x;
|
|
|
|
crop->y1 += inc_y;
|
|
|
|
crop->y2 += inc_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
crop_recalc (tool, crop);
|
2001-03-02 00:57:16 +08:00
|
|
|
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-27 10:09:03 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_crop_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1999-04-27 10:09:03 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
CropOptions *options;
|
|
|
|
|
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (state & GDK_MOD1_MASK)
|
1999-04-27 10:09:03 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! options->allow_enlarge)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active
|
2001-11-20 21:53:21 +08:00
|
|
|
(GTK_TOGGLE_BUTTON (options->allow_enlarge_w), TRUE);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
if (options->allow_enlarge)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active
|
2001-11-20 21:53:21 +08:00
|
|
|
(GTK_TOGGLE_BUTTON (options->allow_enlarge_w), FALSE);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key == GDK_CONTROL_MASK)
|
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
switch (options->type)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2002-03-20 03:17:31 +08:00
|
|
|
case GIMP_CROP:
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
|
|
|
GINT_TO_POINTER (GIMP_RESIZE));
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
2002-03-20 03:17:31 +08:00
|
|
|
case GIMP_RESIZE:
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
|
|
|
GINT_TO_POINTER (GIMP_CROP));
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1999-04-27 10:09:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
GimpCropTool *crop;
|
2001-11-16 05:17:36 +08:00
|
|
|
GimpDrawTool *draw_tool;
|
2001-11-20 21:53:21 +08:00
|
|
|
CropOptions *options;
|
2001-11-09 03:14:51 +08:00
|
|
|
GdkCursorType ctype = GIMP_MOUSE_CURSOR;
|
|
|
|
GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
|
2001-11-16 05:17:36 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
if (!gimp_tool_control_is_active (tool->control) ||
|
|
|
|
(gimp_tool_control_is_active (tool->control) && tool->gdisp != gdisp))
|
|
|
|
/* this expression can be simplified to !..._is_active () || t->g != g */
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
ctype = GIMP_CROSSHAIR_SMALL_CURSOR;
|
|
|
|
}
|
2001-11-16 05:17:36 +08:00
|
|
|
else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_WEST,
|
|
|
|
FALSE) ||
|
|
|
|
gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x2, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_EAST,
|
|
|
|
FALSE))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_RESIZE;
|
|
|
|
}
|
2001-11-16 05:17:36 +08:00
|
|
|
else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x2, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_EAST,
|
|
|
|
FALSE) ||
|
|
|
|
gimp_draw_tool_on_handle (draw_tool, gdisp,
|
|
|
|
coords->x, coords->y,
|
|
|
|
GIMP_HANDLE_SQUARE,
|
|
|
|
crop->x1, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_WEST,
|
|
|
|
FALSE))
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
cmodifier = GIMP_CURSOR_MODIFIER_MOVE;
|
|
|
|
}
|
|
|
|
else if (! (coords->x > crop->x1 && coords->x < crop->x2 &&
|
|
|
|
coords->y > crop->y1 && coords->y < crop->y2))
|
|
|
|
{
|
|
|
|
ctype = GIMP_CROSSHAIR_SMALL_CURSOR;
|
|
|
|
}
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control, ctype);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, (options->type == GIMP_CROP ?
|
|
|
|
GIMP_CROP_TOOL_CURSOR :
|
|
|
|
GIMP_RESIZE_TOOL_CURSOR));
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, cmodifier);
|
2002-02-05 01:43:01 +08:00
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_draw (GimpDrawTool *draw)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpCropTool *crop;
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpDisplayShell *shell;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-03-02 00:57:16 +08:00
|
|
|
crop = GIMP_CROP_TOOL (draw);
|
|
|
|
tool = GIMP_TOOL (draw);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
shell = GIMP_DISPLAY_SHELL (tool->gdisp->shell);
|
|
|
|
|
|
|
|
gdk_draw_line (draw->win, draw->gc,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->dx1, crop->dy1,
|
|
|
|
shell->disp_width, crop->dy1);
|
2001-02-28 11:29:03 +08:00
|
|
|
gdk_draw_line (draw->win, draw->gc,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->dx1, crop->dy1,
|
|
|
|
crop->dx1, shell->disp_height);
|
2001-02-28 11:29:03 +08:00
|
|
|
gdk_draw_line (draw->win, draw->gc,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->dx2, crop->dy2,
|
|
|
|
0, crop->dy2);
|
2001-02-28 11:29:03 +08:00
|
|
|
gdk_draw_line (draw->win, draw->gc,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->dx2, crop->dy2,
|
|
|
|
crop->dx2, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-16 05:17:36 +08:00
|
|
|
gimp_draw_tool_draw_handle (draw,
|
|
|
|
GIMP_HANDLE_FILLED_SQUARE,
|
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_WEST,
|
|
|
|
FALSE);
|
|
|
|
gimp_draw_tool_draw_handle (draw,
|
|
|
|
GIMP_HANDLE_FILLED_SQUARE,
|
|
|
|
crop->x2, crop->y1,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_NORTH_EAST,
|
|
|
|
FALSE);
|
|
|
|
gimp_draw_tool_draw_handle (draw,
|
|
|
|
GIMP_HANDLE_FILLED_SQUARE,
|
|
|
|
crop->x1, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_WEST,
|
|
|
|
FALSE);
|
|
|
|
gimp_draw_tool_draw_handle (draw,
|
|
|
|
GIMP_HANDLE_FILLED_SQUARE,
|
|
|
|
crop->x2, crop->y2,
|
|
|
|
crop->dcw, crop->dch,
|
|
|
|
GTK_ANCHOR_SOUTH_EAST,
|
|
|
|
FALSE);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
crop_info_update (tool);
|
|
|
|
}
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void
|
|
|
|
crop_tool_crop_image (GimpImage *gimage,
|
|
|
|
gint x1,
|
|
|
|
gint y1,
|
|
|
|
gint x2,
|
|
|
|
gint y2,
|
|
|
|
gboolean layer_only,
|
|
|
|
gboolean crop_layers)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
|
|
|
return;
|
2000-06-14 18:59:13 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_image_crop (gimage,
|
|
|
|
x1, y1, x2, y2,
|
|
|
|
layer_only,
|
|
|
|
crop_layers);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-03-08 10:01:52 +08:00
|
|
|
crop_recalc (GimpTool *tool,
|
|
|
|
GimpCropTool *crop)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-01 05:20:09 +08:00
|
|
|
gdisplay_transform_coords (tool->gdisp,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x1, crop->y1,
|
|
|
|
&crop->dx1, &crop->dy1,
|
2001-11-01 05:20:09 +08:00
|
|
|
FALSE);
|
|
|
|
gdisplay_transform_coords (tool->gdisp,
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2, crop->y2,
|
|
|
|
&crop->dx2, &crop->dy2,
|
2001-11-01 05:20:09 +08:00
|
|
|
FALSE);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
#define SRW 10
|
|
|
|
#define SRH 10
|
|
|
|
|
|
|
|
crop->dcw = ((crop->dx2 - crop->dx1) < SRW) ? (crop->dx2 - crop->dx1) : SRW;
|
|
|
|
crop->dch = ((crop->dy2 - crop->dy1) < SRH) ? (crop->dy2 - crop->dy1) : SRH;
|
|
|
|
|
|
|
|
#undef SRW
|
|
|
|
#undef SRH
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-28 11:29:03 +08:00
|
|
|
crop_start (GimpTool *tool,
|
|
|
|
GimpCropTool *crop)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
static GimpDisplay *old_gdisp = NULL;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
crop_recalc (tool, crop);
|
1999-04-06 20:13:54 +08:00
|
|
|
|
|
|
|
if (! crop_info)
|
|
|
|
crop_info_create (tool);
|
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (origin_sizeentry),
|
|
|
|
crop_origin_changed,
|
|
|
|
crop_info);
|
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (size_sizeentry),
|
|
|
|
crop_size_changed,
|
|
|
|
crop_info);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->xresolution, FALSE);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->yresolution, FALSE);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
|
2000-12-31 12:07:42 +08:00
|
|
|
0, tool->gdisp->gimage->width);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
|
2000-12-31 12:07:42 +08:00
|
|
|
0, tool->gdisp->gimage->height);
|
1999-04-06 20:13:54 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 0,
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->xresolution, FALSE);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (size_sizeentry), 1,
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->yresolution, FALSE);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 0,
|
2000-12-31 12:07:42 +08:00
|
|
|
0, tool->gdisp->gimage->width);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (size_sizeentry), 1,
|
2000-12-31 12:07:42 +08:00
|
|
|
0, tool->gdisp->gimage->height);
|
1999-04-06 20:13:54 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
if (old_gdisp != tool->gdisp)
|
1999-04-03 03:46:59 +08:00
|
|
|
{
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry),
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->unit) ;
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry),
|
2000-12-31 12:07:42 +08:00
|
|
|
tool->gdisp->gimage->unit);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
if (tool->gdisp->dot_for_dot)
|
1999-05-31 22:11:10 +08:00
|
|
|
{
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (origin_sizeentry),
|
2000-02-08 04:35:13 +08:00
|
|
|
GIMP_UNIT_PIXEL);
|
1999-05-31 22:11:10 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (size_sizeentry),
|
2000-02-08 04:35:13 +08:00
|
|
|
GIMP_UNIT_PIXEL);
|
1999-05-31 22:11:10 +08:00
|
|
|
}
|
1999-04-03 03:46:59 +08:00
|
|
|
}
|
1999-04-06 20:13:54 +08:00
|
|
|
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (origin_sizeentry),
|
|
|
|
crop_origin_changed,
|
|
|
|
crop_info);
|
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (size_sizeentry),
|
|
|
|
crop_size_changed,
|
|
|
|
crop_info);
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
old_gdisp = tool->gdisp;
|
1999-04-03 03:46:59 +08:00
|
|
|
|
1998-07-27 05:49:42 +08:00
|
|
|
/* initialize the statusbar display */
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_tool_push_status (tool, _("Crop: 0 x 0"));
|
1998-07-27 05:49:42 +08:00
|
|
|
|
2002-02-03 20:10:23 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-06-26 19:16:47 +08:00
|
|
|
/***************************/
|
|
|
|
/* Crop dialog functions */
|
|
|
|
/***************************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-28 11:29:03 +08:00
|
|
|
crop_info_create (GimpTool *tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *button;
|
1999-04-03 03:46:59 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
gdisp = (GimpDisplay *) tool->gdisp;
|
1999-04-03 03:46:59 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* create the info dialog */
|
1999-09-28 01:58:10 +08:00
|
|
|
crop_info = info_dialog_new (_("Crop & Resize Information"),
|
2001-02-28 11:29:03 +08:00
|
|
|
tool_manager_help_func, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* create the action area */
|
2001-09-21 18:47:19 +08:00
|
|
|
gimp_dialog_create_action_area (GIMP_DIALOG (crop_info->shell),
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
GTK_STOCK_CLOSE, crop_close_callback,
|
2000-01-07 00:40:17 +08:00
|
|
|
NULL, NULL, NULL, FALSE, FALSE,
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2002-02-07 19:50:16 +08:00
|
|
|
_("Resize"), crop_resize_callback,
|
|
|
|
NULL, NULL, NULL, FALSE, FALSE,
|
|
|
|
|
|
|
|
_("Crop"), crop_crop_callback,
|
|
|
|
NULL, NULL, NULL, TRUE, FALSE,
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* add the information fields */
|
1999-04-06 20:13:54 +08:00
|
|
|
spinbutton = info_dialog_add_spinbutton (crop_info, _("Origin X:"), NULL,
|
1999-04-03 03:46:59 +08:00
|
|
|
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
|
1999-04-06 20:13:54 +08:00
|
|
|
origin_sizeentry =
|
1999-04-03 03:46:59 +08:00
|
|
|
info_dialog_add_sizeentry (crop_info, _("Y:"), orig_vals, 1,
|
|
|
|
gdisp->dot_for_dot ?
|
2000-02-08 04:35:13 +08:00
|
|
|
GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a",
|
1999-04-06 20:13:54 +08:00
|
|
|
TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
2001-08-01 10:57:58 +08:00
|
|
|
G_CALLBACK (crop_origin_changed),
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
crop_info);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (origin_sizeentry),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
1999-05-31 22:11:10 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (origin_sizeentry), 0,
|
|
|
|
-65536, 65536);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (origin_sizeentry), 1,
|
1999-04-03 03:46:59 +08:00
|
|
|
-65536, 65536);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
1999-04-06 20:13:54 +08:00
|
|
|
spinbutton = info_dialog_add_spinbutton (crop_info, _("Width:"), NULL,
|
1999-04-03 03:46:59 +08:00
|
|
|
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
|
1999-04-06 20:13:54 +08:00
|
|
|
size_sizeentry =
|
1999-04-03 03:46:59 +08:00
|
|
|
info_dialog_add_sizeentry (crop_info, _("Height:"), size_vals, 1,
|
|
|
|
gdisp->dot_for_dot ?
|
2000-02-08 04:35:13 +08:00
|
|
|
GIMP_UNIT_PIXEL : gdisp->gimage->unit, "%a",
|
1999-04-06 20:13:54 +08:00
|
|
|
TRUE, TRUE, FALSE, GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
G_CALLBACK (crop_size_changed),
|
|
|
|
crop_info);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (size_sizeentry),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
1999-04-03 03:46:59 +08:00
|
|
|
|
1999-05-31 22:11:10 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_sizeentry), 0,
|
|
|
|
-65536, 65536);
|
1999-04-06 20:13:54 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (size_sizeentry), 1,
|
1999-04-03 03:46:59 +08:00
|
|
|
-65536, 65536);
|
1999-05-31 22:11:10 +08:00
|
|
|
|
1999-04-03 03:46:59 +08:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (crop_info->info_table), 0, 0);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (crop_info->info_table), 1, 6);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (crop_info->info_table), 2, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-04-13 05:53:41 +08:00
|
|
|
/* Create the area selection buttons */
|
|
|
|
bbox = gtk_hbutton_box_new ();
|
|
|
|
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_SPREAD);
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (bbox), 4);
|
1999-04-13 05:53:41 +08:00
|
|
|
|
|
|
|
button = gtk_button_new_with_label (_("From Selection"));
|
2001-08-01 10:57:58 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER(bbox), button);
|
|
|
|
g_signal_connect (G_OBJECT (button) , "clicked",
|
|
|
|
G_CALLBACK (crop_selection_callback),
|
|
|
|
NULL);
|
1999-04-13 05:53:41 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
1999-07-01 00:19:52 +08:00
|
|
|
button = gtk_button_new_with_label (_("Auto Shrink"));
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (button) , "clicked",
|
|
|
|
G_CALLBACK (crop_automatic_callback),
|
|
|
|
NULL);
|
1999-04-13 05:53:41 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (crop_info->vbox), bbox, FALSE, FALSE, 2);
|
|
|
|
gtk_widget_show (bbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-28 11:29:03 +08:00
|
|
|
crop_info_update (GimpTool *tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-28 11:29:03 +08:00
|
|
|
GimpCropTool *crop;
|
1999-04-27 10:09:03 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
orig_vals[0] = crop->x1;
|
|
|
|
orig_vals[1] = crop->y1;
|
|
|
|
size_vals[0] = crop->x2 - crop->x1;
|
|
|
|
size_vals[1] = crop->y2 - crop->y1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
info_dialog_update (crop_info);
|
|
|
|
info_dialog_popup (crop_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_crop_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
GimpTool *tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
|
|
|
{
|
|
|
|
GimpCropTool *crop;
|
|
|
|
CropOptions *options;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
|
|
|
|
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
|
|
|
crop_tool_crop_image (tool->gdisp->gimage,
|
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->x2, crop->y2,
|
|
|
|
options->layer_only,
|
|
|
|
TRUE);
|
|
|
|
}
|
1999-04-08 13:20:37 +08:00
|
|
|
|
|
|
|
/* Finish the tool */
|
1999-06-26 19:16:47 +08:00
|
|
|
crop_close_callback (NULL, NULL);
|
1999-04-08 13:20:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_resize_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-04-08 13:20:37 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
GimpTool *tool;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
|
|
|
{
|
|
|
|
GimpCropTool *crop;
|
|
|
|
CropOptions *options;
|
|
|
|
|
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
|
|
|
|
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
crop_tool_crop_image (tool->gdisp->gimage,
|
|
|
|
crop->x1, crop->y1,
|
|
|
|
crop->x2, crop->y2,
|
|
|
|
options->layer_only,
|
|
|
|
FALSE);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Finish the tool */
|
1999-06-26 19:16:47 +08:00
|
|
|
crop_close_callback (NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-06-26 19:16:47 +08:00
|
|
|
{
|
2001-11-10 22:17:01 +08:00
|
|
|
GimpTool *tool;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
|
|
|
{
|
2002-05-03 19:31:08 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
2001-11-20 21:53:21 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_halt (tool->control); /* sets paused_count to 0 -- is this ok? */
|
2001-11-20 21:53:21 +08:00
|
|
|
}
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
info_dialog_popdown (crop_info);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_selection_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
GimpTool *tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
|
|
|
{
|
|
|
|
GimpCropTool *crop;
|
|
|
|
CropOptions *options;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
|
|
|
|
|
|
|
gdisp = tool->gdisp;
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-29 06:42:19 +08:00
|
|
|
if (! gimp_image_mask_bounds (gdisp->gimage,
|
|
|
|
&crop->x1, &crop->y1,
|
|
|
|
&crop->x2, &crop->y2))
|
2001-11-20 21:53:21 +08:00
|
|
|
{
|
|
|
|
if (options->layer_only)
|
|
|
|
{
|
|
|
|
layer = gimp_image_get_active_layer (gdisp->gimage);
|
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer),
|
|
|
|
&crop->x1, &crop->y1);
|
|
|
|
crop->x2 = gimp_drawable_width (GIMP_DRAWABLE (layer)) + crop->x1;
|
|
|
|
crop->y2 = gimp_drawable_height (GIMP_DRAWABLE (layer)) + crop->y1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
crop->x1 = crop->y1 = 0;
|
|
|
|
crop->x2 = gdisp->gimage->width;
|
|
|
|
crop->y2 = gdisp->gimage->height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
crop_recalc (tool, crop);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
1999-04-13 05:53:41 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_automatic_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-04-13 05:53:41 +08:00
|
|
|
{
|
2001-11-20 21:53:21 +08:00
|
|
|
GimpTool *tool;
|
1999-04-15 07:39:12 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
/* FIXME: active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
|
|
|
{
|
|
|
|
GimpCropTool *crop;
|
|
|
|
CropOptions *options;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpDrawable *active_drawable;
|
|
|
|
gint offset_x, offset_y;
|
|
|
|
gint width, height;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint shrunk_x1;
|
|
|
|
gint shrunk_y1;
|
|
|
|
gint shrunk_x2;
|
|
|
|
gint shrunk_y2;
|
|
|
|
|
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
options = (CropOptions *) tool->tool_info->tool_options;
|
1999-04-13 05:53:41 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
gdisp = tool->gdisp;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (options->layer_only)
|
|
|
|
{
|
|
|
|
active_drawable = gimp_image_active_drawable (gdisp->gimage);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (! active_drawable)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
width = gimp_drawable_width (GIMP_DRAWABLE (active_drawable));
|
|
|
|
height = gimp_drawable_height (GIMP_DRAWABLE (active_drawable));
|
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (active_drawable),
|
|
|
|
&offset_x, &offset_y);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = gdisp->gimage->width;
|
|
|
|
height = gdisp->gimage->height;
|
|
|
|
offset_x = 0;
|
|
|
|
offset_y = 0;
|
|
|
|
}
|
1999-07-01 00:19:52 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
x1 = crop->x1 - offset_x > 0 ? crop->x1 - offset_x : 0;
|
|
|
|
x2 = crop->x2 - offset_x < width ? crop->x2 - offset_x : width;
|
|
|
|
y1 = crop->y1 - offset_y > 0 ? crop->y1 - offset_y : 0;
|
|
|
|
y2 = crop->y2 - offset_y < height ? crop->y2 - offset_y : height;
|
1999-04-13 05:53:41 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1999-07-01 00:19:52 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
if (gimp_image_crop_auto_shrink (gdisp->gimage,
|
|
|
|
x1, y1, x2, y2,
|
|
|
|
options->layer_only,
|
|
|
|
&shrunk_x1,
|
|
|
|
&shrunk_y1,
|
|
|
|
&shrunk_x2,
|
|
|
|
&shrunk_y2))
|
|
|
|
{
|
|
|
|
crop->x1 = offset_x + shrunk_x1;
|
|
|
|
crop->x2 = offset_x + shrunk_x2;
|
|
|
|
crop->y1 = offset_y + shrunk_y1;
|
|
|
|
crop->y2 = offset_y + shrunk_y2;
|
1999-04-13 05:53:41 +08:00
|
|
|
|
2001-11-20 21:53:21 +08:00
|
|
|
crop_recalc (tool, crop);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
1999-04-15 07:39:12 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2001-08-01 10:57:58 +08:00
|
|
|
crop_origin_changed (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-02-28 11:29:03 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpCropTool *crop;
|
|
|
|
gint ox;
|
|
|
|
gint oy;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-10 22:17:01 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-10 22:17:01 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2000-10-27 06:02:44 +08:00
|
|
|
ox = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
|
|
|
oy = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if ((ox != crop->x1) ||
|
|
|
|
(oy != crop->y1))
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2 = crop->x2 + (ox - crop->x1);
|
|
|
|
crop->x1 = ox;
|
|
|
|
crop->y2 = crop->y2 + (oy - crop->y1);
|
|
|
|
crop->y1 = oy;
|
2001-11-10 22:17:01 +08:00
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
crop_recalc (tool, crop);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-06-14 18:59:13 +08:00
|
|
|
crop_size_changed (GtkWidget *widget,
|
1999-04-03 03:46:59 +08:00
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-02-28 11:29:03 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpCropTool *crop;
|
|
|
|
gint sx;
|
|
|
|
gint sy;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-02-28 11:29:03 +08:00
|
|
|
/* XXX active_tool is bad */
|
2001-07-08 01:36:00 +08:00
|
|
|
tool = tool_manager_get_active (the_gimp);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-10 22:17:01 +08:00
|
|
|
if (GIMP_IS_CROP_TOOL (tool))
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-07-08 01:36:00 +08:00
|
|
|
crop = GIMP_CROP_TOOL (tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2000-06-14 18:59:13 +08:00
|
|
|
sx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
sy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if ((sx != (crop->x2 - crop->x1)) ||
|
|
|
|
(sy != (crop->y2 - crop->y1)))
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-10 22:17:01 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
crop->x2 = sx + crop->x1;
|
|
|
|
crop->y2 = sy + crop->y1;
|
2001-11-10 22:17:01 +08:00
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
crop_recalc (tool, crop);
|
2001-11-10 22:17:01 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-02-28 11:29:03 +08:00
|
|
|
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
/* tool options stuff */
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
static GimpToolOptions *
|
|
|
|
crop_options_new (GimpToolInfo *tool_info)
|
2001-02-28 11:29:03 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
CropOptions *options;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *frame;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
options = g_new0 (CropOptions, 1);
|
2001-11-21 07:00:47 +08:00
|
|
|
|
|
|
|
tool_options_init ((GimpToolOptions *) options, tool_info);
|
|
|
|
|
|
|
|
((GimpToolOptions *) options)->reset_func = crop_options_reset;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
options->layer_only = options->layer_only_d = FALSE;
|
|
|
|
options->allow_enlarge = options->allow_enlarge_d = FALSE;
|
2002-03-20 03:17:31 +08:00
|
|
|
options->type = options->type_d = GIMP_CROP;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
/* the main vbox */
|
|
|
|
vbox = options->tool_options.main_vbox;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2002-03-10 23:05:58 +08:00
|
|
|
/* tool toggle */
|
2002-03-20 03:17:31 +08:00
|
|
|
frame = gimp_enum_radio_frame_new (GIMP_TYPE_CROP_TYPE,
|
|
|
|
gtk_label_new (_("Tool Toggle (<Ctrl>)")),
|
|
|
|
2,
|
|
|
|
G_CALLBACK (gimp_radio_button_update),
|
|
|
|
&options->type,
|
|
|
|
&options->type_w);
|
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
|
|
|
GINT_TO_POINTER (options->type));
|
2002-03-10 23:05:58 +08:00
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
/* layer toggle */
|
|
|
|
options->layer_only_w =
|
2002-05-03 19:31:08 +08:00
|
|
|
gtk_check_button_new_with_label (_("Current Layer only"));
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->layer_only_w,
|
|
|
|
FALSE, FALSE, 0);
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->layer_only_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->layer_only);
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->layer_only_w),
|
2002-04-28 22:35:01 +08:00
|
|
|
options->layer_only);
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_widget_show (options->layer_only_w);
|
2001-03-02 00:57:16 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
/* enlarge toggle */
|
2001-11-26 21:17:18 +08:00
|
|
|
options->allow_enlarge_w =
|
|
|
|
gtk_check_button_new_with_label (_("Allow Enlarging (<Alt>)"));
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), options->allow_enlarge_w,
|
|
|
|
FALSE, FALSE, 0);
|
2001-08-01 10:57:58 +08:00
|
|
|
g_signal_connect (G_OBJECT (options->allow_enlarge_w), "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&options->allow_enlarge);
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->allow_enlarge_w),
|
2002-04-28 22:35:01 +08:00
|
|
|
options->allow_enlarge);
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_widget_show (options->allow_enlarge_w);
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
return (GimpToolOptions *) options;
|
2001-02-28 11:29:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-18 04:50:01 +08:00
|
|
|
crop_options_reset (GimpToolOptions *tool_options)
|
2001-02-28 11:29:03 +08:00
|
|
|
{
|
2001-07-07 22:53:42 +08:00
|
|
|
CropOptions *options;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
options = (CropOptions *) tool_options;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->layer_only_w),
|
|
|
|
options->layer_only_d);
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(options->allow_enlarge_w),
|
|
|
|
options->allow_enlarge_d);
|
2001-11-23 01:11:52 +08:00
|
|
|
|
2002-03-20 03:17:31 +08:00
|
|
|
gimp_radio_group_set_active (GTK_RADIO_BUTTON (options->type_w),
|
2001-11-23 01:11:52 +08:00
|
|
|
GINT_TO_POINTER (options->type_d));
|
2001-02-28 11:29:03 +08:00
|
|
|
}
|