2001-04-21 00:27:44 +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"
|
|
|
|
|
2003-09-01 02:10:15 +08:00
|
|
|
#include <string.h>
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2001-12-04 01:59:48 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "core/gimpimage-merge.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2004-06-23 08:23:25 +08:00
|
|
|
#include "core/gimpitemundo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayermask.h"
|
|
|
|
#include "core/gimplist.h"
|
2004-01-14 03:08:16 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2004-06-23 08:23:25 +08:00
|
|
|
#include "core/gimpundostack.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2004-03-19 02:00:38 +08:00
|
|
|
#include "text/gimptext.h"
|
2004-01-05 08:28:12 +08:00
|
|
|
#include "text/gimptextlayer.h"
|
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
#include "widgets/gimpaction.h"
|
2004-02-01 04:23:53 +08:00
|
|
|
#include "widgets/gimpdock.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2004-10-12 22:59:14 +08:00
|
|
|
#include "widgets/gimpprogressdialog.h"
|
2001-05-26 00:04:54 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2004-06-02 06:04:20 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2002-12-11 00:38:16 +08:00
|
|
|
|
2004-01-14 03:08:16 +08:00
|
|
|
#include "tools/gimptexttool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
#include "dialogs/layer-add-mask-dialog.h"
|
2004-10-23 06:28:45 +08:00
|
|
|
#include "dialogs/layer-options-dialog.h"
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/resize-dialog.h"
|
2004-10-12 22:59:14 +08:00
|
|
|
#include "dialogs/scale-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
#include "layers-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
|
2004-09-15 23:06:08 +08:00
|
|
|
static const GimpLayerModeEffects layer_modes[] =
|
2004-09-15 21:24:45 +08:00
|
|
|
{
|
|
|
|
GIMP_NORMAL_MODE,
|
|
|
|
GIMP_DISSOLVE_MODE,
|
|
|
|
GIMP_MULTIPLY_MODE,
|
|
|
|
GIMP_DIVIDE_MODE,
|
|
|
|
GIMP_SCREEN_MODE,
|
|
|
|
GIMP_OVERLAY_MODE,
|
|
|
|
GIMP_DODGE_MODE,
|
|
|
|
GIMP_BURN_MODE,
|
|
|
|
GIMP_HARDLIGHT_MODE,
|
|
|
|
GIMP_SOFTLIGHT_MODE,
|
|
|
|
GIMP_GRAIN_EXTRACT_MODE,
|
|
|
|
GIMP_GRAIN_MERGE_MODE,
|
|
|
|
GIMP_DIFFERENCE_MODE,
|
|
|
|
GIMP_ADDITION_MODE,
|
|
|
|
GIMP_SUBTRACT_MODE,
|
|
|
|
GIMP_DARKEN_ONLY_MODE,
|
|
|
|
GIMP_LIGHTEN_ONLY_MODE,
|
|
|
|
GIMP_HUE_MODE,
|
|
|
|
GIMP_SATURATION_MODE,
|
|
|
|
GIMP_COLOR_MODE,
|
|
|
|
GIMP_VALUE_MODE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
static void layers_new_layer_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog);
|
2004-10-18 19:29:58 +08:00
|
|
|
static void layers_edit_layer_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog);
|
2004-10-18 19:29:58 +08:00
|
|
|
static void layers_add_mask_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerAddMaskDialog *dialog);
|
2004-10-27 18:33:08 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
static void layers_scale_layer_callback (GtkWidget *dialog,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpUnit unit,
|
|
|
|
GimpInterpolationType interpolation,
|
2004-10-27 07:31:34 +08:00
|
|
|
gdouble xresolution,
|
|
|
|
gdouble yresolution,
|
|
|
|
GimpUnit resolution_unit,
|
2004-10-18 19:29:58 +08:00
|
|
|
gpointer data);
|
2004-10-27 18:33:08 +08:00
|
|
|
static void layers_resize_layer_callback (GtkWidget *dialog,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
2004-10-18 19:29:58 +08:00
|
|
|
gpointer data);
|
2004-10-27 18:33:08 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
static gint layers_mode_index (GimpLayerModeEffects layer_mode);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
/* private variables */
|
|
|
|
|
2004-10-24 03:13:17 +08:00
|
|
|
static GimpFillType layer_fill_type = GIMP_TRANSPARENT_FILL;
|
|
|
|
static gchar *layer_name = NULL;
|
|
|
|
static GimpAddMaskType layer_add_mask_type = GIMP_ADD_WHITE_MASK;
|
|
|
|
static gboolean layer_mask_invert = FALSE;
|
2004-09-20 06:26:41 +08:00
|
|
|
|
|
|
|
|
2001-11-30 22:41:56 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
void
|
|
|
|
layers_text_tool_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkWidget *widget;
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpTool *active_tool;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
if (! gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer)))
|
|
|
|
{
|
2004-10-23 06:28:45 +08:00
|
|
|
layers_edit_attributes_cmd_callback (action, data);
|
2004-10-16 23:48:23 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
|
|
|
|
|
|
|
if (! GIMP_IS_TEXT_TOOL (active_tool))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gimage->gimp->tool_info_list,
|
|
|
|
"gimp-text-tool");
|
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (action_data_get_context (data), tool_info);
|
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_TEXT_TOOL (active_tool))
|
|
|
|
gimp_text_tool_set_layer (GIMP_TEXT_TOOL (active_tool), layer);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_edit_attributes_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog;
|
2004-10-23 06:28:45 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkWidget *widget;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog = layer_options_dialog_new (gimp_item_get_image (GIMP_ITEM (layer)),
|
|
|
|
action_data_get_context (data),
|
|
|
|
layer, widget,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (layer)),
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_fill_type,
|
2004-10-23 22:02:53 +08:00
|
|
|
_("Layer Attributes"),
|
|
|
|
"gimp-layer-edit",
|
|
|
|
GIMP_STOCK_EDIT,
|
|
|
|
_("Edit Layer Attributes"),
|
|
|
|
GIMP_HELP_LAYER_EDIT);
|
|
|
|
|
|
|
|
g_signal_connect (dialog->dialog, "response",
|
2004-10-23 06:28:45 +08:00
|
|
|
G_CALLBACK (layers_edit_layer_response),
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_show (dialog->dialog);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_new_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog;
|
2004-10-23 06:28:45 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpLayer *floating_sel;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
/* If there is a floating selection, the new command transforms
|
|
|
|
* the current fs into a new layer
|
|
|
|
*/
|
|
|
|
if ((floating_sel = gimp_image_floating_sel (gimage)))
|
|
|
|
{
|
|
|
|
floating_sel_to_layer (floating_sel);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog = layer_options_dialog_new (gimage, action_data_get_context (data),
|
|
|
|
NULL, widget,
|
|
|
|
layer_name ? layer_name : _("New Layer"),
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_fill_type,
|
2004-10-23 22:02:53 +08:00
|
|
|
_("New Layer"),
|
|
|
|
"gimp-layer-new",
|
|
|
|
GIMP_STOCK_LAYER,
|
|
|
|
_("Create a New Layer"),
|
|
|
|
GIMP_HELP_LAYER_NEW);
|
|
|
|
|
|
|
|
g_signal_connect (dialog->dialog, "response",
|
2004-10-23 06:28:45 +08:00
|
|
|
G_CALLBACK (layers_new_layer_response),
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog);
|
2004-10-23 06:28:45 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_show (dialog->dialog);
|
2004-10-16 23:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-23 08:53:48 +08:00
|
|
|
layers_new_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2004-10-16 23:48:23 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *floating_sel;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
gint width, height;
|
|
|
|
gint off_x, off_y;
|
|
|
|
gdouble opacity;
|
|
|
|
GimpLayerModeEffects mode;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
/* If there is a floating selection, the new command transforms
|
|
|
|
* the current fs into a new layer
|
|
|
|
*/
|
|
|
|
if ((floating_sel = gimp_image_floating_sel (gimage)))
|
|
|
|
{
|
|
|
|
floating_sel_to_layer (floating_sel);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_LAYER (GIMP_ACTION (action)->viewable))
|
|
|
|
{
|
|
|
|
GimpLayer *template = GIMP_LAYER (GIMP_ACTION (action)->viewable);
|
|
|
|
|
|
|
|
gimp_item_offsets (GIMP_ITEM (template), &off_x, &off_y);
|
|
|
|
width = gimp_item_width (GIMP_ITEM (template));
|
|
|
|
height = gimp_item_height (GIMP_ITEM (template));
|
|
|
|
opacity = template->opacity;
|
|
|
|
mode = template->mode;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
width = gimp_image_get_width (gimage);
|
|
|
|
height = gimp_image_get_height (gimage);
|
|
|
|
off_x = 0;
|
|
|
|
off_y = 0;
|
|
|
|
opacity = 1.0;
|
|
|
|
mode = GIMP_NORMAL_MODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
|
|
|
|
_("New Layer"));
|
|
|
|
|
|
|
|
new_layer = gimp_layer_new (gimage, width, height,
|
|
|
|
gimp_image_base_type_with_alpha (gimage),
|
2004-10-23 08:53:48 +08:00
|
|
|
layer_name ? layer_name : _("New Layer"),
|
|
|
|
opacity, mode);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
|
|
|
gimp_drawable_fill_by_type (GIMP_DRAWABLE (new_layer),
|
|
|
|
action_data_get_context (data),
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_fill_type);
|
2004-10-16 23:48:23 +08:00
|
|
|
gimp_item_translate (GIMP_ITEM (new_layer), off_x, off_y, FALSE);
|
|
|
|
|
|
|
|
gimp_image_add_layer (gimage, new_layer, -1);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
|
|
|
|
gimp_image_flush (gimage);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
void
|
2004-06-23 08:23:25 +08:00
|
|
|
layers_select_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-06-23 08:23:25 +08:00
|
|
|
GimpLayer *layer;
|
2001-04-21 00:27:44 +08:00
|
|
|
GimpLayer *new_layer;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-06-23 08:23:25 +08:00
|
|
|
layer = gimp_image_get_active_layer (gimage);
|
2003-06-06 18:30:14 +08:00
|
|
|
|
2004-06-23 08:23:25 +08:00
|
|
|
new_layer = (GimpLayer *) action_select_object ((GimpActionSelectType) value,
|
|
|
|
gimage->layers,
|
|
|
|
(GimpObject *) layer);
|
2003-06-06 18:30:14 +08:00
|
|
|
|
2004-06-23 08:23:25 +08:00
|
|
|
if (new_layer && new_layer != layer)
|
2003-06-06 18:30:14 +08:00
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, new_layer);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_raise_cmd_callback (GtkAction *action,
|
2001-04-21 00:27:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_image_raise_layer (gimage, layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-09-15 21:24:45 +08:00
|
|
|
layers_raise_to_top_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_raise_layer_to_top (gimage, layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-09-15 21:24:45 +08:00
|
|
|
layers_lower_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_lower_layer (gimage, layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_lower_to_bottom_cmd_callback (GtkAction *action,
|
2001-04-21 00:27:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_image_lower_layer_to_bottom (gimage, layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_duplicate_cmd_callback (GtkAction *action,
|
2001-04-21 00:27:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
2001-04-21 00:27:44 +08:00
|
|
|
GimpLayer *new_layer;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2003-02-17 21:33:29 +08:00
|
|
|
new_layer =
|
2004-05-13 02:36:33 +08:00
|
|
|
GIMP_LAYER (gimp_item_duplicate (GIMP_ITEM (layer),
|
|
|
|
G_TYPE_FROM_INSTANCE (layer),
|
2003-02-17 21:33:29 +08:00
|
|
|
TRUE));
|
2001-04-21 00:27:44 +08:00
|
|
|
gimp_image_add_layer (gimage, new_layer, -1);
|
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_anchor_cmd_callback (GtkAction *action,
|
2001-04-21 00:27:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2003-02-17 21:33:29 +08:00
|
|
|
{
|
2004-05-13 02:36:33 +08:00
|
|
|
floating_sel_anchor (layer);
|
2003-02-17 21:33:29 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
2001-12-04 01:59:48 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-02-13 22:41:35 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_merge_down_cmd_callback (GtkAction *action,
|
2002-02-13 22:41:35 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2002-02-13 22:41:35 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_image_merge_down (gimage, layer, action_data_get_context (data),
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_EXPAND_AS_NECESSARY);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-13 22:41:35 +08:00
|
|
|
}
|
|
|
|
|
2001-12-04 01:59:48 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_delete_cmd_callback (GtkAction *action,
|
2001-12-04 01:59:48 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_remove (layer);
|
2001-04-21 00:27:44 +08:00
|
|
|
else
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_image_remove_layer (gimage, layer);
|
2001-12-04 01:59:48 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-12-04 01:59:48 +08:00
|
|
|
}
|
|
|
|
|
2004-01-05 08:28:12 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_text_discard_cmd_callback (GtkAction *action,
|
2004-01-05 08:28:12 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2004-01-05 08:28:12 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (GIMP_IS_TEXT_LAYER (layer))
|
|
|
|
gimp_text_layer_discard (GIMP_TEXT_LAYER (layer));
|
2004-01-05 08:28:12 +08:00
|
|
|
}
|
|
|
|
|
2001-12-04 01:59:48 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_resize_cmd_callback (GtkAction *action,
|
2002-04-12 20:29:51 +08:00
|
|
|
gpointer data)
|
2001-12-04 01:59:48 +08:00
|
|
|
{
|
2004-10-27 18:33:08 +08:00
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
gdisp = GIMP_IS_DISPLAY (data) ? data : NULL;
|
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
dialog = resize_dialog_new (GIMP_VIEWABLE (layer),
|
|
|
|
_("Set Layer Boundary Size"), "gimp-layer-resize",
|
|
|
|
widget,
|
|
|
|
gimp_standard_help_func, GIMP_HELP_LAYER_RESIZE,
|
|
|
|
(gdisp ?
|
|
|
|
GIMP_DISPLAY_SHELL (gdisp->shell)->unit :
|
|
|
|
GIMP_UNIT_PIXEL),
|
|
|
|
layers_resize_layer_callback,
|
|
|
|
action_data_get_context (data));
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_resize_to_image_cmd_callback (GtkAction *action,
|
2002-04-12 20:29:51 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2003-09-01 02:10:15 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_layer_resize_to_image (layer, action_data_get_context (data));
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-04-12 20:29:51 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2002-04-12 20:29:51 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_scale_cmd_callback (GtkAction *action,
|
2002-04-12 20:29:51 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GimpUnit unit;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
gdisp = action_data_get_display (data);
|
|
|
|
|
|
|
|
unit = gdisp ? GIMP_DISPLAY_SHELL (gdisp->shell)->unit : GIMP_UNIT_PIXEL;
|
|
|
|
|
|
|
|
dialog = scale_dialog_new (GIMP_VIEWABLE (layer),
|
|
|
|
_("Scale Layer"), "gimp-layer-scale",
|
|
|
|
widget,
|
|
|
|
gimp_standard_help_func, GIMP_HELP_LAYER_SCALE,
|
|
|
|
unit, gimage->gimp->config->interpolation_type,
|
|
|
|
layers_scale_layer_callback,
|
|
|
|
gdisp);
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_crop_cmd_callback (GtkAction *action,
|
2002-04-12 20:29:51 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
2002-04-12 20:29:51 +08:00
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint off_x, off_y;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2003-09-04 01:17:18 +08:00
|
|
|
if (! gimp_channel_bounds (gimp_image_get_mask (gimage),
|
|
|
|
&x1, &y1, &x2, &y2))
|
2002-04-12 20:29:51 +08:00
|
|
|
{
|
|
|
|
g_message (_("Cannot crop because the current selection is empty."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
|
|
|
off_x -= x1;
|
|
|
|
off_y -= y1;
|
|
|
|
|
2004-04-13 19:43:27 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
2003-02-13 19:23:50 +08:00
|
|
|
_("Crop Layer"));
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_item_resize (GIMP_ITEM (layer), action_data_get_context (data),
|
2004-04-15 07:37:34 +08:00
|
|
|
x2 - x1, y2 - y1, off_x, off_y);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2002-04-12 20:29:51 +08:00
|
|
|
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_mask_add_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerAddMaskDialog *dialog;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GtkWidget *widget;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog = layer_add_mask_dialog_new (layer, widget,
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_add_mask_type, layer_mask_invert);
|
2004-10-18 19:29:58 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
g_signal_connect (dialog->dialog, "response",
|
2004-10-18 19:29:58 +08:00
|
|
|
G_CALLBACK (layers_add_mask_response),
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog);
|
2004-10-18 19:29:58 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_show (dialog->dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_mask_apply_cmd_callback (GtkAction *action,
|
2004-06-10 22:25:04 +08:00
|
|
|
gint value,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-06-10 22:25:04 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpMaskApplyMode mode;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-06-10 22:25:04 +08:00
|
|
|
mode = (GimpMaskApplyMode) value;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (gimp_layer_get_mask (layer))
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-06-10 22:25:04 +08:00
|
|
|
gimp_layer_apply_mask (layer, mode, TRUE);
|
2003-03-23 04:30:30 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-21 06:32:14 +08:00
|
|
|
void
|
|
|
|
layers_mask_edit_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-08-21 07:01:18 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpLayerMask *mask;
|
2004-08-21 06:32:14 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
|
|
|
mask = gimp_layer_get_mask (layer);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
2004-08-21 06:32:14 +08:00
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
gimp_layer_mask_set_edit (mask, active);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_mask_show_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-08-21 07:01:18 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpLayerMask *mask;
|
2004-08-21 06:32:14 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
|
|
|
mask = gimp_layer_get_mask (layer);
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
gimp_layer_mask_set_show (mask, active);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_mask_disable_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-08-21 07:01:18 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpLayerMask *mask;
|
2004-08-21 06:32:14 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
|
|
|
mask = gimp_layer_get_mask (layer);
|
|
|
|
|
|
|
|
if (mask)
|
|
|
|
{
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
gimp_layer_mask_set_apply (mask, ! active);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_mask_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-08-27 08:52:00 +08:00
|
|
|
{
|
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpLayerMask *mask;
|
2004-05-13 02:36:33 +08:00
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
op = (GimpChannelOps) value;
|
2003-08-27 08:52:00 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
mask = gimp_layer_get_mask (layer);
|
2003-08-21 23:54:47 +08:00
|
|
|
|
|
|
|
if (mask)
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2003-08-21 23:54:47 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
|
|
|
|
gimp_item_offsets (GIMP_ITEM (mask), &off_x, &off_y);
|
|
|
|
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_channel_select_channel (gimp_image_get_mask (gimage),
|
|
|
|
_("Layer Mask to Selection"),
|
|
|
|
GIMP_CHANNEL (mask),
|
|
|
|
off_x, off_y,
|
|
|
|
op, FALSE, 0.0, 0.0);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_alpha_add_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
2002-02-27 00:30:14 +08:00
|
|
|
{
|
2004-05-13 02:36:33 +08:00
|
|
|
gimp_layer_add_alpha (layer);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-27 00:30:14 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
layers_alpha_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2003-08-21 23:54:47 +08:00
|
|
|
{
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
2004-05-13 02:36:33 +08:00
|
|
|
GimpLayer *layer;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
2003-08-21 23:54:47 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
op = (GimpChannelOps) value;
|
2003-08-27 08:52:00 +08:00
|
|
|
|
2004-03-17 00:23:06 +08:00
|
|
|
gimp_channel_select_alpha (gimp_image_get_mask (gimage),
|
2004-05-13 02:36:33 +08:00
|
|
|
GIMP_DRAWABLE (layer),
|
2004-01-10 23:32:51 +08:00
|
|
|
op, FALSE, 0.0, 0.0);
|
|
|
|
gimp_image_flush (gimage);
|
2003-08-21 23:54:47 +08:00
|
|
|
}
|
|
|
|
|
2004-06-23 08:23:25 +08:00
|
|
|
void
|
|
|
|
layers_opacity_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
gdouble opacity;
|
2004-08-03 22:09:49 +08:00
|
|
|
GimpUndo *undo;
|
2004-06-23 08:23:25 +08:00
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
2004-08-03 22:09:49 +08:00
|
|
|
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
GIMP_UNDO_LAYER_OPACITY);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
|
|
|
|
push_undo = FALSE;
|
2004-06-23 08:23:25 +08:00
|
|
|
|
|
|
|
opacity = action_select_value ((GimpActionSelectType) value,
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_layer_get_opacity (layer),
|
2004-06-23 08:23:25 +08:00
|
|
|
0.0, 1.0,
|
|
|
|
0.01, 0.1, FALSE);
|
|
|
|
gimp_layer_set_opacity (layer, opacity, push_undo);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
void
|
2004-09-15 23:06:08 +08:00
|
|
|
layers_mode_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2004-09-15 21:24:45 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
2004-09-15 23:06:08 +08:00
|
|
|
GimpLayerModeEffects layer_mode;
|
2004-09-15 21:24:45 +08:00
|
|
|
gint index;
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
|
|
|
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
|
2004-09-15 23:06:08 +08:00
|
|
|
GIMP_UNDO_LAYER_MODE);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2004-09-15 23:06:08 +08:00
|
|
|
layer_mode = gimp_layer_get_mode (layer);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
|
|
|
index = action_select_value ((GimpActionSelectType) value,
|
2004-09-15 23:06:08 +08:00
|
|
|
layers_mode_index (layer_mode),
|
|
|
|
0, G_N_ELEMENTS (layer_modes) - 1,
|
2004-09-15 21:24:45 +08:00
|
|
|
1.0, 1.0, FALSE);
|
2004-09-15 23:06:08 +08:00
|
|
|
gimp_layer_set_mode (layer, layer_modes[index], push_undo);
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
layers_preserve_trans_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpLayer *layer;
|
|
|
|
gboolean preserve;
|
|
|
|
return_if_no_layer (gimage, layer, data);
|
|
|
|
|
|
|
|
preserve = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (preserve != gimp_layer_get_preserve_trans (layer))
|
|
|
|
{
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
|
|
|
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
GIMP_UNDO_LAYER_PRESERVE_TRANS);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (layer))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
|
|
|
gimp_layer_set_preserve_trans (layer, preserve, push_undo);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
/* private functions */
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
static void
|
2004-10-23 06:28:45 +08:00
|
|
|
layers_new_layer_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
GimpLayer *layer;
|
2004-05-25 22:37:02 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
if (layer_name)
|
|
|
|
g_free (layer_name);
|
|
|
|
layer_name =
|
2004-10-23 22:02:53 +08:00
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
|
|
|
|
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_fill_type = dialog->fill_type;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog->xsize =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
|
2004-10-18 19:29:58 +08:00
|
|
|
0));
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog->ysize =
|
|
|
|
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
|
2004-10-18 19:29:58 +08:00
|
|
|
1));
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
layer = gimp_layer_new (dialog->gimage,
|
|
|
|
dialog->xsize,
|
|
|
|
dialog->ysize,
|
|
|
|
gimp_image_base_type_with_alpha (dialog->gimage),
|
2004-10-18 19:29:58 +08:00
|
|
|
layer_name,
|
|
|
|
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
|
|
|
|
|
|
|
|
if (layer)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
gimp_drawable_fill_by_type (GIMP_DRAWABLE (layer),
|
2004-10-23 22:02:53 +08:00
|
|
|
dialog->context,
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_fill_type);
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_add_layer (dialog->gimage, layer, -1);
|
2004-10-18 19:29:58 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_flush (dialog->gimage);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
2004-10-18 19:29:58 +08:00
|
|
|
else
|
2004-05-25 22:37:02 +08:00
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
g_message ("new_layer_query_response: "
|
|
|
|
"could not allocate new layer");
|
2002-02-26 08:04:55 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_destroy (dialog->dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2004-03-19 02:00:38 +08:00
|
|
|
static void
|
2004-10-23 06:28:45 +08:00
|
|
|
layers_edit_layer_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2004-10-23 22:02:53 +08:00
|
|
|
LayerOptionsDialog *dialog)
|
2004-10-18 19:29:58 +08:00
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
2004-10-23 22:02:53 +08:00
|
|
|
GimpLayer *layer = dialog->layer;
|
2004-10-18 19:29:58 +08:00
|
|
|
const gchar *new_name;
|
2004-05-25 22:37:02 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
new_name = gtk_entry_get_text (GTK_ENTRY (dialog->name_entry));
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (layer))))
|
|
|
|
{
|
|
|
|
gimp_item_rename (GIMP_ITEM (layer), new_name);
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_flush (dialog->gimage);
|
2004-10-18 19:29:58 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
if (dialog->rename_toggle &&
|
2004-10-18 19:29:58 +08:00
|
|
|
gimp_drawable_is_text_layer (GIMP_DRAWABLE (layer)))
|
|
|
|
{
|
|
|
|
g_object_set (layer,
|
|
|
|
"auto-rename",
|
2004-10-23 22:02:53 +08:00
|
|
|
GTK_TOGGLE_BUTTON (dialog->rename_toggle)->active,
|
2004-10-18 19:29:58 +08:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_destroy (dialog->dialog);
|
2004-10-18 19:29:58 +08:00
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
|
|
|
static void
|
2004-10-23 22:02:53 +08:00
|
|
|
layers_add_mask_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
LayerAddMaskDialog *dialog)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-23 22:02:53 +08:00
|
|
|
GimpLayer *layer = dialog->layer;
|
|
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2003-11-06 23:27:05 +08:00
|
|
|
GimpLayerMask *mask;
|
2003-03-06 21:22:11 +08:00
|
|
|
|
2004-10-24 03:13:17 +08:00
|
|
|
layer_add_mask_type = dialog->add_mask_type;
|
|
|
|
layer_mask_invert = dialog->invert;
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_ADD_MASK,
|
|
|
|
_("Add Layer Mask"));
|
2003-11-26 23:48:50 +08:00
|
|
|
|
2004-10-28 18:53:44 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
|
|
|
gimp_layer_add_alpha (layer);
|
|
|
|
|
2004-10-24 03:13:17 +08:00
|
|
|
mask = gimp_layer_create_mask (layer, layer_add_mask_type);
|
2003-03-06 21:22:11 +08:00
|
|
|
|
2004-10-24 03:13:17 +08:00
|
|
|
if (layer_mask_invert)
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_channel_invert (GIMP_CHANNEL (mask), FALSE);
|
2002-09-01 15:25:41 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_layer_add_mask (layer, mask, TRUE);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2003-11-26 23:48:50 +08:00
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
2004-10-23 22:02:53 +08:00
|
|
|
gtk_widget_destroy (dialog->dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-16 23:48:23 +08:00
|
|
|
layers_scale_layer_callback (GtkWidget *dialog,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpUnit unit,
|
|
|
|
GimpInterpolationType interpolation,
|
2004-10-27 07:31:34 +08:00
|
|
|
gdouble xresolution, /* unused */
|
|
|
|
gdouble yresolution, /* unused */
|
|
|
|
GimpUnit resolution_unit,/* unused */
|
2004-10-16 23:48:23 +08:00
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-27 09:20:07 +08:00
|
|
|
GimpDisplay *gdisp = GIMP_DISPLAY (data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
if (width > 0 && height > 0)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-12 22:59:14 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (viewable);
|
2004-04-13 21:54:54 +08:00
|
|
|
GimpProgress *progress;
|
2004-10-12 22:59:14 +08:00
|
|
|
GtkWidget *progress_dialog = NULL;
|
|
|
|
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
|
|
|
|
if (width == gimp_item_width (item) && height == gimp_item_height (item))
|
|
|
|
return;
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
if (gdisp)
|
|
|
|
{
|
|
|
|
progress = GIMP_PROGRESS (gdisp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
progress_dialog = gimp_progress_dialog_new ();
|
|
|
|
progress = GIMP_PROGRESS (progress_dialog);
|
|
|
|
}
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
progress = gimp_progress_start (progress, _("Scaling..."), FALSE);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
gimp_item_scale_by_origin (item,
|
|
|
|
width, height, interpolation,
|
|
|
|
progress, TRUE);
|
2004-02-09 08:09:20 +08:00
|
|
|
|
2004-08-11 02:47:21 +08:00
|
|
|
if (progress)
|
|
|
|
gimp_progress_end (progress);
|
2003-05-07 19:09:00 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
if (progress_dialog)
|
|
|
|
gtk_widget_destroy (progress_dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-12 22:59:14 +08:00
|
|
|
gimp_image_flush (gimp_item_get_image (item));
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Invalid width or height. Both must be positive."));
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-27 18:33:08 +08:00
|
|
|
layers_resize_layer_callback (GtkWidget *dialog,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gpointer data)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-27 18:33:08 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (data);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
if (width > 0 && height > 0)
|
2001-04-21 00:27:44 +08:00
|
|
|
{
|
2004-10-27 18:33:08 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (viewable);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
if (width == gimp_item_width (item) && height == gimp_item_height (item))
|
|
|
|
return;
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
gimp_item_resize (item,
|
|
|
|
context,
|
|
|
|
width, height, offset_x, offset_y);
|
2001-04-21 00:27:44 +08:00
|
|
|
|
2004-10-27 18:33:08 +08:00
|
|
|
gimp_image_flush (gimp_item_get_image (item));
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Invalid width or height. Both must be positive."));
|
2001-04-21 00:27:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
static gint
|
2004-09-15 23:06:08 +08:00
|
|
|
layers_mode_index (GimpLayerModeEffects layer_mode)
|
2004-09-15 21:24:45 +08:00
|
|
|
{
|
|
|
|
gint i = 0;
|
|
|
|
|
2004-09-15 23:06:08 +08:00
|
|
|
while (i < (G_N_ELEMENTS (layer_modes) - 1) && layer_modes[i] != layer_mode)
|
2004-09-15 21:24:45 +08:00
|
|
|
i++;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|