1998-06-30 23:31:32 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-05-27 06:28:40 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-09-24 09:19:57 +08:00
|
|
|
#include <stdlib.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#include <string.h>
|
2000-05-27 06:28:40 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
#include "gimpdrawableP.h"
|
|
|
|
#include "gimpsignal.h"
|
|
|
|
#include "gimage.h"
|
|
|
|
#include "gimage_mask.h"
|
1998-12-22 14:03:53 +08:00
|
|
|
#include "gimpparasite.h"
|
1998-10-30 18:21:33 +08:00
|
|
|
#include "parasitelist.h"
|
gave parasite undo a MISC_UNDO class for now so it compiles
* app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now
so it compiles
* app/tools_cmds.c: fix crop invoker to give correct args to
crop_image
* app/color_cmds.c: s/GRAY/GRAY_LUT/g;
* app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs,
brush_select_dialog, s/active_dialogs/brush_active_dialogs/
* app/gimage_cmds.[ch]
* app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate
function from gimage_cmds to channel_ops, export offset and duplicate
* app/gimpbrushlist.[ch]: removed PDB procs
* app/gradient.[ch]: removed PDB procs,
* app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients,
grad_active_dialogs, gradient_select_dialog
* app/gradient_select.c: removed PDB procs,
s/active_dialogs/grad_active_dialogs/
* app/patterns.[ch]: removed PDB procs
* app/pattern_select.[ch]: removed PDB procs,
s/active_dialogs/pattern_active_dialogs/
* app/procedural_db.c: removed PDB procs and supporting functions
* app/procedrual_db.h: fiddled with enums
* app/channel_cmds.[ch]
* app/drawable_cmds.[ch]
* app/parasite_cmds.[ch]: pdbgenned now, removed header files
* app/gimpparasite.c: minor cleanup
* app/internal_procs.c: use pdbgen stuff
* app/tools_cmds.c
* app/text_tool_cmds.c: updated from pdbgen
* app/brushes_cmds.c
* app/brush_select_cmds.c
* app/gradient_cmds.c
* app/gradient_select_cmds.c
* app/patterns_cmds.c
* app/pattern_select_cmds.c
* app/procedural_db_cmds.c: new pdbgen files
* app/Makefile.am: file shuffle (see above)
-Yosh
1999-04-24 04:54:02 +08:00
|
|
|
#include "undo.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
#include "libgimp/gimpmath.h"
|
2000-05-27 09:30:21 +08:00
|
|
|
#include "libgimp/gimpparasite.h"
|
2000-05-27 06:28:40 +08:00
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
1998-06-30 23:31:32 +08:00
|
|
|
INVALIDATE_PREVIEW,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static void gimp_drawable_class_init (GimpDrawableClass *klass);
|
|
|
|
static void gimp_drawable_init (GimpDrawable *drawable);
|
|
|
|
static void gimp_drawable_destroy (GtkObject *object);
|
|
|
|
|
|
|
|
static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static GimpDrawableClass *parent_class = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
GtkType
|
1999-09-02 09:41:18 +08:00
|
|
|
gimp_drawable_get_type (void)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
|
|
|
static GtkType type;
|
2000-05-27 06:28:40 +08:00
|
|
|
GIMP_TYPE_INIT (type,
|
|
|
|
GimpDrawable,
|
|
|
|
GimpDrawableClass,
|
|
|
|
gimp_drawable_init,
|
|
|
|
gimp_drawable_class_init,
|
|
|
|
GIMP_TYPE_OBJECT);
|
1998-06-30 23:31:32 +08:00
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_class_init (GimpDrawableClass *class)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
1999-08-22 19:45:31 +08:00
|
|
|
GtkType type = GIMP_TYPE_DRAWABLE;
|
|
|
|
|
2000-03-09 19:58:03 +08:00
|
|
|
object_class = GTK_OBJECT_CLASS (class);
|
1998-06-30 23:31:32 +08:00
|
|
|
parent_class = gtk_type_class (GIMP_TYPE_OBJECT);
|
|
|
|
|
|
|
|
gimp_drawable_signals[INVALIDATE_PREVIEW] =
|
|
|
|
gimp_signal_new ("invalidate_pr", GTK_RUN_LAST, type,
|
|
|
|
GTK_SIGNAL_OFFSET(GimpDrawableClass,
|
|
|
|
invalidate_preview),
|
|
|
|
gimp_sigtype_void);
|
|
|
|
|
|
|
|
gtk_object_class_add_signals (object_class, gimp_drawable_signals, LAST_SIGNAL);
|
|
|
|
|
|
|
|
object_class->destroy = gimp_drawable_destroy;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Static variables
|
|
|
|
*/
|
1999-08-22 19:45:31 +08:00
|
|
|
static gint global_drawable_ID = 1;
|
1998-06-30 23:31:32 +08:00
|
|
|
static GHashTable *gimp_drawable_table = NULL;
|
|
|
|
|
|
|
|
/**************************/
|
|
|
|
/* Function definitions */
|
|
|
|
|
|
|
|
GimpDrawable*
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_get_ID (gint drawable_id)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
|
|
|
if (gimp_drawable_table == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return (GimpDrawable*) g_hash_table_lookup (gimp_drawable_table,
|
|
|
|
(gpointer) drawable_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_merge_shadow (GimpDrawable *drawable,
|
|
|
|
gint undo)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
PixelRegion shadowPR;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
g_return_if_fail (gimage != NULL);
|
|
|
|
g_return_if_fail (gimage->shadow != NULL);
|
1999-01-28 06:00:44 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
/* A useful optimization here is to limit the update to the
|
|
|
|
* extents of the selection mask, as it cannot extend beyond
|
|
|
|
* them.
|
|
|
|
*/
|
|
|
|
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
|
|
|
pixel_region_init (&shadowPR, gimage->shadow, x1, y1,
|
|
|
|
(x2 - x1), (y2 - y1), FALSE);
|
|
|
|
gimage_apply_image (gimage, drawable, &shadowPR, undo, OPAQUE_OPACITY,
|
|
|
|
REPLACE_MODE, NULL, x1, y1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_fill (GimpDrawable *drawable,
|
|
|
|
guchar r,
|
|
|
|
guchar g,
|
|
|
|
guchar b,
|
|
|
|
guchar a)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
PixelRegion destPR;
|
|
|
|
guchar c[MAX_CHANNELS];
|
|
|
|
guchar i;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (gimage != NULL);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
switch (gimp_drawable_type (drawable))
|
|
|
|
{
|
|
|
|
case RGB_GIMAGE: case RGBA_GIMAGE:
|
|
|
|
c[RED_PIX] = r;
|
|
|
|
c[GREEN_PIX] = g;
|
|
|
|
c[BLUE_PIX] = b;
|
|
|
|
if (gimp_drawable_type (drawable) == RGBA_GIMAGE)
|
|
|
|
c[ALPHA_PIX] = a;
|
|
|
|
break;
|
|
|
|
case GRAY_GIMAGE: case GRAYA_GIMAGE:
|
|
|
|
c[GRAY_PIX] = r;
|
|
|
|
if (gimp_drawable_type (drawable) == GRAYA_GIMAGE)
|
|
|
|
c[ALPHA_G_PIX] = a;
|
|
|
|
break;
|
|
|
|
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
|
|
|
|
c[RED_PIX] = r;
|
|
|
|
c[GREEN_PIX] = g;
|
|
|
|
c[BLUE_PIX] = b;
|
|
|
|
gimage_transform_color (gimage, drawable, c, &i, RGB);
|
|
|
|
c[INDEXED_PIX] = i;
|
|
|
|
if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE)
|
|
|
|
c[ALPHA_I_PIX] = a;
|
|
|
|
break;
|
|
|
|
default:
|
1998-11-23 22:47:09 +08:00
|
|
|
g_message (_("Can't fill unknown image type."));
|
1998-06-30 23:31:32 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixel_region_init (&destPR,
|
|
|
|
gimp_drawable_data (drawable),
|
|
|
|
0, 0,
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_width (drawable),
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_height (drawable),
|
|
|
|
TRUE);
|
|
|
|
color_region (&destPR, c);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_mask_bounds (GimpDrawable *drawable,
|
1999-08-22 19:45:31 +08:00
|
|
|
gint *x1,
|
|
|
|
gint *y1,
|
|
|
|
gint *x2,
|
|
|
|
gint *y2)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
GimpImage *gimage;
|
1999-08-22 19:45:31 +08:00
|
|
|
gint off_x, off_y;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
g_return_val_if_fail (gimage != NULL, FALSE);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
if (gimage_mask_bounds (gimage, x1, y1, x2, y2))
|
|
|
|
{
|
|
|
|
gimp_drawable_offsets (drawable, &off_x, &off_y);
|
1999-08-22 19:45:31 +08:00
|
|
|
*x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
*y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable));
|
1999-08-22 19:45:31 +08:00
|
|
|
*x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
*y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
*x2 = gimp_drawable_width (drawable);
|
1998-06-30 23:31:32 +08:00
|
|
|
*y2 = gimp_drawable_height (drawable);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-06-04 02:19:22 +08:00
|
|
|
gimp_drawable_invalidate_preview (GimpDrawable *drawable,
|
|
|
|
gboolean emit_signal)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
GimpImage *gimage;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
drawable->preview_valid = FALSE;
|
2000-06-04 02:19:22 +08:00
|
|
|
|
|
|
|
if (emit_signal)
|
|
|
|
gtk_signal_emit (GTK_OBJECT (drawable),
|
|
|
|
gimp_drawable_signals[INVALIDATE_PREVIEW]);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
gimage->comp_preview_valid[0] = FALSE;
|
|
|
|
gimage->comp_preview_valid[1] = FALSE;
|
|
|
|
gimage->comp_preview_valid[2] = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GimpImage *
|
|
|
|
gimp_drawable_gimage (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
return drawable->gimage;
|
|
|
|
}
|
|
|
|
|
1998-10-14 10:54:02 +08:00
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_set_gimage (GimpDrawable *drawable,
|
|
|
|
GimpImage *gimage)
|
1998-10-14 10:54:02 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
1999-08-22 19:45:31 +08:00
|
|
|
|
1998-10-14 10:54:02 +08:00
|
|
|
if (gimage == NULL)
|
|
|
|
drawable->tattoo = 0;
|
1998-12-16 19:23:30 +08:00
|
|
|
else if (drawable->tattoo == 0 || drawable->gimage != gimage )
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->tattoo = gimp_image_get_new_tattoo (gimage);
|
|
|
|
|
1998-12-16 19:23:30 +08:00
|
|
|
drawable->gimage = gimage;
|
1998-10-14 10:54:02 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
|
|
|
gimp_drawable_has_alpha (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
|
|
|
return drawable->has_alpha;
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
1998-10-14 10:54:02 +08:00
|
|
|
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
GimpImageType
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_type (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->type;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
GimpImageType
|
|
|
|
gimp_drawable_type_with_alpha (GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
GimpImageType type;
|
|
|
|
gboolean has_alpha;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-01-31 21:07:39 +08:00
|
|
|
type = gimp_drawable_type (drawable);
|
|
|
|
has_alpha = gimp_drawable_has_alpha (drawable);
|
1999-08-22 19:45:31 +08:00
|
|
|
|
|
|
|
if (has_alpha)
|
|
|
|
return type;
|
1998-06-30 23:31:32 +08:00
|
|
|
else
|
1999-08-22 19:45:31 +08:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RGB_GIMAGE:
|
|
|
|
return RGBA_GIMAGE; break;
|
|
|
|
case GRAY_GIMAGE:
|
|
|
|
return GRAYA_GIMAGE; break;
|
|
|
|
case INDEXED_GIMAGE:
|
|
|
|
return INDEXEDA_GIMAGE; break;
|
Honest, guv, it's not a feature - it's a tightly integrated package of
Mon Sep 20 12:51:30 EDT 1999 Austin Donnelly <austin@gimp.org>
Honest, guv, it's not a feature - it's a tightly integrated
package of undo system cleanups and fixes.
NEW FILES:
* app/undo_history.c: window showing recent undo (and redo) steps
available.
* app/undo_types.h: broken out of undo.h to fix circular includes.
MODIFIED FILES:
* app/Makefile.am: compile undo_history.c
* app/channel.h: use enum for channel undo type, not just magic
numbers.
* app/layer.h: same for layer undos.
* app/commands.c: edit_show_undo_history_cmd_callback() function to
pull up undo history window.
* app/commands.h: prototype for above.
* app/gdisplay.c: make undo / redo menu items sensitive according
to whether they would do anything. Would be easy to change
the text to say what would be undone/redone, but I don't know
the GTK.
* app/gimpimage.c: new signal emitted by gimage:
UNDO_EVENT. gimp_image_undo_event() function to emit it.
* app/gimpimage.h: prototype for above.
* app/gimpimageP.h: pushing_undo_group member is now an undo_type,
not an int. Keep undo history widget here too (if created).
* app/menus.c: add "Edit/Undo history..." to image menu.
* app/undo.c: new types: enums undo_type and undo_state rather than
ints and magic numbers. All undo_pop_* and undo_free_*
functions made static. New static function
undo_type_to_name(). Issue undo event signals on various
important events (eg undo pushed, undo popped etc).
undo_push() now takes a "dirties_image" arg to say whether
image should be dirtied. Layer moves now dirty the image. A
couple of g_return_if_fails () on undo_pop and undo_redo to
assert we're not in the middle of an undo group.
undo_get_{undo,redo}_name() to peek at names of top items on
undo and redo stacks resp. undo_map_over_{undo,redo}_stack()
to run a function for each item or group on stack. Layer and
channel undos use symbolic names rather than 0 or 1. Array
mapping undo types to names.
* app/undo.h: split out undo types to undo_types.h. Prototypes
for functions described above. undo_event_t enum.
undo_history_new() prototype lives here too.
Random other fixes:
* app/gimpdrawable.c
* app/image_render.c: default labels in switches to keep egcs happy.
* app/nav_window.c: some fixes to (sort of) cope with image res !=
screen res. Still needs work to handle non-square pixels
properly.
* app/paths_dialog.c: bad idea to call gimp_image_dirty()
directly. Even though it's currently commented out.
1999-09-21 01:15:20 +08:00
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
|
|
|
return 0;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_visible (GimpDrawable *drawable)
|
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
return drawable->visible;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gchar *
|
1998-09-24 09:19:57 +08:00
|
|
|
gimp_drawable_get_name (GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
return drawable->name;
|
|
|
|
}
|
|
|
|
|
1998-09-24 09:19:57 +08:00
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_set_name (GimpDrawable *drawable,
|
|
|
|
gchar *name)
|
1998-09-24 09:19:57 +08:00
|
|
|
{
|
|
|
|
GSList *list, *listb, *base_list;
|
|
|
|
GimpDrawable *drawableb;
|
1999-08-22 19:45:31 +08:00
|
|
|
gint number = 1;
|
|
|
|
gchar *newname;
|
|
|
|
gchar *ext;
|
|
|
|
gchar numberbuf[20];
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
1999-12-21 08:36:07 +08:00
|
|
|
g_return_if_fail (name != NULL);
|
1998-09-24 09:19:57 +08:00
|
|
|
|
|
|
|
if (drawable->name)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
g_free (drawable->name);
|
|
|
|
drawable->name = NULL;
|
|
|
|
}
|
|
|
|
|
1998-09-24 09:19:57 +08:00
|
|
|
if (drawable->gimage == 0 || drawable->gimage->layers == 0)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
/* no other layers to check name against */
|
|
|
|
drawable->name = g_strdup (name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_LAYER (drawable))
|
1998-09-24 09:19:57 +08:00
|
|
|
base_list = drawable->gimage->layers;
|
1999-08-22 19:45:31 +08:00
|
|
|
else if (GIMP_IS_CHANNEL (drawable))
|
1998-09-24 09:19:57 +08:00
|
|
|
base_list = drawable->gimage->channels;
|
|
|
|
else
|
|
|
|
base_list = NULL;
|
|
|
|
|
|
|
|
list = base_list;
|
|
|
|
while (list)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
drawableb = GIMP_DRAWABLE (list->data);
|
|
|
|
if (drawable != drawableb &&
|
|
|
|
strcmp (name, gimp_drawable_get_name (drawableb)) == 0)
|
|
|
|
{ /* names conflict */
|
|
|
|
newname = g_malloc (strlen (name) + 10); /* if this aint enough
|
|
|
|
yer screwed */
|
|
|
|
strcpy (newname, name);
|
|
|
|
if ((ext = strrchr (newname, '#')))
|
|
|
|
{
|
|
|
|
number = atoi(ext+1);
|
|
|
|
/* Check if there really was the number we think after the # */
|
|
|
|
sprintf (numberbuf, "#%d", number);
|
|
|
|
if (strcmp (ext, numberbuf) != 0)
|
|
|
|
{
|
|
|
|
/* No, so just ignore the # */
|
|
|
|
number = 1;
|
|
|
|
ext = &newname[strlen (newname)];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
number = 1;
|
|
|
|
ext = &newname[strlen (newname)];
|
|
|
|
}
|
|
|
|
sprintf (ext, "#%d", number+1);
|
1998-09-24 09:19:57 +08:00
|
|
|
listb = base_list;
|
1999-08-22 19:45:31 +08:00
|
|
|
while (listb) /* make sure the new name is unique */
|
|
|
|
{
|
|
|
|
drawableb = GIMP_DRAWABLE (listb->data);
|
|
|
|
if (drawable !=
|
|
|
|
drawableb && strcmp (newname,
|
|
|
|
gimp_drawable_get_name(drawableb)) == 0)
|
|
|
|
{
|
|
|
|
number++;
|
|
|
|
sprintf (ext, "#%d", number+1);
|
|
|
|
/* Rescan from beginning */
|
|
|
|
listb = base_list;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
listb = listb->next;
|
|
|
|
}
|
|
|
|
drawable->name = g_strdup (newname);
|
|
|
|
g_free (newname);
|
|
|
|
return;
|
1998-09-24 09:19:57 +08:00
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
list = list->next;
|
1998-09-24 09:19:57 +08:00
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->name = g_strdup (name);
|
1998-09-24 09:19:57 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *
|
|
|
|
gimp_drawable_get_color_at (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1999-02-16 16:53:54 +08:00
|
|
|
{
|
|
|
|
Tile *tile;
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *src;
|
|
|
|
guchar *dest;
|
1999-02-16 16:53:54 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
2000-03-02 06:05:22 +08:00
|
|
|
g_return_val_if_fail (gimp_drawable_gimage (drawable) ||
|
|
|
|
!gimp_drawable_is_indexed (drawable), NULL);
|
2000-03-09 19:58:03 +08:00
|
|
|
|
|
|
|
/* do not make this a g_return_if_fail() */
|
|
|
|
if ( !(x >= 0 && x < drawable->width && y >= 0 && y < drawable->height))
|
|
|
|
return NULL;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
dest = g_new (guchar, 5);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
tile = tile_manager_get_tile (gimp_drawable_data (drawable), x, y,
|
|
|
|
TRUE, FALSE);
|
|
|
|
src = tile_data_pointer (tile, x % TILE_WIDTH, y % TILE_HEIGHT);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_image_get_color (gimp_drawable_gimage (drawable),
|
1999-02-16 16:53:54 +08:00
|
|
|
gimp_drawable_type (drawable), dest, src);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
|
|
|
if (TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
1999-02-16 16:53:54 +08:00
|
|
|
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
|
|
|
else
|
|
|
|
dest[3] = 255;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-10-17 08:07:55 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1999-02-16 16:53:54 +08:00
|
|
|
dest[4] = src[0];
|
|
|
|
else
|
|
|
|
dest[4] = 0;
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
tile_release (tile, FALSE);
|
2000-02-17 19:44:27 +08:00
|
|
|
|
1999-02-16 16:53:54 +08:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_parasite_find (const GimpDrawable *drawable,
|
1999-08-22 19:45:31 +08:00
|
|
|
const gchar *name)
|
1998-10-08 16:15:21 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
return parasite_list_find (drawable->parasites, name);
|
1998-10-08 16:15:21 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
static void
|
2000-05-27 06:28:40 +08:00
|
|
|
list_func (gchar *key,
|
|
|
|
GimpParasite *p,
|
|
|
|
gchar ***cur)
|
1999-02-14 02:19:44 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
*(*cur)++ = (gchar *) g_strdup (key);
|
1999-02-14 02:19:44 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gchar **
|
|
|
|
gimp_drawable_parasite_list (GimpDrawable *drawable,
|
|
|
|
gint *count)
|
1999-02-14 02:19:44 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
gchar **list;
|
|
|
|
gchar **cur;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
|
|
|
*count = parasite_list_length (drawable->parasites);
|
2000-02-17 19:44:27 +08:00
|
|
|
cur = list = g_new (gchar *, *count);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
parasite_list_foreach (drawable->parasites, (GHFunc) list_func, &cur);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
1998-10-08 16:15:21 +08:00
|
|
|
void
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_parasite_attach (GimpDrawable *drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *parasite)
|
1998-10-08 16:15:21 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1999-04-23 14:07:09 +08:00
|
|
|
/* only set the dirty bit manually if we can be saved and the new
|
|
|
|
parasite differs from the current one and we arn't undoable */
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (parasite))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
/* do a group in case we have attach_parent set */
|
|
|
|
undo_push_group_start (drawable->gimage, PARASITE_ATTACH_UNDO);
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
undo_push_drawable_parasite (drawable->gimage, drawable, parasite);
|
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
else if (gimp_parasite_is_persistent (parasite) &&
|
|
|
|
!gimp_parasite_compare (parasite,
|
|
|
|
gimp_drawable_parasite_find
|
|
|
|
(drawable, gimp_parasite_name (parasite))))
|
1999-08-23 22:34:58 +08:00
|
|
|
undo_push_cantundo (drawable->gimage, _("parasite attach to drawable"));
|
1999-08-22 19:45:31 +08:00
|
|
|
|
|
|
|
parasite_list_add (drawable->parasites, parasite);
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
parasite_shift_parent (parasite);
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_image_parasite_attach (drawable->gimage, parasite);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
else if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_GRANDPARENT))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
parasite_shift_parent (parasite);
|
|
|
|
parasite_shift_parent (parasite);
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_parasite_attach (parasite);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (parasite))
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
undo_push_group_end (drawable->gimage);
|
|
|
|
}
|
1998-10-08 16:15:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_parasite_detach (GimpDrawable *drawable,
|
1999-08-22 19:45:31 +08:00
|
|
|
const gchar *parasite)
|
1998-10-08 16:15:21 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *p;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
if (!(p = parasite_list_find (drawable->parasites, parasite)))
|
1998-12-16 19:23:30 +08:00
|
|
|
return;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_undoable (p))
|
1999-04-23 14:07:09 +08:00
|
|
|
undo_push_drawable_parasite_remove (drawable->gimage, drawable,
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_name (p));
|
|
|
|
else if (gimp_parasite_is_persistent (p))
|
1999-08-23 22:34:58 +08:00
|
|
|
undo_push_cantundo (drawable->gimage, _("detach parasite from drawable"));
|
1999-08-22 19:45:31 +08:00
|
|
|
|
|
|
|
parasite_list_remove (drawable->parasites, parasite);
|
1998-10-08 16:15:21 +08:00
|
|
|
}
|
|
|
|
|
1998-10-30 18:21:33 +08:00
|
|
|
Tattoo
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_get_tattoo (const GimpDrawable *drawable)
|
1998-10-14 10:54:02 +08:00
|
|
|
{
|
2000-01-31 21:07:39 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), 0);
|
|
|
|
|
1998-10-14 10:54:02 +08:00
|
|
|
return drawable->tattoo;
|
|
|
|
}
|
1998-10-08 16:15:21 +08:00
|
|
|
|
2000-02-16 07:49:03 +08:00
|
|
|
void
|
2000-02-17 19:44:27 +08:00
|
|
|
gimp_drawable_set_tattoo (GimpDrawable *drawable, Tattoo val)
|
2000-02-16 07:49:03 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
drawable->tattoo = val;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1999-10-25 04:49:09 +08:00
|
|
|
gimp_drawable_is_rgb (GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (gimp_drawable_type (drawable) == RGBA_GIMAGE ||
|
|
|
|
gimp_drawable_type (drawable) == RGB_GIMAGE)
|
1999-08-22 19:45:31 +08:00
|
|
|
return TRUE;
|
1998-06-30 23:31:32 +08:00
|
|
|
else
|
1999-08-22 19:45:31 +08:00
|
|
|
return FALSE;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_is_gray (GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (gimp_drawable_type (drawable) == GRAYA_GIMAGE ||
|
|
|
|
gimp_drawable_type (drawable) == GRAY_GIMAGE)
|
1999-08-22 19:45:31 +08:00
|
|
|
return TRUE;
|
1998-06-30 23:31:32 +08:00
|
|
|
else
|
1999-08-22 19:45:31 +08:00
|
|
|
return FALSE;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
1999-10-17 08:07:55 +08:00
|
|
|
gimp_drawable_is_indexed (GimpDrawable *drawable)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE ||
|
|
|
|
gimp_drawable_type (drawable) == INDEXED_GIMAGE)
|
1999-08-22 19:45:31 +08:00
|
|
|
return TRUE;
|
1998-06-30 23:31:32 +08:00
|
|
|
else
|
1999-08-22 19:45:31 +08:00
|
|
|
return FALSE;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
gimp_drawable_data (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
return drawable->tiles;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
gimp_drawable_shadow (GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (! (gimage = gimp_drawable_gimage (drawable)))
|
|
|
|
return NULL;
|
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
return gimage_shadow (gimage, drawable->width, drawable->height,
|
|
|
|
drawable->bytes);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
gimp_drawable_bytes (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->bytes;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gint
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_width (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->width;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gint
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_height (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), -1);
|
|
|
|
|
|
|
|
return drawable->height;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_offsets (GimpDrawable *drawable,
|
|
|
|
gint *off_x,
|
|
|
|
gint *off_y)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
|
|
|
*off_x = drawable->offset_x;
|
|
|
|
*off_y = drawable->offset_y;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *
|
1998-06-30 23:31:32 +08:00
|
|
|
gimp_drawable_cmap (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
GimpImage *gimage;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
|
|
|
|
|
|
|
|
gimage = gimp_drawable_gimage (drawable);
|
|
|
|
g_return_val_if_fail (gimage != NULL, NULL);
|
|
|
|
|
|
|
|
return gimage->cmap;
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_drawable_deallocate (GimpDrawable *drawable)
|
|
|
|
{
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (drawable->tiles)
|
|
|
|
tile_manager_destroy (drawable->tiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_init (GimpDrawable *drawable)
|
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->name = NULL;
|
|
|
|
drawable->tiles = NULL;
|
|
|
|
drawable->visible = FALSE;
|
|
|
|
drawable->width = 0;
|
|
|
|
drawable->height = 0;
|
|
|
|
drawable->offset_x = 0;
|
|
|
|
drawable->offset_y = 0;
|
|
|
|
drawable->bytes = 0;
|
2000-02-17 19:44:27 +08:00
|
|
|
drawable->ID = global_drawable_ID++;
|
|
|
|
drawable->tattoo = 0;
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->gimage = NULL;
|
|
|
|
drawable->type = -1;
|
|
|
|
drawable->has_alpha = FALSE;
|
1999-06-24 07:01:14 +08:00
|
|
|
drawable->preview_cache = NULL;
|
1998-06-30 23:31:32 +08:00
|
|
|
drawable->preview_valid = FALSE;
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->parasites = parasite_list_new ();
|
2000-02-17 19:44:27 +08:00
|
|
|
drawable->preview_cache = NULL;
|
|
|
|
drawable->preview_valid = FALSE;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (gimp_drawable_table == NULL)
|
|
|
|
gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL);
|
1999-08-22 19:45:31 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_hash_table_insert (gimp_drawable_table,
|
|
|
|
(gpointer) drawable->ID,
|
1998-06-30 23:31:32 +08:00
|
|
|
(gpointer) drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_drawable_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
GimpDrawable *drawable;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (object));
|
|
|
|
|
|
|
|
drawable = GIMP_DRAWABLE (object);
|
|
|
|
|
|
|
|
g_hash_table_remove (gimp_drawable_table, (gpointer) drawable->ID);
|
|
|
|
|
|
|
|
if (drawable->name)
|
|
|
|
g_free (drawable->name);
|
|
|
|
|
|
|
|
if (drawable->tiles)
|
|
|
|
tile_manager_destroy (drawable->tiles);
|
|
|
|
|
1999-06-24 07:01:14 +08:00
|
|
|
if (drawable->preview_cache)
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_preview_cache_invalidate (&drawable->preview_cache);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
1998-10-08 16:15:21 +08:00
|
|
|
if (drawable->parasites)
|
1999-08-22 19:45:31 +08:00
|
|
|
gtk_object_unref (GTK_OBJECT (drawable->parasites));
|
1998-10-08 16:15:21 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
1999-08-22 19:45:31 +08:00
|
|
|
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
1998-06-30 23:31:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_configure (GimpDrawable *drawable,
|
|
|
|
GimpImage *gimage,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpImageType type,
|
|
|
|
gchar *name)
|
1998-06-30 23:31:32 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
gint bpp;
|
|
|
|
gboolean alpha;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
2000-02-17 19:44:27 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
if (!name)
|
1998-11-23 22:47:09 +08:00
|
|
|
name = _("unnamed");
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case RGB_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 3; alpha = FALSE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
case GRAY_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 1; alpha = FALSE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
case RGBA_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 4; alpha = TRUE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
case GRAYA_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 2; alpha = TRUE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
case INDEXED_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 1; alpha = FALSE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
case INDEXEDA_GIMAGE:
|
1999-08-22 19:45:31 +08:00
|
|
|
bpp = 2; alpha = TRUE; break;
|
1998-06-30 23:31:32 +08:00
|
|
|
default:
|
1998-11-23 22:47:09 +08:00
|
|
|
g_message (_("Layer type %d not supported."), type);
|
1998-06-30 23:31:32 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->name = NULL;
|
|
|
|
drawable->width = width;
|
|
|
|
drawable->height = height;
|
|
|
|
drawable->bytes = bpp;
|
|
|
|
drawable->type = type;
|
1998-06-30 23:31:32 +08:00
|
|
|
drawable->has_alpha = alpha;
|
1999-08-22 19:45:31 +08:00
|
|
|
drawable->offset_x = 0;
|
|
|
|
drawable->offset_y = 0;
|
1998-06-30 23:31:32 +08:00
|
|
|
|
|
|
|
if (drawable->tiles)
|
|
|
|
tile_manager_destroy (drawable->tiles);
|
|
|
|
drawable->tiles = tile_manager_new (width, height, bpp);
|
|
|
|
drawable->visible = TRUE;
|
|
|
|
|
1998-10-14 10:54:02 +08:00
|
|
|
if (gimage)
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_set_gimage (drawable, gimage);
|
1998-06-30 23:31:32 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_set_name (drawable, name);
|
1998-09-24 09:19:57 +08:00
|
|
|
|
1998-06-30 23:31:32 +08:00
|
|
|
/* preview variables */
|
1999-06-24 07:01:14 +08:00
|
|
|
drawable->preview_cache = NULL;
|
1998-06-30 23:31:32 +08:00
|
|
|
drawable->preview_valid = FALSE;
|
|
|
|
}
|