added offset_x and offset_y to gimp_drawable_configure().

2003-01-31  Sven Neumann  <sven@gimp.org>

	* app/core/gimpdrawable.[ch]: added offset_x and offset_y to
	gimp_drawable_configure().

	* app/core/gimpchannel.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.c: changed accordingly.

	* app/text/gimptextlayer.[ch]: update the layer when the associated
	GimpText object changes.
This commit is contained in:
Sven Neumann 2003-01-31 16:37:03 +00:00 committed by Sven Neumann
parent b1fed0c0a3
commit 291eb383c7
9 changed files with 79 additions and 19 deletions

View File

@ -1,3 +1,15 @@
2003-01-31 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable.[ch]: added offset_x and offset_y to
gimp_drawable_configure().
* app/core/gimpchannel.c
* app/core/gimplayer.c
* app/core/gimplayermask.c: changed accordingly.
* app/text/gimptextlayer.[ch]: update the layer when the associated
GimpText object changes.
2003-01-31 Sven Neumann <sven@gimp.org>
* app/widgets/gimpfontselection.c: allow NULL as context parameter

View File

@ -208,7 +208,9 @@ gimp_channel_new (GimpImage *gimage,
channel = g_object_new (GIMP_TYPE_CHANNEL, NULL);
gimp_drawable_configure (GIMP_DRAWABLE (channel),
gimage, width, height, GIMP_GRAY_IMAGE, name);
gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;

View File

@ -208,7 +208,9 @@ gimp_channel_new (GimpImage *gimage,
channel = g_object_new (GIMP_TYPE_CHANNEL, NULL);
gimp_drawable_configure (GIMP_DRAWABLE (channel),
gimage, width, height, GIMP_GRAY_IMAGE, name);
gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the channel color and opacity */
channel->color = *color;

View File

@ -216,6 +216,8 @@ gimp_drawable_invalidate_preview (GimpViewable *viewable)
void
gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage,
gint offset_x,
gint offset_y,
gint width,
gint height,
GimpImageType type,
@ -235,8 +237,8 @@ gimp_drawable_configure (GimpDrawable *drawable,
drawable->type = type;
drawable->bytes = GIMP_IMAGE_TYPE_BYTES (type);
drawable->has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (type);
drawable->offset_x = 0;
drawable->offset_y = 0;
drawable->offset_x = offset_x;
drawable->offset_y = offset_y;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
@ -310,14 +312,14 @@ gimp_drawable_copy (GimpDrawable *drawable,
gimp_drawable_configure (new_drawable,
gimp_item_get_image (GIMP_ITEM (drawable)),
drawable->offset_x,
drawable->offset_y,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable),
new_image_type,
new_name);
g_free (new_name);
new_drawable->offset_x = drawable->offset_x;
new_drawable->offset_y = drawable->offset_y;
new_drawable->visible = drawable->visible;
pixel_region_init (&srcPR, drawable->tiles,

View File

@ -65,6 +65,8 @@ GType gimp_drawable_get_type (void) G_GNUC_CONST;
void gimp_drawable_configure (GimpDrawable *drawable,
GimpImage *gimage,
gint offset_x,
gint offset_y,
gint width,
gint height,
GimpImageType type,

View File

@ -324,7 +324,7 @@ gimp_layer_new (GimpImage *gimage,
gimp_drawable_configure (GIMP_DRAWABLE (layer),
gimage,
width, height,
0, 0, width, height,
type,
name);
@ -1227,7 +1227,7 @@ gimp_layer_resize (GimpLayer *layer,
}
/* Update the old layer position */
gimp_drawable_update (GIMP_DRAWABLE( layer),
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
GIMP_DRAWABLE (layer)->width,
GIMP_DRAWABLE (layer)->height);

View File

@ -136,7 +136,9 @@ gimp_layer_mask_new (GimpImage *gimage,
layer_mask = g_object_new (GIMP_TYPE_LAYER_MASK, NULL);
gimp_drawable_configure (GIMP_DRAWABLE (layer_mask),
gimage, width, height, GIMP_GRAY_IMAGE, name);
gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the layer_mask color and opacity */
GIMP_CHANNEL (layer_mask)->color = *color;

View File

@ -156,9 +156,14 @@ gimp_text_layer_new (GimpImage *image,
layer = g_object_new (GIMP_TYPE_TEXT_LAYER, NULL);
layer->text = g_object_ref (text);
gimp_item_set_image (GIMP_ITEM (layer), image);
layer->text = g_object_ref (text);
g_signal_connect_object (text, "notify",
G_CALLBACK (gimp_text_layer_render),
layer, G_CONNECT_SWAPPED);
if (!gimp_text_layer_render (layer))
{
g_object_unref (layer);
@ -168,6 +173,14 @@ gimp_text_layer_new (GimpImage *image,
return GIMP_LAYER (layer);
}
GimpText *
gimp_text_layer_get_text (GimpTextLayer *layer)
{
g_return_val_if_fail (GIMP_IS_TEXT_LAYER (layer), NULL);
return layer->text;
}
static gsize
gimp_text_layer_get_memsize (GimpObject *object)
{
@ -200,10 +213,13 @@ gimp_text_layer_get_preview (GimpViewable *viewable,
static gboolean
gimp_text_layer_render (GimpTextLayer *layer)
{
GimpDrawable *drawable;
PangoLayout *layout;
gint x, y;
gint width, height;
GimpImage *image;
GimpDrawable *drawable;
PangoLayout *layout;
gchar *name;
gchar *newline;
gint x, y;
gint width, height;
layout = gimp_text_layer_layout_new (layer);
@ -214,27 +230,46 @@ gimp_text_layer_render (GimpTextLayer *layer)
return FALSE;
}
newline = strchr (layer->text->text, '\n');
if (newline)
name = g_strndup (layer->text->text, newline - layer->text->text);
else
name = layer->text->text;
image = gimp_item_get_image (GIMP_ITEM (layer));
drawable = GIMP_DRAWABLE (layer);
if (width != gimp_drawable_width (drawable) ||
height != gimp_drawable_height (drawable))
{
GimpImage * image = gimp_item_get_image (GIMP_ITEM (drawable));
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
gimp_drawable_configure (drawable,
image,
drawable->offset_x,
drawable->offset_y,
width, height,
gimp_image_base_type_with_alpha (image),
layer->text->text /* name */);
name);
gimp_viewable_size_changed (GIMP_VIEWABLE (layer));
}
else
{
gimp_object_set_name (GIMP_OBJECT (layer), layer->text->text);
gimp_object_set_name (GIMP_OBJECT (layer), name);
}
if (newline)
g_free (name);
gimp_text_layer_render_layout (layer, layout, x, y);
g_object_unref (layout);
gimp_image_flush (image);
return TRUE;
}
@ -416,6 +451,8 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
apply_mask_to_region (&textPR, &maskPR, OPAQUE_OPACITY);
tile_manager_destroy (mask);
gimp_drawable_update (drawable, 0, 0, width, height);
}

View File

@ -53,8 +53,9 @@ struct _GimpTextLayerClass
GType gimp_text_layer_get_type (void) G_GNUC_CONST;
GimpLayer * gimp_text_layer_new (GimpImage *image,
GimpText *text);
GimpLayer * gimp_text_layer_new (GimpImage *image,
GimpText *text);
GimpText * gimp_text_layer_get_text (GimpTextLayer *layer);
#endif /* __GIMP_TEXT_LAYER_H__ */