mirror of https://github.com/GNOME/gimp.git
app/appenums.h app/gimplayer.c When adding a layer mask allow the option
* app/appenums.h * app/gimplayer.c * app/layers_dialog.c: When adding a layer mask allow the option of using the current selection (or it's inverse) to initialise the mask.
This commit is contained in:
parent
9d13b929ef
commit
b56e0e1853
|
@ -1,3 +1,11 @@
|
|||
2001-02-27 Jay Cox <jaycox@gimp.org>
|
||||
|
||||
* app/appenums.h
|
||||
* app/gimplayer.c
|
||||
* app/layers_dialog.c: When adding a layer mask allow the option
|
||||
of using the current selection (or it's inverse) to initialise
|
||||
the mask.
|
||||
|
||||
2001-02-28 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/gdisplay.c
|
||||
|
|
|
@ -109,7 +109,9 @@ typedef enum /*< chop=ADD_ >*/
|
|||
{
|
||||
ADD_WHITE_MASK,
|
||||
ADD_BLACK_MASK,
|
||||
ADD_ALPHA_MASK
|
||||
ADD_ALPHA_MASK,
|
||||
ADD_SELECTION_MASK,
|
||||
ADD_INV_SELECTION_MASK
|
||||
} AddMaskType;
|
||||
|
||||
/* gradient paint modes */
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "temp_buf.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tile.h"
|
||||
#include "invert.h"
|
||||
|
||||
#include "libgimp/gimpparasite.h"
|
||||
|
||||
|
@ -450,15 +451,24 @@ gimp_layer_create_mask (GimpLayer *layer,
|
|||
PixelRegion maskPR;
|
||||
PixelRegion layerPR;
|
||||
GimpLayerMask *mask;
|
||||
GimpImage *gimage;
|
||||
GimpDrawable *selection;
|
||||
gchar *mask_name;
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
|
||||
selection = GIMP_DRAWABLE(gimage->selection_mask);
|
||||
|
||||
mask_name = g_strdup_printf (_("%s mask"),
|
||||
gimp_object_get_name (GIMP_OBJECT (layer)));
|
||||
|
||||
/* Start an undo group. Needed if we are modifying the selection */
|
||||
undo_push_group_start (gimage, LAYER_MASK_ADD_UNDO);
|
||||
/* Create the layer mask */
|
||||
|
||||
mask = gimp_layer_mask_new (GIMP_DRAWABLE (layer)->gimage,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
|
@ -491,8 +501,32 @@ gimp_layer_create_mask (GimpLayer *layer,
|
|||
extract_alpha_region (&layerPR, NULL, &maskPR);
|
||||
}
|
||||
break;
|
||||
case ADD_SELECTION_MASK:
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (selection)->tiles,
|
||||
GIMP_DRAWABLE (layer)->offset_x,
|
||||
GIMP_DRAWABLE (layer)->offset_y,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
FALSE);
|
||||
copy_region (&layerPR, &maskPR);
|
||||
gimage_mask_none (gimage);
|
||||
break;
|
||||
case ADD_INV_SELECTION_MASK:
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (selection)->tiles,
|
||||
GIMP_DRAWABLE (layer)->offset_x,
|
||||
GIMP_DRAWABLE (layer)->offset_y,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
FALSE);
|
||||
copy_region (&layerPR, &maskPR);
|
||||
gimage_mask_none (gimage);
|
||||
invert(GIMP_DRAWABLE(mask));
|
||||
break;
|
||||
}
|
||||
|
||||
/* finish the undo group. */
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
g_free (mask_name);
|
||||
|
||||
return mask;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "temp_buf.h"
|
||||
#include "tile_manager.h"
|
||||
#include "tile.h"
|
||||
#include "invert.h"
|
||||
|
||||
#include "libgimp/gimpparasite.h"
|
||||
|
||||
|
@ -450,15 +451,24 @@ gimp_layer_create_mask (GimpLayer *layer,
|
|||
PixelRegion maskPR;
|
||||
PixelRegion layerPR;
|
||||
GimpLayerMask *mask;
|
||||
GimpImage *gimage;
|
||||
GimpDrawable *selection;
|
||||
gchar *mask_name;
|
||||
GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
|
||||
guchar white_mask = OPAQUE_OPACITY;
|
||||
guchar black_mask = TRANSPARENT_OPACITY;
|
||||
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
|
||||
selection = GIMP_DRAWABLE(gimage->selection_mask);
|
||||
|
||||
mask_name = g_strdup_printf (_("%s mask"),
|
||||
gimp_object_get_name (GIMP_OBJECT (layer)));
|
||||
|
||||
/* Start an undo group. Needed if we are modifying the selection */
|
||||
undo_push_group_start (gimage, LAYER_MASK_ADD_UNDO);
|
||||
/* Create the layer mask */
|
||||
|
||||
mask = gimp_layer_mask_new (GIMP_DRAWABLE (layer)->gimage,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
|
@ -491,8 +501,32 @@ gimp_layer_create_mask (GimpLayer *layer,
|
|||
extract_alpha_region (&layerPR, NULL, &maskPR);
|
||||
}
|
||||
break;
|
||||
case ADD_SELECTION_MASK:
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (selection)->tiles,
|
||||
GIMP_DRAWABLE (layer)->offset_x,
|
||||
GIMP_DRAWABLE (layer)->offset_y,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
FALSE);
|
||||
copy_region (&layerPR, &maskPR);
|
||||
gimage_mask_none (gimage);
|
||||
break;
|
||||
case ADD_INV_SELECTION_MASK:
|
||||
pixel_region_init (&layerPR, GIMP_DRAWABLE (selection)->tiles,
|
||||
GIMP_DRAWABLE (layer)->offset_x,
|
||||
GIMP_DRAWABLE (layer)->offset_y,
|
||||
GIMP_DRAWABLE (layer)->width,
|
||||
GIMP_DRAWABLE (layer)->height,
|
||||
FALSE);
|
||||
copy_region (&layerPR, &maskPR);
|
||||
gimage_mask_none (gimage);
|
||||
invert(GIMP_DRAWABLE(mask));
|
||||
break;
|
||||
}
|
||||
|
||||
/* finish the undo group. */
|
||||
undo_push_group_end (gimage);
|
||||
|
||||
g_free (mask_name);
|
||||
|
||||
return mask;
|
||||
|
|
|
@ -3856,12 +3856,15 @@ layers_dialog_add_mask_query (GimpLayer *layer)
|
|||
{
|
||||
AddMaskOptions *options;
|
||||
GtkWidget *frame;
|
||||
|
||||
GimpImage *gimage;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (AddMaskOptions, 1);
|
||||
options->layer = layer;
|
||||
options->add_mask_type = ADD_WHITE_MASK;
|
||||
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
gimp_dialog_new (_("Add Mask Options"), "add_mask_options",
|
||||
|
@ -3882,19 +3885,41 @@ layers_dialog_add_mask_query (GimpLayer *layer)
|
|||
(GtkObject *) options);
|
||||
|
||||
/* The radio frame and box */
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
if (gimage->selection_mask)
|
||||
{
|
||||
options->add_mask_type = ADD_SELECTION_MASK;
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
_("Show Selection"),
|
||||
(gpointer) ADD_SELECTION_MASK, NULL,
|
||||
_("Hide Selection"),
|
||||
(gpointer) ADD_INV_SELECTION_MASK, NULL,
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
}
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
||||
frame);
|
||||
|
|
|
@ -3856,12 +3856,15 @@ layers_dialog_add_mask_query (GimpLayer *layer)
|
|||
{
|
||||
AddMaskOptions *options;
|
||||
GtkWidget *frame;
|
||||
|
||||
GimpImage *gimage;
|
||||
|
||||
/* The new options structure */
|
||||
options = g_new (AddMaskOptions, 1);
|
||||
options->layer = layer;
|
||||
options->add_mask_type = ADD_WHITE_MASK;
|
||||
|
||||
gimage = GIMP_DRAWABLE (layer)->gimage;
|
||||
|
||||
/* The dialog */
|
||||
options->query_box =
|
||||
gimp_dialog_new (_("Add Mask Options"), "add_mask_options",
|
||||
|
@ -3882,19 +3885,41 @@ layers_dialog_add_mask_query (GimpLayer *layer)
|
|||
(GtkObject *) options);
|
||||
|
||||
/* The radio frame and box */
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
if (gimage->selection_mask)
|
||||
{
|
||||
options->add_mask_type = ADD_SELECTION_MASK;
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
_("Show Selection"),
|
||||
(gpointer) ADD_SELECTION_MASK, NULL,
|
||||
_("Hide Selection"),
|
||||
(gpointer) ADD_INV_SELECTION_MASK, NULL,
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Initialize Layer Mask to:"),
|
||||
gimp_radio_button_update,
|
||||
&options->add_mask_type,
|
||||
(gpointer) options->add_mask_type,
|
||||
|
||||
_("White (Full Opacity)"),
|
||||
(gpointer) ADD_WHITE_MASK, NULL,
|
||||
_("Black (Full Transparency)"),
|
||||
(gpointer) ADD_BLACK_MASK, NULL,
|
||||
_("Layer's Alpha Channel"),
|
||||
(gpointer) ADD_ALPHA_MASK, NULL,
|
||||
NULL);
|
||||
}
|
||||
gtk_container_set_border_width (GTK_CONTAINER (frame), 6);
|
||||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
||||
frame);
|
||||
|
|
Loading…
Reference in New Issue