Commit 88388467 authored by Michael Natterer's avatar Michael Natterer 😴

app: move the layer mask show, edit, apply API from GimpLayerMask to GimpLayer

because it would require really evil hacks to honor these properties
in the gegl projection if they were on the mask, and because they
actually belong to the layer.
parent c22b6a28
......@@ -24,10 +24,10 @@
#include "actions-types.h"
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "text/gimptextlayer.h"
......@@ -659,9 +659,9 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac && mask);
SET_ACTIVE ("layers-mask-edit", mask && gimp_layer_mask_get_edit (mask));
SET_ACTIVE ("layers-mask-show", mask && gimp_layer_mask_get_show (mask));
SET_ACTIVE ("layers-mask-disable", mask && !gimp_layer_mask_get_apply (mask));
SET_ACTIVE ("layers-mask-edit", mask && gimp_layer_get_edit_mask (layer));
SET_ACTIVE ("layers-mask-show", mask && gimp_layer_get_show_mask (layer));
SET_ACTIVE ("layers-mask-disable", mask && !gimp_layer_get_apply_mask (layer));
SET_SENSITIVE ("layers-mask-selection-replace", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-selection-add", layer && !fs && !ac && mask);
......
......@@ -31,6 +31,7 @@
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage.h"
......@@ -39,7 +40,6 @@
#include "core/gimpimage-undo-push.h"
#include "core/gimpitemundo.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "core/gimppickable.h"
#include "core/gimptoolinfo.h"
#include "core/gimpundostack.h"
......@@ -766,7 +766,7 @@ layers_mask_edit_cmd_callback (GtkAction *action,
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_edit (mask, active);
gimp_layer_set_edit_mask (layer, active);
gimp_image_flush (image);
}
}
......@@ -788,7 +788,7 @@ layers_mask_show_cmd_callback (GtkAction *action,
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_show (mask, active, TRUE);
gimp_layer_set_show_mask (layer, active, TRUE);
gimp_image_flush (image);
}
}
......@@ -810,7 +810,7 @@ layers_mask_disable_cmd_callback (GtkAction *action,
active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
gimp_layer_mask_set_apply (mask, ! active, TRUE);
gimp_layer_set_apply_mask (layer, ! active, TRUE);
gimp_image_flush (image);
}
}
......
......@@ -651,7 +651,7 @@ gimp_image_merge_layers (GimpImage *image,
FALSE);
if (gimp_layer_get_mask (layer) &&
gimp_layer_mask_get_apply (layer->mask))
gimp_layer_get_apply_mask (layer))
{
TileManager *tiles;
......
......@@ -656,34 +656,34 @@ gimp_image_undo_push_layer_mask_remove (GimpImage *image,
}
GimpUndo *
gimp_image_undo_push_layer_mask_apply (GimpImage *image,
const gchar *undo_desc,
GimpLayerMask *mask)
gimp_image_undo_push_layer_mask_apply (GimpImage *image,
const gchar *undo_desc,
GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
GIMP_UNDO_LAYER_MASK_APPLY, undo_desc,
GIMP_DIRTY_ITEM_META,
"item", mask,
"item", layer,
NULL);
}
GimpUndo *
gimp_image_undo_push_layer_mask_show (GimpImage *image,
const gchar *undo_desc,
GimpLayerMask *mask)
gimp_image_undo_push_layer_mask_show (GimpImage *image,
const gchar *undo_desc,
GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (mask)), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)), NULL);
return gimp_image_undo_push (image, GIMP_TYPE_LAYER_MASK_PROP_UNDO,
GIMP_UNDO_LAYER_MASK_SHOW, undo_desc,
GIMP_DIRTY_ITEM_META,
"item", mask,
"item", layer,
NULL);
}
......
......@@ -164,10 +164,10 @@ GimpUndo * gimp_image_undo_push_layer_mask_remove (GimpImage *image,
GimpLayerMask *mask);
GimpUndo * gimp_image_undo_push_layer_mask_apply (GimpImage *image,
const gchar *undo_desc,
GimpLayerMask *mask);
GimpLayer *layer);
GimpUndo * gimp_image_undo_push_layer_mask_show (GimpImage *image,
const gchar *undo_desc,
GimpLayerMask *mask);
GimpLayer *layer);
/* channel undos */
......
......@@ -3214,7 +3214,7 @@ gimp_image_get_active_drawable (const GimpImage *image)
GimpLayer *layer = GIMP_LAYER (active_layer);
GimpLayerMask *mask = gimp_layer_get_mask (layer);
if (mask && gimp_layer_mask_get_edit (mask))
if (mask && gimp_layer_get_edit_mask (layer))
return GIMP_DRAWABLE (mask);
else
return GIMP_DRAWABLE (layer);
......
......@@ -46,7 +46,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
GimpLayer *layer = GIMP_LAYER (drawable);
GimpLayerMask *mask = gimp_layer_get_mask (layer);
if (mask && gimp_layer_mask_get_show (mask))
if (mask && gimp_layer_get_show_mask (layer))
{
/* If we're showing the layer mask instead of the layer... */
......@@ -81,7 +81,7 @@ gimp_layer_project_region (GimpDrawable *drawable,
x, y, width, height,
&temp_layer_tiles);
if (mask && gimp_layer_mask_get_apply (mask))
if (mask && gimp_layer_get_apply_mask (layer))
{
gimp_drawable_init_src_region (GIMP_DRAWABLE (mask), &maskPR,
x, y, width, height,
......
......@@ -65,6 +65,9 @@ enum
MODE_CHANGED,
LOCK_ALPHA_CHANGED,
MASK_CHANGED,
APPLY_MASK_CHANGED,
EDIT_MASK_CHANGED,
SHOW_MASK_CHANGED,
LAST_SIGNAL
};
......@@ -241,6 +244,33 @@ gimp_layer_class_init (GimpLayerClass *klass)
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_signals[APPLY_MASK_CHANGED] =
g_signal_new ("apply-mask-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerClass, apply_mask_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_signals[EDIT_MASK_CHANGED] =
g_signal_new ("edit-mask-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerClass, edit_mask_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_signals[SHOW_MASK_CHANGED] =
g_signal_new ("show-mask-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerClass, show_mask_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
object_class->set_property = gimp_layer_set_property;
object_class->get_property = gimp_layer_get_property;
object_class->dispose = gimp_layer_dispose;
......@@ -295,6 +325,9 @@ gimp_layer_class_init (GimpLayerClass *klass)
klass->mode_changed = NULL;
klass->lock_alpha_changed = NULL;
klass->mask_changed = NULL;
klass->apply_mask_changed = NULL;
klass->edit_mask_changed = NULL;
klass->show_mask_changed = NULL;
g_object_class_install_property (object_class, PROP_OPACITY,
g_param_spec_double ("opacity", NULL, NULL,
......@@ -336,6 +369,9 @@ gimp_layer_init (GimpLayer *layer)
layer->lock_alpha = FALSE;
layer->mask = NULL;
layer->apply_mask = TRUE;
layer->edit_mask = TRUE;
layer->show_mask = FALSE;
/* floating selection */
layer->fs.drawable = NULL;
......@@ -575,6 +611,10 @@ gimp_layer_duplicate (GimpItem *item,
mask = gimp_item_duplicate (GIMP_ITEM (layer->mask),
G_TYPE_FROM_INSTANCE (layer->mask));
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (mask), FALSE, NULL);
new_layer->apply_mask = layer->apply_mask;
new_layer->edit_mask = layer->edit_mask;
new_layer->show_mask = layer->show_mask;
}
}
......@@ -1077,10 +1117,8 @@ gimp_layer_layer_mask_update (GimpDrawable *drawable,
gint height,
GimpLayer *layer)
{
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (drawable);
if (gimp_layer_mask_get_apply (layer_mask) ||
gimp_layer_mask_get_show (layer_mask))
if (gimp_layer_get_apply_mask (layer) ||
gimp_layer_get_show_mask (layer))
{
gimp_drawable_update (GIMP_DRAWABLE (layer),
x, y, width, height);
......@@ -1511,6 +1549,9 @@ gimp_layer_add_mask (GimpLayer *layer,
layer, mask);
layer->mask = g_object_ref_sink (mask);
layer->apply_mask = TRUE;
layer->edit_mask = TRUE;
layer->show_mask = FALSE;
gimp_layer_mask_set_layer (mask, layer);
......@@ -1524,8 +1565,8 @@ gimp_layer_add_mask (GimpLayer *layer,
layer->opacity_node, "aux");
}
if (gimp_layer_mask_get_apply (mask) ||
gimp_layer_mask_get_show (mask))
if (gimp_layer_get_apply_mask (layer) ||
gimp_layer_get_show_mask (layer))
{
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
......@@ -1792,6 +1833,8 @@ gimp_layer_apply_mask (GimpLayer *layer,
C_("undo-type", "Apply Layer Mask") :
C_("undo-type", "Delete Layer Mask"));
gimp_image_undo_push_layer_mask_show (image, NULL, layer);
gimp_image_undo_push_layer_mask_apply (image, NULL, layer);
gimp_image_undo_push_layer_mask_remove (image, NULL, layer, mask);
if (mode == GIMP_MASK_APPLY &&
......@@ -1802,9 +1845,9 @@ gimp_layer_apply_mask (GimpLayer *layer,
}
/* check if applying the mask changes the projection */
if (gimp_layer_mask_get_show (mask) ||
(mode == GIMP_MASK_APPLY && ! gimp_layer_mask_get_apply (mask)) ||
(mode == GIMP_MASK_DISCARD && gimp_layer_mask_get_apply (mask)))
if (gimp_layer_get_show_mask (layer) ||
(mode == GIMP_MASK_APPLY && ! gimp_layer_get_apply_mask (layer)) ||
(mode == GIMP_MASK_DISCARD && gimp_layer_get_apply_mask (layer)))
{
view_changed = TRUE;
}
......@@ -1866,6 +1909,106 @@ gimp_layer_apply_mask (GimpLayer *layer,
g_object_notify (G_OBJECT (layer), "mask");
}
void
gimp_layer_set_apply_mask (GimpLayer *layer,
gboolean apply,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (layer->mask != NULL);
if (layer->apply_mask != apply)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
if (push_undo)
gimp_image_undo_push_layer_mask_apply (image,
apply ?
C_("undo-type", "Enable Layer Mask") :
C_("undo-type", "Disable Layer Mask"),
layer);
layer->apply_mask = apply ? TRUE : FALSE;
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
gimp_item_get_width (GIMP_ITEM (layer)),
gimp_item_get_height (GIMP_ITEM (layer)));
g_signal_emit (layer, layer_signals[APPLY_MASK_CHANGED], 0);
}
}
gboolean
gimp_layer_get_apply_mask (const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
g_return_val_if_fail (layer->mask, FALSE);
return layer->apply_mask;
}
void
gimp_layer_set_edit_mask (GimpLayer *layer,
gboolean edit)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (layer->mask != NULL);
if (layer->edit_mask != edit)
{
layer->edit_mask = edit ? TRUE : FALSE;
g_signal_emit (layer, layer_signals[EDIT_MASK_CHANGED], 0);
}
}
gboolean
gimp_layer_get_edit_mask (const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
g_return_val_if_fail (layer->mask, FALSE);
return layer->edit_mask;
}
void
gimp_layer_set_show_mask (GimpLayer *layer,
gboolean show,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
g_return_if_fail (layer->mask != NULL);
if (layer->show_mask != show)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
if (push_undo)
gimp_image_undo_push_layer_mask_show (image,
C_("undo-type", "Show Layer Mask"),
layer);
layer->show_mask = show ? TRUE : FALSE;
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
gimp_item_get_width (GIMP_ITEM (layer)),
gimp_item_get_height (GIMP_ITEM (layer)));
g_signal_emit (layer, layer_signals[SHOW_MASK_CHANGED], 0);
}
}
gboolean
gimp_layer_get_show_mask (const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
g_return_val_if_fail (layer->mask, FALSE);
return layer->show_mask;
}
void
gimp_layer_add_alpha (GimpLayer *layer)
{
......
......@@ -41,6 +41,9 @@ struct _GimpLayer
gboolean lock_alpha; /* lock the alpha channel */
GimpLayerMask *mask; /* possible layer mask */
gboolean apply_mask; /* controls mask application */
gboolean edit_mask; /* edit mask or layer? */
gboolean show_mask; /* show mask or layer? */
GeglNode *opacity_node;
......@@ -62,6 +65,9 @@ struct _GimpLayerClass
void (* mode_changed) (GimpLayer *layer);
void (* lock_alpha_changed) (GimpLayer *layer);
void (* mask_changed) (GimpLayer *layer);
void (* apply_mask_changed) (GimpLayer *layer);
void (* edit_mask_changed) (GimpLayer *layer);
void (* show_mask_changed) (GimpLayer *layer);
};
......@@ -116,6 +122,20 @@ void gimp_layer_apply_mask (GimpLayer *layer,
GimpMaskApplyMode mode,
gboolean push_undo);
void gimp_layer_set_apply_mask (GimpLayer *layer,
gboolean apply,
gboolean push_undo);
gboolean gimp_layer_get_apply_mask (const GimpLayer *layer);
void gimp_layer_set_edit_mask (GimpLayer *layer,
gboolean edit);
gboolean gimp_layer_get_edit_mask (const GimpLayer *layer);
void gimp_layer_set_show_mask (GimpLayer *layer,
gboolean show,
gboolean push_undo);
gboolean gimp_layer_get_show_mask (const GimpLayer *layer);
void gimp_layer_add_alpha (GimpLayer *layer);
void gimp_layer_flatten (GimpLayer *layer,
GimpContext *context);
......
......@@ -31,20 +31,10 @@
#include "gimpimage-undo-push.h"
#include "gimplayer.h"
#include "gimplayermask.h"
#include "gimpmarshal.h"
#include "gimp-intl.h"
enum
{
APPLY_CHANGED,
EDIT_CHANGED,
SHOW_CHANGED,
LAST_SIGNAL
};
static gboolean gimp_layer_mask_is_attached (const GimpItem *item);
static gboolean gimp_layer_mask_is_content_locked (const GimpItem *item);
static GimpItemTree * gimp_layer_mask_get_tree (GimpItem *item);
......@@ -60,8 +50,6 @@ G_DEFINE_TYPE (GimpLayerMask, gimp_layer_mask, GIMP_TYPE_CHANNEL)
#define parent_class gimp_layer_mask_parent_class
static guint layer_mask_signals[LAST_SIGNAL] = { 0 };
static void
gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
......@@ -69,37 +57,8 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
layer_mask_signals[APPLY_CHANGED] =
g_signal_new ("apply-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, apply_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_mask_signals[EDIT_CHANGED] =
g_signal_new ("edit-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, edit_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_mask_signals[SHOW_CHANGED] =
g_signal_new ("show-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, show_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
viewable_class->default_stock_id = "gimp-layer-mask";
klass->edit_changed = NULL;
item_class->is_attached = gimp_layer_mask_is_attached;
item_class->is_content_locked = gimp_layer_mask_is_content_locked;
item_class->get_tree = gimp_layer_mask_get_tree;
......@@ -112,10 +71,7 @@ gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
static void
gimp_layer_mask_init (GimpLayerMask *layer_mask)
{
layer_mask->layer = NULL;
layer_mask->apply_mask = TRUE;
layer_mask->edit_mask = TRUE;
layer_mask->show_mask = FALSE;
layer_mask->layer = NULL;
}
static gboolean
......@@ -158,16 +114,6 @@ gimp_layer_mask_duplicate (GimpItem *item,
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type);
if (GIMP_IS_LAYER_MASK (new_item))
{
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (item);
GimpLayerMask *new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask;
}
return new_item;
}
......@@ -246,107 +192,3 @@ gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask)
return layer_mask->layer;
}
void
gimp_layer_mask_set_apply (GimpLayerMask *layer_mask,
gboolean apply,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->apply_mask != apply)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer_mask));
if (push_undo)
gimp_image_undo_push_layer_mask_apply (image,
apply ?
C_("undo-type", "Enable Layer Mask") :
C_("undo-type", "Disable Layer Mask"),
layer_mask);
layer_mask->apply_mask = apply ? TRUE : FALSE;
if (layer_mask->layer)
{
GimpDrawable *drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)));
}
g_signal_emit (layer_mask, layer_mask_signals[APPLY_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_apply (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->apply_mask;
}
void
gimp_layer_mask_set_edit (GimpLayerMask *layer_mask,
gboolean edit)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->edit_mask != edit)
{
layer_mask->edit_mask = edit ? TRUE : FALSE;
g_signal_emit (layer_mask, layer_mask_signals[EDIT_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_edit (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->edit_mask;
}
void
gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
gboolean show,
gboolean push_undo)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->show_mask != show)
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer_mask));
if (push_undo)
gimp_image_undo_push_layer_mask_show (image,
C_("undo-type", "Show Layer Mask"),
layer_mask);
layer_mask->show_mask = show ? TRUE : FALSE;
if (layer_mask->layer)
{
GimpDrawable *drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,
gimp_item_get_width (GIMP_ITEM (drawable)),
gimp_item_get_height (GIMP_ITEM (drawable)));
}
g_signal_emit (layer_mask, layer_mask_signals[SHOW_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_show (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->show_mask;
}
......@@ -37,49 +37,27 @@ struct _GimpLayerMask
GimpChannel parent_instance;
GimpLayer *layer;
gboolean apply_mask; /* controls mask application */
gboolean edit_mask; /* edit mask or layer? */
gboolean show_mask; /* show mask or layer? */
};
struct _GimpLayerMaskClass
{
GimpChannelClass parent_class;
void (* apply_changed) (GimpLayerMask *layer_mask);
void (* edit_changed) (GimpLayerMask *layer_mask);
void (* show_changed) (GimpLayerMask *layer_mask);
};
/* function declarations */
GType gimp_layer_mask_get_type (void) G_GNUC_CONST;
GimpLayerMask * gimp_layer_mask_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer);
GimpLayer * gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask);
void gimp_layer_mask_set_apply (GimpLayerMask *layer_mask,
gboolean apply,
gboolean push_undo);
gboolean gimp_layer_mask_get_apply (const GimpLayerMask *layer_mask);
GType gimp_layer_mask_get_type (void) G_GNUC_CONST;
void gimp_layer_mask_set_edit (GimpLayerMask *layer_mask,
gboolean edit);
gboolean gimp_layer_mask_get_edit (const GimpLayerMask *layer_mask);
GimpLayerMask * gimp_layer_mask_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
const GimpRGB *color);
void gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
gboolean show,
gboolean push_undo);
gboolean gimp_layer_mask_get_show (const GimpLayerMask *layer_mask);
void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer);
GimpLayer * gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask);
#endif /* __GIMP_LAYER_MASK_H__ */
......@@ -21,7 +21,7 @@
#include "core-types.h"
#include "gimplayermask.h"
#include "gimplayer.h"
#include "gimplayermaskpropundo.h"
......@@ -58,25 +58,25 @@ static void
gimp_layer_mask_prop_undo_constructed (GObject *object)
{
GimpLayerMaskPropUndo *layer_mask_prop_undo;
GimpLayerMask *layer_mask;
GimpLayer *layer;
layer_mask_prop_undo = GIMP_LAYER_MASK_PROP_UNDO (object);
if (G_OBJECT_CLASS (parent_class)->constructed)
G_OBJECT_CLASS (parent_class)->constructed (object);
g_assert (GIMP_IS_LAYER_MASK (GIMP_ITEM_UNDO (object)->item));
g_assert (GIMP_IS_LAYER (GIMP_ITEM_UNDO (object)->item));
layer_mask = GIMP_LAYER_MASK (GIMP_ITEM_UNDO (object)->item);
layer = GIMP_LAYER (GIMP_ITEM_UNDO (object)->item);
switch (GIMP_UNDO (object)->undo_type)
{
case GIMP_UNDO_LAYER_MASK_APPLY:
layer_mask_prop_undo->apply = gimp_layer_mask_get_apply (layer_mask);
layer_mask_prop_undo->apply = gimp_layer_get_apply_mask (layer);
break;