Commit c267c55b authored by scott's avatar scott

Rewrite to make drawables (layers, channels, layer masks) into GtkObjects.

--sg
parent c263b2ff
Thu Jan 22 01:54:17 1998 Scott Goehring <scott@poverty.bloomington.in.us>
* Rework of drawables, images, and layers to use GtkObjects. Lots
and lots of secondary changes.
Sun Jan 18 18:07:23 EST 1998 Adrian Likins <adrian@gimp.org>
* added plugins/gflare/gflares and edited the makefiles
......
......@@ -40,6 +40,7 @@ gimp_SOURCES = \
by_color_select.h \
channel.c \
channel.h \
channel_pvt.h \
channel_cmds.c \
channel_cmds.h \
channels_dialog.c \
......@@ -85,6 +86,7 @@ gimp_SOURCES = \
draw_core.h \
drawable.c \
drawable.h \
drawable_pvt.h \
drawable_cmds.c \
drawable_cmds.h \
edit_cmds.c \
......@@ -167,6 +169,7 @@ gimp_SOURCES = \
iscissors.h \
layer.c \
layer.h \
layer_pvt.h \
layer_cmds.c \
layer_cmds.h \
layer_select.c \
......@@ -241,6 +244,7 @@ gimp_SOURCES = \
tile_cache.h \
tile_manager.c \
tile_manager.h \
tile_manager_pvt.h \
tile_swap.c \
tile_swap.h \
tips_dialog.c \
......@@ -270,7 +274,8 @@ CPPFLAGS = \
-DLIBDIR=\""$(gimpplugindir)"\" \
-DDATADIR=\""$(gimpdatadir)"\" \
-DGIMPDIR=\""$(gimpdir)"\" \
-DVERSION=\"$(VERSION)\"
-DVERSION=\"$(VERSION)\" \
-DNDEBUG
INCLUDES = \
$(X_CFLAGS) \
......
......@@ -39,6 +39,7 @@
#include "floating_sel.h"
#include "gdisplay_ops.h"
#include "general.h"
#include "gimage_cmds.h"
#include "gimage_mask.h"
#include "gimprc.h"
#include "global_edit.h"
......@@ -213,7 +214,7 @@ file_new_ok_callback (GtkWidget *widget,
gimage_add_layer (gimage, layer, 0);
gimage_enable_undo (gimage);
drawable_fill (layer->ID, vals->fill_type);
drawable_fill (GIMP_DRAWABLE(layer), vals->fill_type);
gimage_clean_all (gimage);
......
......@@ -1041,7 +1041,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[2].value.pdb_int = gimage_active_drawable (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
/* run the plug-in procedure */
plug_in_run (last_plug_in, args, FALSE, TRUE);
......@@ -1220,9 +1220,9 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
tile_info = msg.data;
if (tile_info->shadow)
tm = drawable_shadow (tile_info->drawable_ID);
tm = drawable_shadow (drawable_get_ID (tile_info->drawable_ID));
else
tm = drawable_data (tile_info->drawable_ID);
tm = drawable_data (drawable_get_ID (tile_info->drawable_ID));
if (!tm)
{
......@@ -1259,9 +1259,9 @@ plug_in_handle_tile_req (GPTileReq *tile_req)
else
{
if (tile_req->shadow)
tm = drawable_shadow (tile_req->drawable_ID);
tm = drawable_shadow (drawable_get_ID (tile_req->drawable_ID));
else
tm = drawable_data (tile_req->drawable_ID);
tm = drawable_data (drawable_get_ID (tile_req->drawable_ID));
if (!tm)
{
......@@ -2089,7 +2089,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[2].value.pdb_int = gimage_active_drawable (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
{
......@@ -2108,7 +2108,7 @@ plug_in_callback (GtkWidget *widget,
if (gdisplay)
{
args[1].value.pdb_int = gdisplay->gimage->ID;
args[2].value.pdb_int = gimage_active_drawable (gdisplay->gimage);
args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage));
}
else
{
......
......@@ -33,11 +33,11 @@ typedef struct _AirbrushTimeout AirbrushTimeout;
struct _AirbrushTimeout
{
PaintCore *paint_core;
int drawable_id;
GimpDrawable *drawable;
};
/* forward function declarations */
static void airbrush_motion (PaintCore *, int, double);
static void airbrush_motion (PaintCore *, GimpDrawable *, double);
static gint airbrush_time_out (gpointer);
static Argument * airbrush_invoker (Argument *);
......@@ -139,11 +139,14 @@ create_airbrush_options (void)
void *
airbrush_paint_func (PaintCore *paint_core,
int drawable_id,
GimpDrawable *drawable,
int state)
{
GBrushP brush;
if (!drawable)
return NULL;
brush = get_active_brush ();
switch (state)
{
......@@ -156,12 +159,12 @@ airbrush_paint_func (PaintCore *paint_core,
gtk_timeout_remove (timer);
timer_state = OFF;
airbrush_motion (paint_core, drawable_id, airbrush_options->pressure);
airbrush_motion (paint_core, drawable, airbrush_options->pressure);
if (airbrush_options->rate != 0.0)
{
airbrush_timeout.paint_core = paint_core;
airbrush_timeout.drawable_id = drawable_id;
airbrush_timeout.drawable = drawable;
timer = gtk_timeout_add ((10000 / airbrush_options->rate),
airbrush_time_out, NULL);
timer_state = ON;
......@@ -216,7 +219,7 @@ airbrush_time_out (gpointer client_data)
{
/* service the timer */
airbrush_motion (airbrush_timeout.paint_core,
airbrush_timeout.drawable_id,
airbrush_timeout.drawable,
airbrush_options->pressure);
gdisplays_flush ();
......@@ -230,19 +233,22 @@ airbrush_time_out (gpointer client_data)
static void
airbrush_motion (PaintCore *paint_core,
int drawable_id,
GimpDrawable *drawable,
double pressure)
{
GImage *gimage;
TempBuf * area;
unsigned char col[MAX_CHANNELS];
if (! (gimage = drawable_gimage (drawable_id)))
if (!drawable)
return;
if (! (gimage = drawable_gimage (drawable)))
return;
gimage_get_foreground (gimage, drawable_id, col);
gimage_get_foreground (gimage, drawable, col);
if (! (area = paint_core_get_paint_area (paint_core, drawable_id)))
if (! (area = paint_core_get_paint_area (paint_core, drawable)))
return;
/* color the pixels */
......@@ -253,7 +259,7 @@ airbrush_motion (PaintCore *paint_core,
area->width * area->height, area->bytes);
/* paste the newly painted area to the image */
paint_core_paste_canvas (paint_core, drawable_id,
paint_core_paste_canvas (paint_core, drawable,
(int) (pressure * 2.55),
(int) (get_brush_opacity () * 255),
get_brush_paint_mode (),
......@@ -263,10 +269,10 @@ airbrush_motion (PaintCore *paint_core,
static void *
airbrush_non_gui_paint_func (PaintCore *paint_core,
int drawable_id,
GimpDrawable *drawable,
int state)
{
airbrush_motion (paint_core, drawable_id, non_gui_pressure);
airbrush_motion (paint_core, drawable, non_gui_pressure);
return NULL;
}
......@@ -326,14 +332,14 @@ airbrush_invoker (Argument *args)
{
int success = TRUE;
GImage *gimage;
int drawable_id;
GimpDrawable *drawable;
int num_strokes;
double *stroke_array;
int int_value;
double fp_value;
int i;
drawable_id = -1;
drawable = NULL;
num_strokes = 0;
/* the gimage */
......@@ -347,10 +353,9 @@ airbrush_invoker (Argument *args)
if (success)
{
int_value = args[1].value.pdb_int;
if (! (gimage == drawable_gimage (int_value)))
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
else
drawable_id = int_value;
}
/* pressure */
if (success)
......@@ -377,7 +382,7 @@ airbrush_invoker (Argument *args)
if (success)
/* init the paint core */
success = paint_core_init (&non_gui_paint_core, drawable_id,
success = paint_core_init (&non_gui_paint_core, drawable,
stroke_array[0], stroke_array[1]);
if (success)
......@@ -389,21 +394,21 @@ airbrush_invoker (Argument *args)
non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1];
if (num_strokes == 1)
airbrush_non_gui_paint_func (&non_gui_paint_core, drawable_id, 0);
airbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0);
for (i = 1; i < num_strokes; i++)
{
non_gui_paint_core.curx = stroke_array[i * 2 + 0];
non_gui_paint_core.cury = stroke_array[i * 2 + 1];
paint_core_interpolate (&non_gui_paint_core, drawable_id);
paint_core_interpolate (&non_gui_paint_core, drawable);
non_gui_paint_core.lastx = non_gui_paint_core.curx;
non_gui_paint_core.lasty = non_gui_paint_core.cury;
}
/* finish the painting */
paint_core_finish (&non_gui_paint_core, drawable_id, -1);
paint_core_finish (&non_gui_paint_core, drawable, -1);
/* cleanup */
paint_core_cleanup ();
......
......@@ -22,7 +22,7 @@
#include "paint_core.h"
#include "procedural_db.h"
void * airbrush_paint_func (PaintCore *, int, int);
void * airbrush_paint_func (PaintCore *, GimpDrawable *, int);
Tool * tools_new_airbrush (void);
void tools_free_airbrush (Tool *);
......
......@@ -62,7 +62,7 @@ struct _ColorBalanceDialog
GtkAdjustment *magenta_green_data;
GtkAdjustment *yellow_blue_data;
int drawable_id;
GimpDrawable *drawable;
ImageMap image_map;
double cyan_red[3];
......@@ -330,8 +330,8 @@ color_balance_initialize (void *gdisp_ptr)
color_balance_dialog->magenta_green[i] = 0.0;
color_balance_dialog->yellow_blue[i] = 0.0;
}
color_balance_dialog->drawable_id = gimage_active_drawable (gdisp->gimage);
color_balance_dialog->image_map = image_map_create (gdisp_ptr, color_balance_dialog->drawable_id);
color_balance_dialog->drawable = gimage_active_drawable (gdisp->gimage);
color_balance_dialog->image_map = image_map_create (gdisp_ptr, color_balance_dialog->drawable);
color_balance_update (color_balance_dialog, ALL);
}
......@@ -921,7 +921,6 @@ color_balance_invoker (Argument *args)
int int_value;
ColorBalanceDialog cbd;
GImage *gimage;
int drawable_id;
int transfer_mode;
int preserve_lum;
double cyan_red;
......@@ -931,8 +930,9 @@ color_balance_invoker (Argument *args)
int x1, y1, x2, y2;
int i;
void *pr;
GimpDrawable *drawable;
drawable_id = -1;
drawable = NULL;
transfer_mode = MIDTONES;
cyan_red = 0;
magenta_green = 0;
......@@ -949,9 +949,8 @@ color_balance_invoker (Argument *args)
if (success)
{
int_value = args[1].value.pdb_int;
if (gimage == drawable_gimage (int_value))
drawable_id = int_value;
else
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* transfer_mode */
......@@ -1016,16 +1015,16 @@ color_balance_invoker (Argument *args)
cbd.yellow_blue[transfer_mode] = yellow_blue;
/* The application should occur only within selection bounds */
drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, drawable_data (drawable_id), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable_id), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr))
color_balance (&srcPR, &destPR, (void *) &cbd);
drawable_merge_shadow (drawable_id, TRUE);
drawable_update (drawable_id, x1, y1, (x2 - x1), (y2 - y1));
drawable_merge_shadow (drawable, TRUE);
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
return procedural_db_return_args (&color_balance_proc, success);
......
......@@ -81,7 +81,7 @@ struct _CurvesDialog
GtkWidget * graph;
GdkPixmap * pixmap;
int drawable_id;
GimpDrawable * drawable;
ImageMap image_map;
int color;
int channel;
......@@ -367,12 +367,12 @@ curves_initialize (void *gdisp_ptr)
curves_dialog->points[i][16][1] = 255;
}
curves_dialog->drawable_id = gimage_active_drawable (gdisp->gimage);
curves_dialog->color = drawable_color (curves_dialog->drawable_id);
curves_dialog->image_map = image_map_create (gdisp_ptr, curves_dialog->drawable_id);
curves_dialog->drawable = gimage_active_drawable (gdisp->gimage);
curves_dialog->color = drawable_color ( (curves_dialog->drawable));
curves_dialog->image_map = image_map_create (gdisp_ptr, curves_dialog->drawable);
/* check for alpha channel */
if (drawable_has_alpha (curves_dialog->drawable_id))
if (drawable_has_alpha ( (curves_dialog->drawable)))
gtk_widget_set_sensitive( channel_items[4].widget, TRUE);
else
gtk_widget_set_sensitive( channel_items[4].widget, FALSE);
......@@ -1326,15 +1326,13 @@ curves_spline_invoker (Argument *args)
int int_value;
CurvesDialog cd;
GImage *gimage;
int drawable_id;
int channel;
int num_cp;
unsigned char *control_pts;
int x1, y1, x2, y2;
int i, j;
void *pr;
drawable_id = -1;
GimpDrawable *drawable;
/* the gimage */
if (success)
......@@ -1347,9 +1345,8 @@ curves_spline_invoker (Argument *args)
if (success)
{
int_value = args[1].value.pdb_int;
if (gimage == drawable_gimage (int_value))
drawable_id = int_value;
else
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* channel */
......@@ -1358,10 +1355,10 @@ curves_spline_invoker (Argument *args)
int_value = args[2].value.pdb_int;
if (success)
{
if (drawable_gray (drawable_id))
if (drawable_gray (drawable))
if (int_value != 0)
success = FALSE;
else if (drawable_color (drawable_id))
else if (drawable_color (drawable))
if (int_value < 0 || int_value > 3)
success = FALSE;
else
......@@ -1396,7 +1393,7 @@ curves_spline_invoker (Argument *args)
}
cd.channel = channel;
cd.color = drawable_color (drawable_id);
cd.color = drawable_color (drawable);
cd.curve_type = SMOOTH;
for (j = 0; j < num_cp / 2; j++)
......@@ -1407,16 +1404,16 @@ curves_spline_invoker (Argument *args)
curves_calculate_curve (&cd);
/* The application should occur only within selection bounds */
drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, drawable_data (drawable_id), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable_id), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr))
curves (&srcPR, &destPR, (void *) &cd);
drawable_merge_shadow (drawable_id, TRUE);
drawable_update (drawable_id, x1, y1, (x2 - x1), (y2 - y1));
drawable_merge_shadow (drawable, TRUE);
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
return procedural_db_return_args (&curves_spline_proc, success);
......@@ -1478,14 +1475,12 @@ curves_explicit_invoker (Argument *args)
int int_value;
CurvesDialog cd;
GImage *gimage;
int drawable_id;
int channel;
unsigned char *curve;
int x1, y1, x2, y2;
int i, j;
void *pr;
drawable_id = -1;
GimpDrawable *drawable;
/* the gimage */
if (success)
......@@ -1498,9 +1493,8 @@ curves_explicit_invoker (Argument *args)
if (success)
{
int_value = args[1].value.pdb_int;
if (gimage == drawable_gimage (int_value))
drawable_id = int_value;
else
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* channel */
......@@ -1509,10 +1503,10 @@ curves_explicit_invoker (Argument *args)
int_value = args[2].value.pdb_int;
if (success)
{
if (drawable_gray (drawable_id))
if (drawable_gray (drawable))
if (int_value != 0)
success = FALSE;
else if (drawable_color (drawable_id))
else if (drawable_color (drawable))
if (int_value < 0 || int_value > 3)
success = FALSE;
else
......@@ -1541,22 +1535,22 @@ curves_explicit_invoker (Argument *args)
cd.curve[i][j] = j;
cd.channel = channel;
cd.color = drawable_color (drawable_id);
cd.color = drawable_color (drawable);
for (j = 0; j < 256; j++)
cd.curve[cd.channel][j] = curve[j];
/* The application should occur only within selection bounds */
drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, drawable_data (drawable_id), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable_id), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr))
curves (&srcPR, &destPR, (void *) &cd);
drawable_merge_shadow (drawable_id, TRUE);
drawable_update (drawable_id, x1, y1, (x2 - x1), (y2 - y1));
drawable_merge_shadow (drawable, TRUE);
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
return procedural_db_return_args (&curves_explicit_proc, success);
......
......@@ -69,7 +69,7 @@ struct _HueSaturationDialog
GtkAdjustment *lightness_data;
GtkAdjustment *saturation_data;
int drawable_id;
GimpDrawable *drawable;
ImageMap image_map;
double hue[7];
......@@ -373,8 +373,8 @@ hue_saturation_initialize (void *gdisp_ptr)
hue_saturation_dialog->saturation[i] = 0.0;
}
hue_saturation_dialog->drawable_id = gimage_active_drawable (gdisp->gimage);
hue_saturation_dialog->image_map = image_map_create (gdisp_ptr, hue_saturation_dialog->drawable_id);
hue_saturation_dialog->drawable = gimage_active_drawable (gdisp->gimage);
hue_saturation_dialog->image_map = image_map_create (gdisp_ptr, hue_saturation_dialog->drawable);
hue_saturation_update (hue_saturation_dialog, ALL);
}
......@@ -1066,7 +1066,7 @@ hue_saturation_invoker (Argument *args)
int success = TRUE;
HueSaturationDialog hsd;
GImage *gimage;
int drawable_id;
GimpDrawable *drawable;
int hue_range;
double hue_offset;
double lightness;
......@@ -1077,7 +1077,7 @@ hue_saturation_invoker (Argument *args)
int i;
void *pr;
drawable_id = -1;
drawable = NULL;
hue_range = 0;
hue_offset = 0.0;
lightness = 0.0;
......@@ -1094,9 +1094,8 @@ hue_saturation_invoker (Argument *args)
if (success)
{
int_value = args[1].value.pdb_int;
if (gimage == drawable_gimage (int_value))
drawable_id = int_value;
else
drawable = drawable_get_ID (int_value);
if (drawable == NULL || gimage != drawable_gimage (drawable))
success = FALSE;
}
/* hue_range */
......@@ -1154,16 +1153,16 @@ hue_saturation_invoker (Argument *args)
hue_saturation_calculate_transfers (&hsd);
/* The application should occur only within selection bounds */
drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, drawable_data (drawable_id), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable_id), x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_region_init (&srcPR, drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, drawable_shadow (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE);
for (pr = pixel_regions_register (2, &srcPR, &destPR); pr != NULL; pr = pixel_regions_process (pr))
hue_saturation (&srcPR, &destPR, (void *) &hsd);
drawable_merge_shadow (drawable_id, TRUE);
drawable_update (drawable_id, x1, y1, (x2 - x1), (y2 - y1));
drawable_merge_shadow (drawable, TRUE);
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
return procedural_db_return_args (&hue_saturation_proc, success);
......
......@@ -23,6 +23,7 @@
#include "linked.h"
#include "pixel_region.h"
#include "tile_manager_pvt.h"
typedef struct _PixelRegionHolder PixelRegionHolder;
......
......@@ -48,7 +48,7 @@ struct _ThresholdDialog
GtkWidget *high_threshold_text;
Histogram *histogram;
int drawable_id;
GimpDrawable *drawable;
ImageMap image_map;
int color;
int low_threshold;
......@@ -347,11 +347,11 @@ threshold_initialize (void *gdisp_ptr)
if (!GTK_WIDGET_VISIBLE (threshold_dialog->shell))
gtk_widget_show (threshold_dialog->shell);
threshold_dialog->drawable_id = gimage_active_drawable (gdisp->gimage);
threshold_dialog->color = drawable_color (threshold_dialog->drawable_id);
threshold_dialog->image_map = image_map_create (gdisp_ptr, threshold_dialog->drawable_id);
threshold_dialog->drawable = gimage_active_drawable (gdisp->gimage);
threshold_dialog->color = drawable_color (threshold_dialog->drawable);
threshold_dialog->image_map = image_map_create (gdisp_ptr, threshold_dialog->drawable);