Skip to content
  • Ell's avatar
    Bug 51112 - Support layer masks on layer groups · 36dec4e6
    Ell authored
    Add layer-mask support for group layers.  Group-layer masks work
    similarly to ordinary-layer masks, with the following
    considerations:
    
    The group's mask size is the same as group's size (i.e., the
    bounding box of its children) at all times.  When the group's size
    changes, the mask is cropped to the new size -- areas of the mask
    that fall outside of the new bounds are discarded and their data is
    lost (sans undo), and newly added areas are filled with black (and
    hence are transparent by default).
    
    The new gimp_group_layer_{suspend,resume}_mask() functions can be
    used to modify this behavior.  Between the outermost pair of
    suspend/resume calls, the old mask data is remembered, and is used
    to fill the newly added areas while cropping the mask when the
    group is resized.  We override GimpItem::{start,end}_move() for
    GimpLayer, to call these functions (suspend() in start_move(), and
    resume() in end_move()) for each of the layer's ancestors.
    
    As a result, while moving a layer, or a set of layers, atomically,
    such as while dragging with the move tool, or moving linked layers,
    the ancestors' mask data is not lost, and is only discarded at the
    end of the operation.
    
    This commit also takes care of properly handling undo for group-
    layer mask crops, properly invalidating the image when the group
    layer's mask is shown, and enabling the mask actions for group
    layers (obviously :).
    36dec4e6