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>
* app/widgets/gimpcontainergridview.c

View File

@ -524,29 +524,64 @@ floating_sel_boundary (GimpLayer *layer,
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)
g_free (layer->fs.segs);
/* find the segments */
pixel_region_init (&bPR, GIMP_DRAWABLE (layer)->tiles,
0, 0,
GIMP_ITEM (layer)->width,
GIMP_ITEM (layer)->height, FALSE);
layer->fs.segs = boundary_find (&bPR, BOUNDARY_WITHIN_BOUNDS,
0, 0,
GIMP_ITEM (layer)->width,
GIMP_ITEM (layer)->height,
BOUNDARY_HALF_WAY,
&layer->fs.num_segs);
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
{
/* find the segments */
pixel_region_init (&bPR, gimp_drawable_data (GIMP_DRAWABLE (layer)),
0, 0, width, height, FALSE);
layer->fs.segs = boundary_find (&bPR, BOUNDARY_WITHIN_BOUNDS,
0, 0, width, height,
BOUNDARY_HALF_WAY,
&layer->fs.num_segs);
/* offset the segments */
for (i = 0; i < layer->fs.num_segs; i++)
{
layer->fs.segs[i].x1 += GIMP_ITEM (layer)->offset_x;
layer->fs.segs[i].y1 += GIMP_ITEM (layer)->offset_y;
layer->fs.segs[i].x2 += GIMP_ITEM (layer)->offset_x;
layer->fs.segs[i].y2 += GIMP_ITEM (layer)->offset_y;
}
/* offset the segments */
for (i = 0; i < layer->fs.num_segs; i++)
{
layer->fs.segs[i].x1 += off_x;
layer->fs.segs[i].y1 += off_y;
layer->fs.segs[i].x2 += off_x;
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;
}

View File

@ -917,17 +917,14 @@ gimp_layer_tree_view_floating_selection_changed (GimpImage *gimage,
{
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)
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
tree_view->model_column_name_attributes,
NULL,
-1);
}
if (iter)
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
tree_view->model_column_name_attributes,
gimp_drawable_has_alpha (drawable) ?
NULL : layer_view->bold_attrs,
-1);
}
}
}