Commit ef3e162e authored by Lauri Alanko's avatar Lauri Alanko

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. :)
parent 5c5c73f3
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:
......
......@@ -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) \
......
......@@ -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)
......
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
......@@ -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__ */
......@@ -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 */
......
......@@ -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)
......
......@@ -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__ */
......@@ -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__ */
......@@ -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,
......
......@@ -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);
......
/* 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)