start collecting some core stuff to libgimpim.a

Started separating crud out of drawables.

	Isolated the id system of images entirely within pdb. Even the
	window titles and menus use pointers instead of ids. Should at
	least remind people that this is a developers' version. :)
This commit is contained in:
Lauri Alanko 1998-06-30 15:31:32 +00:00
parent 5c5c73f3f5
commit ef3e162eae
109 changed files with 1777 additions and 1083 deletions

View File

@ -1,3 +1,51 @@
Tue Jun 30 18:08:01 EEST 1998 Lauri Alanko <nether@gimp.org>
* app/Makefile.am: start collecting some core stuff to libgimpim.a
* app/gdisplay.c (gdisplays_update_area): remove an (apparently)
redundant display area
* app/drawable.c:
* app/drawable.h:
* app/gimpdrawable.c:
* app/gimpdrawable.h:
* app/gimpdrawableF.h:
* app/gimpdrawableP.h:
Started separating crud out of drawables.
* app/blend.c:
* app/bucket_fill.c:
* app/channel.h:
* app/clone.c:
* app/commands.c:
* app/disp_callbacks.c:
* app/drawable_cmds.c:
* app/drawable_pvt.h:
* app/fileops.c:
* app/floating_sel.c:
* app/gimage.c:
* app/gimage_cmds.c:
* app/gimage_mask.c:
* app/gimpimage.c:
* app/gimpimage.h:
* app/gimpimageP.h:
* app/indexed_palette.c:
* app/interface.c:
* app/interface.h:
* app/invert.c:
* app/layer.c:
* app/layer.h:
* app/layers_dialog.c:
* app/plug_in.c:
* app/procedural_db.c:
* app/procedural_db.h:
* app/transform_core.c:
* app/xcf.c:
Isolated the id system of images entirely within pdb. Even the
window titles and menus use pointers instead of ids. Should at
least remind people that this is a developers' version. :)
Tue Jun 30 04:00:38 EEST 1998 Lauri Alanko <nether@gimp.org>
* app/commands.c:

View File

@ -3,6 +3,9 @@
scriptdata =
bin_PROGRAMS = gimp
noinst_LIBRARIES = libgimpim.a
libgimpim_a_SOURCES = gimpobject.c gimpimage.c gimpsignal.c gimpdrawable.c
gimp_SOURCES = \
about_dialog.c \
@ -139,14 +142,8 @@ gimp_SOURCES = \
gimage_mask.h \
gimage_mask_cmds.c \
gimage_mask_cmds.h \
gimpimage.c \
gimpimage.h \
gimpobject.c \
gimpobject.h \
gimprc.c \
gimprc.h \
gimpsignal.c \
gimpsignal.h \
global_edit.c \
global_edit.h \
gradient.c \
@ -313,6 +310,7 @@ INCLUDES = \
-I$(includedir)
LDADD = \
libgimpim.a \
$(top_builddir)/libgimp/libgimpi.a \
$(GTK_LIBS) \
$(THREAD_LIBS) \

View File

@ -70,7 +70,7 @@ typedef struct
{
GtkWidget * shell;
Resize * resize;
int gimage_id;
GimpImage* gimage;
} ImageResize;
/* external functions */
@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize->gimage_id = gdisp->gimage->ID;
image_resize->gimage = gdisp->gimage;
image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale->gimage_id = gdisp->gimage->ID;
image_scale->gimage = gdisp->gimage;
image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w,
GImage *gimage;
image_resize = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL)
if ((gimage = image_resize->gimage) != NULL)
{
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w,
GImage *gimage;
image_scale = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL)
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -602,7 +602,7 @@ blend_button_release (Tool *tool,
{
return_vals = procedural_db_run_proc ("gimp_blend",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
PDB_INT32, (gint32) blend_options->blend_mode,
PDB_INT32, (gint32) blend_options->paint_mode,

View File

@ -313,7 +313,8 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr)
return_vals = procedural_db_run_proc ("gimp_bucket_fill",
&nreturn_vals,
PDB_IMAGE, gdisp->gimage->ID,
PDB_IMAGE,
pdb_image_to_id(gdisp->gimage),
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)),
PDB_INT32, (gint32) fill_mode,
PDB_INT32, (gint32) bucket_options->paint_mode,

View File

@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *);
extern int channel_get_count;
/* from drawable.c */
Channel * drawable_channel (GimpDrawable *);
#define drawable_channel GIMP_IS_CHANNEL
#endif /* __CHANNEL_H__ */

View File

@ -72,7 +72,7 @@ static int offset_x = 0; /* */
static int offset_y = 0; /* offset for cloning */
static int first = TRUE;
static int trans_tx, trans_ty; /* transformed target */
static int src_gdisp_ID = -1; /* ID of source gdisplay */
static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */
static GimpDrawable * src_drawable_ = NULL; /* source drawable */
static CloneOptions *clone_options = NULL;
@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core,
case INIT_PAINT :
if (paint_core->state & ControlMask)
{
src_gdisp_ID = gdisp->ID;
the_src_gdisp = gdisp;
src_drawable_ = drawable;
src_x = paint_core->curx;
src_y = paint_core->cury;
@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core,
}
/* Calculate the coordinates of the target */
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
src_gdisp = the_src_gdisp;
if (!src_gdisp)
{
src_gdisp_ID = gdisp->ID;
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
the_src_gdisp = gdisp;
src_gdisp = the_src_gdisp;
}
/* Find the target cursor's location onscreen */

View File

@ -70,7 +70,7 @@ typedef struct
{
GtkWidget * shell;
Resize * resize;
int gimage_id;
GimpImage* gimage;
} ImageResize;
/* external functions */
@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize->gimage_id = gdisp->gimage->ID;
image_resize->gimage = gdisp->gimage;
image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale->gimage_id = gdisp->gimage->ID;
image_scale->gimage = gdisp->gimage;
image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w,
GImage *gimage;
image_resize = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL)
if ((gimage = image_resize->gimage) != NULL)
{
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w,
GImage *gimage;
image_scale = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL)
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)

View File

@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *);
extern int channel_get_count;
/* from drawable.c */
Channel * drawable_channel (GimpDrawable *);
#define drawable_channel GIMP_IS_CHANNEL
#endif /* __CHANNEL_H__ */

View File

@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *);
extern int channel_get_count;
/* from drawable.c */
Channel * drawable_channel (GimpDrawable *);
#define drawable_channel GIMP_IS_CHANNEL
#endif /* __CHANNEL_H__ */

View File

@ -602,7 +602,7 @@ blend_button_release (Tool *tool,
{
return_vals = procedural_db_run_proc ("gimp_blend",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
PDB_INT32, (gint32) blend_options->blend_mode,
PDB_INT32, (gint32) blend_options->paint_mode,

View File

@ -48,7 +48,7 @@ image_invert (gimage_ptr)
return_vals = procedural_db_run_proc ("gimp_invert",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);

543
app/core/gimpdrawable.c Normal file
View File

@ -0,0 +1,543 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpdrawableP.h"
#include "gimpsignal.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "undo.h"
enum {
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
gimp_drawable_get_type ()
{
static GtkType type;
GIMP_TYPE_INIT(type,
GimpDrawable,
GimpDrawableClass,
gimp_drawable_init,
gimp_drawable_class_init,
GIMP_TYPE_OBJECT);
return type;
}
static void
gimp_drawable_class_init (GimpDrawableClass *class)
{
GtkObjectClass *object_class;
GtkType type=GIMP_TYPE_DRAWABLE;
object_class = GTK_OBJECT_CLASS(class);
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
*/
int global_drawable_ID = 1;
static GHashTable *gimp_drawable_table = NULL;
/**************************/
/* Function definitions */
GimpDrawable*
gimp_drawable_get_ID (int drawable_id)
{
if (gimp_drawable_table == NULL)
return NULL;
return (GimpDrawable*) g_hash_table_lookup (gimp_drawable_table,
(gpointer) drawable_id);
}
void
gimp_drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}
void
gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo)
{
GImage *gimage;
PixelRegion shadowPR;
int x1, y1, x2, y2;
if (! drawable)
return;
if (! (gimage = gimp_drawable_gimage (drawable)))
return;
/* 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
gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a)
{
GImage *gimage;
PixelRegion destPR;
guchar c[MAX_CHANNELS];
guchar i;
g_assert(GIMP_IS_DRAWABLE(drawable));
gimage=gimp_drawable_gimage(drawable);
g_assert(gimage);
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:
g_message ("Can't fill unknown image type.");
break;
}
pixel_region_init (&destPR,
gimp_drawable_data (drawable),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
TRUE);
color_region (&destPR, c);
}
int
gimp_drawable_mask_bounds (GimpDrawable *drawable,
int *x1, int *y1, int *x2, int *y2)
{
GImage *gimage;
int off_x, off_y;
if (! drawable)
return FALSE;
if (! (gimage = gimp_drawable_gimage (drawable)))
return FALSE;
if (gimage_mask_bounds (gimage, x1, y1, x2, y2))
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
*x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable));
*y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable));
*x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable));
*y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable));
return TRUE;
}
else
{
*x2 = gimp_drawable_width (drawable);
*y2 = gimp_drawable_height (drawable);
return FALSE;
}
}
void
gimp_drawable_invalidate_preview (GimpDrawable *drawable)
{
GImage *gimage;
if (! drawable)
return;
drawable->preview_valid = FALSE;
#if 0
gtk_signal_emit (GTK_OBJECT(drawable), gimp_drawable_signals[INVALIDATE_PREVIEW]);
#endif
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;
}
}
int
gimp_drawable_dirty (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1;
else
return 0;
}
int
gimp_drawable_clean (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1;
else
return 0;
}
GimpImage *
gimp_drawable_gimage (GimpDrawable *drawable)
{
g_assert(GIMP_IS_DRAWABLE(drawable));
return drawable->gimage;
}
int
gimp_drawable_type (GimpDrawable *drawable)
{
if (drawable)
return drawable->type;
else
return -1;
}
int
gimp_drawable_has_alpha (GimpDrawable *drawable)
{
if (drawable)
return drawable->has_alpha;
else
return FALSE;
}
int
gimp_drawable_visible (GimpDrawable *drawable)
{
return drawable->visible;
}
char *
gimp_drawable_name (GimpDrawable *drawable)
{
return drawable->name;
}
int
gimp_drawable_type_with_alpha (GimpDrawable *drawable)
{
int type = gimp_drawable_type (drawable);
int has_alpha = gimp_drawable_has_alpha (drawable);
if (has_alpha)
return type;
else
switch (type)
{
case RGB_GIMAGE:
return RGBA_GIMAGE; break;
case GRAY_GIMAGE:
return GRAYA_GIMAGE; break;
case INDEXED_GIMAGE:
return INDEXEDA_GIMAGE; break;
}
return 0;
}
int
gimp_drawable_color (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == RGBA_GIMAGE ||
gimp_drawable_type (drawable) == RGB_GIMAGE)
return 1;
else
return 0;
}
int
gimp_drawable_gray (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == GRAYA_GIMAGE ||
gimp_drawable_type (drawable) == GRAY_GIMAGE)
return 1;
else
return 0;
}
int
gimp_drawable_indexed (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE ||
gimp_drawable_type (drawable) == INDEXED_GIMAGE)
return 1;
else
return 0;
}
TileManager *
gimp_drawable_data (GimpDrawable *drawable)
{
if (drawable)
return drawable->tiles;
else
return NULL;
}
TileManager *
gimp_drawable_shadow (GimpDrawable *drawable)
{
GImage *gimage;
if (! (gimage = gimp_drawable_gimage (drawable)))
return NULL;
if (drawable)
return gimage_shadow (gimage, drawable->width, drawable->height,
drawable->bytes);
else
return NULL;
}
int
gimp_drawable_bytes (GimpDrawable *drawable)
{
if (drawable)
return drawable->bytes;
else
return -1;
}
int
gimp_drawable_width (GimpDrawable *drawable)
{
if (drawable)
return drawable->width;
else
return -1;
}
int
gimp_drawable_height (GimpDrawable *drawable)
{
if (drawable)
return drawable->height;
else
return -1;
}
void
gimp_drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y)
{
if (drawable)
{
*off_x = drawable->offset_x;
*off_y = drawable->offset_y;
}
else
*off_x = *off_y = 0;
}
unsigned char *
gimp_drawable_cmap (GimpDrawable *drawable)
{
GImage *gimage;
if ((gimage = gimp_drawable_gimage (drawable)))
return gimage->cmap;
else
return NULL;
}
void
gimp_drawable_deallocate (GimpDrawable *drawable)
{
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
}
static void
gimp_drawable_init (GimpDrawable *drawable)
{
drawable->name = NULL;
drawable->tiles = NULL;
drawable->visible = FALSE;
drawable->width = drawable->height = 0;
drawable->offset_x = drawable->offset_y = 0;
drawable->bytes = 0;
drawable->dirty = FALSE;
drawable->gimage = NULL;
drawable->type = -1;
drawable->has_alpha = FALSE;
drawable->preview = NULL;
drawable->preview_valid = FALSE;
drawable->ID = global_drawable_ID++;
if (gimp_drawable_table == NULL)
gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_drawable_table, (gpointer) drawable->ID,
(gpointer) drawable);
}
static void
gimp_drawable_destroy (GtkObject *object)
{
GimpDrawable *drawable;
g_return_if_fail (object != NULL);
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);
if (drawable->preview)
temp_buf_free (drawable->preview);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage* gimage, int width, int height,
int type, char *name)
{
int bpp;
int alpha;
if (!name)
name = "unnamed";
switch (type)
{
case RGB_GIMAGE:
bpp = 3; alpha = 0; break;
case GRAY_GIMAGE:
bpp = 1; alpha = 0; break;
case RGBA_GIMAGE:
bpp = 4; alpha = 1; break;
case GRAYA_GIMAGE:
bpp = 2; alpha = 1; break;
case INDEXED_GIMAGE:
bpp = 1; alpha = 0; break;
case INDEXEDA_GIMAGE:
bpp = 2; alpha = 1; break;
default:
g_message ("Layer type %d not supported.", type);
return;
}
if (drawable->name)
g_free (drawable->name);
drawable->name = g_strdup(name);
drawable->width = width;
drawable->height = height;
drawable->bytes = bpp;
drawable->type = type;
drawable->has_alpha = alpha;
drawable->offset_x = 0;
drawable->offset_y = 0;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
drawable->tiles = tile_manager_new (width, height, bpp);
drawable->dirty = FALSE;
drawable->visible = TRUE;
drawable->gimage = gimage;
/* preview variables */
drawable->preview = NULL;
drawable->preview_valid = FALSE;
}

75
app/core/gimpdrawable.h Normal file
View File

@ -0,0 +1,75 @@
/* 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.
*/
#ifndef __GIMPDRAWABLE_H__
#define __GIMPDRAWABLE_H__
#include "gimpobject.h"
#include "gimpdrawableF.h"
#include "tile_manager.h"
#include "temp_buf.h"
#include "gimpimageF.h"
#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ())
#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable))
#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE))
GtkType gimp_drawable_get_type (void);
typedef enum
{
BACKGROUND_FILL,
WHITE_FILL,
TRANSPARENT_FILL,
NO_FILL
} GimpFillType;
/* drawable access functions */
void gimp_drawable_apply_image (GimpDrawable *,
int, int, int, int,
TileManager *, int);
void gimp_drawable_merge_shadow (GimpDrawable *, int);
void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a);
int gimp_drawable_mask_bounds (GimpDrawable *,
int *, int *, int *, int *);
void gimp_drawable_invalidate_preview (GimpDrawable *);
int gimp_drawable_dirty (GimpDrawable *);
int gimp_drawable_clean (GimpDrawable *);
int gimp_drawable_type (GimpDrawable *);
int gimp_drawable_has_alpha (GimpDrawable *);
int gimp_drawable_type_with_alpha (GimpDrawable *);
int gimp_drawable_color (GimpDrawable *);
int gimp_drawable_gray (GimpDrawable *);
int gimp_drawable_indexed (GimpDrawable *);
TileManager * gimp_drawable_data (GimpDrawable *);
TileManager * gimp_drawable_shadow (GimpDrawable *);
int gimp_drawable_bytes (GimpDrawable *);
int gimp_drawable_width (GimpDrawable *);
int gimp_drawable_height (GimpDrawable *);
int gimp_drawable_visible (GimpDrawable *);
void gimp_drawable_offsets (GimpDrawable *, int *, int *);
unsigned char * gimp_drawable_cmap (GimpDrawable *);
char * gimp_drawable_name (GimpDrawable *);
GimpDrawable * gimp_drawable_get_ID (int);
void gimp_drawable_deallocate (GimpDrawable *);
GimpImage * gimp_drawable_gimage (GimpDrawable*);
#endif /* __GIMPDRAWABLE_H__ */

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -297,8 +297,8 @@ gimage_mask_extract (gimage, drawable, cut_gimage, keep_indexed)
*/
if (cut_gimage && drawable_layer (drawable))
{
if (layer_is_floating_sel (drawable_layer (drawable)))
floating_sel_remove (drawable_layer (drawable));
if (layer_is_floating_sel (GIMP_LAYER (drawable)))
floating_sel_remove (GIMP_LAYER (drawable));
else
gimage_remove_layer (gimage, GIMP_LAYER (drawable));
}

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -131,7 +131,6 @@ floating_sel_reset (layer)
Layer *layer;
{
GImage *gimage;
LayerMask *lm;
if (! (gimage = drawable_gimage (GIMP_DRAWABLE(layer))))
return;
@ -139,8 +138,10 @@ floating_sel_reset (layer)
/* set the underlying drawable to active */
if (drawable_layer ( (layer->fs.drawable)))
gimage_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable));
else if ((lm = drawable_layer_mask ( (layer->fs.drawable))))
gimage_set_active_layer (gimage, lm->layer);
else if (GIMP_IS_LAYER_MASK(layer->fs.drawable))
gimage_set_active_layer (gimage,
GIMP_LAYER_MASK(layer->fs.drawable)
->layer);
else if (drawable_channel ( (layer->fs.drawable)))
{
gimage_set_active_channel (gimage, GIMP_CHANNEL(layer->fs.drawable));

View File

@ -655,10 +655,8 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
/* update gdisplay titles to reflect the possibility of
* this layer being the only layer in the gimage
*/
gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage);
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");
}
@ -893,7 +891,7 @@ layer_invalidate_boundary (layer)
Channel *mask;
/* first get the selection mask channel */
if (! (gimage = GIMP_DRAWABLE(layer)->gimage))
if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer))))
return;
/* Turn the current selection off */
@ -909,7 +907,8 @@ layer_invalidate_boundary (layer)
}
/* clear the affected region surrounding the layer */
gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff);
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */
}

View File

@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* from drawable.c */
Layer * drawable_layer (GimpDrawable *);
LayerMask * drawable_layer_mask (GimpDrawable *);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK
/* from channel.c */
void channel_layer_alpha (Channel *, Layer *);

View File

@ -4,7 +4,6 @@
#include <gtk/gtktypeutils.h>
#include "gimpobjectF.h"
#define GIMP_TYPE_OBJECT gimp_object_get_type()
#define GIMP_OBJECT(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_OBJECT, GimpObject)

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage,
display_list = g_slist_append (display_list, (void *) gdisp);
/* create the shell for the image */
create_display_shell (gdisp->ID, gimage->width, gimage->height,
create_display_shell (gdisp, gimage->width, gimage->height,
title, gimage_base_type (gimage));
/* set the gdisplay colormap type and install the appropriate colormap */
@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage,
image_type_str = NULL;
}
sprintf (title, "%s" "-%d" ".%d (%s)",
sprintf (title, "%s" "-%p" ".%d (%s)",
prune_filename (gimage_filename (gimage)),
/*gimage->ID,*/
gimage,
gimage->instance_count,
image_type_str);
}
@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp)
if (active_tool && active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (gdisp->ID == tool_gdisp->ID) {
if (gdisp == tool_gdisp) {
active_tool->drawable = NULL;
active_tool->gdisp_ptr = NULL;
}
@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage,
*/
gdisplay_add_update_area (gdisp, x, y, w, h);
/* Seems like this isn't needed, it's done in
gdisplay_flush. -la
gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0);
gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0);
gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
*/
}
list = g_slist_next (list);
}

View File

@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/*
if (active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp->ID != gdisp->ID) {
if (tool_gdisp != gdisp) {
tools_initialize (active_tool->type, gdisp);
active_tool->drawable = gimage_active_drawable(gdisp->gimage);
}

View File

@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/*
if (active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp->ID != gdisp->ID) {
if (tool_gdisp != gdisp) {
tools_initialize (active_tool->type, gdisp);
active_tool->drawable = gimage_active_drawable(gdisp->gimage);
}

View File

@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage,
display_list = g_slist_append (display_list, (void *) gdisp);
/* create the shell for the image */
create_display_shell (gdisp->ID, gimage->width, gimage->height,
create_display_shell (gdisp, gimage->width, gimage->height,
title, gimage_base_type (gimage));
/* set the gdisplay colormap type and install the appropriate colormap */
@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage,
image_type_str = NULL;
}
sprintf (title, "%s" "-%d" ".%d (%s)",
sprintf (title, "%s" "-%p" ".%d (%s)",
prune_filename (gimage_filename (gimage)),
/*gimage->ID,*/
gimage,
gimage->instance_count,
image_type_str);
}
@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp)
if (active_tool && active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (gdisp->ID == tool_gdisp->ID) {
if (gdisp == tool_gdisp) {
active_tool->drawable = NULL;
active_tool->gdisp_ptr = NULL;
}
@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage,
*/
gdisplay_add_update_area (gdisp, x, y, w, h);
/* Seems like this isn't needed, it's done in
gdisplay_flush. -la
gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0);
gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0);
gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
*/
}
list = g_slist_next (list);
}

View File

@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
/*
if (active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (tool_gdisp->ID != gdisp->ID) {
if (tool_gdisp != gdisp) {
tools_initialize (active_tool->type, gdisp);
active_tool->drawable = gimage_active_drawable(gdisp->gimage);
}

View File

@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget,
void
create_display_shell (int gdisp_id,
create_display_shell (GDisplay* gdisp,
int width,
int height,
char *title,
@ -550,7 +550,6 @@ create_display_shell (int gdisp_id,
{
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
@ -561,10 +560,6 @@ create_display_shell (int gdisp_id,
int scalesrc, scaledest;
int contextid;
/* Get the gdisplay */
if (! (gdisp = gdisplay_get_ID (gdisp_id)))
return;
/* adjust the initial scale -- so that window fits on screen */
{
s_width = gdk_screen_width ();

View File

@ -19,6 +19,7 @@
#define __INTERFACE_H__
#include "tools.h"
#include "gdisplay.h"
/* typedefs */
typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer);
@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType);
void create_toolbox (void);
void toolbox_free (void);
void toolbox_raise_callback (GtkWidget *, gpointer);
void create_display_shell (int, int, int, char *, int);
void create_display_shell (GDisplay* , int, int, char *, int);
void position_dialog (GtkWidget *, gpointer, gpointer);
void center_dialog (GtkWidget *, gpointer, gpointer);
GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer);

View File

@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget,
void
create_display_shell (int gdisp_id,
create_display_shell (GDisplay* gdisp,
int width,
int height,
char *title,
@ -550,7 +550,6 @@ create_display_shell (int gdisp_id,
{
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
@ -561,10 +560,6 @@ create_display_shell (int gdisp_id,
int scalesrc, scaledest;
int contextid;
/* Get the gdisplay */
if (! (gdisp = gdisplay_get_ID (gdisp_id)))
return;
/* adjust the initial scale -- so that window fits on screen */
{
s_width = gdk_screen_width ();

View File

@ -19,6 +19,7 @@
#define __INTERFACE_H__
#include "tools.h"
#include "gdisplay.h"
/* typedefs */
typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer);
@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType);
void create_toolbox (void);
void toolbox_free (void);
void toolbox_raise_callback (GtkWidget *, gpointer);
void create_display_shell (int, int, int, char *, int);
void create_display_shell (GDisplay* , int, int, char *, int);
void position_dialog (GtkWidget *, gpointer, gpointer);
void center_dialog (GtkWidget *, gpointer, gpointer);
GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer);

View File

@ -1,3 +1,4 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
@ -15,104 +16,12 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "appenv.h"
#include "channel.h"
#include "drawable.h"
#include "errors.h"
#include "floating_sel.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "gdisplay.h"
#include "layer.h"
#include "palette.h"
#include "undo.h"
#include "drawable_pvt.h"
enum {
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 gint drawable_signals[LAST_SIGNAL] = { 0 };
static GimpDrawableClass *parent_class = NULL;
GtkType
gimp_drawable_get_type ()
{
static GtkType drawable_type = 0;
if (!drawable_type)
{
GtkTypeInfo drawable_info =
{
"GimpDrawable",
sizeof (GimpDrawable),
sizeof (GimpDrawableClass),
(GtkClassInitFunc) gimp_drawable_class_init,
(GtkObjectInitFunc) gimp_drawable_init,
/* reversed_1 */ NULL,
/* reversed_2 */ NULL,
(GtkClassInitFunc) NULL,
};
drawable_type = gtk_type_unique (gtk_data_get_type (), &drawable_info);
}
return drawable_type;
}
static void
gimp_drawable_class_init (GimpDrawableClass *class)
{
GtkObjectClass *object_class;
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gtk_data_get_type ());
drawable_signals[INVALIDATE_PREVIEW] =
gtk_signal_new ("invalidate_preview",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpDrawableClass, invalidate_preview),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, (guint *)drawable_signals, LAST_SIGNAL);
object_class->destroy = gimp_drawable_destroy;
}
/*
* Static variables
*/
int global_drawable_ID = 1;
static GHashTable *drawable_table = NULL;
/**************************/
/* Function definitions */
GimpDrawable*
drawable_get_ID (int drawable_id)
{
if (drawable_table == NULL)
return NULL;
return (GimpDrawable*) g_hash_table_lookup (drawable_table,
(gpointer) drawable_id);
}
#include "palette.h"
#include "gimpimageF.h"
#include "gdisplay.h"
int
drawable_ID (GimpDrawable *drawable)
@ -121,529 +30,45 @@ drawable_ID (GimpDrawable *drawable)
}
void
drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}
void
drawable_merge_shadow (GimpDrawable *drawable, int undo)
{
GImage *gimage;
PixelRegion shadowPR;
int x1, y1, x2, y2;
if (! drawable)
return;
if (! (gimage = drawable_gimage (drawable)))
return;
/* A useful optimization here is to limit the update to the
* extents of the selection mask, as it cannot extend beyond
* them.
*/
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
drawable_fill (GimpDrawable *drawable, int fill_type)
{
GImage *gimage;
PixelRegion destPR;
unsigned char c[MAX_CHANNELS];
unsigned char i, r, g, b, a;
if (! drawable)
return;
if (! (gimage = drawable_gimage (drawable)))
return;
drawable_fill (GimpDrawable *drawable, int fill_type){
guchar r,g,b,a;
a=255;
/* a gimage_fill affects the active layer */
switch (fill_type)
{
switch(fill_type){
case BACKGROUND_FILL:
palette_get_background(&r, &g, &b);
a = 255;
break;
case WHITE_FILL:
a = r = g = b = 255;
r=g=b=255;
break;
case TRANSPARENT_FILL:
r = g = b = a = 0;
a=r=g=b=0;
break;
case NO_FILL:
return;
break;
}
switch (drawable_type (drawable))
{
case RGB_GIMAGE: case RGBA_GIMAGE:
c[RED_PIX] = r;
c[GREEN_PIX] = g;
c[BLUE_PIX] = b;
if (drawable_type (drawable) == RGBA_GIMAGE)
c[ALPHA_PIX] = a;
break;
case GRAY_GIMAGE: case GRAYA_GIMAGE:
c[GRAY_PIX] = r;
if (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 (drawable_type (drawable) == INDEXEDA_GIMAGE)
c[ALPHA_I_PIX] = a;
break;
default:
g_message ("Can't fill unknown image type.");
break;
}
pixel_region_init (&destPR,
drawable_data (drawable),
0, 0,
drawable_width (drawable),
drawable_height (drawable),
TRUE);
color_region (&destPR, c);
/* Update the filled area */
gimp_drawable_fill(drawable,r,g,b,a);
drawable_update (drawable, 0, 0,
drawable_width (drawable),
drawable_height (drawable));
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
}
void
drawable_update (GimpDrawable *drawable, int x, int y, int w, int h)
{
GImage *gimage;
GimpImage *gimage;
int offset_x, offset_y;
if (! drawable)
return;
if (! (gimage = drawable_gimage (drawable)))
if (! (gimage = gimp_drawable_gimage (drawable)))
return;
drawable_offsets (drawable, &offset_x, &offset_y);
gimp_drawable_offsets (drawable, &offset_x, &offset_y);
x += offset_x;
y += offset_y;
gdisplays_update_area (gimage, x, y, w, h);
/* invalidate the preview */
drawable_invalidate_preview (drawable);
gimp_drawable_invalidate_preview (drawable);
}
int
drawable_mask_bounds (GimpDrawable *drawable,
int *x1, int *y1, int *x2, int *y2)
{
GImage *gimage;
int off_x, off_y;
if (! drawable)
return FALSE;
if (! (gimage = drawable_gimage (drawable)))
return FALSE;
if (gimage_mask_bounds (gimage, x1, y1, x2, y2))
{
drawable_offsets (drawable, &off_x, &off_y);
*x1 = BOUNDS (*x1 - off_x, 0, drawable_width (drawable));
*y1 = BOUNDS (*y1 - off_y, 0, drawable_height (drawable));
*x2 = BOUNDS (*x2 - off_x, 0, drawable_width (drawable));
*y2 = BOUNDS (*y2 - off_y, 0, drawable_height (drawable));
return TRUE;
}
else
{
*x2 = drawable_width (drawable);
*y2 = drawable_height (drawable);
return FALSE;
}
}
void
drawable_invalidate_preview (GimpDrawable *drawable)
{
GImage *gimage;
if (! drawable)
return;
drawable->preview_valid = FALSE;
gtk_signal_emit (GTK_OBJECT(drawable), drawable_signals[INVALIDATE_PREVIEW]);
gimage = drawable_gimage (drawable);
if (gimage)
{
gimage->comp_preview_valid[0] = FALSE;
gimage->comp_preview_valid[1] = FALSE;
gimage->comp_preview_valid[2] = FALSE;
}
}
int
drawable_dirty (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1;
else
return 0;
}
int
drawable_clean (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1;
else
return 0;
}
GImage *
drawable_gimage (GimpDrawable *drawable)
{
if (drawable)
return drawable->gimage;
else
return NULL;
}
int
drawable_type (GimpDrawable *drawable)
{
if (drawable)
return drawable->type;
else
return -1;
}
int
drawable_has_alpha (GimpDrawable *drawable)
{
if (drawable)
return drawable->has_alpha;
else
return FALSE;
}
int
drawable_visible (GimpDrawable *drawable)
{
return drawable->visible;
}
char *
drawable_name (GimpDrawable *drawable)
{
return drawable->name;
}
int
drawable_type_with_alpha (GimpDrawable *drawable)
{
int type = drawable_type (drawable);
int has_alpha = drawable_has_alpha (drawable);
if (has_alpha)
return type;
else
switch (type)
{
case RGB_GIMAGE:
return RGBA_GIMAGE; break;
case GRAY_GIMAGE:
return GRAYA_GIMAGE; break;
case INDEXED_GIMAGE:
return INDEXEDA_GIMAGE; break;
}
return 0;
}
int
drawable_color (GimpDrawable *drawable)
{
if (drawable_type (drawable) == RGBA_GIMAGE ||
drawable_type (drawable) == RGB_GIMAGE)
return 1;
else
return 0;
}
int
drawable_gray (GimpDrawable *drawable)
{
if (drawable_type (drawable) == GRAYA_GIMAGE ||
drawable_type (drawable) == GRAY_GIMAGE)
return 1;
else
return 0;
}
int
drawable_indexed (GimpDrawable *drawable)
{
if (drawable_type (drawable) == INDEXEDA_GIMAGE ||
drawable_type (drawable) == INDEXED_GIMAGE)
return 1;
else
return 0;
}
TileManager *
drawable_data (GimpDrawable *drawable)
{
if (drawable)
return drawable->tiles;
else
return NULL;
}
TileManager *
drawable_shadow (GimpDrawable *drawable)
{
GImage *gimage;
if (! (gimage = drawable_gimage (drawable)))
return NULL;
if (drawable)
return gimage_shadow (gimage, drawable->width, drawable->height,
drawable->bytes);
else
return NULL;
}
int
drawable_bytes (GimpDrawable *drawable)
{
if (drawable)
return drawable->bytes;
else
return -1;
}
int
drawable_width (GimpDrawable *drawable)
{
if (drawable)
return drawable->width;
else
return -1;
}
int
drawable_height (GimpDrawable *drawable)
{
if (drawable)
return drawable->height;
else
return -1;
}
void
drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y)
{
if (drawable)
{
*off_x = drawable->offset_x;
*off_y = drawable->offset_y;
}
else
*off_x = *off_y = 0;
}
unsigned char *
drawable_cmap (GimpDrawable *drawable)
{
GImage *gimage;
if ((gimage = drawable_gimage (drawable)))
return gimage->cmap;
else
return NULL;
}
Layer *
drawable_layer (GimpDrawable *drawable)
{
if (drawable && GIMP_IS_LAYER(drawable))
return GIMP_LAYER (drawable);
else
return NULL;
}
LayerMask *
drawable_layer_mask (GimpDrawable *drawable)
{
if (drawable && GIMP_IS_LAYER_MASK(drawable))
return GIMP_LAYER_MASK(drawable);
else
return NULL;
}
Channel *
drawable_channel (GimpDrawable *drawable)
{
if (drawable && GIMP_IS_CHANNEL(drawable))
return GIMP_CHANNEL(drawable);
else
return NULL;
}
void
drawable_deallocate (GimpDrawable *drawable)
{
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
}
static void
gimp_drawable_init (GimpDrawable *drawable)
{
drawable->name = NULL;
drawable->tiles = NULL;
drawable->visible = FALSE;
drawable->width = drawable->height = 0;
drawable->offset_x = drawable->offset_y = 0;
drawable->bytes = 0;
drawable->dirty = FALSE;
drawable->gimage = NULL;
drawable->type = -1;
drawable->has_alpha = FALSE;
drawable->preview = NULL;
drawable->preview_valid = FALSE;
drawable->ID = global_drawable_ID++;
if (drawable_table == NULL)
drawable_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (drawable_table, (gpointer) drawable->ID,
(gpointer) drawable);
}
static void
gimp_drawable_destroy (GtkObject *object)
{
GimpDrawable *drawable;
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE (object));
drawable = GIMP_DRAWABLE (object);
g_hash_table_remove (drawable_table, (gpointer) drawable->ID);
if (drawable->name)
g_free (drawable->name);
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
if (drawable->preview)
temp_buf_free (drawable->preview);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage* gimage, int width, int height,
int type, char *name)
{
int bpp;
int alpha;
if (!name)
name = "unnamed";
switch (type)
{
case RGB_GIMAGE:
bpp = 3; alpha = 0; break;
case GRAY_GIMAGE:
bpp = 1; alpha = 0; break;
case RGBA_GIMAGE:
bpp = 4; alpha = 1; break;
case GRAYA_GIMAGE:
bpp = 2; alpha = 1; break;
case INDEXED_GIMAGE:
bpp = 1; alpha = 0; break;
case INDEXEDA_GIMAGE:
bpp = 2; alpha = 1; break;
default:
g_message ("Layer type %d not supported.", type);
return;
}
if (drawable->name)
g_free (drawable->name);
drawable->name = g_strdup(name);
drawable->width = width;
drawable->height = height;
drawable->bytes = bpp;
drawable->type = type;
drawable->has_alpha = alpha;
drawable->offset_x = 0;
drawable->offset_y = 0;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
drawable->tiles = tile_manager_new (width, height, bpp);
drawable->dirty = FALSE;
drawable->visible = TRUE;
drawable->gimage = gimage;
/* preview variables */
drawable->preview = NULL;
drawable->preview_valid = FALSE;
}

View File

@ -18,56 +18,37 @@
#ifndef __DRAWABLE_H__
#define __DRAWABLE_H__
#include <gtk/gtkdata.h>
#include "tile_manager.h"
#include "temp_buf.h"
#include "gimpimageF.h"
#include "gimpdrawable.h"
#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ())
#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable))
#define GIMP_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE, GimpDrawableClass))
#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE))
#define GIMP_IS_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE))
typedef struct _GimpDrawable GimpDrawable;
typedef struct _GimpDrawableClass GimpDrawableClass;
GtkType gimp_drawable_get_type (void);
/* drawable access functions */
int drawable_ID (GimpDrawable *);
void drawable_apply_image (GimpDrawable *,
int, int, int, int,
TileManager *, int);
void drawable_merge_shadow (GimpDrawable *, int);
void drawable_fill (GimpDrawable *, int);
void drawable_update (GimpDrawable *,
int, int, int, int);
int drawable_mask_bounds (GimpDrawable *,
int *, int *, int *, int *);
void drawable_invalidate_preview (GimpDrawable *);
int drawable_dirty (GimpDrawable *);
int drawable_clean (GimpDrawable *);
int drawable_type (GimpDrawable *);
int drawable_has_alpha (GimpDrawable *);
int drawable_type_with_alpha (GimpDrawable *);
int drawable_color (GimpDrawable *);
int drawable_gray (GimpDrawable *);
int drawable_indexed (GimpDrawable *);
TileManager * drawable_data (GimpDrawable *);
TileManager * drawable_shadow (GimpDrawable *);
int drawable_bytes (GimpDrawable *);
int drawable_width (GimpDrawable *);
int drawable_height (GimpDrawable *);
int drawable_visible (GimpDrawable *);
void drawable_offsets (GimpDrawable *, int *, int *);
unsigned char * drawable_cmap (GimpDrawable *);
char * drawable_name (GimpDrawable *);
void drawable_fill (GimpDrawable *drawable, int fill_type);
void drawable_update (GimpDrawable *drawable, int x, int y, int w, int h);
GimpDrawable * drawable_get_ID (int);
void drawable_deallocate (GimpDrawable *);
void gimp_drawable_configure (GimpDrawable *,
GimpImage*,
int, int, int, char *);
#define drawable_apply_image gimp_drawable_apply_image
#define drawable_merge_shadow gimp_drawable_merge_shadow
#define drawable_mask_bounds gimp_drawable_mask_bounds
#define drawable_invalidate_preview gimp_drawable_invalidate_preview
#define drawable_dirty gimp_drawable_dirty
#define drawable_clean gimp_drawable_clean
#define drawable_type gimp_drawable_type
#define drawable_has_alpha gimp_drawable_has_alpha
#define drawable_type_with_alpha gimp_drawable_type_with_alpha
#define drawable_color gimp_drawable_color
#define drawable_gray gimp_drawable_gray
#define drawable_indexed gimp_drawable_indexed
#define drawable_data gimp_drawable_data
#define drawable_shadow gimp_drawable_shadow
#define drawable_bytes gimp_drawable_bytes
#define drawable_width gimp_drawable_width
#define drawable_height gimp_drawable_height
#define drawable_visible gimp_drawable_visible
#define drawable_offsets gimp_drawable_offsets
#define drawable_cmap gimp_drawable_cmap
#define drawable_name gimp_drawable_name
#define drawable_get_ID gimp_drawable_get_ID
#define drawable_deallocate gimp_drawable_deallocate
#define drawable_gimage gimp_drawable_gimage
#endif /* __DRAWABLE_H__ */

View File

@ -336,7 +336,7 @@ drawable_gimage_invoker (Argument *args)
return_args = procedural_db_return_args (&drawable_gimage_proc, success);
if (success)
return_args[1].value.pdb_int = gimage->ID;
return_args[1].value.pdb_int = pdb_image_to_id(gimage);
return return_args;
}

View File

@ -18,37 +18,6 @@
#ifndef __DRAWABLE_PVT_H__
#define __DRAWABLE_PVT_H__
#include <gtk/gtkdata.h>
#include "tile_manager.h"
#include "temp_buf.h"
struct _GimpDrawable
{
GtkData data;
char *name; /* name of drawable */
TileManager *tiles; /* tiles for drawable data */
int visible; /* controls visibility */
int width, height; /* size of drawable */
int offset_x, offset_y; /* offset of layer in image */
int bytes; /* bytes per pixel */
int dirty; /* dirty bit */
int ID; /* provides a unique ID */
GimpImage* gimage; /* gimage owner */
int type; /* type of drawable */
int has_alpha; /* drawable has alpha */
/* Preview variables */
TempBuf *preview; /* preview of the channel */
int preview_valid; /* is the preview valid? */
};
struct _GimpDrawableClass
{
GtkDataClass parent_class;
void (*invalidate_preview) (GtkObject *);
};
#include "gimpdrawableP.h"
#endif /* __DRAWABLE_PVT_H__ */

View File

@ -785,7 +785,7 @@ file_save (GimpImage* gimage,
args[i].arg_type = proc->args[i].arg_type;
args[0].value.pdb_int = 0;
args[1].value.pdb_int = the_gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(the_gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gimage));
args[3].value.pdb_pointer = filename;
args[4].value.pdb_pointer = raw_filename;

View File

@ -131,7 +131,6 @@ floating_sel_reset (layer)
Layer *layer;
{
GImage *gimage;
LayerMask *lm;
if (! (gimage = drawable_gimage (GIMP_DRAWABLE(layer))))
return;
@ -139,8 +138,10 @@ floating_sel_reset (layer)
/* set the underlying drawable to active */
if (drawable_layer ( (layer->fs.drawable)))
gimage_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable));
else if ((lm = drawable_layer_mask ( (layer->fs.drawable))))
gimage_set_active_layer (gimage, lm->layer);
else if (GIMP_IS_LAYER_MASK(layer->fs.drawable))
gimage_set_active_layer (gimage,
GIMP_LAYER_MASK(layer->fs.drawable)
->layer);
else if (drawable_channel ( (layer->fs.drawable)))
{
gimage_set_active_channel (gimage, GIMP_CHANNEL(layer->fs.drawable));

View File

@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage,
display_list = g_slist_append (display_list, (void *) gdisp);
/* create the shell for the image */
create_display_shell (gdisp->ID, gimage->width, gimage->height,
create_display_shell (gdisp, gimage->width, gimage->height,
title, gimage_base_type (gimage));
/* set the gdisplay colormap type and install the appropriate colormap */
@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage,
image_type_str = NULL;
}
sprintf (title, "%s" "-%d" ".%d (%s)",
sprintf (title, "%s" "-%p" ".%d (%s)",
prune_filename (gimage_filename (gimage)),
/*gimage->ID,*/
gimage,
gimage->instance_count,
image_type_str);
}
@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp)
if (active_tool && active_tool->gdisp_ptr) {
tool_gdisp = active_tool->gdisp_ptr;
if (gdisp->ID == tool_gdisp->ID) {
if (gdisp == tool_gdisp) {
active_tool->drawable = NULL;
active_tool->gdisp_ptr = NULL;
}
@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage,
*/
gdisplay_add_update_area (gdisp, x, y, w, h);
/* Seems like this isn't needed, it's done in
gdisplay_flush. -la
gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0);
gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0);
gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
*/
}
list = g_slist_next (list);
}

View File

@ -8,7 +8,7 @@
#include "drawable.h"
#include "gdisplay.h"
#include "procedural_db.h"
#include "palette.h"
#include "undo.h"
@ -23,18 +23,6 @@
to proper places. That is, the handlers should be moved to
layers_dialog, gdisplay, tools, etc.. */
/* Todo: obliterate the idiotic id system. We get rid of lotsa list
lookups, and it clears the code.. */
static int global_gimage_ID = 1;
/* Any global vars like this are damn well app-specific, and don't
belong in class implementations */
/* To do: a more generic "set" class */
GSList* image_list;
static void gimage_dirty_handler (GimpImage* gimage);
static void gimage_destroy_handler (GimpImage* gimage);
static void gimage_rename_handler (GimpImage* gimage);
@ -42,7 +30,10 @@ static void gimage_resize_handler (GimpImage* gimage);
static void gimage_restructure_handler (GimpImage* gimage);
static void gimage_repaint_handler (GimpImage* gimage, gint, gint, gint, gint);
/* This is the app's global context of "all images".. This should be
unglobalized, too */
static GSList* image_list;
GImage*
gimage_new(int width, int height, GimpImageBaseType base_type)
@ -62,10 +53,8 @@ gimage_new(int width, int height, GimpImageBaseType base_type)
gtk_signal_connect (GTK_OBJECT (gimage), "repaint",
GTK_SIGNAL_FUNC(gimage_repaint_handler), NULL);
gimage->ref_count = 0;
gimage->ID = global_gimage_ID ++;
image_list = g_slist_append (image_list, gimage);
image_list=g_slist_prepend(image_list, gimage);
pdb_add_image(gimage);
lc_dialog_update_image_list ();
indexed_palette_update_image_list ();
return gimage;
@ -74,20 +63,7 @@ gimage_new(int width, int height, GimpImageBaseType base_type)
GImage*
gimage_get_ID (gint ID)
{
GSList *tmp = image_list;
GimpImage *gimage;
while (tmp)
{
gimage = (GimpImage *) tmp->data;
if (gimage->ID == ID)
return gimage;
tmp = g_slist_next (tmp);
}
return NULL;
return pdb_id_to_image(ID);
}
@ -121,7 +97,7 @@ gimage_dirty_handler (GimpImage* gimage){
if (active_tool && !active_tool->preserve) {
GDisplay* gdisp = active_tool->gdisp_ptr;
if (gdisp) {
if (gdisp->gimage->ID == gimage->ID)
if (gdisp->gimage == gimage)
tools_initialize (active_tool->type, gdisp);
else
tools_initialize (active_tool->type, NULL);
@ -132,10 +108,12 @@ gimage_dirty_handler (GimpImage* gimage){
static void
gimage_destroy_handler (GimpImage* gimage)
{
/* free the undo list */
undo_free (gimage);
image_list = g_slist_remove (image_list, (void *) gimage);
pdb_remove_image(gimage);
image_list=g_slist_remove(image_list, gimage);
lc_dialog_update_image_list ();
indexed_palette_update_image_list ();

View File

@ -33,7 +33,6 @@ static int int_value;
static int success;
static Argument *return_args;
extern GSList * image_list;
static GImage * duplicate (GImage *gimage);
@ -41,37 +40,40 @@ static Argument * channel_ops_duplicate_invoker (Argument *args);
/************************/
/* GIMAGE_LIST_IMAGES */
/* Yuup, this is somewhat unsmooth, to say the least */
static void
gimlist_cb(gpointer im, gpointer data){
GSList** l=(GSList**)data;
*l=g_slist_prepend(*l, im);
}
static Argument *
gimage_list_images_invoker (Argument *args)
{
GSList *list;
GSList *list=NULL;
int num_images;
int *image_ids;
Argument *return_args;
success = TRUE;
return_args = procedural_db_return_args (&gimage_get_layers_proc, success);
return_args = procedural_db_return_args (&gimage_get_layers_proc, TRUE);
gimage_foreach(gimlist_cb, &list);
if (success)
{
list = image_list;
num_images = g_slist_length (list);
image_ids = NULL;
if (num_images)
{
int i;
image_ids = (int *) g_malloc (sizeof (int) * num_images);
for (i = 0; i < num_images; i++, list = g_slist_next (list))
image_ids[i] = ((GImage *) list->data)->ID;
}
image_ids[i] = pdb_image_to_id(GIMP_IMAGE(list->data));
}
return_args[1].value.pdb_int = num_images;
return_args[2].value.pdb_pointer = image_ids;
}
g_slist_free(list);
return return_args;
}
@ -160,7 +162,7 @@ gimage_new_invoker (Argument *args)
return_args = procedural_db_return_args (&gimage_new_proc, success);
if (success)
return_args[1].value.pdb_int = gimage->ID;
return_args[1].value.pdb_int = pdb_image_to_id(gimage);
return return_args;
}
@ -3399,7 +3401,7 @@ channel_ops_duplicate_invoker (Argument *args)
return_args = procedural_db_return_args (&channel_ops_duplicate_proc, success);
if (success)
return_args[1].value.pdb_int = new_gimage->ID;
return_args[1].value.pdb_int = pdb_image_to_id(new_gimage);
return return_args;
}

View File

@ -297,8 +297,8 @@ gimage_mask_extract (gimage, drawable, cut_gimage, keep_indexed)
*/
if (cut_gimage && drawable_layer (drawable))
{
if (layer_is_floating_sel (drawable_layer (drawable)))
floating_sel_remove (drawable_layer (drawable));
if (layer_is_floating_sel (GIMP_LAYER (drawable)))
floating_sel_remove (GIMP_LAYER (drawable));
else
gimage_remove_layer (gimage, GIMP_LAYER (drawable));
}

View File

@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *);
extern int channel_get_count;
/* from drawable.c */
Channel * drawable_channel (GimpDrawable *);
#define drawable_channel GIMP_IS_CHANNEL
#endif /* __CHANNEL_H__ */

View File

@ -48,7 +48,7 @@ image_invert (gimage_ptr)
return_vals = procedural_db_run_proc ("gimp_invert",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);

543
app/gimpdrawable.c Normal file
View File

@ -0,0 +1,543 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "gimpdrawableP.h"
#include "gimpsignal.h"
#include "gimage.h"
#include "gimage_mask.h"
#include "undo.h"
enum {
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
gimp_drawable_get_type ()
{
static GtkType type;
GIMP_TYPE_INIT(type,
GimpDrawable,
GimpDrawableClass,
gimp_drawable_init,
gimp_drawable_class_init,
GIMP_TYPE_OBJECT);
return type;
}
static void
gimp_drawable_class_init (GimpDrawableClass *class)
{
GtkObjectClass *object_class;
GtkType type=GIMP_TYPE_DRAWABLE;
object_class = GTK_OBJECT_CLASS(class);
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
*/
int global_drawable_ID = 1;
static GHashTable *gimp_drawable_table = NULL;
/**************************/
/* Function definitions */
GimpDrawable*
gimp_drawable_get_ID (int drawable_id)
{
if (gimp_drawable_table == NULL)
return NULL;
return (GimpDrawable*) g_hash_table_lookup (gimp_drawable_table,
(gpointer) drawable_id);
}
void
gimp_drawable_apply_image (GimpDrawable *drawable,
int x1, int y1, int x2, int y2,
TileManager *tiles, int sparse)
{
if (drawable)
{
if (! tiles)
undo_push_image (drawable->gimage, drawable,
x1, y1, x2, y2);
else
undo_push_image_mod (drawable->gimage, drawable,
x1, y1, x2, y2, tiles, sparse);
}
}
void
gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo)
{
GImage *gimage;
PixelRegion shadowPR;
int x1, y1, x2, y2;
if (! drawable)
return;
if (! (gimage = gimp_drawable_gimage (drawable)))
return;
/* 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
gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a)
{
GImage *gimage;
PixelRegion destPR;
guchar c[MAX_CHANNELS];
guchar i;
g_assert(GIMP_IS_DRAWABLE(drawable));
gimage=gimp_drawable_gimage(drawable);
g_assert(gimage);
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:
g_message ("Can't fill unknown image type.");
break;
}
pixel_region_init (&destPR,
gimp_drawable_data (drawable),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
TRUE);
color_region (&destPR, c);
}
int
gimp_drawable_mask_bounds (GimpDrawable *drawable,
int *x1, int *y1, int *x2, int *y2)
{
GImage *gimage;
int off_x, off_y;
if (! drawable)
return FALSE;
if (! (gimage = gimp_drawable_gimage (drawable)))
return FALSE;
if (gimage_mask_bounds (gimage, x1, y1, x2, y2))
{
gimp_drawable_offsets (drawable, &off_x, &off_y);
*x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable));
*y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable));
*x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable));
*y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable));
return TRUE;
}
else
{
*x2 = gimp_drawable_width (drawable);
*y2 = gimp_drawable_height (drawable);
return FALSE;
}
}
void
gimp_drawable_invalidate_preview (GimpDrawable *drawable)
{
GImage *gimage;
if (! drawable)
return;
drawable->preview_valid = FALSE;
#if 0
gtk_signal_emit (GTK_OBJECT(drawable), gimp_drawable_signals[INVALIDATE_PREVIEW]);
#endif
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;
}
}
int
gimp_drawable_dirty (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1;
else
return 0;
}
int
gimp_drawable_clean (GimpDrawable *drawable)
{
if (drawable)
return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1;
else
return 0;
}
GimpImage *
gimp_drawable_gimage (GimpDrawable *drawable)
{
g_assert(GIMP_IS_DRAWABLE(drawable));
return drawable->gimage;
}
int
gimp_drawable_type (GimpDrawable *drawable)
{
if (drawable)
return drawable->type;
else
return -1;
}
int
gimp_drawable_has_alpha (GimpDrawable *drawable)
{
if (drawable)
return drawable->has_alpha;
else
return FALSE;
}
int
gimp_drawable_visible (GimpDrawable *drawable)
{
return drawable->visible;
}
char *
gimp_drawable_name (GimpDrawable *drawable)
{
return drawable->name;
}
int
gimp_drawable_type_with_alpha (GimpDrawable *drawable)
{
int type = gimp_drawable_type (drawable);
int has_alpha = gimp_drawable_has_alpha (drawable);
if (has_alpha)
return type;
else
switch (type)
{
case RGB_GIMAGE:
return RGBA_GIMAGE; break;
case GRAY_GIMAGE:
return GRAYA_GIMAGE; break;
case INDEXED_GIMAGE:
return INDEXEDA_GIMAGE; break;
}
return 0;
}
int
gimp_drawable_color (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == RGBA_GIMAGE ||
gimp_drawable_type (drawable) == RGB_GIMAGE)
return 1;
else
return 0;
}
int
gimp_drawable_gray (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == GRAYA_GIMAGE ||
gimp_drawable_type (drawable) == GRAY_GIMAGE)
return 1;
else
return 0;
}
int
gimp_drawable_indexed (GimpDrawable *drawable)
{
if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE ||
gimp_drawable_type (drawable) == INDEXED_GIMAGE)
return 1;
else
return 0;
}
TileManager *
gimp_drawable_data (GimpDrawable *drawable)
{
if (drawable)
return drawable->tiles;
else
return NULL;
}
TileManager *
gimp_drawable_shadow (GimpDrawable *drawable)
{
GImage *gimage;
if (! (gimage = gimp_drawable_gimage (drawable)))
return NULL;
if (drawable)
return gimage_shadow (gimage, drawable->width, drawable->height,
drawable->bytes);
else
return NULL;
}
int
gimp_drawable_bytes (GimpDrawable *drawable)
{
if (drawable)
return drawable->bytes;
else
return -1;
}
int
gimp_drawable_width (GimpDrawable *drawable)
{
if (drawable)
return drawable->width;
else
return -1;
}
int
gimp_drawable_height (GimpDrawable *drawable)
{
if (drawable)
return drawable->height;
else
return -1;
}
void
gimp_drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y)
{
if (drawable)
{
*off_x = drawable->offset_x;
*off_y = drawable->offset_y;
}
else
*off_x = *off_y = 0;
}
unsigned char *
gimp_drawable_cmap (GimpDrawable *drawable)
{
GImage *gimage;
if ((gimage = gimp_drawable_gimage (drawable)))
return gimage->cmap;
else
return NULL;
}
void
gimp_drawable_deallocate (GimpDrawable *drawable)
{
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
}
static void
gimp_drawable_init (GimpDrawable *drawable)
{
drawable->name = NULL;
drawable->tiles = NULL;
drawable->visible = FALSE;
drawable->width = drawable->height = 0;
drawable->offset_x = drawable->offset_y = 0;
drawable->bytes = 0;
drawable->dirty = FALSE;
drawable->gimage = NULL;
drawable->type = -1;
drawable->has_alpha = FALSE;
drawable->preview = NULL;
drawable->preview_valid = FALSE;
drawable->ID = global_drawable_ID++;
if (gimp_drawable_table == NULL)
gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL);
g_hash_table_insert (gimp_drawable_table, (gpointer) drawable->ID,
(gpointer) drawable);
}
static void
gimp_drawable_destroy (GtkObject *object)
{
GimpDrawable *drawable;
g_return_if_fail (object != NULL);
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);
if (drawable->preview)
temp_buf_free (drawable->preview);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage* gimage, int width, int height,
int type, char *name)
{
int bpp;
int alpha;
if (!name)
name = "unnamed";
switch (type)
{
case RGB_GIMAGE:
bpp = 3; alpha = 0; break;
case GRAY_GIMAGE:
bpp = 1; alpha = 0; break;
case RGBA_GIMAGE:
bpp = 4; alpha = 1; break;
case GRAYA_GIMAGE:
bpp = 2; alpha = 1; break;
case INDEXED_GIMAGE:
bpp = 1; alpha = 0; break;
case INDEXEDA_GIMAGE:
bpp = 2; alpha = 1; break;
default:
g_message ("Layer type %d not supported.", type);
return;
}
if (drawable->name)
g_free (drawable->name);
drawable->name = g_strdup(name);
drawable->width = width;
drawable->height = height;
drawable->bytes = bpp;
drawable->type = type;
drawable->has_alpha = alpha;
drawable->offset_x = 0;
drawable->offset_y = 0;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
drawable->tiles = tile_manager_new (width, height, bpp);
drawable->dirty = FALSE;
drawable->visible = TRUE;
drawable->gimage = gimage;
/* preview variables */
drawable->preview = NULL;
drawable->preview_valid = FALSE;
}

75
app/gimpdrawable.h Normal file
View File

@ -0,0 +1,75 @@
/* 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.
*/
#ifndef __GIMPDRAWABLE_H__
#define __GIMPDRAWABLE_H__
#include "gimpobject.h"
#include "gimpdrawableF.h"
#include "tile_manager.h"
#include "temp_buf.h"
#include "gimpimageF.h"
#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ())
#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable))
#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE))
GtkType gimp_drawable_get_type (void);
typedef enum
{
BACKGROUND_FILL,
WHITE_FILL,
TRANSPARENT_FILL,
NO_FILL
} GimpFillType;
/* drawable access functions */
void gimp_drawable_apply_image (GimpDrawable *,
int, int, int, int,
TileManager *, int);
void gimp_drawable_merge_shadow (GimpDrawable *, int);
void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g,
guchar b, guchar a);
int gimp_drawable_mask_bounds (GimpDrawable *,
int *, int *, int *, int *);
void gimp_drawable_invalidate_preview (GimpDrawable *);
int gimp_drawable_dirty (GimpDrawable *);
int gimp_drawable_clean (GimpDrawable *);
int gimp_drawable_type (GimpDrawable *);
int gimp_drawable_has_alpha (GimpDrawable *);
int gimp_drawable_type_with_alpha (GimpDrawable *);
int gimp_drawable_color (GimpDrawable *);
int gimp_drawable_gray (GimpDrawable *);
int gimp_drawable_indexed (GimpDrawable *);
TileManager * gimp_drawable_data (GimpDrawable *);
TileManager * gimp_drawable_shadow (GimpDrawable *);
int gimp_drawable_bytes (GimpDrawable *);
int gimp_drawable_width (GimpDrawable *);
int gimp_drawable_height (GimpDrawable *);
int gimp_drawable_visible (GimpDrawable *);
void gimp_drawable_offsets (GimpDrawable *, int *, int *);
unsigned char * gimp_drawable_cmap (GimpDrawable *);
char * gimp_drawable_name (GimpDrawable *);
GimpDrawable * gimp_drawable_get_ID (int);
void gimp_drawable_deallocate (GimpDrawable *);
GimpImage * gimp_drawable_gimage (GimpDrawable*);
#endif /* __GIMPDRAWABLE_H__ */

6
app/gimpdrawableF.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef __GIMPDRAWABLEF_H__
#define __GIMPDRAWABLEF_H__
typedef struct _GimpDrawable GimpDrawable;
#endif

62
app/gimpdrawableP.h Normal file
View File

@ -0,0 +1,62 @@
/* 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.
*/
#ifndef __GIMPDRAWABLEP_H__
#define __GIMPDRAWABLEP_H__
#include "gimpobjectP.h"
#include "gimpdrawable.h"
struct _GimpDrawable
{
GimpObject data;
char *name; /* name of drawable */
TileManager *tiles; /* tiles for drawable data */
int visible; /* controls visibility */
int width, height; /* size of drawable */
int offset_x, offset_y; /* offset of layer in image */
int bytes; /* bytes per pixel */
int dirty; /* dirty bit */
int ID; /* provides a unique ID */
GimpImage* gimage; /* gimage owner */
int type; /* type of drawable */
int has_alpha; /* drawable has alpha */
/* Preview variables */
TempBuf *preview; /* preview of the channel */
int preview_valid; /* is the preview valid? */
};
struct _GimpDrawableClass
{
GimpObjectClass parent_class;
void (*invalidate_preview) (GtkObject *);
};
typedef struct _GimpDrawableClass GimpDrawableClass;
#define GIMP_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE, GimpDrawableClass))
#define GIMP_IS_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE))
void gimp_drawable_configure (GimpDrawable *, GimpImage*,
gint, gint, gint, gchar*);
#endif /* __GIMPDRAWABLEP_H__ */

View File

@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int *
/* If the drawable is a channel (a saved selection, etc.)
* make sure that the alpha channel is not valid
*/
if (drawable_channel (drawable) != NULL)
if (GIMP_IS_CHANNEL (drawable))
active[ALPHA_G_PIX] = 0; /* no alpha values in channels */
else
{
/* otherwise, check whether preserve transparency is
* enabled in the layer and if the layer has alpha
*/
if ((layer = drawable_layer (drawable)))
if (GIMP_IS_LAYER (drawable)){
layer=GIMP_LAYER(drawable);
if (layer_has_alpha (layer) && layer->preserve_trans)
active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0;
active[drawable_bytes (drawable) - 1] = 0;
}
}
}

View File

@ -50,14 +50,6 @@ typedef enum
} GimpImageBaseType;
/* the image fill types */
#define BACKGROUND_FILL 0
#define WHITE_FILL 1
#define TRANSPARENT_FILL 2
#define NO_FILL 3
#define COLORMAP_SIZE 768
#define HORIZONTAL_GUIDE 1
@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *);
void gimp_image_invalidate_previews (void);
/* from drawable.c */
/* Ugly! */
GimpImage * drawable_gimage (GimpDrawable*);
#endif

View File

@ -32,8 +32,6 @@ struct _GimpImage
TileManager *shadow; /* shadow buffer tiles */
int ID; /* Unique gimp_image identifier */
/* Projection attributes */
int flat; /* Is the gimp_image flat? */
int construct_flag; /* flag for construction */

View File

@ -655,10 +655,8 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
/* update gdisplay titles to reflect the possibility of
* this layer being the only layer in the gimage
*/
gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage);
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");
}
@ -893,7 +891,7 @@ layer_invalidate_boundary (layer)
Channel *mask;
/* first get the selection mask channel */
if (! (gimage = GIMP_DRAWABLE(layer)->gimage))
if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer))))
return;
/* Turn the current selection off */
@ -909,7 +907,8 @@ layer_invalidate_boundary (layer)
}
/* clear the affected region surrounding the layer */
gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff);
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */
}

View File

@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* from drawable.c */
Layer * drawable_layer (GimpDrawable *);
LayerMask * drawable_layer_mask (GimpDrawable *);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK
/* from channel.c */
void channel_layer_alpha (Channel *, Layer *);

View File

@ -4,7 +4,6 @@
#include <gtk/gtktypeutils.h>
#include "gimpobjectF.h"
#define GIMP_TYPE_OBJECT gimp_object_get_type()
#define GIMP_OBJECT(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_OBJECT, GimpObject)

View File

@ -70,7 +70,7 @@ typedef struct
{
GtkWidget * shell;
Resize * resize;
int gimage_id;
GimpImage* gimage;
} ImageResize;
/* external functions */
@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize->gimage_id = gdisp->gimage->ID;
image_resize->gimage = gdisp->gimage;
image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale->gimage_id = gdisp->gimage->ID;
image_scale->gimage = gdisp->gimage;
image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w,
GImage *gimage;
image_resize = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL)
if ((gimage = image_resize->gimage) != NULL)
{
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w,
GImage *gimage;
image_scale = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL)
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)

View File

@ -70,7 +70,7 @@ typedef struct
{
GtkWidget * shell;
Resize * resize;
int gimage_id;
GimpImage* gimage;
} ImageResize;
/* external functions */
@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_resize = (ImageResize *) g_malloc (sizeof (ImageResize));
image_resize->gimage_id = gdisp->gimage->ID;
image_resize->gimage = gdisp->gimage;
image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget,
/* the ImageResize structure */
image_scale = (ImageResize *) g_malloc (sizeof (ImageResize));
image_scale->gimage_id = gdisp->gimage->ID;
image_scale->gimage = gdisp->gimage;
image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height);
/* the dialog */
@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w,
GImage *gimage;
image_resize = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL)
if ((gimage = image_resize->gimage) != NULL)
{
if (image_resize->resize->width > 0 &&
image_resize->resize->height > 0)
@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w,
GImage *gimage;
image_scale = (ImageResize *) client_data;
if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL)
if ((gimage = image_scale->gimage) != NULL)
{
if (image_scale->resize->width > 0 &&
image_scale->resize->height > 0)

View File

@ -776,7 +776,7 @@ create_image_menu_cb (gpointer im, gpointer d)
image_name = prune_filename (gimage_filename (gimage));
menu_item_label = (char *) g_malloc (strlen (image_name) + 15);
sprintf (menu_item_label, "%s-%d", image_name, gimage->ID);
sprintf (menu_item_label, "%s-%p", image_name, gimage);
menu_item = gtk_menu_item_new_with_label (menu_item_label);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) data->callback,

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -485,7 +485,7 @@ create_image_menu_cb (gpointer im, gpointer d)
image_name = prune_filename (gimage_filename (gimage));
menu_item_label = (char *) g_malloc (strlen (image_name) + 15);
sprintf (menu_item_label, "%s-%d", image_name, gimage->ID);
sprintf (menu_item_label, "%s-%p", image_name, gimage);
menu_item = gtk_menu_item_new_with_label (menu_item_label);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) data->callback,

View File

@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget,
void
create_display_shell (int gdisp_id,
create_display_shell (GDisplay* gdisp,
int width,
int height,
char *title,
@ -550,7 +550,6 @@ create_display_shell (int gdisp_id,
{
static GtkWidget *image_popup_menu = NULL;
static GtkAccelGroup *image_accel_group = NULL;
GDisplay *gdisp;
GtkWidget *vbox;
GtkWidget *table;
GtkWidget *table_inner;
@ -561,10 +560,6 @@ create_display_shell (int gdisp_id,
int scalesrc, scaledest;
int contextid;
/* Get the gdisplay */
if (! (gdisp = gdisplay_get_ID (gdisp_id)))
return;
/* adjust the initial scale -- so that window fits on screen */
{
s_width = gdk_screen_width ();

View File

@ -19,6 +19,7 @@
#define __INTERFACE_H__
#include "tools.h"
#include "gdisplay.h"
/* typedefs */
typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer);
@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType);
void create_toolbox (void);
void toolbox_free (void);
void toolbox_raise_callback (GtkWidget *, gpointer);
void create_display_shell (int, int, int, char *, int);
void create_display_shell (GDisplay* , int, int, char *, int);
void position_dialog (GtkWidget *, gpointer, gpointer);
void center_dialog (GtkWidget *, gpointer, gpointer);
GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer);

View File

@ -48,7 +48,7 @@ image_invert (gimage_ptr)
return_vals = procedural_db_run_proc ("gimp_invert",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (drawable),
PDB_END);

View File

@ -655,10 +655,8 @@ layer_add_alpha (layer)
GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1;
GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type);
/* update gdisplay titles to reflect the possibility of
* this layer being the only layer in the gimage
*/
gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage);
gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))),
"restructure");
}
@ -893,7 +891,7 @@ layer_invalidate_boundary (layer)
Channel *mask;
/* first get the selection mask channel */
if (! (gimage = GIMP_DRAWABLE(layer)->gimage))
if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer))))
return;
/* Turn the current selection off */
@ -909,7 +907,8 @@ layer_invalidate_boundary (layer)
}
/* clear the affected region surrounding the layer */
gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff);
/* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage,
SelectionLayerOff); */
}

View File

@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int);
void layer_invalidate_previews (GimpImage*);
/* from drawable.c */
Layer * drawable_layer (GimpDrawable *);
LayerMask * drawable_layer_mask (GimpDrawable *);
/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be
defined */
#define drawable_layer GIMP_IS_LAYER
#define drawable_layer_mask GIMP_IS_LAYER_MASK
/* from channel.c */
void channel_layer_alpha (Channel *, Layer *);

View File

@ -776,7 +776,7 @@ create_image_menu_cb (gpointer im, gpointer d)
image_name = prune_filename (gimage_filename (gimage));
menu_item_label = (char *) g_malloc (strlen (image_name) + 15);
sprintf (menu_item_label, "%s-%d", image_name, gimage->ID);
sprintf (menu_item_label, "%s-%p", image_name, gimage);
menu_item = gtk_menu_item_new_with_label (menu_item_label);
gtk_signal_connect (GTK_OBJECT (menu_item), "activate",
(GtkSignalFunc) data->callback,

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -72,7 +72,7 @@ static int offset_x = 0; /* */
static int offset_y = 0; /* offset for cloning */
static int first = TRUE;
static int trans_tx, trans_ty; /* transformed target */
static int src_gdisp_ID = -1; /* ID of source gdisplay */
static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */
static GimpDrawable * src_drawable_ = NULL; /* source drawable */
static CloneOptions *clone_options = NULL;
@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core,
case INIT_PAINT :
if (paint_core->state & ControlMask)
{
src_gdisp_ID = gdisp->ID;
the_src_gdisp = gdisp;
src_drawable_ = drawable;
src_x = paint_core->curx;
src_y = paint_core->cury;
@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core,
}
/* Calculate the coordinates of the target */
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
src_gdisp = the_src_gdisp;
if (!src_gdisp)
{
src_gdisp_ID = gdisp->ID;
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
the_src_gdisp = gdisp;
src_gdisp = the_src_gdisp;
}
/* Find the target cursor's location onscreen */

View File

@ -72,7 +72,7 @@ static int offset_x = 0; /* */
static int offset_y = 0; /* offset for cloning */
static int first = TRUE;
static int trans_tx, trans_ty; /* transformed target */
static int src_gdisp_ID = -1; /* ID of source gdisplay */
static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */
static GimpDrawable * src_drawable_ = NULL; /* source drawable */
static CloneOptions *clone_options = NULL;
@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core,
case INIT_PAINT :
if (paint_core->state & ControlMask)
{
src_gdisp_ID = gdisp->ID;
the_src_gdisp = gdisp;
src_drawable_ = drawable;
src_x = paint_core->curx;
src_y = paint_core->cury;
@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core,
}
/* Calculate the coordinates of the target */
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
src_gdisp = the_src_gdisp;
if (!src_gdisp)
{
src_gdisp_ID = gdisp->ID;
src_gdisp = gdisplay_get_ID (src_gdisp_ID);
the_src_gdisp = gdisp;
src_gdisp = the_src_gdisp;
}
/* Find the target cursor's location onscreen */

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface)
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS);
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget,
/* initialize the first 3 plug-in arguments */
args[0].value.pdb_int = RUN_INTERACTIVE;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget,
{
gdisp_ID = gdisplay->ID;
args[1].value.pdb_int = gdisplay->gimage->ID;
args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else

View File

@ -69,6 +69,7 @@ static Argument * procedural_db_query (Argument *);
static void procedural_db_query_entry (gpointer, gpointer, gpointer);
static int match_strings (regex_t *, char *);
static guint procedural_db_hash_func (gconstpointer key);
static void pdb_id_init (void);
/* Local data */
@ -528,6 +529,7 @@ procedural_db_init ()
if (!procedural_ht)
procedural_ht = g_hash_table_new (procedural_db_hash_func,
g_str_equal);
pdb_id_init ();
}
void
@ -1244,3 +1246,53 @@ procedural_db_hash_func (gconstpointer key)
return result;
}
/* The id system's remnants ... */
static gint next_image_id;
static gint next_drawable_id;
static gint next_display_id;
static GHashTable* image_hash;
static GHashTable* drawable_hash;
static GHashTable* display_hash;
static guint id_hash_func(gconstpointer id){
return *((guint*)id);
}
static gboolean id_cmp_func(gconstpointer id1, gconstpointer id2){
return (*((guint*)id1)==*((guint*)id2));
}
static void pdb_id_init (void){
image_hash=g_hash_table_new(id_hash_func, id_cmp_func);
drawable_hash=g_hash_table_new(id_hash_func, id_cmp_func);
display_hash=g_hash_table_new(id_hash_func, id_cmp_func);
}
void pdb_add_image(GimpImage* gimage){
guint* id=g_new(gint,1);
*id=next_image_id++;
gtk_object_set_data(GTK_OBJECT(gimage), "pdb_id", id);
g_hash_table_insert(image_hash, id, gimage);
}
gint pdb_image_to_id(GimpImage* gimage){
guint *id=gtk_object_get_data(GTK_OBJECT(gimage), "pdb_id");
return id?(gint)*id:-1;
}
GimpImage* pdb_id_to_image(gint id){
return g_hash_table_lookup(image_hash, &id);
}
void pdb_remove_image(GimpImage* image){
guint* id=gtk_object_get_data(GTK_OBJECT(image), "pdb_id");
gtk_object_remove_data(GTK_OBJECT(image), "pdb_id");
g_hash_table_remove(image_hash, id);
g_free(id);
}

View File

@ -18,6 +18,8 @@
#ifndef __PROCEDURAL_DB_H__
#define __PROCEDURAL_DB_H__
#include "gimpimageF.h"
/* Procedural database types */
typedef enum
{
@ -190,5 +192,11 @@ Argument * procedural_db_return_args (ProcRecord *,
int);
void procedural_db_destroy_args (Argument *,
int);
void pdb_add_image(GimpImage* gimage);
gint pdb_image_to_id(GimpImage* gimage);
GimpImage* pdb_id_to_image(gint id);
void pdb_remove_image(GimpImage* image);
#endif /* __PROCEDURAL_DB_H__ */

View File

@ -602,7 +602,7 @@ blend_button_release (Tool *tool,
{
return_vals = procedural_db_run_proc ("gimp_blend",
&nreturn_vals,
PDB_IMAGE, gimage->ID,
PDB_IMAGE, pdb_image_to_id(gimage),
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
PDB_INT32, (gint32) blend_options->blend_mode,
PDB_INT32, (gint32) blend_options->paint_mode,

View File

@ -313,7 +313,8 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr)
return_vals = procedural_db_run_proc ("gimp_bucket_fill",
&nreturn_vals,
PDB_IMAGE, gdisp->gimage->ID,
PDB_IMAGE,
pdb_image_to_id(gdisp->gimage),
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)),
PDB_INT32, (gint32) fill_mode,
PDB_INT32, (gint32) bucket_options->paint_mode,

Some files were not shown because too many files have changed in this diff Show More