Fix automatic size updates of nested groups (again!)

Make sure a group layer really emits all needed size change signals
when children get added and removed, so the group layer above it can
also update itself based on these signals. Spotted (again) by tobi.
This commit is contained in:
Michael Natterer 2009-08-27 23:07:38 +02:00
parent e0d062aa38
commit 6031800b90
1 changed files with 29 additions and 15 deletions

View File

@ -816,12 +816,15 @@ gimp_group_layer_child_resize (GimpLayer *child,
static void static void
gimp_group_layer_update_size (GimpGroupLayer *group) gimp_group_layer_update_size (GimpGroupLayer *group)
{ {
GList *list; GimpItem *item = GIMP_ITEM (group);
gint x = 0; gint old_width = gimp_item_get_width (item);
gint y = 0; gint old_height = gimp_item_get_height (item);
gint width = 1; gint x = 0;
gint height = 1; gint y = 0;
gboolean first = TRUE; gint width = 1;
gint height = 1;
gboolean first = TRUE;
GList *list;
for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (group->children)); for (list = gimp_item_stack_get_item_iter (GIMP_ITEM_STACK (group->children));
list; list;
@ -849,24 +852,35 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
} }
} }
if (x != gimp_item_get_offset_x (GIMP_ITEM (group)) || if (x != gimp_item_get_offset_x (item) ||
y != gimp_item_get_offset_y (GIMP_ITEM (group)) || y != gimp_item_get_offset_y (item) ||
width != gimp_item_get_width (GIMP_ITEM (group)) || width != old_width ||
height != gimp_item_get_height (GIMP_ITEM (group))) height != old_height)
{ {
if (width != gimp_item_get_width (GIMP_ITEM (group)) || if (width != old_width ||
height != gimp_item_get_height (GIMP_ITEM (group))) height != old_height)
{ {
TileManager *tiles; TileManager *tiles;
GIMP_ITEM (group)->width = width; /* FIXME: find a better way to do this: need to set the item's
GIMP_ITEM (group)->height = height; * extents to the new values so the projection will create
* its tiles with the right size
*/
item->width = width;
item->height = height;
gimp_projectable_structure_changed (GIMP_PROJECTABLE (group)); gimp_projectable_structure_changed (GIMP_PROJECTABLE (group));
tiles = gimp_projection_get_tiles_at_level (group->projection, tiles = gimp_projection_get_tiles_at_level (group->projection,
0, NULL); 0, NULL);
/* FIXME: need to set the item's extents back to the old
* values so gimp_drawable_set_tiles_full() will emit all
* signals needed by the layer tree to update itself
*/
item->width = old_width;
item->height = old_height;
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (group), gimp_drawable_set_tiles_full (GIMP_DRAWABLE (group),
FALSE, NULL, FALSE, NULL,
tiles, tiles,
@ -875,7 +889,7 @@ gimp_group_layer_update_size (GimpGroupLayer *group)
} }
else else
{ {
gimp_item_set_offset (GIMP_ITEM (group), x, y); gimp_item_set_offset (item, x, y);
} }
if (group->offset_node) if (group->offset_node)