mirror of https://github.com/GNOME/gimp.git
app: copying from selection creates layers the size of the selection.
After further discussions with Aryeom, we had to make decisions about a few problems. The main problem was: what happens when we copy a selection of a layer whose bounds don't intersect with the selection? The silent treatment of discarding the layer was not acceptable, because e.g. it could happen on huge set of selected layers (like say you copy 100 layers with a selection: you expect 100 created layers and if you realize you don't have them all — e.g. you have 99! — after hours of work, trying to find the missing one can be a huge time loss). The status bar notification (or even error) did not feel right either because this can typically be missed easily. Also it doesn't give a lot of feedback (e.g. you might want hint to find the non-intersecting layers, in case it was not supposed to happen). An error box was even considered, possibly proposing to ignore the problematic layers, or even giving easy ways to find them. Finally what if we let the selection happen regardless the non-intersecting layers? What should the dimension and offset of said layers be? In the end, we went with the more consistent behavior of always creating new layers of the exact same size as the selection. It can be considered as a rule which would make the behavior predictable. For the non-intersecting layers, we'd just have new layers with the dimension/offset of the selection bounding box, and no contents. For other layers, they'd be also this same dimension, possibly increasing the dimension of the source layers (though any new pixel is fully transparent obviously). Aryeom wondered if some people might absolutely need for their workflow that the new layers stick to the origin bounding box. But we felt it was enough of a stretch that we'd try this way for now. Note: of course if some day we get infinite canvas/layers, this whole discussion could be less of a problem anyway! This was Aryeom's conclusion! Ahahah!
This commit is contained in:
parent
363facef5e
commit
18c5b39cf5
|
@ -214,16 +214,10 @@ gimp_edit_copy (GimpImage *image,
|
|||
|
||||
for (iter = all_items; iter; iter = g_list_next (iter))
|
||||
{
|
||||
GeglRectangle bounds;
|
||||
gint item_x;
|
||||
gint item_y;
|
||||
gint x, y;
|
||||
gint item_x;
|
||||
gint item_y;
|
||||
|
||||
gimp_item_get_offset (GIMP_ITEM (iter->data), &item_x, &item_y);
|
||||
bounds.x = item_x;
|
||||
bounds.y = item_y;
|
||||
bounds.width = gimp_item_get_width (GIMP_ITEM (iter->data));
|
||||
bounds.height = gimp_item_get_height (GIMP_ITEM (iter->data));
|
||||
|
||||
/* Even if the original layer may not have an alpha channel, the
|
||||
* selected data must always have one. First because a selection
|
||||
|
@ -236,13 +230,10 @@ gimp_edit_copy (GimpImage *image,
|
|||
gimp_layer_add_alpha (GIMP_LAYER (iter->data));
|
||||
gimp_drawable_edit_clear (GIMP_DRAWABLE (iter->data), context);
|
||||
|
||||
gegl_rectangle_intersect (&bounds, &bounds, &selection_bounds);
|
||||
x = MIN (item_x - selection_bounds.x, 0.0);
|
||||
y = MIN (item_y - selection_bounds.y, 0.0);
|
||||
|
||||
/* Finally shrink the copied layer to contents. */
|
||||
/* Finally shrink the copied layer to selection bounds. */
|
||||
gimp_item_resize (iter->data, context, GIMP_FILL_TRANSPARENT,
|
||||
bounds.width, bounds.height, x, y);
|
||||
selection_bounds.width, selection_bounds.height,
|
||||
item_x - selection_bounds.x, item_y - selection_bounds.y);
|
||||
}
|
||||
g_list_free (all_items);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue