2002-02-27 00:30:14 +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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2002-02-27 00:30:14 +08:00
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpdrawable-desaturate.h"
|
|
|
|
#include "core/gimpdrawable-equalize.h"
|
2002-02-27 21:57:49 +08:00
|
|
|
#include "core/gimpdrawable-invert.h"
|
2002-02-27 00:30:14 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-05-20 23:26:38 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
|
|
|
#include "core/gimpitem-linked.h"
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "gui/offset-dialog.h"
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2004-04-29 20:52:29 +08:00
|
|
|
#include "drawable-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-02-27 00:30:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_desaturate_cmd_callback (GtkAction *action,
|
2002-02-27 00:30:14 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (! gimp_drawable_is_rgb (drawable))
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Desaturate operates only on RGB color layers."));
|
2002-02-27 00:30:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
gimp_drawable_desaturate (drawable);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_invert_cmd_callback (GtkAction *action,
|
2002-02-27 00:30:14 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Invert does not operate on indexed layers."));
|
2002-02-27 00:30:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
gimp_drawable_invert (drawable);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_equalize_cmd_callback (GtkAction *action,
|
2002-02-27 00:30:14 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpDrawable *drawable;
|
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Equalize does not operate on indexed layers."));
|
2002-02-27 00:30:14 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
gimp_drawable_equalize (drawable, TRUE);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
|
|
|
|
2003-05-20 00:28:35 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_flip_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-05-20 00:28:35 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpDrawable *drawable;
|
2003-05-20 00:28:35 +08:00
|
|
|
GimpItem *item;
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context;
|
2003-05-20 00:28:35 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
gdouble axis = 0.0;
|
2004-05-23 18:04:41 +08:00
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
|
|
|
return_if_no_context (context, data);
|
2003-05-20 00:28:35 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
item = GIMP_ITEM (drawable);
|
2003-05-20 00:28:35 +08:00
|
|
|
|
|
|
|
gimp_item_offsets (item, &off_x, &off_y);
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
switch ((GimpOrientationType) value)
|
2003-05-20 00:28:35 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
|
|
|
axis = ((gdouble) off_x + (gdouble) gimp_item_width (item) / 2.0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
|
|
|
axis = ((gdouble) off_y + (gdouble) gimp_item_height (item) / 2.0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-05-20 23:26:38 +08:00
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
|
|
|
|
_("Flip Layer"));
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_item_flip (item, context, (GimpOrientationType) value, axis, FALSE);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
{
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_linked_flip (item, context, (GimpOrientationType) action, axis,
|
|
|
|
FALSE);
|
2003-05-20 23:26:38 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-20 00:28:35 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_rotate_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-05-20 18:36:29 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpDrawable *drawable;
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpItem *item;
|
2003-05-20 18:36:29 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
gdouble center_x, center_y;
|
2004-05-23 18:04:41 +08:00
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
|
|
|
return_if_no_context (context, data);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
item = GIMP_ITEM (drawable);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
|
|
|
gimp_item_offsets (item, &off_x, &off_y);
|
|
|
|
|
|
|
|
center_x = ((gdouble) off_x + (gdouble) gimp_item_width (item) / 2.0);
|
|
|
|
center_y = ((gdouble) off_y + (gdouble) gimp_item_height (item) / 2.0);
|
|
|
|
|
2003-05-20 23:26:38 +08:00
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_TRANSFORM,
|
|
|
|
_("Rotate Layer"));
|
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_item_rotate (item, context, (GimpRotationType) value,
|
2004-04-15 07:37:34 +08:00
|
|
|
center_x, center_y, FALSE);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
{
|
2004-04-29 20:52:29 +08:00
|
|
|
gimp_item_linked_rotate (item, context, (GimpRotationType) value,
|
2003-05-20 23:26:38 +08:00
|
|
|
center_x, center_y, FALSE);
|
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
drawable_offset_cmd_callback (GtkAction *action,
|
2002-02-27 00:30:14 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpDrawable *drawable;
|
2004-04-29 20:52:29 +08:00
|
|
|
GtkWidget *widget;
|
2004-04-20 21:44:19 +08:00
|
|
|
GtkWidget *dialog;
|
2004-04-15 07:37:34 +08:00
|
|
|
return_if_no_drawable (gimage, drawable, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-04-20 21:44:19 +08:00
|
|
|
dialog = offset_dialog_new (drawable, widget);
|
|
|
|
gtk_widget_show (dialog);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|