1997-11-24 22:05:25 +00: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 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-14 13:52:16 +00:00
|
|
|
|
2000-04-27 17:27:28 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-09-24 01:19:57 +00:00
|
|
|
#include <stdlib.h>
|
2000-12-14 13:52:16 +00:00
|
|
|
#include <string.h>
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "core-types.h"
|
2000-12-29 15:22:01 +00:00
|
|
|
|
2001-05-15 11:25:25 +00:00
|
|
|
#include "base/boundary.h"
|
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2001-04-07 15:58:26 +00:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2001-04-19 00:23:43 +00:00
|
|
|
#include "gimpdrawable-invert.h"
|
2001-10-31 21:18:57 +00:00
|
|
|
#include "gimpcontainer.h"
|
2000-12-29 15:22:01 +00:00
|
|
|
#include "gimpimage.h"
|
2001-12-12 23:48:18 +00:00
|
|
|
#include "gimpimage-convert.h"
|
2003-02-13 11:23:50 +00:00
|
|
|
#include "gimpimage-undo.h"
|
2003-02-14 14:14:29 +00:00
|
|
|
#include "gimpimage-undo-push.h"
|
2001-02-01 18:44:22 +00:00
|
|
|
#include "gimplayer.h"
|
2002-02-21 22:19:45 +00:00
|
|
|
#include "gimplayer-floating-sel.h"
|
2001-01-28 16:44:22 +00:00
|
|
|
#include "gimplayermask.h"
|
2001-11-22 23:46:13 +00:00
|
|
|
#include "gimpmarshal.h"
|
2001-07-09 19:48:30 +00:00
|
|
|
#include "gimpparasitelist.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 17:27:28 +00:00
|
|
|
|
|
|
|
|
2001-03-04 20:06:48 +00:00
|
|
|
enum
|
|
|
|
{
|
2001-03-11 17:24:47 +00:00
|
|
|
OPACITY_CHANGED,
|
|
|
|
MODE_CHANGED,
|
|
|
|
PRESERVE_TRANS_CHANGED,
|
2001-04-29 16:26:44 +00:00
|
|
|
LINKED_CHANGED,
|
2001-03-04 20:06:48 +00:00
|
|
|
MASK_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static void gimp_layer_class_init (GimpLayerClass *klass);
|
|
|
|
static void gimp_layer_init (GimpLayer *layer);
|
2001-08-11 14:39:19 +00:00
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static void gimp_layer_finalize (GObject *object);
|
2001-08-11 14:39:19 +00:00
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static gsize gimp_layer_get_memsize (GimpObject *object);
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static void gimp_layer_invalidate_preview (GimpViewable *viewable);
|
2002-01-30 16:14:26 +00:00
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static GimpItem * gimp_layer_duplicate (GimpItem *item,
|
|
|
|
GType new_type,
|
|
|
|
gboolean add_alpha);
|
2003-03-17 00:14:59 +00:00
|
|
|
static void gimp_layer_rename (GimpItem *item,
|
|
|
|
const gchar *new_name,
|
|
|
|
const gchar *undo_desc);
|
2003-05-07 11:09:00 +00:00
|
|
|
static void gimp_layer_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
|
|
|
GimpInterpolationType interp_type);
|
2003-05-07 13:01:17 +00:00
|
|
|
static void gimp_layer_resize (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
2003-02-11 13:52:47 +00:00
|
|
|
|
|
|
|
static void gimp_layer_transform_color (GimpImage *gimage,
|
|
|
|
PixelRegion *layerPR,
|
|
|
|
PixelRegion *bufPR,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpImageBaseType type);
|
2000-12-16 22:02:10 +00:00
|
|
|
|
|
|
|
|
2001-03-04 20:06:48 +00:00
|
|
|
static guint layer_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static GimpDrawableClass *parent_class = NULL;
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2001-01-10 00:36:54 +00:00
|
|
|
|
2001-08-11 14:39:19 +00:00
|
|
|
GType
|
2000-02-17 11:44:27 +00:00
|
|
|
gimp_layer_get_type (void)
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-08-11 14:39:19 +00:00
|
|
|
static GType layer_type = 0;
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2001-01-10 00:36:54 +00:00
|
|
|
if (! layer_type)
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-08-11 14:39:19 +00:00
|
|
|
static const GTypeInfo layer_info =
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-08-11 14:39:19 +00:00
|
|
|
sizeof (GimpLayerClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_layer_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
1998-01-22 07:02:57 +00:00
|
|
|
sizeof (GimpLayer),
|
2001-08-11 14:39:19 +00:00
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_layer_init,
|
1998-01-22 07:02:57 +00:00
|
|
|
};
|
|
|
|
|
2001-08-11 14:39:19 +00:00
|
|
|
layer_type = g_type_register_static (GIMP_TYPE_DRAWABLE,
|
|
|
|
"GimpLayer",
|
|
|
|
&layer_info, 0);
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return layer_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-12-28 16:19:55 +00:00
|
|
|
gimp_layer_class_init (GimpLayerClass *klass)
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-08-11 14:39:19 +00:00
|
|
|
GObjectClass *object_class;
|
2002-01-30 16:14:26 +00:00
|
|
|
GimpObjectClass *gimp_object_class;
|
2001-02-04 22:10:54 +00:00
|
|
|
GimpViewableClass *viewable_class;
|
2003-02-11 13:52:47 +00:00
|
|
|
GimpItemClass *item_class;
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2002-01-30 16:14:26 +00:00
|
|
|
object_class = G_OBJECT_CLASS (klass);
|
|
|
|
gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
2003-02-11 13:52:47 +00:00
|
|
|
item_class = GIMP_ITEM_CLASS (klass);
|
1998-01-22 07:02:57 +00:00
|
|
|
|
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-24 21:27:11 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2001-03-11 17:24:47 +00:00
|
|
|
layer_signals[OPACITY_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-24 21:27:11 +00:00
|
|
|
g_signal_new ("opacity_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, opacity_changed),
|
|
|
|
NULL, NULL,
|
2001-11-22 23:46:13 +00:00
|
|
|
gimp_marshal_VOID__VOID,
|
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-24 21:27:11 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
|
|
|
layer_signals[MODE_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-24 21:27:11 +00:00
|
|
|
g_signal_new ("mode_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, mode_changed),
|
|
|
|
NULL, NULL,
|
2001-11-22 23:46:13 +00:00
|
|
|
gimp_marshal_VOID__VOID,
|
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-24 21:27:11 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
|
|
|
layer_signals[PRESERVE_TRANS_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-24 21:27:11 +00:00
|
|
|
g_signal_new ("preserve_trans_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, preserve_trans_changed),
|
|
|
|
NULL, NULL,
|
2001-11-22 23:46:13 +00:00
|
|
|
gimp_marshal_VOID__VOID,
|
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-24 21:27:11 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
2001-04-29 16:26:44 +00:00
|
|
|
layer_signals[LINKED_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-24 21:27:11 +00:00
|
|
|
g_signal_new ("linked_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, linked_changed),
|
|
|
|
NULL, NULL,
|
2001-11-22 23:46:13 +00:00
|
|
|
gimp_marshal_VOID__VOID,
|
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-24 21:27:11 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2001-04-29 16:26:44 +00:00
|
|
|
|
2001-03-04 20:06:48 +00:00
|
|
|
layer_signals[MASK_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-24 21:27:11 +00:00
|
|
|
g_signal_new ("mask_changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, mask_changed),
|
|
|
|
NULL, NULL,
|
2001-11-22 23:46:13 +00:00
|
|
|
gimp_marshal_VOID__VOID,
|
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-24 21:27:11 +00:00
|
|
|
G_TYPE_NONE, 0);
|
2001-03-04 20:06:48 +00:00
|
|
|
|
2001-08-11 14:39:19 +00:00
|
|
|
object_class->finalize = gimp_layer_finalize;
|
2000-12-28 16:19:55 +00:00
|
|
|
|
2002-01-30 16:14:26 +00:00
|
|
|
gimp_object_class->get_memsize = gimp_layer_get_memsize;
|
|
|
|
|
2003-03-22 00:48:09 +00:00
|
|
|
viewable_class->default_stock_id = "gimp-layer";
|
2001-02-04 22:10:54 +00:00
|
|
|
viewable_class->invalidate_preview = gimp_layer_invalidate_preview;
|
2001-03-04 20:06:48 +00:00
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
item_class->duplicate = gimp_layer_duplicate;
|
2003-03-17 00:14:59 +00:00
|
|
|
item_class->rename = gimp_layer_rename;
|
2003-05-07 11:09:00 +00:00
|
|
|
item_class->scale = gimp_layer_scale;
|
2003-05-07 13:01:17 +00:00
|
|
|
item_class->resize = gimp_layer_resize;
|
2003-03-17 00:14:59 +00:00
|
|
|
item_class->default_name = _("Layer");
|
|
|
|
item_class->rename_desc = _("Rename Layer");
|
2003-02-11 13:52:47 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
klass->opacity_changed = NULL;
|
|
|
|
klass->mode_changed = NULL;
|
|
|
|
klass->preserve_trans_changed = NULL;
|
|
|
|
klass->linked_changed = NULL;
|
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-24 21:27:11 +00:00
|
|
|
klass->mask_changed = NULL;
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_init (GimpLayer *layer)
|
|
|
|
{
|
2002-06-06 19:07:59 +00:00
|
|
|
layer->opacity = GIMP_OPACITY_OPAQUE;
|
|
|
|
layer->mode = GIMP_NORMAL_MODE;
|
2001-01-28 16:44:22 +00:00
|
|
|
layer->preserve_trans = FALSE;
|
2002-06-06 19:07:59 +00:00
|
|
|
layer->linked = FALSE;
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
layer->mask = NULL;
|
1998-01-22 07:02:57 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
/* floating selection */
|
|
|
|
layer->fs.backing_store = NULL;
|
|
|
|
layer->fs.drawable = NULL;
|
|
|
|
layer->fs.initial = TRUE;
|
|
|
|
layer->fs.boundary_known = FALSE;
|
|
|
|
layer->fs.segs = NULL;
|
|
|
|
layer->fs.num_segs = 0;
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
|
|
|
|
2001-08-11 14:39:19 +00:00
|
|
|
static void
|
|
|
|
gimp_layer_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (object));
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (object);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
2003-01-05 22:07:10 +00:00
|
|
|
g_object_unref (layer->mask);
|
2001-08-11 14:39:19 +00:00
|
|
|
layer->mask = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layer->fs.segs)
|
|
|
|
{
|
|
|
|
g_free (layer->fs.segs);
|
|
|
|
layer->fs.segs = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free the floating selection if it exists */
|
|
|
|
if (layer->fs.backing_store)
|
|
|
|
{
|
|
|
|
tile_manager_destroy (layer->fs.backing_store);
|
|
|
|
layer->fs.backing_store = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2002-01-30 16:14:26 +00:00
|
|
|
static gsize
|
|
|
|
gimp_layer_get_memsize (GimpObject *object)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
gsize memsize = 0;
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (object);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (layer->mask));
|
|
|
|
|
|
|
|
if (layer->fs.backing_store)
|
|
|
|
memsize += tile_manager_get_memsize (layer->fs.backing_store);
|
|
|
|
|
|
|
|
memsize += layer->fs.num_segs * sizeof (BoundSeg);
|
|
|
|
|
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object);
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2001-02-04 22:10:54 +00:00
|
|
|
gimp_layer_invalidate_preview (GimpViewable *viewable)
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
layer = GIMP_LAYER (viewable);
|
|
|
|
|
2001-06-18 13:10:03 +00:00
|
|
|
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
|
|
|
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
|
|
|
|
2001-01-28 23:25:25 +00:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2001-06-18 13:10:03 +00:00
|
|
|
floating_sel_invalidate (layer);
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
static GimpItem *
|
|
|
|
gimp_layer_duplicate (GimpItem *item,
|
|
|
|
GType new_type,
|
|
|
|
gboolean add_alpha)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpItem *new_item;
|
|
|
|
GimpLayer *new_layer;
|
|
|
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
|
|
|
|
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
|
|
|
|
add_alpha);
|
|
|
|
|
|
|
|
if (! GIMP_IS_LAYER (new_item))
|
|
|
|
return new_item;
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (item);
|
|
|
|
new_layer = GIMP_LAYER (new_item);
|
|
|
|
|
|
|
|
new_layer->linked = layer->linked;
|
|
|
|
new_layer->preserve_trans = layer->preserve_trans;
|
|
|
|
|
|
|
|
new_layer->mode = layer->mode;
|
|
|
|
new_layer->opacity = layer->opacity;
|
|
|
|
|
|
|
|
/* duplicate the layer mask if necessary */
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
|
|
|
new_layer->mask =
|
|
|
|
GIMP_LAYER_MASK (gimp_item_duplicate (GIMP_ITEM (layer->mask),
|
|
|
|
G_TYPE_FROM_INSTANCE (layer->mask),
|
|
|
|
FALSE));
|
|
|
|
|
|
|
|
gimp_layer_mask_set_layer (new_layer->mask, new_layer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_item;
|
|
|
|
}
|
|
|
|
|
2003-03-17 00:14:59 +00:00
|
|
|
static void
|
|
|
|
gimp_layer_rename (GimpItem *item,
|
|
|
|
const gchar *new_name,
|
|
|
|
const gchar *undo_desc)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
gboolean floating_sel = FALSE;
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (item);
|
|
|
|
floating_sel = gimp_layer_is_floating_sel (GIMP_LAYER (item));
|
|
|
|
|
|
|
|
if (gimage && floating_sel)
|
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (gimage,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
|
|
|
undo_desc);
|
|
|
|
|
|
|
|
floating_sel_to_layer (GIMP_LAYER (item));
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->rename (item, new_name, undo_desc);
|
|
|
|
|
|
|
|
if (gimage && floating_sel)
|
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
|
|
|
|
2003-05-07 11:09:00 +00:00
|
|
|
static void
|
|
|
|
gimp_layer_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
|
|
|
GimpInterpolationType interpolation_type)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
2003-05-07 13:01:17 +00:00
|
|
|
layer = GIMP_LAYER (item);
|
2003-05-07 11:09:00 +00:00
|
|
|
gimage = gimp_item_get_image (item);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_SCALE,
|
|
|
|
_("Scale Layer"));
|
|
|
|
|
|
|
|
gimp_image_undo_push_layer_mod (gimage, _("Scale Layer"), layer);
|
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->scale (item, new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
|
|
|
interpolation_type);
|
|
|
|
|
|
|
|
/* If there is a layer mask, make sure it gets scaled also */
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
|
|
|
gimp_item_scale (GIMP_ITEM (layer->mask),
|
|
|
|
new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
|
|
|
interpolation_type);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure we're not caching any old selection info */
|
|
|
|
gimp_layer_invalidate_boundary (layer);
|
|
|
|
}
|
|
|
|
|
2003-05-07 13:01:17 +00:00
|
|
|
static void
|
|
|
|
gimp_layer_resize (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
|
|
|
{
|
|
|
|
GimpLayer *layer;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (item);
|
|
|
|
gimage = gimp_item_get_image (item);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_RESIZE,
|
|
|
|
_("Resize Layer"));
|
|
|
|
|
|
|
|
gimp_image_undo_push_layer_mod (gimage, _("Resize Layer"), layer);
|
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->resize (item, new_width, new_height,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
|
|
|
gimp_item_resize (GIMP_ITEM (layer->mask),
|
|
|
|
new_width, new_height, offset_x, offset_y);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (gimage);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure we're not caching any old selection info */
|
|
|
|
gimp_layer_invalidate_boundary (layer);
|
|
|
|
}
|
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
static void
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_transform_color (GimpImage *gimage,
|
|
|
|
PixelRegion *layerPR,
|
|
|
|
PixelRegion *bufPR,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GimpImageBaseType type)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2000-12-03 18:15:08 +00:00
|
|
|
gint i;
|
|
|
|
gint h;
|
2001-12-12 23:48:18 +00:00
|
|
|
guchar *src;
|
|
|
|
guchar *dest;
|
2000-12-03 18:15:08 +00:00
|
|
|
gpointer pr;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
for (pr = pixel_regions_register (2, layerPR, bufPR);
|
|
|
|
pr != NULL;
|
2000-05-12 17:07:54 +00:00
|
|
|
pr = pixel_regions_process (pr))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-12-12 23:48:18 +00:00
|
|
|
h = layerPR->h;
|
|
|
|
src = bufPR->data;
|
|
|
|
dest = layerPR->data;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
for (i = 0; i < layerPR->w; i++)
|
|
|
|
{
|
2000-12-29 15:22:01 +00:00
|
|
|
gimp_image_transform_color (gimage, drawable,
|
2001-12-12 23:48:18 +00:00
|
|
|
src + (i * bufPR->bytes),
|
|
|
|
dest + (i * layerPR->bytes), type);
|
1997-11-24 22:05:25 +00:00
|
|
|
/* copy alpha channel */
|
2001-12-12 23:48:18 +00:00
|
|
|
dest[(i + 1) * layerPR->bytes - 1] = src[(i + 1) * bufPR->bytes - 1];
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
src += bufPR->rowstride;
|
|
|
|
dest += layerPR->rowstride;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* Function definitions */
|
1999-08-22 11:45:31 +00:00
|
|
|
/**************************/
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayer *
|
2001-12-08 23:12:59 +00:00
|
|
|
gimp_layer_new (GimpImage *gimage,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpImageType type,
|
|
|
|
const gchar *name,
|
2002-03-04 14:52:54 +00:00
|
|
|
gdouble opacity,
|
2001-12-08 23:12:59 +00:00
|
|
|
GimpLayerModeEffects mode)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayer *layer;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
|
|
|
g_return_val_if_fail (width > 0, NULL);
|
|
|
|
g_return_val_if_fail (height > 0, NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-08-10 14:41:39 +00:00
|
|
|
layer = g_object_new (GIMP_TYPE_LAYER, NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-08-22 11:45:31 +00:00
|
|
|
gimp_drawable_configure (GIMP_DRAWABLE (layer),
|
2001-12-12 23:48:18 +00:00
|
|
|
gimage,
|
2003-01-31 16:37:03 +00:00
|
|
|
0, 0, width, height,
|
2001-12-12 23:48:18 +00:00
|
|
|
type,
|
|
|
|
name);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
layer->opacity = opacity;
|
2002-03-04 14:52:54 +00:00
|
|
|
layer->mode = mode;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
/**
|
|
|
|
* gimp_layer_new_from_tiles:
|
|
|
|
* @tiles: The buffer to make the new layer from.
|
|
|
|
* @dest_gimage: The image the new layer will be added to.
|
2002-05-21 11:29:20 +00:00
|
|
|
* @type: The #GimpImageType of the new layer.
|
2002-03-04 14:52:54 +00:00
|
|
|
* @name: The new layer's name.
|
|
|
|
* @opacity: The new layer's opacity.
|
|
|
|
* @mode: The new layer's mode.
|
|
|
|
*
|
|
|
|
* Copies %tiles to a layer taking into consideration the
|
|
|
|
* possibility of transforming the contents to meet the requirements
|
|
|
|
* of the target image type
|
|
|
|
*
|
|
|
|
* Return value: The new layer.
|
|
|
|
**/
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayer *
|
2002-02-25 17:58:50 +00:00
|
|
|
gimp_layer_new_from_tiles (TileManager *tiles,
|
|
|
|
GimpImage *dest_gimage,
|
2002-05-21 11:29:20 +00:00
|
|
|
GimpImageType type,
|
2001-12-12 23:48:18 +00:00
|
|
|
const gchar *name,
|
2002-03-04 14:52:54 +00:00
|
|
|
gdouble opacity,
|
2001-12-08 23:12:59 +00:00
|
|
|
GimpLayerModeEffects mode)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayer *new_layer;
|
2000-12-03 18:15:08 +00:00
|
|
|
PixelRegion layerPR;
|
|
|
|
PixelRegion bufPR;
|
2002-03-04 14:52:54 +00:00
|
|
|
gint width, height;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
g_return_val_if_fail (tiles != NULL, NULL);
|
2002-02-25 17:58:50 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (dest_gimage), NULL);
|
2001-12-12 23:48:18 +00:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
width = tile_manager_width (tiles);
|
|
|
|
height = tile_manager_height (tiles);
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
new_layer = gimp_layer_new (dest_gimage,
|
2002-03-04 14:52:54 +00:00
|
|
|
width, height,
|
2002-05-21 11:29:20 +00:00
|
|
|
type,
|
2001-01-28 16:44:22 +00:00
|
|
|
name,
|
|
|
|
opacity,
|
|
|
|
mode);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
if (! new_layer)
|
1999-08-22 11:45:31 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
g_message ("gimp_layer_new_from_tiles: could not allocate new layer");
|
1999-08-22 11:45:31 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Configure the pixel regions */
|
2001-12-12 23:48:18 +00:00
|
|
|
pixel_region_init (&bufPR, tiles,
|
|
|
|
0, 0,
|
2002-03-04 14:52:54 +00:00
|
|
|
width, height,
|
2000-05-12 17:07:54 +00:00
|
|
|
FALSE);
|
2001-12-12 23:48:18 +00:00
|
|
|
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
|
|
|
|
0, 0,
|
2002-03-04 14:52:54 +00:00
|
|
|
width, height,
|
2001-12-12 23:48:18 +00:00
|
|
|
TRUE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-23 13:01:48 +00:00
|
|
|
if ((tile_manager_bpp (tiles) == 4 &&
|
2001-12-11 18:11:56 +00:00
|
|
|
GIMP_DRAWABLE (new_layer)->type == GIMP_RGBA_IMAGE) ||
|
2001-01-23 13:01:48 +00:00
|
|
|
(tile_manager_bpp (tiles) == 2 &&
|
2001-12-11 18:11:56 +00:00
|
|
|
GIMP_DRAWABLE (new_layer)->type == GIMP_GRAYA_IMAGE))
|
2001-12-12 23:48:18 +00:00
|
|
|
{
|
|
|
|
/* If we want a layer the same type as the buffer */
|
|
|
|
copy_region (&bufPR, &layerPR);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
else
|
2001-12-12 23:48:18 +00:00
|
|
|
{
|
|
|
|
/* Transform the contents of the buf to the new_layer */
|
2002-02-25 17:58:50 +00:00
|
|
|
gimp_layer_transform_color (dest_gimage,
|
2001-12-12 23:48:18 +00:00
|
|
|
&layerPR, &bufPR,
|
|
|
|
GIMP_DRAWABLE (new_layer),
|
|
|
|
((tile_manager_bpp (tiles) == 4) ?
|
|
|
|
GIMP_RGB : GIMP_GRAY));
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
return new_layer;
|
|
|
|
}
|
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
GimpLayer *
|
2002-02-25 17:58:50 +00:00
|
|
|
gimp_layer_new_from_drawable (GimpDrawable *drawable,
|
|
|
|
GimpImage *dest_image)
|
2001-12-12 23:48:18 +00:00
|
|
|
{
|
2002-05-28 21:32:06 +00:00
|
|
|
GimpImageBaseType src_base_type;
|
2001-12-12 23:48:18 +00:00
|
|
|
GimpDrawable *new_drawable;
|
|
|
|
GimpImageBaseType new_base_type;
|
|
|
|
|
2002-05-28 21:32:06 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2002-02-25 17:58:50 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
2001-12-12 23:48:18 +00:00
|
|
|
|
2002-05-28 21:32:06 +00:00
|
|
|
src_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
|
2001-12-12 23:48:18 +00:00
|
|
|
new_base_type = gimp_image_base_type (dest_image);
|
|
|
|
|
2003-02-11 13:52:47 +00:00
|
|
|
new_drawable = GIMP_DRAWABLE (gimp_item_duplicate (GIMP_ITEM (drawable),
|
|
|
|
GIMP_TYPE_LAYER,
|
2001-12-12 23:48:18 +00:00
|
|
|
TRUE));
|
|
|
|
|
2002-05-28 21:32:06 +00:00
|
|
|
if (src_base_type != new_base_type)
|
2001-12-12 23:48:18 +00:00
|
|
|
{
|
|
|
|
TileManager *new_tiles;
|
|
|
|
GimpImageType new_type;
|
|
|
|
|
|
|
|
new_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_base_type);
|
|
|
|
|
|
|
|
if (gimp_drawable_has_alpha (new_drawable))
|
|
|
|
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
|
|
|
|
|
|
|
|
new_tiles = tile_manager_new (gimp_drawable_width (new_drawable),
|
|
|
|
gimp_drawable_height (new_drawable),
|
|
|
|
GIMP_IMAGE_TYPE_BYTES (new_type));
|
|
|
|
|
|
|
|
switch (new_base_type)
|
|
|
|
{
|
|
|
|
case GIMP_RGB:
|
|
|
|
gimp_drawable_convert_rgb (new_drawable,
|
|
|
|
new_tiles,
|
2002-05-28 21:32:06 +00:00
|
|
|
src_base_type);
|
2001-12-12 23:48:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY:
|
|
|
|
gimp_drawable_convert_grayscale (new_drawable,
|
|
|
|
new_tiles,
|
2002-05-28 21:32:06 +00:00
|
|
|
src_base_type);
|
2001-12-12 23:48:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED:
|
|
|
|
{
|
|
|
|
PixelRegion layerPR;
|
|
|
|
PixelRegion newPR;
|
|
|
|
|
|
|
|
pixel_region_init (&layerPR, new_drawable->tiles,
|
|
|
|
0, 0,
|
|
|
|
gimp_drawable_width (new_drawable),
|
|
|
|
gimp_drawable_height (new_drawable),
|
|
|
|
FALSE);
|
|
|
|
pixel_region_init (&newPR, new_tiles,
|
|
|
|
0, 0,
|
|
|
|
gimp_drawable_width (new_drawable),
|
|
|
|
gimp_drawable_height (new_drawable),
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
gimp_layer_transform_color (dest_image,
|
|
|
|
&newPR, &layerPR,
|
|
|
|
NULL,
|
2002-05-28 21:32:06 +00:00
|
|
|
src_base_type);
|
2001-12-12 23:48:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
tile_manager_destroy (new_drawable->tiles);
|
|
|
|
|
|
|
|
new_drawable->tiles = new_tiles;
|
|
|
|
new_drawable->type = new_type;
|
|
|
|
new_drawable->bytes = GIMP_IMAGE_TYPE_BYTES (new_type);
|
|
|
|
new_drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (new_type);
|
|
|
|
}
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
gimp_item_set_image (GIMP_ITEM (new_drawable), dest_image);
|
2001-12-12 23:48:18 +00:00
|
|
|
|
|
|
|
return GIMP_LAYER (new_drawable);
|
|
|
|
}
|
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayerMask *
|
|
|
|
gimp_layer_add_mask (GimpLayer *layer,
|
2001-03-04 20:06:48 +00:00
|
|
|
GimpLayerMask *mask,
|
|
|
|
gboolean push_undo)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-02-23 17:29:19 +00:00
|
|
|
GimpImage *gimage;
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
if (! gimage)
|
|
|
|
{
|
2003-03-23 21:30:09 +00:00
|
|
|
g_message (_("Cannot add layer mask to layer "
|
2001-03-04 20:06:48 +00:00
|
|
|
"which is not part of an image."));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
if (layer->mask)
|
2001-03-04 20:06:48 +00:00
|
|
|
{
|
2003-03-23 21:30:09 +00:00
|
|
|
g_message (_("Unable to add a layer mask since "
|
|
|
|
"the layer already has one."));
|
2001-03-04 20:06:48 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-01-31 16:47:20 +00:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
2001-03-04 20:06:48 +00:00
|
|
|
{
|
2003-03-23 21:30:09 +00:00
|
|
|
g_message (_("Cannot add layer mask to a layer "
|
2001-03-04 20:06:48 +00:00
|
|
|
"with no alpha channel."));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((gimp_drawable_width (GIMP_DRAWABLE (layer)) !=
|
|
|
|
gimp_drawable_width (GIMP_DRAWABLE (mask))) ||
|
|
|
|
(gimp_drawable_height (GIMP_DRAWABLE (layer)) !=
|
|
|
|
gimp_drawable_height (GIMP_DRAWABLE (mask))))
|
|
|
|
{
|
2003-03-23 21:30:09 +00:00
|
|
|
g_message(_("Cannot add layer mask of different "
|
2001-03-04 20:06:48 +00:00
|
|
|
"dimensions than specified layer."));
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
layer->mask = mask;
|
2003-01-05 22:07:10 +00:00
|
|
|
g_object_ref (layer->mask);
|
2001-01-28 16:44:22 +00:00
|
|
|
|
|
|
|
gimp_layer_mask_set_layer (mask, layer);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-07-07 22:49:01 +00:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-04 20:06:48 +00:00
|
|
|
if (push_undo)
|
2003-02-17 12:30:41 +00:00
|
|
|
gimp_image_undo_push_layer_mask_add (gimage, _("Add Layer Mask"),
|
2003-02-14 14:14:29 +00:00
|
|
|
layer, mask);
|
2001-03-04 20:06:48 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[MASK_CHANGED], 0);
|
2001-03-04 20:06:48 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
return layer->mask;
|
|
|
|
}
|
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayerMask *
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_create_mask (const GimpLayer *layer,
|
2002-03-18 11:07:34 +00:00
|
|
|
GimpAddMaskType add_mask_type)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-05-07 17:00:57 +00:00
|
|
|
GimpDrawable *drawable;
|
2003-05-08 11:52:31 +00:00
|
|
|
GimpItem *item;
|
2002-02-20 16:15:53 +00:00
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion destPR;
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayerMask *mask;
|
2001-02-28 07:54:05 +00:00
|
|
|
GimpImage *gimage;
|
2001-01-28 16:44:22 +00:00
|
|
|
gchar *mask_name;
|
2002-03-03 17:38:12 +00:00
|
|
|
GimpRGB black = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
|
2003-05-07 17:00:57 +00:00
|
|
|
drawable = GIMP_DRAWABLE (layer);
|
2003-05-08 11:52:31 +00:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
gimage = gimp_item_get_image (item);
|
2001-02-28 07:54:05 +00:00
|
|
|
|
2001-01-10 03:13:03 +00:00
|
|
|
mask_name = g_strdup_printf (_("%s mask"),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (layer)));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-05-07 17:00:57 +00:00
|
|
|
mask = gimp_layer_mask_new (gimage,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2001-01-28 16:44:22 +00:00
|
|
|
mask_name, &black);
|
2002-02-20 16:15:53 +00:00
|
|
|
|
|
|
|
g_free (mask_name);
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (mask)->offset_x = item->offset_x;
|
|
|
|
GIMP_ITEM (mask)->offset_y = item->offset_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-08-27 14:17:46 +00:00
|
|
|
switch (add_mask_type)
|
|
|
|
{
|
|
|
|
case GIMP_ADD_WHITE_MASK:
|
|
|
|
gimp_channel_all (GIMP_CHANNEL (mask), FALSE);
|
|
|
|
return mask;
|
|
|
|
|
|
|
|
case GIMP_ADD_BLACK_MASK:
|
|
|
|
gimp_channel_clear (GIMP_CHANNEL (mask), FALSE);
|
|
|
|
return mask;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-02-20 16:15:53 +00:00
|
|
|
pixel_region_init (&destPR, GIMP_DRAWABLE (mask)->tiles,
|
2000-05-12 17:07:54 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (mask)->width,
|
|
|
|
GIMP_ITEM (mask)->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
TRUE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
switch (add_mask_type)
|
|
|
|
{
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_ADD_WHITE_MASK:
|
|
|
|
case GIMP_ADD_BLACK_MASK:
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
2001-12-12 23:48:18 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_ADD_ALPHA_MASK:
|
2003-05-07 17:00:57 +00:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-05-07 17:00:57 +00:00
|
|
|
pixel_region_init (&srcPR, drawable->tiles,
|
2000-05-12 17:07:54 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
FALSE);
|
2003-05-08 11:52:31 +00:00
|
|
|
|
2002-02-20 16:15:53 +00:00
|
|
|
extract_alpha_region (&srcPR, NULL, &destPR);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-12-12 23:48:18 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_ADD_SELECTION_MASK:
|
2002-02-20 16:15:53 +00:00
|
|
|
{
|
2002-08-27 14:17:46 +00:00
|
|
|
GimpChannel *selection;
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2002-08-27 14:17:46 +00:00
|
|
|
selection = gimp_image_get_mask (gimage);
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (item->offset_x < 0 ||
|
|
|
|
item->offset_y < 0 ||
|
|
|
|
item->offset_x + item->width > gimage->width ||
|
|
|
|
item->offset_y + item->height > gimage->height)
|
2003-05-07 17:00:57 +00:00
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
width = item->width;
|
|
|
|
height = item->height;
|
2003-05-07 17:00:57 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (item->offset_x < 0)
|
|
|
|
width += item->offset_x;
|
2003-05-07 17:00:57 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (item->offset_y < 0)
|
|
|
|
height += item->offset_y;
|
2003-05-07 17:00:57 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (item->offset_x + item->width > gimage->width)
|
|
|
|
width -= item->offset_x + item->width - gimage->width;
|
2003-05-07 17:00:57 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (item->offset_y + item->height > gimage->height)
|
|
|
|
height -= item->offset_y + item->height - gimage->height;
|
2003-05-07 17:00:57 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (width < item->width || height < item->height)
|
2003-05-07 17:00:57 +00:00
|
|
|
gimp_channel_clear (GIMP_CHANNEL (mask), FALSE);
|
|
|
|
|
|
|
|
if (width > 0 && height > 0)
|
|
|
|
{
|
|
|
|
gint x, y;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
x = MAX (0, item->offset_x);
|
|
|
|
y = MAX (0, item->offset_y);
|
2003-05-07 17:00:57 +00:00
|
|
|
|
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (selection)->tiles,
|
|
|
|
x, y, width, height,
|
|
|
|
FALSE);
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
x = MAX (0, -item->offset_x);
|
|
|
|
y = MAX (0, -item->offset_y);
|
2003-05-07 17:00:57 +00:00
|
|
|
|
|
|
|
pixel_region_init (&destPR, GIMP_DRAWABLE (mask)->tiles,
|
|
|
|
x, y, width, height,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (selection)->tiles,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->offset_x,
|
|
|
|
item->offset_y,
|
|
|
|
item->width,
|
|
|
|
item->height,
|
2003-05-07 17:00:57 +00:00
|
|
|
FALSE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
2002-08-27 14:17:46 +00:00
|
|
|
|
|
|
|
if (! (selection->bounds_known && selection->empty))
|
|
|
|
GIMP_CHANNEL (mask)->bounds_known = FALSE;
|
2002-02-20 16:15:53 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
case GIMP_ADD_COPY_MASK:
|
2002-02-20 16:15:53 +00:00
|
|
|
{
|
2003-03-03 12:36:42 +00:00
|
|
|
TileManager *copy_tiles = NULL;
|
2002-02-20 16:15:53 +00:00
|
|
|
GimpImageType layer_type;
|
|
|
|
|
2003-05-07 17:00:57 +00:00
|
|
|
layer_type = drawable->type;
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-03-03 12:36:42 +00:00
|
|
|
if (GIMP_IMAGE_TYPE_BASE_TYPE (layer_type) != GIMP_GRAY)
|
|
|
|
{
|
|
|
|
GimpImageType copy_type;
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-03-03 12:36:42 +00:00
|
|
|
copy_type = (GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type) ?
|
|
|
|
GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE);
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
copy_tiles = tile_manager_new (item->width,
|
|
|
|
item->height,
|
2003-03-03 12:36:42 +00:00
|
|
|
GIMP_IMAGE_TYPE_BYTES (copy_type));
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-05-07 17:00:57 +00:00
|
|
|
gimp_drawable_convert_grayscale (drawable,
|
2003-03-03 12:36:42 +00:00
|
|
|
copy_tiles,
|
|
|
|
GIMP_IMAGE_TYPE_BASE_TYPE (layer_type));
|
|
|
|
|
|
|
|
pixel_region_init (&srcPR, copy_tiles,
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2003-03-03 12:36:42 +00:00
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-05-07 17:00:57 +00:00
|
|
|
pixel_region_init (&srcPR, drawable->tiles,
|
2003-03-03 12:36:42 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2003-03-03 12:36:42 +00:00
|
|
|
FALSE);
|
|
|
|
}
|
2002-02-20 16:15:53 +00:00
|
|
|
|
2003-05-07 17:00:57 +00:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2002-02-20 16:15:53 +00:00
|
|
|
{
|
2003-03-03 12:36:42 +00:00
|
|
|
guchar black_uchar[] = { 0, 0, 0, 0 };
|
|
|
|
|
2002-02-20 16:15:53 +00:00
|
|
|
flatten_region (&srcPR, &destPR, black_uchar);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
|
2003-03-03 12:36:42 +00:00
|
|
|
if (copy_tiles)
|
|
|
|
tile_manager_destroy (copy_tiles);
|
2002-02-20 16:15:53 +00:00
|
|
|
}
|
2002-08-27 14:17:46 +00:00
|
|
|
|
|
|
|
GIMP_CHANNEL (mask)->bounds_known = FALSE;
|
2002-02-20 16:15:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-01-28 16:44:22 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-18 11:07:34 +00:00
|
|
|
gimp_layer_apply_mask (GimpLayer *layer,
|
|
|
|
GimpMaskApplyMode mode,
|
|
|
|
gboolean push_undo)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-05-08 11:52:31 +00:00
|
|
|
GimpItem *item;
|
2002-02-23 17:29:19 +00:00
|
|
|
GimpImage *gimage;
|
|
|
|
PixelRegion srcPR, maskPR;
|
|
|
|
gboolean view_changed = FALSE;
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
if (! layer->mask)
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* this operation can only be done to layers with an alpha channel */
|
2002-01-31 16:47:20 +00:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (item);
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
if (! gimage)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (push_undo)
|
|
|
|
{
|
2003-02-13 11:23:50 +00:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_APPLY_MASK,
|
|
|
|
_("Apply Layer Mask"));
|
2001-03-04 20:06:48 +00:00
|
|
|
|
2003-02-14 14:14:29 +00:00
|
|
|
gimp_image_undo_push_layer_mask_remove (gimage, NULL, layer, layer->mask);
|
2001-03-04 20:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check if applying the mask changes the projection */
|
2003-03-24 12:21:58 +00:00
|
|
|
if ((mode == GIMP_MASK_APPLY && (! layer->mask->apply_mask ||
|
|
|
|
layer->mask->show_mask)) ||
|
|
|
|
(mode == GIMP_MASK_DISCARD && (layer->mask->apply_mask ||
|
|
|
|
layer->mask->show_mask)))
|
2001-03-04 20:06:48 +00:00
|
|
|
{
|
|
|
|
view_changed = TRUE;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-03-18 11:07:34 +00:00
|
|
|
if (mode == GIMP_MASK_APPLY)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-03-04 20:06:48 +00:00
|
|
|
if (push_undo)
|
2003-02-14 14:14:29 +00:00
|
|
|
gimp_drawable_push_undo (GIMP_DRAWABLE (layer), NULL,
|
2002-06-06 19:44:05 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2002-06-06 19:44:05 +00:00
|
|
|
NULL, FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Combine the current layer's alpha channel and the mask */
|
2000-12-14 13:52:16 +00:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
|
2000-05-12 17:07:54 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
TRUE);
|
2000-12-14 13:52:16 +00:00
|
|
|
pixel_region_init (&maskPR, GIMP_DRAWABLE (layer->mask)->tiles,
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1998-01-25 01:24:46 +00:00
|
|
|
apply_mask_to_region (&srcPR, &maskPR, OPAQUE_OPACITY);
|
2001-03-04 20:06:48 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_object_unref (layer->mask);
|
2001-03-06 13:28:39 +00:00
|
|
|
layer->mask = NULL;
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
if (push_undo)
|
2003-02-14 14:14:29 +00:00
|
|
|
gimp_image_undo_group_end (gimage);
|
2001-03-04 20:06:48 +00:00
|
|
|
|
|
|
|
/* If applying actually changed the view */
|
|
|
|
if (view_changed)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-07-07 22:49:01 +00:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
item->width,
|
|
|
|
item->height);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2003-03-24 12:21:58 +00:00
|
|
|
else
|
|
|
|
{
|
2003-04-07 09:27:08 +00:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
|
2003-03-24 12:21:58 +00:00
|
|
|
}
|
2001-03-04 20:06:48 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[MASK_CHANGED], 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2000-10-23 09:05:45 +00:00
|
|
|
void
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_translate (GimpLayer *layer,
|
|
|
|
gint off_x,
|
2003-03-18 16:42:45 +00:00
|
|
|
gint off_y,
|
|
|
|
gboolean push_undo)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2003-03-18 16:42:45 +00:00
|
|
|
if (push_undo)
|
|
|
|
gimp_image_undo_push_layer_displace (gimp_item_get_image (GIMP_ITEM (layer)),
|
|
|
|
_("Move Layer"),
|
|
|
|
layer);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* update the affected region */
|
2001-07-07 22:49:01 +00:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-10-23 09:05:45 +00:00
|
|
|
/* invalidate the selection boundary because of a layer modification */
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_invalidate_boundary (layer);
|
2000-10-23 09:05:45 +00:00
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* update the layer offsets */
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->offset_x += off_x;
|
|
|
|
GIMP_ITEM (layer)->offset_y += off_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* update the affected region */
|
2001-07-07 22:49:01 +00:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
if (layer->mask)
|
|
|
|
{
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer->mask)->offset_x += off_x;
|
|
|
|
GIMP_ITEM (layer->mask)->offset_y += off_y;
|
1999-02-07 15:16:45 +00:00
|
|
|
|
2000-10-23 09:05:45 +00:00
|
|
|
/* invalidate the mask preview */
|
2001-02-04 22:10:54 +00:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->mask));
|
1998-01-22 07:02:57 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_add_alpha (GimpLayer *layer)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
TileManager *new_tiles;
|
|
|
|
GimpImageType type;
|
2001-10-31 21:18:57 +00:00
|
|
|
GimpImage *gimage;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2001-12-12 23:48:18 +00:00
|
|
|
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
type = gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Configure the pixel regions */
|
2000-12-14 13:52:16 +00:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
|
2000-05-12 17:07:54 +00:00
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Allocate the new layer, configure dest region */
|
2003-05-08 11:52:31 +00:00
|
|
|
new_tiles = tile_manager_new (GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_drawable_bytes_with_alpha (GIMP_DRAWABLE (layer)));
|
2000-05-12 17:07:54 +00:00
|
|
|
pixel_region_init (&destPR, new_tiles,
|
2003-05-08 11:52:31 +00:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
2000-05-12 17:07:54 +00:00
|
|
|
TRUE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Add an alpha channel */
|
|
|
|
add_alpha_region (&srcPR, &destPR);
|
|
|
|
|
|
|
|
/* Push the layer on the undo stack */
|
2003-02-14 14:14:29 +00:00
|
|
|
gimp_image_undo_push_layer_mod (gimp_item_get_image (GIMP_ITEM (layer)),
|
|
|
|
_("Add Alpha Channel"), layer);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Configure the new layer */
|
2000-12-14 13:52:16 +00:00
|
|
|
GIMP_DRAWABLE (layer)->tiles = new_tiles;
|
|
|
|
GIMP_DRAWABLE (layer)->type = type;
|
2001-10-31 21:18:57 +00:00
|
|
|
GIMP_DRAWABLE (layer)->bytes = GIMP_DRAWABLE (layer)->bytes + 1;
|
2000-12-14 13:52:16 +00:00
|
|
|
GIMP_DRAWABLE (layer)->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
|
|
|
|
GIMP_DRAWABLE (layer)->preview_valid = FALSE;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-10-31 21:18:57 +00:00
|
|
|
|
2002-08-28 14:09:14 +00:00
|
|
|
if (gimp_container_num_children (gimage->layers) == 1)
|
2001-10-31 21:18:57 +00:00
|
|
|
{
|
|
|
|
gimp_image_alpha_changed (gimage);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2000-02-26 18:46:08 +00:00
|
|
|
/**
|
2001-01-28 16:44:22 +00:00
|
|
|
* gimp_layer_check_scaling:
|
2000-02-26 18:46:08 +00:00
|
|
|
* @layer: Layer to check
|
2001-05-22 21:12:43 +00:00
|
|
|
* @new_width: proposed width of layer's image, in pixels
|
|
|
|
* @new_height: proposed height of layer's image, in pixels
|
2000-02-27 12:09:29 +00:00
|
|
|
*
|
2000-02-26 18:46:08 +00:00
|
|
|
* Scales layer dimensions, then snaps them to pixel centers
|
2000-02-27 12:09:29 +00:00
|
|
|
*
|
2001-05-22 21:12:43 +00:00
|
|
|
* Returns: #FALSE if any dimension reduces to zero as a result
|
|
|
|
* of this; otherwise, returns #TRUE.
|
|
|
|
**/
|
2001-01-28 16:44:22 +00:00
|
|
|
gboolean
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_check_scaling (const GimpLayer *layer,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height)
|
2000-02-26 18:46:08 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpImage *gimage;
|
|
|
|
gdouble img_scale_w;
|
|
|
|
gdouble img_scale_h;
|
|
|
|
gint new_layer_width;
|
|
|
|
gint new_layer_height;
|
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-01-28 16:44:22 +00:00
|
|
|
img_scale_w = (gdouble) new_width / (gdouble) gimage->width;
|
|
|
|
img_scale_h = (gdouble) new_height / (gdouble) gimage->height;
|
|
|
|
new_layer_width = ROUND (img_scale_w *
|
2003-05-08 11:52:31 +00:00
|
|
|
(gdouble) GIMP_ITEM (layer)->width);
|
2001-01-28 16:44:22 +00:00
|
|
|
new_layer_height = ROUND (img_scale_h *
|
2003-05-08 11:52:31 +00:00
|
|
|
(gdouble) GIMP_ITEM (layer)->height);
|
2001-01-28 16:44:22 +00:00
|
|
|
|
|
|
|
return (new_layer_width != 0 && new_layer_height != 0);
|
2000-02-26 18:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-01-28 16:44:22 +00:00
|
|
|
* gimp_layer_scale_by_factors:
|
2001-05-22 21:12:43 +00:00
|
|
|
* @layer: Layer to be transformed by explicit width and height factors.
|
2000-02-26 18:46:08 +00:00
|
|
|
* @w_factor: scale factor to apply to width and horizontal offset
|
|
|
|
* @h_factor: scale factor to apply to height and vertical offset
|
|
|
|
*
|
|
|
|
* Scales layer dimensions and offsets by uniform width and
|
|
|
|
* height factors.
|
2001-05-22 21:12:43 +00:00
|
|
|
*
|
2001-01-28 16:44:22 +00:00
|
|
|
* Use gimp_layer_scale_by_factors() in circumstances when the
|
2000-02-26 18:46:08 +00:00
|
|
|
* same width and height scaling factors are to be uniformly
|
|
|
|
* applied to a set of layers. In this context, the layer's
|
|
|
|
* dimensions and offsets from the sides of the containing
|
|
|
|
* image all change by these predetermined factors. By fiat,
|
|
|
|
* the fixed point of the transform is the upper left hand
|
|
|
|
* corner of the image. Returns gboolean FALSE if a requested
|
|
|
|
* scale factor is zero or if a scaling zero's out a layer
|
2001-05-22 21:12:43 +00:00
|
|
|
* dimension; returns #TRUE otherwise.
|
2000-02-26 18:46:08 +00:00
|
|
|
*
|
2001-01-28 16:44:22 +00:00
|
|
|
* Use gimp_layer_scale() in circumstances where new layer width
|
2000-02-26 18:46:08 +00:00
|
|
|
* and height dimensions are predetermined instead.
|
|
|
|
*
|
2000-02-27 12:09:29 +00:00
|
|
|
* Side effects: Undo set created for layer. Old layer imagery
|
|
|
|
* scaled & painted to new layer tiles.
|
2000-02-26 18:46:08 +00:00
|
|
|
*
|
2001-05-22 21:12:43 +00:00
|
|
|
* Returns: #TRUE, if the scaled layer has positive dimensions
|
|
|
|
* #FALSE if the scaled layer has at least one zero dimension
|
|
|
|
**/
|
2000-02-26 18:46:08 +00:00
|
|
|
gboolean
|
2002-02-12 02:31:45 +00:00
|
|
|
gimp_layer_scale_by_factors (GimpLayer *layer,
|
|
|
|
gdouble w_factor,
|
|
|
|
gdouble h_factor,
|
|
|
|
GimpInterpolationType interpolation_type)
|
2000-02-26 18:46:08 +00:00
|
|
|
{
|
2000-02-27 12:09:29 +00:00
|
|
|
gint new_width, new_height;
|
|
|
|
gint new_offset_x, new_offset_y;
|
2001-01-28 16:44:22 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2000-02-26 18:46:08 +00:00
|
|
|
if (w_factor == 0.0 || h_factor == 0.0)
|
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
g_message ("gimp_layer_scale_by_factors: Error. Requested width or height scale equals zero.");
|
2000-02-26 18:46:08 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_offset_x = ROUND (w_factor * (gdouble) GIMP_ITEM (layer)->offset_x);
|
|
|
|
new_offset_y = ROUND (h_factor * (gdouble) GIMP_ITEM (layer)->offset_y);
|
|
|
|
new_width = ROUND (w_factor * (gdouble) GIMP_ITEM (layer)->width);
|
|
|
|
new_height = ROUND (h_factor * (gdouble) GIMP_ITEM (layer)->height);
|
2000-02-26 18:46:08 +00:00
|
|
|
|
2000-02-27 12:09:29 +00:00
|
|
|
if (new_width != 0 && new_height != 0)
|
2000-02-26 18:46:08 +00:00
|
|
|
{
|
2003-05-07 11:09:00 +00:00
|
|
|
gimp_item_scale (GIMP_ITEM (layer),
|
|
|
|
new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
|
|
|
interpolation_type);
|
2000-02-26 18:46:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2001-01-28 16:44:22 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2000-02-26 18:46:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-05-07 11:09:00 +00:00
|
|
|
* gimp_layer_scale_by_origin:
|
2000-05-12 17:07:54 +00:00
|
|
|
* @layer: The layer to be transformed by width & height scale factors
|
2000-02-26 18:46:08 +00:00
|
|
|
* @new_width: The width that layer will acquire
|
|
|
|
* @new_height: The height that the layer will acquire
|
|
|
|
* @local_origin: sets fixed point of the scaling transform. See below.
|
|
|
|
*
|
|
|
|
* Sets layer dimensions to new_width and
|
|
|
|
* new_height. Derives vertical and horizontal scaling
|
|
|
|
* transforms from new width and height. If local_origin is
|
|
|
|
* TRUE, the fixed point of the scaling transform coincides
|
|
|
|
* with the layer's center point. Otherwise, the fixed
|
|
|
|
* point is taken to be [-GIMP_DRAWABLE(layer)->offset_x,
|
|
|
|
* -GIMP_DRAWABLE(layer)->offset_y].
|
|
|
|
*
|
|
|
|
* Since this function derives scale factors from new and
|
|
|
|
* current layer dimensions, these factors will vary from
|
|
|
|
* layer to layer because of aliasing artifacts; factor
|
|
|
|
* variations among layers can be quite large where layer
|
|
|
|
* dimensions approach pixel dimensions. Use
|
2001-01-28 16:44:22 +00:00
|
|
|
* gimp_layer_scale_by_factors() where constant scales are to
|
2000-02-26 18:46:08 +00:00
|
|
|
* be uniformly applied to a number of layers.
|
|
|
|
*
|
|
|
|
* Side effects: undo set created for layer.
|
|
|
|
* Old layer imagery scaled
|
|
|
|
* & painted to new layer tiles
|
2001-05-22 21:12:43 +00:00
|
|
|
**/
|
2000-02-26 18:46:08 +00:00
|
|
|
void
|
2003-05-07 11:09:00 +00:00
|
|
|
gimp_layer_scale_by_origin (GimpLayer *layer,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
GimpInterpolationType interpolation_type,
|
|
|
|
gboolean local_origin)
|
2000-02-26 18:46:08 +00:00
|
|
|
{
|
|
|
|
gint new_offset_x, new_offset_y;
|
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2000-02-26 18:46:08 +00:00
|
|
|
if (new_width == 0 || new_height == 0)
|
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
g_message ("gimp_layer_scale: Error. Requested width or height equals zero.");
|
2000-02-26 18:46:08 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-01-28 16:44:22 +00:00
|
|
|
|
2000-02-26 18:46:08 +00:00
|
|
|
if (local_origin)
|
|
|
|
{
|
2003-05-08 11:52:31 +00:00
|
|
|
new_offset_x = GIMP_ITEM (layer)->offset_x +
|
|
|
|
((GIMP_ITEM (layer)->width - new_width) / 2.0);
|
2001-01-28 16:44:22 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_offset_y = GIMP_ITEM (layer)->offset_y +
|
|
|
|
((GIMP_ITEM (layer)->height - new_height) / 2.0);
|
2000-02-26 18:46:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
new_offset_x = (gint) (((gdouble) new_width *
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->offset_x /
|
|
|
|
(gdouble) GIMP_ITEM (layer)->width));
|
2001-01-28 16:44:22 +00:00
|
|
|
|
|
|
|
new_offset_y = (gint) (((gdouble) new_height *
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->offset_y /
|
|
|
|
(gdouble) GIMP_ITEM (layer)->height));
|
2000-02-26 18:46:08 +00:00
|
|
|
}
|
2001-01-28 16:44:22 +00:00
|
|
|
|
2003-05-07 11:09:00 +00:00
|
|
|
gimp_item_scale (GIMP_ITEM (layer),
|
|
|
|
new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
|
|
|
interpolation_type);
|
2000-02-26 18:46:08 +00:00
|
|
|
}
|
|
|
|
|
1999-11-27 14:00:26 +00:00
|
|
|
void
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_resize_to_image (GimpLayer *layer)
|
1999-11-27 14:00:26 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpImage *gimage;
|
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
1999-11-27 14:00:26 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
|
1999-11-27 14:00:26 +00:00
|
|
|
return;
|
|
|
|
|
2003-02-13 11:23:50 +00:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_LAYER_RESIZE,
|
|
|
|
_("Layer to Image Size"));
|
1999-11-27 14:00:26 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
1999-11-27 14:00:26 +00:00
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
|
|
|
|
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &offset_x, &offset_y);
|
2003-05-07 13:01:17 +00:00
|
|
|
gimp_item_resize (GIMP_ITEM (layer), gimage->width, gimage->height,
|
|
|
|
offset_x, offset_y);
|
1999-11-27 14:00:26 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
1999-11-27 14:00:26 +00:00
|
|
|
floating_sel_rigor (layer, TRUE);
|
|
|
|
|
2003-02-13 11:23:50 +00:00
|
|
|
gimp_image_undo_group_end (gimage);
|
1999-11-27 14:00:26 +00:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
BoundSeg *
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_boundary (GimpLayer *layer,
|
|
|
|
gint *num_segs)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2003-05-08 11:52:31 +00:00
|
|
|
GimpItem *item;
|
1997-11-24 22:05:25 +00:00
|
|
|
BoundSeg *new_segs;
|
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* Create the four boundary segments that encompass this
|
|
|
|
* layer's boundary.
|
|
|
|
*/
|
2001-01-28 16:44:22 +00:00
|
|
|
new_segs = g_new (BoundSeg, 4);
|
1997-11-24 22:05:25 +00:00
|
|
|
*num_segs = 4;
|
|
|
|
|
|
|
|
/* if the layer is a floating selection */
|
2001-01-28 16:44:22 +00:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1999-08-22 11:45:31 +00:00
|
|
|
if (GIMP_IS_CHANNEL (layer->fs.drawable))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
/* if the owner drawable is a channel, just return nothing */
|
|
|
|
|
|
|
|
g_free (new_segs);
|
1997-11-24 22:05:25 +00:00
|
|
|
*num_segs = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
2001-01-28 16:44:22 +00:00
|
|
|
{
|
|
|
|
/* otherwise, set the layer to the owner drawable */
|
|
|
|
|
|
|
|
layer = GIMP_LAYER (layer->fs.drawable);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_segs[0].x1 = item->offset_x;
|
|
|
|
new_segs[0].y1 = item->offset_y;
|
|
|
|
new_segs[0].x2 = item->offset_x;
|
|
|
|
new_segs[0].y2 = item->offset_y + item->height;
|
1997-11-24 22:05:25 +00:00
|
|
|
new_segs[0].open = 1;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_segs[1].x1 = item->offset_x;
|
|
|
|
new_segs[1].y1 = item->offset_y;
|
|
|
|
new_segs[1].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[1].y2 = item->offset_y;
|
1997-11-24 22:05:25 +00:00
|
|
|
new_segs[1].open = 1;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_segs[2].x1 = item->offset_x + item->width;
|
|
|
|
new_segs[2].y1 = item->offset_y;
|
|
|
|
new_segs[2].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[2].y2 = item->offset_y + item->height;
|
1997-11-24 22:05:25 +00:00
|
|
|
new_segs[2].open = 0;
|
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
new_segs[3].x1 = item->offset_x;
|
|
|
|
new_segs[3].y1 = item->offset_y + item->height;
|
|
|
|
new_segs[3].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[3].y2 = item->offset_y + item->height;
|
1997-11-24 22:05:25 +00:00
|
|
|
new_segs[3].open = 0;
|
|
|
|
|
|
|
|
return new_segs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_invalidate_boundary (GimpLayer *layer)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-29 02:45:02 +00:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpChannel *mask;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Turn the current selection off */
|
2001-09-25 17:44:03 +00:00
|
|
|
gimp_image_selection_control (gimage, GIMP_SELECTION_OFF);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-02-08 19:22:46 +00:00
|
|
|
/* clear the affected region surrounding the layer */
|
2001-09-25 17:44:03 +00:00
|
|
|
gimp_image_selection_control (gimage, GIMP_SELECTION_LAYER_OFF);
|
1999-02-08 19:22:46 +00:00
|
|
|
|
2001-01-29 17:54:02 +00:00
|
|
|
/* get the selection mask channel */
|
2000-12-29 15:22:01 +00:00
|
|
|
mask = gimp_image_get_mask (gimage);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Only bother with the bounds if there is a selection */
|
2001-01-29 02:45:02 +00:00
|
|
|
if (! gimp_channel_is_empty (mask))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
1999-08-22 11:45:31 +00:00
|
|
|
mask->bounds_known = FALSE;
|
1997-11-24 22:05:25 +00:00
|
|
|
mask->boundary_known = FALSE;
|
|
|
|
}
|
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_invalidate (layer);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2002-04-12 12:29:51 +00:00
|
|
|
gboolean
|
2001-01-28 16:44:22 +00:00
|
|
|
gimp_layer_pick_correlate (GimpLayer *layer,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
Tile *tile;
|
|
|
|
Tile *mask_tile;
|
2001-01-28 16:44:22 +00:00
|
|
|
gint val;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* Is the point inside the layer?
|
|
|
|
* First transform the point to layer coordinates...
|
|
|
|
*/
|
2003-05-08 11:52:31 +00:00
|
|
|
x -= GIMP_ITEM (layer)->offset_x;
|
|
|
|
y -= GIMP_ITEM (layer)->offset_y;
|
2001-01-28 16:44:22 +00:00
|
|
|
|
2003-05-08 11:52:31 +00:00
|
|
|
if (x >= 0 && x < GIMP_ITEM (layer)->width &&
|
|
|
|
y >= 0 && y < GIMP_ITEM (layer)->height &&
|
2001-03-04 16:52:37 +00:00
|
|
|
gimp_drawable_get_visible (GIMP_DRAWABLE (layer)))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
/* If the point is inside, and the layer has no
|
|
|
|
* alpha channel, success!
|
|
|
|
*/
|
2002-01-31 16:47:20 +00:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
1997-11-24 22:05:25 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* Otherwise, determine if the alpha value at
|
|
|
|
* the given point is non-zero
|
|
|
|
*/
|
2000-12-03 18:15:08 +00:00
|
|
|
tile = tile_manager_get_tile (GIMP_DRAWABLE(layer)->tiles,
|
|
|
|
x, y, TRUE, FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
val = * ((guchar *) tile_data_pointer (tile,
|
|
|
|
x % TILE_WIDTH,
|
|
|
|
y % TILE_HEIGHT) +
|
|
|
|
tile_bpp (tile) - 1);
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
if (layer->mask)
|
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
guchar *ptr;
|
|
|
|
|
2000-12-03 18:15:08 +00:00
|
|
|
mask_tile = tile_manager_get_tile (GIMP_DRAWABLE(layer->mask)->tiles,
|
|
|
|
x, y, TRUE, FALSE);
|
1998-08-11 17:35:34 +00:00
|
|
|
ptr = tile_data_pointer (mask_tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
|
|
|
val = val * (*ptr) / 255;
|
1998-07-10 02:43:12 +00:00
|
|
|
tile_release (mask_tile, FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1998-07-10 02:43:12 +00:00
|
|
|
tile_release (tile, FALSE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
if (val > 63)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-22 11:45:31 +00:00
|
|
|
/**********************/
|
|
|
|
/* access functions */
|
|
|
|
/**********************/
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-01-28 16:44:22 +00:00
|
|
|
GimpLayerMask *
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_get_mask (const GimpLayer *layer)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-12-12 23:48:18 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
return layer->mask;
|
|
|
|
}
|
|
|
|
|
1999-08-22 11:45:31 +00:00
|
|
|
gboolean
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_is_floating_sel (const GimpLayer *layer)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-01-28 16:44:22 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
return (layer->fs.drawable != NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 17:24:47 +00:00
|
|
|
void
|
|
|
|
gimp_layer_set_opacity (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
gdouble opacity,
|
|
|
|
gboolean push_undo)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
if (layer->opacity != opacity)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
if (push_undo)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
gimp_image_undo_push_layer_opacity (gimage, NULL, layer);
|
|
|
|
}
|
|
|
|
|
2002-03-04 14:52:54 +00:00
|
|
|
layer->opacity = opacity;
|
2001-03-11 17:24:47 +00:00
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[OPACITY_CHANGED], 0);
|
2001-07-07 22:49:01 +00:00
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
2001-03-11 17:24:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_get_opacity (const GimpLayer *layer)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
2002-03-03 17:38:12 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), GIMP_OPACITY_OPAQUE);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
2002-06-06 19:07:59 +00:00
|
|
|
return layer->opacity;
|
2001-03-11 17:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-08 23:12:59 +00:00
|
|
|
gimp_layer_set_mode (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
GimpLayerModeEffects mode,
|
|
|
|
gboolean push_undo)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
|
|
|
if (layer->mode != mode)
|
|
|
|
{
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
if (push_undo)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
gimp_image_undo_push_layer_mode (gimage, NULL, layer);
|
|
|
|
}
|
|
|
|
|
2001-03-11 17:24:47 +00:00
|
|
|
layer->mode = mode;
|
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[MODE_CHANGED], 0);
|
2001-07-07 22:49:01 +00:00
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 11:52:31 +00:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
2001-03-11 17:24:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-08 23:12:59 +00:00
|
|
|
GimpLayerModeEffects
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_get_mode (const GimpLayer *layer)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
2001-12-08 23:12:59 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), GIMP_NORMAL_MODE);
|
2001-03-11 17:24:47 +00:00
|
|
|
|
|
|
|
return layer->mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_layer_set_preserve_trans (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
gboolean preserve,
|
|
|
|
gboolean push_undo)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
|
|
|
if (layer->preserve_trans != preserve)
|
|
|
|
{
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
if (push_undo)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
gimp_image_undo_push_layer_preserve_trans (gimage, NULL, layer);
|
|
|
|
}
|
|
|
|
|
2001-03-11 17:24:47 +00:00
|
|
|
layer->preserve_trans = preserve ? TRUE : FALSE;
|
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[PRESERVE_TRANS_CHANGED], 0);
|
2001-03-11 17:24:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_get_preserve_trans (const GimpLayer *layer)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
return layer->preserve_trans;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_layer_set_linked (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
gboolean linked,
|
|
|
|
gboolean push_undo)
|
2001-03-11 17:24:47 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2001-04-29 16:26:44 +00:00
|
|
|
if (layer->linked != linked)
|
|
|
|
{
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-17 18:02:41 +00:00
|
|
|
if (push_undo)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
gimp_image_undo_push_layer_linked (gimage, NULL, layer);
|
|
|
|
}
|
|
|
|
|
2001-04-29 16:26:44 +00:00
|
|
|
layer->linked = linked ? TRUE : FALSE;
|
|
|
|
|
2003-01-05 22:07:10 +00:00
|
|
|
g_signal_emit (layer, layer_signals[LINKED_CHANGED], 0);
|
2001-04-29 16:26:44 +00:00
|
|
|
}
|
2001-03-11 17:24:47 +00:00
|
|
|
}
|
|
|
|
|
1999-08-22 11:45:31 +00:00
|
|
|
gboolean
|
2001-12-12 23:48:18 +00:00
|
|
|
gimp_layer_get_linked (const GimpLayer *layer)
|
1998-01-22 07:02:57 +00:00
|
|
|
{
|
2001-03-11 17:24:47 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
1998-01-22 07:02:57 +00:00
|
|
|
return layer->linked;
|
|
|
|
}
|