Removed the obsolete drawable argument from layer_from_tiles.

The layer_type is now taken from the base_type of the image.
Also changed the name to layer_new_from_tiles.


--Sven
This commit is contained in:
Sven Neumann 2000-01-01 18:33:40 +00:00
parent fa16d08f1f
commit a34415cb7b
25 changed files with 241 additions and 208 deletions

View File

@ -1,3 +1,21 @@
Sat Jan 1 18:54:13 CET 2000 Sven Neumann <sven@gimp.org>
* app/disp_callbacks.c
* app/gdisplay.c
* app/gimage_mask.c
* app/global_edit.c
* app/interface.c
* app/layer.c
* app/layer.h
* app/transform_core.c: Removed the obsolete drawable argument from
layer_from_tiles. The layer_type is now taken from the base_type
of the image. Also changed the name to layer_new_from_tiles.
This simplifies some code and finally allows to paste into an empty
image, so I've enabled this. Please test this heavily!!
Should fix bug #4708.
* app/gdisplay_color.c: fixed a compiler warning
Sat Jan 1 17:10:31 CET 2000 Sven Neumann <sven@gimp.org> Sat Jan 1 17:10:31 CET 2000 Sven Neumann <sven@gimp.org>
* plug-ins/common/sunras.c: small i18n fix * plug-ins/common/sunras.c: small i18n fix

View File

@ -281,26 +281,35 @@ edit_paste (GImage *gimage,
TileManager *paste, TileManager *paste,
int paste_into) int paste_into)
{ {
Layer * float_layer; Layer * layer;
int x1, y1, x2, y2; int x1, y1, x2, y2;
int cx, cy; int cx, cy;
/* Make a new floating layer */ /* Make a new layer */
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (float_layer) if (layer)
{ {
/* Start a group undo */ /* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO); undo_push_group_start (gimage, EDIT_PASTE_UNDO);
/* Set the offsets to the center of the image */ /* Set the offsets to the center of the image */
drawable_offsets ( (drawable), &cx, &cy); if (drawable != NULL)
drawable_mask_bounds ( (drawable), &x1, &y1, &x2, &y2); {
drawable_offsets (drawable, &cx, &cy);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
cx += (x1 + x2) >> 1; cx += (x1 + x2) >> 1;
cy += (y1 + y2) >> 1; cy += (y1 + y2) >> 1;
}
else
{
cx = gimage->width >> 1;
cy = gimage->height >> 1;
}
GIMP_DRAWABLE(float_layer)->offset_x = cx - (GIMP_DRAWABLE(float_layer)->width >> 1); GIMP_DRAWABLE(layer)->offset_x = cx - (GIMP_DRAWABLE(layer)->width >> 1);
GIMP_DRAWABLE(float_layer)->offset_y = cy - (GIMP_DRAWABLE(float_layer)->height >> 1); GIMP_DRAWABLE(layer)->offset_y = cy - (GIMP_DRAWABLE(layer)->height >> 1);
/* If there is a selection mask clear it-- /* If there is a selection mask clear it--
* this might not always be desired, but in general, * this might not always be desired, but in general,
@ -309,13 +318,21 @@ edit_paste (GImage *gimage,
if (! gimage_mask_is_empty (gimage) && !paste_into) if (! gimage_mask_is_empty (gimage) && !paste_into)
channel_clear (gimage_get_mask (gimage)); channel_clear (gimage_get_mask (gimage));
/* add a new floating selection */ /* if there's a drawable, add a new floating selection */
floating_sel_attach (float_layer, drawable); if (drawable != NULL)
{
floating_sel_attach (layer, drawable);
}
else
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0);
}
/* end the group undo */ /* end the group undo */
undo_push_group_end (gimage); undo_push_group_end (gimage);
return float_layer; return layer;
} }
else else
return NULL; return NULL;
@ -326,9 +343,7 @@ edit_paste_as_new (GImage *invoke,
TileManager *paste) TileManager *paste)
{ {
GImage *gimage; GImage *gimage;
GimpDrawable *drawable;
Layer *layer; Layer *layer;
Layer *float_layer;
GDisplay *gdisp; GDisplay *gdisp;
if (!global_buf) if (!global_buf)
@ -336,26 +351,19 @@ edit_paste_as_new (GImage *invoke,
/* create a new image (always of type RGB) */ /* create a new image (always of type RGB) */
gimage = gimage_new (paste->width, paste->height, RGB); gimage = gimage_new (paste->width, paste->height, RGB);
gimage_disable_undo (gimage);
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution); gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit); gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new (gimage, gimage->width, gimage->height, RGBA_GIMAGE, layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */ /* add the new layer to the image */
gimage_disable_undo (gimage); gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0); gimage_add_layer (gimage, layer, 0);
drawable = gimage_active_drawable (gimage);
drawable_fill (GIMP_DRAWABLE (drawable), TRANSPARENT_FILL);
/* make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new floating selection */
floating_sel_attach (float_layer, drawable);
floating_sel_anchor (float_layer);
gimage_enable_undo (gimage); gimage_enable_undo (gimage);
gdisp = gdisplay_new (gimage, 0x0101); gdisp = gdisplay_new (gimage, 0x0101);
gimp_context_set_display (gimp_context_get_user (), gdisp); gimp_context_set_display (gimp_context_get_user (), gdisp);
@ -486,6 +494,7 @@ global_edit_paste (void *gdisp_ptr,
else else
{ {
/* flush the display */ /* flush the display */
gdisplays_update_title (gdisp->gimage);
gdisplays_flush (); gdisplays_flush ();
return TRUE; return TRUE;
} }

View File

@ -281,26 +281,35 @@ edit_paste (GImage *gimage,
TileManager *paste, TileManager *paste,
int paste_into) int paste_into)
{ {
Layer * float_layer; Layer * layer;
int x1, y1, x2, y2; int x1, y1, x2, y2;
int cx, cy; int cx, cy;
/* Make a new floating layer */ /* Make a new layer */
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (float_layer) if (layer)
{ {
/* Start a group undo */ /* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO); undo_push_group_start (gimage, EDIT_PASTE_UNDO);
/* Set the offsets to the center of the image */ /* Set the offsets to the center of the image */
drawable_offsets ( (drawable), &cx, &cy); if (drawable != NULL)
drawable_mask_bounds ( (drawable), &x1, &y1, &x2, &y2); {
drawable_offsets (drawable, &cx, &cy);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
cx += (x1 + x2) >> 1; cx += (x1 + x2) >> 1;
cy += (y1 + y2) >> 1; cy += (y1 + y2) >> 1;
}
else
{
cx = gimage->width >> 1;
cy = gimage->height >> 1;
}
GIMP_DRAWABLE(float_layer)->offset_x = cx - (GIMP_DRAWABLE(float_layer)->width >> 1); GIMP_DRAWABLE(layer)->offset_x = cx - (GIMP_DRAWABLE(layer)->width >> 1);
GIMP_DRAWABLE(float_layer)->offset_y = cy - (GIMP_DRAWABLE(float_layer)->height >> 1); GIMP_DRAWABLE(layer)->offset_y = cy - (GIMP_DRAWABLE(layer)->height >> 1);
/* If there is a selection mask clear it-- /* If there is a selection mask clear it--
* this might not always be desired, but in general, * this might not always be desired, but in general,
@ -309,13 +318,21 @@ edit_paste (GImage *gimage,
if (! gimage_mask_is_empty (gimage) && !paste_into) if (! gimage_mask_is_empty (gimage) && !paste_into)
channel_clear (gimage_get_mask (gimage)); channel_clear (gimage_get_mask (gimage));
/* add a new floating selection */ /* if there's a drawable, add a new floating selection */
floating_sel_attach (float_layer, drawable); if (drawable != NULL)
{
floating_sel_attach (layer, drawable);
}
else
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0);
}
/* end the group undo */ /* end the group undo */
undo_push_group_end (gimage); undo_push_group_end (gimage);
return float_layer; return layer;
} }
else else
return NULL; return NULL;
@ -326,9 +343,7 @@ edit_paste_as_new (GImage *invoke,
TileManager *paste) TileManager *paste)
{ {
GImage *gimage; GImage *gimage;
GimpDrawable *drawable;
Layer *layer; Layer *layer;
Layer *float_layer;
GDisplay *gdisp; GDisplay *gdisp;
if (!global_buf) if (!global_buf)
@ -336,26 +351,19 @@ edit_paste_as_new (GImage *invoke,
/* create a new image (always of type RGB) */ /* create a new image (always of type RGB) */
gimage = gimage_new (paste->width, paste->height, RGB); gimage = gimage_new (paste->width, paste->height, RGB);
gimage_disable_undo (gimage);
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution); gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit); gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new (gimage, gimage->width, gimage->height, RGBA_GIMAGE, layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */ /* add the new layer to the image */
gimage_disable_undo (gimage); gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0); gimage_add_layer (gimage, layer, 0);
drawable = gimage_active_drawable (gimage);
drawable_fill (GIMP_DRAWABLE (drawable), TRANSPARENT_FILL);
/* make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new floating selection */
floating_sel_attach (float_layer, drawable);
floating_sel_anchor (float_layer);
gimage_enable_undo (gimage); gimage_enable_undo (gimage);
gdisp = gdisplay_new (gimage, 0x0101); gdisp = gdisplay_new (gimage, 0x0101);
gimp_context_set_display (gimp_context_get_user (), gdisp); gimp_context_set_display (gimp_context_get_user (), gdisp);
@ -486,6 +494,7 @@ global_edit_paste (void *gdisp_ptr,
else else
{ {
/* flush the display */ /* flush the display */
gdisplays_update_title (gdisp->gimage);
gdisplays_flush (); gdisplays_flush ();
return TRUE; return TRUE;
} }

View File

@ -344,8 +344,8 @@ gimage_mask_float (GImage *gimage,
tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE); tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE);
/* Create a new layer from the buffer */ /* Create a new layer from the buffer */
layer = layer_from_tiles (gimage, drawable, tiles, _("Floated Layer"), layer = layer_new_from_tiles (gimage, tiles,
OPAQUE_OPACITY, NORMAL_MODE); _("Floated Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* Set the offsets */ /* Set the offsets */
GIMP_DRAWABLE(layer)->offset_x = tiles->x + off_x; GIMP_DRAWABLE(layer)->offset_x = tiles->x + off_x;

View File

@ -393,14 +393,12 @@ layer_copy (Layer *layer,
} }
Layer * Layer *
layer_from_tiles (void *gimage_ptr, layer_new_from_tiles (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *tiles, TileManager *tiles,
gchar *name, gchar *name,
gint opacity, gint opacity,
LayerModeEffects mode) LayerModeEffects mode)
{ {
GImage * gimage;
Layer * new_layer; Layer * new_layer;
GimpImageType layer_type; GimpImageType layer_type;
PixelRegion layerPR, bufPR; PixelRegion layerPR, bufPR;
@ -410,13 +408,11 @@ layer_from_tiles (void *gimage_ptr,
* the contents to meet the requirements of the target image type * the contents to meet the requirements of the target image type
*/ */
/* If no tile manager, return NULL */ /* If no image or no tile manager, return NULL */
if (!tiles) if (!gimage || !tiles )
return NULL; return NULL;
gimage = (GImage *) gimage_ptr; layer_type = gimp_image_base_type_with_alpha (gimage);
layer_type = drawable_type_with_alpha (drawable);
/* Create the new layer */ /* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height, new_layer = layer_new (0, tiles->width, tiles->height,
@ -424,7 +420,7 @@ layer_from_tiles (void *gimage_ptr,
if (!new_layer) if (!new_layer)
{ {
g_message ("layer_from_tiles: could not allocate new layer"); g_message ("layer_new_from_tiles: could not allocate new layer");
return NULL; return NULL;
} }

View File

@ -79,10 +79,8 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *); Layer * layer_ref (Layer *);
void layer_unref (Layer *); void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, Layer * layer_new_from_tiles (GimpImage *, TileManager *,
TileManager *, gchar *, gint, LayerModeEffects);
gchar *, gint,
LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *); LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType); LayerMask * layer_create_mask (Layer *, AddMaskType);
Layer * layer_get_ID (gint); Layer * layer_get_ID (gint);

View File

@ -633,7 +633,8 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
static void static void
gdisplay_flush_whenever (GDisplay *gdisp, gboolean now) gdisplay_flush_whenever (GDisplay *gdisp,
gboolean now)
{ {
GSList *list; GSList *list;
GArea *ga; GArea *ga;
@ -699,7 +700,8 @@ gdisplay_flush_now (GDisplay *gdisp)
} }
/* Force all gdisplays to finish their idlerender projection */ /* Force all gdisplays to finish their idlerender projection */
void gdisplays_finish_draw (void) void
gdisplays_finish_draw (void)
{ {
GSList *list = display_list; GSList *list = display_list;
GDisplay* gdisp; GDisplay* gdisp;
@ -1018,7 +1020,9 @@ gdisplay_draw_cursor (GDisplay *gdisp)
} }
void void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y) gdisplay_update_cursor (GDisplay *gdisp,
int x,
int y)
{ {
int new_cursor; int new_cursor;
char buffer[CURSOR_STR_LENGTH]; char buffer[CURSOR_STR_LENGTH];
@ -1090,7 +1094,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
void void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value) gdisplay_set_dot_for_dot (GDisplay *gdisp,
int value)
{ {
if (value != gdisp->dot_for_dot) if (value != gdisp->dot_for_dot)
{ {
@ -1649,12 +1654,8 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage)); SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage));
SET_SENSITIVE ("Edit/Cut", lp); SET_SENSITIVE ("Edit/Cut", lp);
SET_SENSITIVE ("Edit/Copy", lp); SET_SENSITIVE ("Edit/Copy", lp);
SET_SENSITIVE ("Edit/Paste", lp);
SET_SENSITIVE ("Edit/Paste Into", lp);
SET_SENSITIVE ("Edit/Paste as New", lp);
SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp); SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp); SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Paste Named...", lp);
SET_SENSITIVE ("Edit/Clear", lp); SET_SENSITIVE ("Edit/Clear", lp);
SET_SENSITIVE ("Edit/Fill", lp); SET_SENSITIVE ("Edit/Fill", lp);
SET_SENSITIVE ("Edit/Stroke", lp); SET_SENSITIVE ("Edit/Stroke", lp);
@ -2063,7 +2064,7 @@ gdisplays_nav_preview_resized (void)
} }
void void
gdisplays_selection_visibility (GimpImage* gimage, gdisplays_selection_visibility (GimpImage *gimage,
SelectionControl function) SelectionControl function)
{ {
GDisplay *gdisp; GDisplay *gdisp;
@ -2140,7 +2141,8 @@ gdisplays_delete (void)
GDisplay * GDisplay *
gdisplays_check_valid (GDisplay *gtest, GimpImage *gimage) gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{ {
/* Give a gdisp check that it is still valid and points to the require /* Give a gdisp check that it is still valid and points to the require
* GimpImage. If not return the first gDisplay that does point to the * GimpImage. If not return the first gDisplay that does point to the
@ -2217,7 +2219,8 @@ gdisplay_hash (GDisplay *display)
} }
void void
gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage) gdisplay_reconnect (GDisplay *gdisp,
GimpImage *gimage)
{ {
int instance; int instance;
@ -2252,7 +2255,8 @@ gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage)
/* Called whenever the underlying gimage is dirtied or cleaned */ /* Called whenever the underlying gimage is dirtied or cleaned */
static void static void
gdisplay_cleandirty_handler (GimpImage *gimage, void *data) gdisplay_cleandirty_handler (GimpImage *gimage,
void *data)
{ {
GDisplay *gdisp = data; GDisplay *gdisp = data;

View File

@ -729,10 +729,8 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height; dest_height = dest_gimage->height;
new_layer = new_layer =
layer_from_tiles (dest_gimage, layer_new_from_tiles (dest_gimage, tiles,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)), _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -729,10 +729,8 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height; dest_height = dest_gimage->height;
new_layer = new_layer =
layer_from_tiles (dest_gimage, layer_new_from_tiles (dest_gimage, tiles,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)), _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -633,7 +633,8 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
static void static void
gdisplay_flush_whenever (GDisplay *gdisp, gboolean now) gdisplay_flush_whenever (GDisplay *gdisp,
gboolean now)
{ {
GSList *list; GSList *list;
GArea *ga; GArea *ga;
@ -699,7 +700,8 @@ gdisplay_flush_now (GDisplay *gdisp)
} }
/* Force all gdisplays to finish their idlerender projection */ /* Force all gdisplays to finish their idlerender projection */
void gdisplays_finish_draw (void) void
gdisplays_finish_draw (void)
{ {
GSList *list = display_list; GSList *list = display_list;
GDisplay* gdisp; GDisplay* gdisp;
@ -1018,7 +1020,9 @@ gdisplay_draw_cursor (GDisplay *gdisp)
} }
void void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y) gdisplay_update_cursor (GDisplay *gdisp,
int x,
int y)
{ {
int new_cursor; int new_cursor;
char buffer[CURSOR_STR_LENGTH]; char buffer[CURSOR_STR_LENGTH];
@ -1090,7 +1094,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
void void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value) gdisplay_set_dot_for_dot (GDisplay *gdisp,
int value)
{ {
if (value != gdisp->dot_for_dot) if (value != gdisp->dot_for_dot)
{ {
@ -1649,12 +1654,8 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage)); SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage));
SET_SENSITIVE ("Edit/Cut", lp); SET_SENSITIVE ("Edit/Cut", lp);
SET_SENSITIVE ("Edit/Copy", lp); SET_SENSITIVE ("Edit/Copy", lp);
SET_SENSITIVE ("Edit/Paste", lp);
SET_SENSITIVE ("Edit/Paste Into", lp);
SET_SENSITIVE ("Edit/Paste as New", lp);
SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp); SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp); SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Paste Named...", lp);
SET_SENSITIVE ("Edit/Clear", lp); SET_SENSITIVE ("Edit/Clear", lp);
SET_SENSITIVE ("Edit/Fill", lp); SET_SENSITIVE ("Edit/Fill", lp);
SET_SENSITIVE ("Edit/Stroke", lp); SET_SENSITIVE ("Edit/Stroke", lp);
@ -2063,7 +2064,7 @@ gdisplays_nav_preview_resized (void)
} }
void void
gdisplays_selection_visibility (GimpImage* gimage, gdisplays_selection_visibility (GimpImage *gimage,
SelectionControl function) SelectionControl function)
{ {
GDisplay *gdisp; GDisplay *gdisp;
@ -2140,7 +2141,8 @@ gdisplays_delete (void)
GDisplay * GDisplay *
gdisplays_check_valid (GDisplay *gtest, GimpImage *gimage) gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{ {
/* Give a gdisp check that it is still valid and points to the require /* Give a gdisp check that it is still valid and points to the require
* GimpImage. If not return the first gDisplay that does point to the * GimpImage. If not return the first gDisplay that does point to the
@ -2217,7 +2219,8 @@ gdisplay_hash (GDisplay *display)
} }
void void
gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage) gdisplay_reconnect (GDisplay *gdisp,
GimpImage *gimage)
{ {
int instance; int instance;
@ -2252,7 +2255,8 @@ gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage)
/* Called whenever the underlying gimage is dirtied or cleaned */ /* Called whenever the underlying gimage is dirtied or cleaned */
static void static void
gdisplay_cleandirty_handler (GimpImage *gimage, void *data) gdisplay_cleandirty_handler (GimpImage *gimage,
void *data)
{ {
GDisplay *gdisp = data; GDisplay *gdisp = data;

View File

@ -729,10 +729,8 @@ gdisplay_drag_drop (GtkWidget *widget,
dest_height = dest_gimage->height; dest_height = dest_gimage->height;
new_layer = new_layer =
layer_from_tiles (dest_gimage, layer_new_from_tiles (dest_gimage, tiles,
GIMP_DRAWABLE (gimage_get_active_layer (dest_gimage)), _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
tiles, _("Pasted Layer"),
OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -1164,7 +1164,7 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR); add_alpha_region (&srcPR, &destPR);
new_layer = layer_from_tiles (new_gimage, drawable, tiles, new_layer = layer_new_from_tiles (new_gimage, tiles,
"", OPAQUE_OPACITY, NORMAL_MODE); "", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -154,7 +154,7 @@ gdisplay_color_attach (GDisplay *gdisp,
ColorDisplayInfo *info; ColorDisplayInfo *info;
ColorDisplayNode *node; ColorDisplayNode *node;
g_return_if_fail (gdisp != NULL); g_return_val_if_fail (gdisp != NULL, NULL);
if ((info = g_hash_table_lookup (color_display_table, name))) if ((info = g_hash_table_lookup (color_display_table, name)))
{ {

View File

@ -1164,7 +1164,7 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR); add_alpha_region (&srcPR, &destPR);
new_layer = layer_from_tiles (new_gimage, drawable, tiles, new_layer = layer_new_from_tiles (new_gimage, tiles,
"", OPAQUE_OPACITY, NORMAL_MODE); "", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -633,7 +633,8 @@ gdisplay_flush_displays_only (GDisplay *gdisp)
static void static void
gdisplay_flush_whenever (GDisplay *gdisp, gboolean now) gdisplay_flush_whenever (GDisplay *gdisp,
gboolean now)
{ {
GSList *list; GSList *list;
GArea *ga; GArea *ga;
@ -699,7 +700,8 @@ gdisplay_flush_now (GDisplay *gdisp)
} }
/* Force all gdisplays to finish their idlerender projection */ /* Force all gdisplays to finish their idlerender projection */
void gdisplays_finish_draw (void) void
gdisplays_finish_draw (void)
{ {
GSList *list = display_list; GSList *list = display_list;
GDisplay* gdisp; GDisplay* gdisp;
@ -1018,7 +1020,9 @@ gdisplay_draw_cursor (GDisplay *gdisp)
} }
void void
gdisplay_update_cursor (GDisplay *gdisp, int x, int y) gdisplay_update_cursor (GDisplay *gdisp,
int x,
int y)
{ {
int new_cursor; int new_cursor;
char buffer[CURSOR_STR_LENGTH]; char buffer[CURSOR_STR_LENGTH];
@ -1090,7 +1094,8 @@ gdisplay_update_cursor (GDisplay *gdisp, int x, int y)
void void
gdisplay_set_dot_for_dot (GDisplay *gdisp, int value) gdisplay_set_dot_for_dot (GDisplay *gdisp,
int value)
{ {
if (value != gdisp->dot_for_dot) if (value != gdisp->dot_for_dot)
{ {
@ -1649,12 +1654,8 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage)); SET_SENSITIVE ("Edit/Redo", undo_get_redo_name (gdisp->gimage));
SET_SENSITIVE ("Edit/Cut", lp); SET_SENSITIVE ("Edit/Cut", lp);
SET_SENSITIVE ("Edit/Copy", lp); SET_SENSITIVE ("Edit/Copy", lp);
SET_SENSITIVE ("Edit/Paste", lp);
SET_SENSITIVE ("Edit/Paste Into", lp);
SET_SENSITIVE ("Edit/Paste as New", lp);
SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp); SET_SENSITIVE ("Edit/Buffer/Cut Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp); SET_SENSITIVE ("Edit/Buffer/Copy Named...", lp);
SET_SENSITIVE ("Edit/Buffer/Paste Named...", lp);
SET_SENSITIVE ("Edit/Clear", lp); SET_SENSITIVE ("Edit/Clear", lp);
SET_SENSITIVE ("Edit/Fill", lp); SET_SENSITIVE ("Edit/Fill", lp);
SET_SENSITIVE ("Edit/Stroke", lp); SET_SENSITIVE ("Edit/Stroke", lp);
@ -2063,7 +2064,7 @@ gdisplays_nav_preview_resized (void)
} }
void void
gdisplays_selection_visibility (GimpImage* gimage, gdisplays_selection_visibility (GimpImage *gimage,
SelectionControl function) SelectionControl function)
{ {
GDisplay *gdisp; GDisplay *gdisp;
@ -2140,7 +2141,8 @@ gdisplays_delete (void)
GDisplay * GDisplay *
gdisplays_check_valid (GDisplay *gtest, GimpImage *gimage) gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{ {
/* Give a gdisp check that it is still valid and points to the require /* Give a gdisp check that it is still valid and points to the require
* GimpImage. If not return the first gDisplay that does point to the * GimpImage. If not return the first gDisplay that does point to the
@ -2217,7 +2219,8 @@ gdisplay_hash (GDisplay *display)
} }
void void
gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage) gdisplay_reconnect (GDisplay *gdisp,
GimpImage *gimage)
{ {
int instance; int instance;
@ -2252,7 +2255,8 @@ gdisplay_reconnect (GDisplay *gdisp, GimpImage *gimage)
/* Called whenever the underlying gimage is dirtied or cleaned */ /* Called whenever the underlying gimage is dirtied or cleaned */
static void static void
gdisplay_cleandirty_handler (GimpImage *gimage, void *data) gdisplay_cleandirty_handler (GimpImage *gimage,
void *data)
{ {
GDisplay *gdisp = data; GDisplay *gdisp = data;

View File

@ -154,7 +154,7 @@ gdisplay_color_attach (GDisplay *gdisp,
ColorDisplayInfo *info; ColorDisplayInfo *info;
ColorDisplayNode *node; ColorDisplayNode *node;
g_return_if_fail (gdisp != NULL); g_return_val_if_fail (gdisp != NULL, NULL);
if ((info = g_hash_table_lookup (color_display_table, name))) if ((info = g_hash_table_lookup (color_display_table, name)))
{ {

View File

@ -344,8 +344,8 @@ gimage_mask_float (GImage *gimage,
tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE); tiles = gimage_mask_extract (gimage, drawable, TRUE, FALSE);
/* Create a new layer from the buffer */ /* Create a new layer from the buffer */
layer = layer_from_tiles (gimage, drawable, tiles, _("Floated Layer"), layer = layer_new_from_tiles (gimage, tiles,
OPAQUE_OPACITY, NORMAL_MODE); _("Floated Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* Set the offsets */ /* Set the offsets */
GIMP_DRAWABLE(layer)->offset_x = tiles->x + off_x; GIMP_DRAWABLE(layer)->offset_x = tiles->x + off_x;

View File

@ -393,14 +393,12 @@ layer_copy (Layer *layer,
} }
Layer * Layer *
layer_from_tiles (void *gimage_ptr, layer_new_from_tiles (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *tiles, TileManager *tiles,
gchar *name, gchar *name,
gint opacity, gint opacity,
LayerModeEffects mode) LayerModeEffects mode)
{ {
GImage * gimage;
Layer * new_layer; Layer * new_layer;
GimpImageType layer_type; GimpImageType layer_type;
PixelRegion layerPR, bufPR; PixelRegion layerPR, bufPR;
@ -410,13 +408,11 @@ layer_from_tiles (void *gimage_ptr,
* the contents to meet the requirements of the target image type * the contents to meet the requirements of the target image type
*/ */
/* If no tile manager, return NULL */ /* If no image or no tile manager, return NULL */
if (!tiles) if (!gimage || !tiles )
return NULL; return NULL;
gimage = (GImage *) gimage_ptr; layer_type = gimp_image_base_type_with_alpha (gimage);
layer_type = drawable_type_with_alpha (drawable);
/* Create the new layer */ /* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height, new_layer = layer_new (0, tiles->width, tiles->height,
@ -424,7 +420,7 @@ layer_from_tiles (void *gimage_ptr,
if (!new_layer) if (!new_layer)
{ {
g_message ("layer_from_tiles: could not allocate new layer"); g_message ("layer_new_from_tiles: could not allocate new layer");
return NULL; return NULL;
} }

View File

@ -79,10 +79,8 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *); Layer * layer_ref (Layer *);
void layer_unref (Layer *); void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, Layer * layer_new_from_tiles (GimpImage *, TileManager *,
TileManager *, gchar *, gint, LayerModeEffects);
gchar *, gint,
LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *); LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType); LayerMask * layer_create_mask (Layer *, AddMaskType);
Layer * layer_get_ID (gint); Layer * layer_get_ID (gint);

View File

@ -281,26 +281,35 @@ edit_paste (GImage *gimage,
TileManager *paste, TileManager *paste,
int paste_into) int paste_into)
{ {
Layer * float_layer; Layer * layer;
int x1, y1, x2, y2; int x1, y1, x2, y2;
int cx, cy; int cx, cy;
/* Make a new floating layer */ /* Make a new layer */
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
if (float_layer) if (layer)
{ {
/* Start a group undo */ /* Start a group undo */
undo_push_group_start (gimage, EDIT_PASTE_UNDO); undo_push_group_start (gimage, EDIT_PASTE_UNDO);
/* Set the offsets to the center of the image */ /* Set the offsets to the center of the image */
drawable_offsets ( (drawable), &cx, &cy); if (drawable != NULL)
drawable_mask_bounds ( (drawable), &x1, &y1, &x2, &y2); {
drawable_offsets (drawable, &cx, &cy);
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
cx += (x1 + x2) >> 1; cx += (x1 + x2) >> 1;
cy += (y1 + y2) >> 1; cy += (y1 + y2) >> 1;
}
else
{
cx = gimage->width >> 1;
cy = gimage->height >> 1;
}
GIMP_DRAWABLE(float_layer)->offset_x = cx - (GIMP_DRAWABLE(float_layer)->width >> 1); GIMP_DRAWABLE(layer)->offset_x = cx - (GIMP_DRAWABLE(layer)->width >> 1);
GIMP_DRAWABLE(float_layer)->offset_y = cy - (GIMP_DRAWABLE(float_layer)->height >> 1); GIMP_DRAWABLE(layer)->offset_y = cy - (GIMP_DRAWABLE(layer)->height >> 1);
/* If there is a selection mask clear it-- /* If there is a selection mask clear it--
* this might not always be desired, but in general, * this might not always be desired, but in general,
@ -309,13 +318,21 @@ edit_paste (GImage *gimage,
if (! gimage_mask_is_empty (gimage) && !paste_into) if (! gimage_mask_is_empty (gimage) && !paste_into)
channel_clear (gimage_get_mask (gimage)); channel_clear (gimage_get_mask (gimage));
/* add a new floating selection */ /* if there's a drawable, add a new floating selection */
floating_sel_attach (float_layer, drawable); if (drawable != NULL)
{
floating_sel_attach (layer, drawable);
}
else
{
gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0);
}
/* end the group undo */ /* end the group undo */
undo_push_group_end (gimage); undo_push_group_end (gimage);
return float_layer; return layer;
} }
else else
return NULL; return NULL;
@ -326,9 +343,7 @@ edit_paste_as_new (GImage *invoke,
TileManager *paste) TileManager *paste)
{ {
GImage *gimage; GImage *gimage;
GimpDrawable *drawable;
Layer *layer; Layer *layer;
Layer *float_layer;
GDisplay *gdisp; GDisplay *gdisp;
if (!global_buf) if (!global_buf)
@ -336,26 +351,19 @@ edit_paste_as_new (GImage *invoke,
/* create a new image (always of type RGB) */ /* create a new image (always of type RGB) */
gimage = gimage_new (paste->width, paste->height, RGB); gimage = gimage_new (paste->width, paste->height, RGB);
gimage_disable_undo (gimage);
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution); gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit); gimp_image_set_unit (gimage, invoke->unit);
layer = layer_new (gimage, gimage->width, gimage->height, RGBA_GIMAGE, layer = layer_new_from_tiles (gimage, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE); _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new layer to the image */ /* add the new layer to the image */
gimage_disable_undo (gimage); gimp_drawable_set_gimage (GIMP_DRAWABLE (layer), gimage);
gimage_add_layer (gimage, layer, 0); gimage_add_layer (gimage, layer, 0);
drawable = gimage_active_drawable (gimage);
drawable_fill (GIMP_DRAWABLE (drawable), TRANSPARENT_FILL);
/* make a new floating layer */
float_layer = layer_from_tiles (gimage, drawable, paste,
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
/* add the new floating selection */
floating_sel_attach (float_layer, drawable);
floating_sel_anchor (float_layer);
gimage_enable_undo (gimage); gimage_enable_undo (gimage);
gdisp = gdisplay_new (gimage, 0x0101); gdisp = gdisplay_new (gimage, 0x0101);
gimp_context_set_display (gimp_context_get_user (), gdisp); gimp_context_set_display (gimp_context_get_user (), gdisp);
@ -486,6 +494,7 @@ global_edit_paste (void *gdisp_ptr,
else else
{ {
/* flush the display */ /* flush the display */
gdisplays_update_title (gdisp->gimage);
gdisplays_flush (); gdisplays_flush ();
return TRUE; return TRUE;
} }

View File

@ -1164,7 +1164,7 @@ toolbox_drag_drop (GtkWidget *widget,
add_alpha_region (&srcPR, &destPR); add_alpha_region (&srcPR, &destPR);
new_layer = layer_from_tiles (new_gimage, drawable, tiles, new_layer = layer_new_from_tiles (new_gimage, tiles,
"", OPAQUE_OPACITY, NORMAL_MODE); "", OPAQUE_OPACITY, NORMAL_MODE);
tile_manager_destroy (tiles); tile_manager_destroy (tiles);

View File

@ -393,14 +393,12 @@ layer_copy (Layer *layer,
} }
Layer * Layer *
layer_from_tiles (void *gimage_ptr, layer_new_from_tiles (GimpImage *gimage,
GimpDrawable *drawable,
TileManager *tiles, TileManager *tiles,
gchar *name, gchar *name,
gint opacity, gint opacity,
LayerModeEffects mode) LayerModeEffects mode)
{ {
GImage * gimage;
Layer * new_layer; Layer * new_layer;
GimpImageType layer_type; GimpImageType layer_type;
PixelRegion layerPR, bufPR; PixelRegion layerPR, bufPR;
@ -410,13 +408,11 @@ layer_from_tiles (void *gimage_ptr,
* the contents to meet the requirements of the target image type * the contents to meet the requirements of the target image type
*/ */
/* If no tile manager, return NULL */ /* If no image or no tile manager, return NULL */
if (!tiles) if (!gimage || !tiles )
return NULL; return NULL;
gimage = (GImage *) gimage_ptr; layer_type = gimp_image_base_type_with_alpha (gimage);
layer_type = drawable_type_with_alpha (drawable);
/* Create the new layer */ /* Create the new layer */
new_layer = layer_new (0, tiles->width, tiles->height, new_layer = layer_new (0, tiles->width, tiles->height,
@ -424,7 +420,7 @@ layer_from_tiles (void *gimage_ptr,
if (!new_layer) if (!new_layer)
{ {
g_message ("layer_from_tiles: could not allocate new layer"); g_message ("layer_new_from_tiles: could not allocate new layer");
return NULL; return NULL;
} }

View File

@ -79,10 +79,8 @@ Layer * layer_copy (Layer *, gboolean);
Layer * layer_ref (Layer *); Layer * layer_ref (Layer *);
void layer_unref (Layer *); void layer_unref (Layer *);
Layer * layer_from_tiles (void *, GimpDrawable *, Layer * layer_new_from_tiles (GimpImage *, TileManager *,
TileManager *, gchar *, gint, LayerModeEffects);
gchar *, gint,
LayerModeEffects);
LayerMask * layer_add_mask (Layer *, LayerMask *); LayerMask * layer_add_mask (Layer *, LayerMask *);
LayerMask * layer_create_mask (Layer *, AddMaskType); LayerMask * layer_create_mask (Layer *, AddMaskType);
Layer * layer_get_ID (gint); Layer * layer_get_ID (gint);

View File

@ -1533,8 +1533,8 @@ transform_core_paste (GImage *gimage,
if (new_layer) if (new_layer)
{ {
layer = layer_from_tiles (gimage, drawable, tiles, _("Transformation"), layer = layer_new_from_tiles (gimage, tiles,
OPAQUE_OPACITY, NORMAL_MODE); _("Transformation"), OPAQUE_OPACITY, NORMAL_MODE);
GIMP_DRAWABLE(layer)->offset_x = tiles->x; GIMP_DRAWABLE(layer)->offset_x = tiles->x;
GIMP_DRAWABLE(layer)->offset_y = tiles->y; GIMP_DRAWABLE(layer)->offset_y = tiles->y;

View File

@ -1533,8 +1533,8 @@ transform_core_paste (GImage *gimage,
if (new_layer) if (new_layer)
{ {
layer = layer_from_tiles (gimage, drawable, tiles, _("Transformation"), layer = layer_new_from_tiles (gimage, tiles,
OPAQUE_OPACITY, NORMAL_MODE); _("Transformation"), OPAQUE_OPACITY, NORMAL_MODE);
GIMP_DRAWABLE(layer)->offset_x = tiles->x; GIMP_DRAWABLE(layer)->offset_x = tiles->x;
GIMP_DRAWABLE(layer)->offset_y = tiles->y; GIMP_DRAWABLE(layer)->offset_y = tiles->y;