From b5f1ae88e233c723af7b0238224ec6528376053d Mon Sep 17 00:00:00 2001 From: William Skaggs Date: Thu, 24 Mar 2005 17:10:03 +0000 Subject: [PATCH] Bill Skaggs * app/core/core-enums.[ch] * app/core/gimpimage-undo-push.[ch] * app/core/gimplayermask.[ch]: * app/pdb/pdb_glue.h * app/actions/layers-commands.c: try again from clean tree; hopefully will work this time. (bug #148852) --- ChangeLog | 9 ++++ app/actions/layers-commands.c | 13 +++-- app/core/core-enums.c | 6 +++ app/core/core-enums.h | 3 ++ app/core/gimpimage-undo-push.c | 93 ++++++++++++++++++++++++++++++++++ app/core/gimpimage-undo-push.h | 4 ++ app/core/gimplayermask.c | 36 +++++++++++-- app/core/gimplayermask.h | 9 ++-- app/pdb/pdb_glue.h | 6 +-- 9 files changed, 166 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index fcac0cd7ed..4c0c416cbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-03-24 Bill Skaggs + + * app/core/core-enums.[ch] + * app/core/gimpimage-undo-push.[ch] + * app/core/gimplayermask.[ch]: + * app/pdb/pdb_glue.h + * app/actions/layers-commands.c: try again from clean tree; + hopefully will work this time. (bug #148852) + 2005-03-24 Sven Neumann * plug-ins/script-fu/scripts/*.scm: don't mark menu branches for diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index b8863f5d22..2b53488195 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -36,6 +36,7 @@ #include "core/gimpimage.h" #include "core/gimpimage-merge.h" #include "core/gimpimage-undo.h" +#include "core/gimpimage-undo-push.h" #include "core/gimpitemundo.h" #include "core/gimplayer.h" #include "core/gimplayer-floating-sel.h" @@ -610,7 +611,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_mask_set_edit (mask, active, TRUE); gimp_image_flush (gimage); } } @@ -632,7 +633,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); + gimp_layer_mask_set_show (mask, active, TRUE); gimp_image_flush (gimage); } } @@ -654,8 +655,12 @@ layers_mask_disable_cmd_callback (GtkAction *action, active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); - gimp_layer_mask_set_apply (mask, ! active); - gimp_image_flush (gimage); + if (active == gimp_layer_mask_get_apply (mask)) + { + gimp_layer_mask_set_apply (mask, ! active, TRUE); + + gimp_image_flush (gimage); + } } } diff --git a/app/core/core-enums.c b/app/core/core-enums.c index 7316c5f72d..a18c234b99 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -734,6 +734,9 @@ gimp_undo_type_get_type (void) { GIMP_UNDO_LAYER_REMOVE, "GIMP_UNDO_LAYER_REMOVE", "layer-remove" }, { GIMP_UNDO_LAYER_MASK_ADD, "GIMP_UNDO_LAYER_MASK_ADD", "layer-mask-add" }, { GIMP_UNDO_LAYER_MASK_REMOVE, "GIMP_UNDO_LAYER_MASK_REMOVE", "layer-mask-remove" }, + { GIMP_UNDO_LAYER_MASK_APPLY, "GIMP_UNDO_LAYER_MASK_APPLY", "layer-mask-apply" }, + { GIMP_UNDO_LAYER_MASK_EDIT, "GIMP_UNDO_LAYER_MASK_EDIT", "layer-mask-edit" }, + { GIMP_UNDO_LAYER_MASK_SHOW, "GIMP_UNDO_LAYER_MASK_SHOW", "layer-mask-show" }, { GIMP_UNDO_LAYER_REPOSITION, "GIMP_UNDO_LAYER_REPOSITION", "layer-reposition" }, { GIMP_UNDO_LAYER_MODE, "GIMP_UNDO_LAYER_MODE", "layer-mode" }, { GIMP_UNDO_LAYER_OPACITY, "GIMP_UNDO_LAYER_OPACITY", "layer-opacity" }, @@ -817,6 +820,9 @@ gimp_undo_type_get_type (void) { GIMP_UNDO_LAYER_REMOVE, N_("Delete layer"), NULL }, { GIMP_UNDO_LAYER_MASK_ADD, N_("Add layer mask"), NULL }, { GIMP_UNDO_LAYER_MASK_REMOVE, N_("Delete layer mask"), NULL }, + { GIMP_UNDO_LAYER_MASK_APPLY, N_("Apply layer mask"), NULL }, + { GIMP_UNDO_LAYER_MASK_EDIT, N_("Edit layer mask"), NULL }, + { GIMP_UNDO_LAYER_MASK_SHOW, N_("Show layer mask"), NULL }, { GIMP_UNDO_LAYER_REPOSITION, N_("Reposition layer"), NULL }, { GIMP_UNDO_LAYER_MODE, N_("Set layer mode"), NULL }, { GIMP_UNDO_LAYER_OPACITY, N_("Set layer opacity"), NULL }, diff --git a/app/core/core-enums.h b/app/core/core-enums.h index 53c2edd0af..a1686d0613 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -384,6 +384,9 @@ typedef enum /*< pdb-skip >*/ GIMP_UNDO_LAYER_REMOVE, /*< desc="Delete layer" >*/ GIMP_UNDO_LAYER_MASK_ADD, /*< desc="Add layer mask" >*/ GIMP_UNDO_LAYER_MASK_REMOVE, /*< desc="Delete layer mask" >*/ + GIMP_UNDO_LAYER_MASK_APPLY, /*< desc="Apply layer mask" >*/ + GIMP_UNDO_LAYER_MASK_EDIT, /*< desc="Edit layer mask" >*/ + GIMP_UNDO_LAYER_MASK_SHOW, /*< desc="Show layer mask" >*/ GIMP_UNDO_LAYER_REPOSITION, /*< desc="Reposition layer" >*/ GIMP_UNDO_LAYER_MODE, /*< desc="Set layer mode" >*/ GIMP_UNDO_LAYER_OPACITY, /*< desc="Set layer opacity" >*/ diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index b7943aec77..ab63e4c192 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -1626,6 +1626,7 @@ gimp_image_undo_push_layer_mask_remove (GimpImage *gimage, layer, mask); } + static gboolean undo_push_layer_mask (GimpImage *gimage, const gchar *undo_desc, @@ -1703,6 +1704,98 @@ undo_free_layer_mask (GimpUndo *undo, g_free (lmu); } +/********************************/ +/* Layer Mask Property Undo */ +/********************************/ + +typedef struct _LayerMaskPropertyUndo LayerMaskPropertyUndo; + +struct _LayerMaskPropertyUndo +{ + GimpLayerMask *mask; + gboolean apply; + gboolean edit; + gboolean show; +}; + +static gboolean undo_pop_layer_mask_properties (GimpUndo *undo, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum); + + + +gboolean +gimp_image_undo_push_layer_mask_properties (GimpImage *gimage, + const gchar *undo_desc, + GimpUndoType type, + GimpLayer *layer, + GimpLayerMask *mask) +{ + GimpUndo *new; + gint64 size; + + size = sizeof (LayerMaskPropertyUndo); + + if ((new = gimp_image_undo_push (gimage, GIMP_TYPE_ITEM_UNDO, + size, sizeof (LayerMaskPropertyUndo), + type, undo_desc, + GIMP_DIRTY_ITEM_META, + undo_pop_layer_mask_properties, + undo_free_layer_mask, + "item", layer, + NULL))) + { + LayerMaskPropertyUndo *lmp_undo = new->data; + + lmp_undo->mask = g_object_ref (mask); + lmp_undo->apply = mask->apply_mask; + lmp_undo->edit = mask->edit_mask; + lmp_undo->show = mask->show_mask; + + return TRUE; + } + + return FALSE; +} + +static gboolean +undo_pop_layer_mask_properties (GimpUndo *undo, + GimpUndoMode undo_mode, + GimpUndoAccumulator *accum) +{ + LayerMaskPropertyUndo *lmp_undo = undo->data; + GimpLayer *layer = GIMP_LAYER (GIMP_ITEM_UNDO (undo)->item); + GimpLayerMask *mask; + gboolean val; + mask = lmp_undo->mask; + + switch (undo->undo_type) + { + case GIMP_UNDO_LAYER_MASK_APPLY: + val = (undo_mode == GIMP_UNDO_MODE_UNDO) ? + lmp_undo->apply : ! lmp_undo->apply; + gimp_layer_mask_set_apply (mask, val, FALSE); + break; + + case GIMP_UNDO_LAYER_MASK_EDIT: + val = (undo_mode == GIMP_UNDO_MODE_UNDO) ? + lmp_undo->edit : ! lmp_undo->edit; + gimp_layer_mask_set_edit (mask, val, FALSE); + break; + + case GIMP_UNDO_LAYER_MASK_SHOW: + val = (undo_mode == GIMP_UNDO_MODE_UNDO) ? + lmp_undo->show : ! lmp_undo->show; + gimp_layer_mask_set_show (mask, val, FALSE); + break; + + default: + return FALSE; + break; + } + + return TRUE; +} /***************************/ /* Layer re-position Undo */ diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h index 9e1fcb8538..0ef589172f 100644 --- a/app/core/gimpimage-undo-push.h +++ b/app/core/gimpimage-undo-push.h @@ -100,6 +100,10 @@ gboolean gimp_image_undo_push_layer_mask_remove (GimpImage *gimage, const gchar *undo_desc, GimpLayer *layer, GimpLayerMask *mask); +gboolean gimp_image_undo_push_layer_mask_properties (GimpImage *gimage, + const gchar *undo_desc, + GimpLayer *layer, + GimpLayerMask *mask); gboolean gimp_image_undo_push_layer_reposition (GimpImage *gimage, const gchar *undo_desc, GimpLayer *layer); diff --git a/app/core/gimplayermask.c b/app/core/gimplayermask.c index 74be69c4f6..fdb646db62 100644 --- a/app/core/gimplayermask.c +++ b/app/core/gimplayermask.c @@ -250,12 +250,22 @@ gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask) void gimp_layer_mask_set_apply (GimpLayerMask *layer_mask, - gboolean apply) + gboolean apply, + gboolean push_undo) { g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask)); if (layer_mask->apply_mask != apply) { + GimpImage *gimage = GIMP_ITEM (layer_mask)->gimage; + + if (push_undo) + gimp_image_undo_push_layer_mask_properties (gimage, + _("Apply Layer Mask"), + GIMP_UNDO_LAYER_MASK_APPLY, + layer_mask->layer, + layer_mask); + layer_mask->apply_mask = apply ? TRUE : FALSE; if (layer_mask->layer) @@ -282,12 +292,22 @@ gimp_layer_mask_get_apply (const GimpLayerMask *layer_mask) void gimp_layer_mask_set_edit (GimpLayerMask *layer_mask, - gboolean edit) + gboolean edit, + gboolean push_undo) { g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask)); if (layer_mask->edit_mask != edit) { + GimpImage *gimage = GIMP_ITEM (layer_mask)->gimage; + + if (push_undo) + gimp_image_undo_push_layer_mask_properties (gimage, + _("Edit Layer Mask"), + GIMP_UNDO_LAYER_MASK_EDIT, + layer_mask->layer, + layer_mask); + layer_mask->edit_mask = edit ? TRUE : FALSE; g_signal_emit (layer_mask, layer_mask_signals[EDIT_CHANGED], 0); @@ -304,12 +324,22 @@ gimp_layer_mask_get_edit (const GimpLayerMask *layer_mask) void gimp_layer_mask_set_show (GimpLayerMask *layer_mask, - gboolean show) + gboolean show, + gboolean push_undo) { g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask)); if (layer_mask->show_mask != show) { + GimpImage *gimage = GIMP_ITEM (layer_mask)->gimage; + + if (push_undo) + gimp_image_undo_push_layer_mask_properties (gimage, + _("Show Layer Mask"), + GIMP_UNDO_LAYER_MASK_SHOW, + layer_mask->layer, + layer_mask); + layer_mask->show_mask = show ? TRUE : FALSE; if (layer_mask->layer) diff --git a/app/core/gimplayermask.h b/app/core/gimplayermask.h index d89e9f886d..7d2e46298e 100644 --- a/app/core/gimplayermask.h +++ b/app/core/gimplayermask.h @@ -69,15 +69,18 @@ void gimp_layer_mask_set_layer (GimpLayerMask *layer_mask, GimpLayer * gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask); void gimp_layer_mask_set_apply (GimpLayerMask *layer_mask, - gboolean apply); + gboolean apply, + gboolean push_undo); gboolean gimp_layer_mask_get_apply (const GimpLayerMask *layer_mask); void gimp_layer_mask_set_edit (GimpLayerMask *layer_mask, - gboolean apply); + gboolean apply, + gboolean push_undo); gboolean gimp_layer_mask_get_edit (const GimpLayerMask *layer_mask); void gimp_layer_mask_set_show (GimpLayerMask *layer_mask, - gboolean show); + gboolean show, + gboolean push_undo); gboolean gimp_layer_mask_get_show (const GimpLayerMask *layer_mask); diff --git a/app/pdb/pdb_glue.h b/app/pdb/pdb_glue.h index 588b4ffbe9..d69076b345 100644 --- a/app/pdb/pdb_glue.h +++ b/app/pdb/pdb_glue.h @@ -24,9 +24,9 @@ #define gimp_layer_get_show_mask(l) (l)->mask ? gimp_layer_mask_get_show((l)->mask) : FALSE; #define gimp_layer_get_edit_mask(l) (l)->mask ? gimp_layer_mask_get_edit((l)->mask) : FALSE; -#define gimp_layer_set_apply_mask(l,a) { if((l)->mask) gimp_layer_mask_set_apply((l)->mask,(a)); else success = FALSE; } -#define gimp_layer_set_show_mask(l,s) { if((l)->mask) gimp_layer_mask_set_show((l)->mask,(s)); else success = FALSE; } -#define gimp_layer_set_edit_mask(l,e) { if((l)->mask) gimp_layer_mask_set_edit((l)->mask,(e)); else success = FALSE; } +#define gimp_layer_set_apply_mask(l,a) { if((l)->mask) gimp_layer_mask_set_apply((l)->mask,(a), TRUE); else success = FALSE; } +#define gimp_layer_set_show_mask(l,s) { if((l)->mask) gimp_layer_mask_set_show((l)->mask,(s), TRUE); else success = FALSE; } +#define gimp_layer_set_edit_mask(l,e) { if((l)->mask) gimp_layer_mask_set_edit((l)->mask,(e), TRUE); else success = FALSE; } #endif /* __PDB_GLUE_H__ */