if the floating selection has no alpha, manually create BoundSegs of its

2005-09-08  Michael Natterer  <mitch@gimp.org>

	* app/core/gimplayer-floating-sel.c (floating_sel_boundary): if
	the floating selection has no alpha, manually create BoundSegs of
	its outline instead of calling boundary_find() (which creates a
	boundary of the last channel). Fixes bug #145373.

	* app/widgets/gimplayertreeview.c
	(gimp_layer_tree_view_floating_selection_changed): update all
	layer names' text attributes, not only for layers with alpha.
	Fixes layer name display when making a new layer out of a floating
	selection without alpha.
This commit is contained in:
Michael Natterer 2005-09-08 19:38:58 +00:00 committed by Michael Natterer
parent 7e34681f86
commit 805602b657
3 changed files with 74 additions and 29 deletions

View File

@ -1,3 +1,16 @@
2005-09-08 Michael Natterer <mitch@gimp.org>
* app/core/gimplayer-floating-sel.c (floating_sel_boundary): if
the floating selection has no alpha, manually create BoundSegs of
its outline instead of calling boundary_find() (which creates a
boundary of the last channel). Fixes bug #145373.
* app/widgets/gimplayertreeview.c
(gimp_layer_tree_view_floating_selection_changed): update all
layer names' text attributes, not only for layers with alpha.
Fixes layer name display when making a new layer out of a floating
selection without alpha.
2005-09-08 Michael Natterer <mitch@gimp.org> 2005-09-08 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainergridview.c * app/widgets/gimpcontainergridview.c

View File

@ -524,29 +524,64 @@ floating_sel_boundary (GimpLayer *layer,
if (layer->fs.boundary_known == FALSE) if (layer->fs.boundary_known == FALSE)
{ {
gint width, height;
gint off_x, off_y;
width = gimp_item_width (GIMP_ITEM (layer));
height = gimp_item_height (GIMP_ITEM (layer));
gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);
if (layer->fs.segs) if (layer->fs.segs)
g_free (layer->fs.segs); g_free (layer->fs.segs);
/* find the segments */ if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
pixel_region_init (&bPR, GIMP_DRAWABLE (layer)->tiles, {
0, 0, /* find the segments */
GIMP_ITEM (layer)->width, pixel_region_init (&bPR, gimp_drawable_data (GIMP_DRAWABLE (layer)),
GIMP_ITEM (layer)->height, FALSE); 0, 0, width, height, FALSE);
layer->fs.segs = boundary_find (&bPR, BOUNDARY_WITHIN_BOUNDS, layer->fs.segs = boundary_find (&bPR, BOUNDARY_WITHIN_BOUNDS,
0, 0, 0, 0, width, height,
GIMP_ITEM (layer)->width, BOUNDARY_HALF_WAY,
GIMP_ITEM (layer)->height, &layer->fs.num_segs);
BOUNDARY_HALF_WAY,
&layer->fs.num_segs);
/* offset the segments */ /* offset the segments */
for (i = 0; i < layer->fs.num_segs; i++) for (i = 0; i < layer->fs.num_segs; i++)
{ {
layer->fs.segs[i].x1 += GIMP_ITEM (layer)->offset_x; layer->fs.segs[i].x1 += off_x;
layer->fs.segs[i].y1 += GIMP_ITEM (layer)->offset_y; layer->fs.segs[i].y1 += off_y;
layer->fs.segs[i].x2 += GIMP_ITEM (layer)->offset_x; layer->fs.segs[i].x2 += off_x;
layer->fs.segs[i].y2 += GIMP_ITEM (layer)->offset_y; layer->fs.segs[i].y2 += off_y;
} }
}
else
{
layer->fs.num_segs = 4;
layer->fs.segs = g_new0 (BoundSeg, 4);
/* top */
layer->fs.segs[0].x1 = off_x;
layer->fs.segs[0].y1 = off_y;
layer->fs.segs[0].x2 = off_x + width;
layer->fs.segs[0].y2 = off_y;
/* left */
layer->fs.segs[1].x1 = off_x;
layer->fs.segs[1].y1 = off_y;
layer->fs.segs[1].x2 = off_x;
layer->fs.segs[1].y2 = off_y + height;
/* right */
layer->fs.segs[2].x1 = off_x + width;
layer->fs.segs[2].y1 = off_y;
layer->fs.segs[2].x2 = off_x + width;
layer->fs.segs[2].y2 = off_y + height;
/* bottom */
layer->fs.segs[3].x1 = off_x;
layer->fs.segs[3].y1 = off_y + height;
layer->fs.segs[3].x2 = off_x + width;
layer->fs.segs[3].y2 = off_y + height;
}
layer->fs.boundary_known = TRUE; layer->fs.boundary_known = TRUE;
} }

View File

@ -917,17 +917,14 @@ gimp_layer_tree_view_floating_selection_changed (GimpImage *gimage,
{ {
GimpDrawable *drawable = list->data; GimpDrawable *drawable = list->data;
if (gimp_drawable_has_alpha (drawable)) iter = gimp_container_view_lookup (view, (GimpViewable *) drawable);
{
iter = gimp_container_view_lookup (view,
(GimpViewable *) drawable);
if (iter) if (iter)
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter, gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
tree_view->model_column_name_attributes, tree_view->model_column_name_attributes,
NULL, gimp_drawable_has_alpha (drawable) ?
-1); NULL : layer_view->bold_attrs,
} -1);
} }
} }
} }