Commit 16d17959 authored by Garry R. Osgood's avatar Garry R. Osgood Committed by Garry R. Osgood

app/disp_callbacks.c app/gimage_mask.c app/global_edit.c app/interface.c

2000-01-11  Garry R. Osgood <gosgood@idt.net>
* app/disp_callbacks.c
* app/gimage_mask.c
* app/global_edit.c
* app/interface.c
* app/layer.c
* app/layer.h
* app/transform_core.c  Followup to #4708. Some clients
of layer_new_from_tiles() need to specify the
kind of layer they need; added a GimpImageType
parameter for this purpose. Closes #5045.
* app/paths_dialog.c paths_dialog_set_default_op()
now checks for the existence of the path_dialog
before manipulating its internals. Closes #5049;
parent 4eefabde
2000-01-11 Garry R. Osgood <gosgood@idt.net>
* app/disp_callbacks.c
* app/gimage_mask.c
* app/global_edit.c
* app/interface.c
* app/layer.c
* app/layer.h
* app/transform_core.c
Followup to #4708. Some clients
of layer_new_from_tiles() need to specify the
kind of layer they need; added a GimpImageType
parameter for this purpose. (A reference to a
whole Drawable once was used for this purpose;
Sven factored this out. Good Riddance). Function
internals are correct only with alpha-equipped image
types, so don't ask for alpha-less types or
furnish alpha-less tiles. <imho>This function is
not robust and is overused; its scope is to
fatten TileManagers referenced by cut buffers
into Layers. If you already have a layer,
consider yourself blessed and work with it.</imho>
Closes #5045.
* app/paths_dialog.c paths_dialog_set_default_op()
now checks for the existence of the path_dialog
before manipulating its internals. Closes #5049;
Tue Jan 11 21:41:23 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/common/rotate.c: fixed the progressbar on 270 degree (bug #5108)
......
......@@ -286,7 +286,7 @@ edit_paste (GImage *gimage,
int cx, cy;
/* Make a new layer */
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
......@@ -355,7 +355,7 @@ edit_paste_as_new (GImage *invoke,
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */
......
......@@ -286,7 +286,7 @@ edit_paste (GImage *gimage,
int cx, cy;
/* Make a new layer */
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
......@@ -355,7 +355,7 @@ edit_paste_as_new (GImage *invoke,
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */
......
......@@ -344,7 +344,7 @@ gimage_mask_float (GImage *gimage,
tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE);
/* Create a new layer from the buffer */
layer = layer_new_from_tiles (gimage, tiles,
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), tiles,
_("Floated Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* Set the offsets */
......
......@@ -394,13 +394,13 @@ layer_copy (Layer *layer,
Layer *
layer_new_from_tiles (GimpImage *gimage,
GimpImageType layer_type,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * new_layer;
GimpImageType layer_type;
PixelRegion layerPR, bufPR;
/* Function copies buffer to a layer
......@@ -412,9 +412,7 @@ layer_new_from_tiles (GimpImage *gimage,
if (!gimage || !tiles )
return NULL;
layer_type = gimp_image_base_type_with_alpha (gimage);
/* Create the new layer */
/* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height,
layer_type, name, opacity, mode);
......
......@@ -79,7 +79,7 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_new_from_tiles (GimpImage *, TileManager *,
Layer * layer_new_from_tiles (GimpImage *, GimpImageType, TileManager *,
gchar *, gint, LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -671,20 +671,21 @@ gdisplay_drag_drop (GtkWidget *widget,
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
GImage *src_gimage;
Layer *new_layer;
GImage *dest_gimage;
gint src_width, src_height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes;
GimpImageBaseType type;
src_gimage = gimp_drawable_gimage (drawable);
src_width = gimp_drawable_width (drawable);
src_height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
......@@ -703,14 +704,14 @@ gdisplay_drag_drop (GtkWidget *widget,
break;
}
gimage_get_background (gimage, drawable, bg);
gimage_get_background (src_gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
tiles = tile_manager_new (src_width, src_height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
0, 0, src_width, src_height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
0, 0, src_width, src_height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
......@@ -729,7 +730,7 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height;
new_layer =
layer_new_from_tiles (dest_gimage, tiles,
layer_new_from_tiles (dest_gimage, gimp_image_base_type_with_alpha(dest_gimage), tiles,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......@@ -740,8 +741,8 @@ gdisplay_drag_drop (GtkWidget *widget,
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
off_x = (dest_gimage->width - src_width) / 2;
off_y = (dest_gimage->height - src_height) / 2;
layer_translate (new_layer, off_x, off_y);
......
......@@ -671,20 +671,21 @@ gdisplay_drag_drop (GtkWidget *widget,
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
GImage *src_gimage;
Layer *new_layer;
GImage *dest_gimage;
gint src_width, src_height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes;
GimpImageBaseType type;
src_gimage = gimp_drawable_gimage (drawable);
src_width = gimp_drawable_width (drawable);
src_height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
......@@ -703,14 +704,14 @@ gdisplay_drag_drop (GtkWidget *widget,
break;
}
gimage_get_background (gimage, drawable, bg);
gimage_get_background (src_gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
tiles = tile_manager_new (src_width, src_height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
0, 0, src_width, src_height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
0, 0, src_width, src_height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
......@@ -729,7 +730,7 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height;
new_layer =
layer_new_from_tiles (dest_gimage, tiles,
layer_new_from_tiles (dest_gimage, gimp_image_base_type_with_alpha(dest_gimage), tiles,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......@@ -740,8 +741,8 @@ gdisplay_drag_drop (GtkWidget *widget,
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
off_x = (dest_gimage->width - src_width) / 2;
off_y = (dest_gimage->height - src_height) / 2;
layer_translate (new_layer, off_x, off_y);
......
......@@ -671,20 +671,21 @@ gdisplay_drag_drop (GtkWidget *widget,
*/
if (drawable)
{
GImage *gimage;
Layer *new_layer;
GImage *dest_gimage;
gint width, height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes, type;
gimage = gimp_drawable_gimage (drawable);
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
GImage *src_gimage;
Layer *new_layer;
GImage *dest_gimage;
gint src_width, src_height;
gint dest_width, dest_height;
gint off_x, off_y;
TileManager *tiles;
PixelRegion srcPR, destPR;
guchar bg[MAX_CHANNELS];
gint bytes;
GimpImageBaseType type;
src_gimage = gimp_drawable_gimage (drawable);
src_width = gimp_drawable_width (drawable);
src_height = gimp_drawable_height (drawable);
/* How many bytes in the temp buffer? */
switch (drawable_type (drawable))
......@@ -703,14 +704,14 @@ gdisplay_drag_drop (GtkWidget *widget,
break;
}
gimage_get_background (gimage, drawable, bg);
gimage_get_background (src_gimage, drawable, bg);
tiles = tile_manager_new (width, height, bytes);
tiles = tile_manager_new (src_width, src_height, bytes);
pixel_region_init (&srcPR, drawable_data (drawable),
0, 0, width, height, FALSE);
0, 0, src_width, src_height, FALSE);
pixel_region_init (&destPR, tiles,
0, 0, width, height, TRUE);
0, 0, src_width, src_height, TRUE);
if (type == INDEXED)
/* If the layer is indexed...we need to extract pixels */
......@@ -729,7 +730,7 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height;
new_layer =
layer_new_from_tiles (dest_gimage, tiles,
layer_new_from_tiles (dest_gimage, gimp_image_base_type_with_alpha(dest_gimage), tiles,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......@@ -740,8 +741,8 @@ gdisplay_drag_drop (GtkWidget *widget,
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_layer), dest_gimage);
off_x = (dest_gimage->width - width) / 2;
off_y = (dest_gimage->height - height) / 2;
off_x = (dest_gimage->width - src_width) / 2;
off_y = (dest_gimage->height - src_height) / 2;
layer_translate (new_layer, off_x, off_y);
......
......@@ -1166,7 +1166,9 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR);
new_layer = layer_new_from_tiles (new_gimage, tiles,
new_layer = layer_new_from_tiles (new_gimage,
gimp_image_base_type_with_alpha(new_gimage),
tiles,
"", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......
......@@ -1166,7 +1166,9 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR);
new_layer = layer_new_from_tiles (new_gimage, tiles,
new_layer = layer_new_from_tiles (new_gimage,
gimp_image_base_type_with_alpha(new_gimage),
tiles,
"", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......
......@@ -344,7 +344,7 @@ gimage_mask_float (GImage *gimage,
tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE);
/* Create a new layer from the buffer */
layer = layer_new_from_tiles (gimage, tiles,
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), tiles,
_("Floated Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* Set the offsets */
......
......@@ -394,13 +394,13 @@ layer_copy (Layer *layer,
Layer *
layer_new_from_tiles (GimpImage *gimage,
GimpImageType layer_type,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * new_layer;
GimpImageType layer_type;
PixelRegion layerPR, bufPR;
/* Function copies buffer to a layer
......@@ -412,9 +412,7 @@ layer_new_from_tiles (GimpImage *gimage,
if (!gimage || !tiles )
return NULL;
layer_type = gimp_image_base_type_with_alpha (gimage);
/* Create the new layer */
/* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height,
layer_type, name, opacity, mode);
......
......@@ -79,7 +79,7 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_new_from_tiles (GimpImage *, TileManager *,
Layer * layer_new_from_tiles (GimpImage *, GimpImageType, TileManager *,
gchar *, gint, LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -286,7 +286,7 @@ edit_paste (GImage *gimage,
int cx, cy;
/* Make a new layer */
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (layer)
......@@ -355,7 +355,7 @@ edit_paste_as_new (GImage *invoke,
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new_from_tiles (gimage, paste,
layer = layer_new_from_tiles (gimage, gimp_image_base_type_with_alpha (gimage), paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */
......
......@@ -285,8 +285,11 @@ paths_dialog_set_menu_sensitivity (void)
void
paths_dialog_set_default_op (void)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (point_ops_buttons[0].widget),
TRUE);
if(paths_dialog != NULL) /* Bug #5049: Clients may call this because it is possible */
/* to create a path before the L&C dialog exists. */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (point_ops_buttons[0].widget),
TRUE);
}
GtkWidget *
......
......@@ -1166,7 +1166,9 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR);
new_layer = layer_new_from_tiles (new_gimage, tiles,
new_layer = layer_new_from_tiles (new_gimage,
gimp_image_base_type_with_alpha(new_gimage),
tiles,
"", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles);
......
......@@ -394,13 +394,13 @@ layer_copy (Layer *layer,
Layer *
layer_new_from_tiles (GimpImage *gimage,
GimpImageType layer_type,
TileManager *tiles,
gchar *name,
gint opacity,
LayerModeEffects mode)
{
Layer * new_layer;
GimpImageType layer_type;
PixelRegion layerPR, bufPR;
/* Function copies buffer to a layer
......@@ -412,9 +412,7 @@ layer_new_from_tiles (GimpImage *gimage,
if (!gimage || !tiles )
return NULL;
layer_type = gimp_image_base_type_with_alpha (gimage);
/* Create the new layer */
/* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height,
layer_type, name, opacity, mode);
......
......@@ -79,7 +79,7 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *);
void layer_unref (Layer *);
Layer * layer_new_from_tiles (GimpImage *, TileManager *,
Layer * layer_new_from_tiles (GimpImage *, GimpImageType, TileManager *,
gchar *, gint, LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType);
......
......@@ -285,8 +285,11 @@ paths_dialog_set_menu_sensitivity (void)
void
paths_dialog_set_default_op (void)
{
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (point_ops_buttons[0].widget),
TRUE);
if(paths_dialog != NULL) /* Bug #5049: Clients may call this because it is possible */
/* to create a path before the L&C dialog exists. */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (point_ops_buttons[0].widget),
TRUE);
}
GtkWidget *
......
......@@ -1579,7 +1579,7 @@ transform_core_paste (GImage *gimage,
if (new_layer)
{
layer = layer_new_from_tiles (gimage, tiles, _("Transformation"),
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), tiles, _("Transformation"),
OPAQUE_OPACITY, NORMAL_MODE);
GIMP_DRAWABLE (layer)->offset_x = tiles->x;
GIMP_DRAWABLE (layer)->offset_y = tiles->y;
......
......@@ -1579,7 +1579,7 @@ transform_core_paste (GImage *gimage,
if (new_layer)
{
layer = layer_new_from_tiles (gimage, tiles, _("Transformation"),
layer = layer_new_from_tiles (gimage, gimp_drawable_type_with_alpha(drawable), tiles, _("Transformation"),
OPAQUE_OPACITY, NORMAL_MODE);
GIMP_DRAWABLE (layer)->offset_x = tiles->x;
GIMP_DRAWABLE (layer)->offset_y = tiles->y;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment