Added "Edit -> Fade" which allows to modify the paint mode and opacity of

2006-10-21  Michael Natterer  <mitch@gimp.org>

	Added "Edit -> Fade" which allows to modify the paint mode and
	opacity of the last drawable operation (fill, plugins etc.).
	Started from a patch by Bill Skaggs. Fixes bug #170707.

	* app/base/base-enums.[ch] (enum GimpLayerModeEffects): register
	the values REPLACE_MODE, ERASE_MODE and ANTI_ERASE_MODE with
	the type system.

	* app/widgets/gimppropwidgets.[ch]
	* app/widgets/gimpwidgets-constructors.[ch]: added "gboolean
	with_replace_modes" to the paint mode menu constructors.

	* app/tools/gimppaintoptions-gui.c
	* app/widgets/gimpbrushselect.c
	* app/widgets/gimplayertreeview.c: pass with_replace_modes = FALSE.

	* app/core/gimpdrawableundo.[ch]: added members which keep tiles,
	paint mode and opacity of the pasted pixels.

	* app/core/gimpimage-undo.[ch] (gimp_image_undo_get_fadeable):
	returns a GimpUndo suitable for a fade operation, or NULL.

	* app/core/gimp-edit.[ch] (gimp_edit_fade): implements the actual
	fade by undoing the last operation and then re-applying the pixels
	with different paint mode and opacity.

	* app/core/gimpdrawable-combine.c: store the pasted pixels in
	the GimpDrawableUndo.

	* app/actions/edit-actions.c
	* app/actions/edit-commands.[ch]: action and callback for fade.

	* app/dialogs/Makefile.am
	* app/dialogs/fade-dialog.[ch]: the fade dialog.

	* app/widgets/gimphelp-ids.h: the fade help ID.

	* menus/image-menu.xml.in: added a menu entry in "Edit".
This commit is contained in:
Michael Natterer 2006-10-21 18:46:49 +00:00 committed by Michael Natterer
parent 046fa38b75
commit e634d4d718
25 changed files with 584 additions and 109 deletions

View File

@ -1,3 +1,44 @@
2006-10-21 Michael Natterer <mitch@gimp.org>
Added "Edit -> Fade" which allows to modify the paint mode and
opacity of the last drawable operation (fill, plugins etc.).
Started from a patch by Bill Skaggs. Fixes bug #170707.
* app/base/base-enums.[ch] (enum GimpLayerModeEffects): register
the values REPLACE_MODE, ERASE_MODE and ANTI_ERASE_MODE with
the type system.
* app/widgets/gimppropwidgets.[ch]
* app/widgets/gimpwidgets-constructors.[ch]: added "gboolean
with_replace_modes" to the paint mode menu constructors.
* app/tools/gimppaintoptions-gui.c
* app/widgets/gimpbrushselect.c
* app/widgets/gimplayertreeview.c: pass with_replace_modes = FALSE.
* app/core/gimpdrawableundo.[ch]: added members which keep tiles,
paint mode and opacity of the pasted pixels.
* app/core/gimpimage-undo.[ch] (gimp_image_undo_get_fadeable):
returns a GimpUndo suitable for a fade operation, or NULL.
* app/core/gimp-edit.[ch] (gimp_edit_fade): implements the actual
fade by undoing the last operation and then re-applying the pixels
with different paint mode and opacity.
* app/core/gimpdrawable-combine.c: store the pasted pixels in
the GimpDrawableUndo.
* app/actions/edit-actions.c
* app/actions/edit-commands.[ch]: action and callback for fade.
* app/dialogs/Makefile.am
* app/dialogs/fade-dialog.[ch]: the fade dialog.
* app/widgets/gimphelp-ids.h: the fade help ID.
* menus/image-menu.xml.in: added a menu entry in "Edit".
2006-10-20 Michael Natterer <mitch@gimp.org>
* tools/pdbgen/stddefs.pdb

View File

@ -27,7 +27,9 @@
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawableundo.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimplayer.h"
#include "core/gimplist.h"
#include "core/gimptoolinfo.h"
@ -96,6 +98,11 @@ static const GimpActionEntry edit_actions[] =
G_CALLBACK (edit_undo_clear_cmd_callback),
GIMP_HELP_EDIT_UNDO_CLEAR },
{ "edit-fade", GTK_STOCK_UNDO,
N_("_Fade..."), "", NULL,
G_CALLBACK (edit_fade_cmd_callback),
GIMP_HELP_EDIT_FADE },
{ "edit-cut", GTK_STOCK_CUT,
N_("Cu_t"), "<control>X",
N_("Move the selected pixels to the clipboard"),
@ -240,7 +247,9 @@ edit_actions_update (GimpActionGroup *group,
GimpDrawable *drawable = NULL;
gchar *undo_name = NULL;
gchar *redo_name = NULL;
gchar *fade_name = NULL;
gboolean undo_enabled = FALSE;
gboolean fade_enabled = FALSE;
if (image)
{
@ -265,6 +274,17 @@ edit_actions_update (GimpActionGroup *group,
redo_name =
g_strdup_printf (_("_Redo %s"),
gimp_object_get_name (GIMP_OBJECT (redo)));
undo = gimp_image_undo_get_fadeable (image);
if (GIMP_IS_DRAWABLE_UNDO (undo) &&
GIMP_DRAWABLE_UNDO (undo)->src2_tiles)
fade_enabled = TRUE;
if (fade_enabled)
fade_name =
g_strdup_printf (_("_Fade %s..."),
gimp_object_get_name (GIMP_OBJECT (undo)));
}
}
@ -276,12 +296,14 @@ edit_actions_update (GimpActionGroup *group,
SET_LABEL ("edit-undo", undo_name ? undo_name : _("_Undo"));
SET_LABEL ("edit-redo", redo_name ? redo_name : _("_Redo"));
SET_LABEL ("edit-fade", fade_name ? fade_name : _("_Fade..."));
SET_SENSITIVE ("edit-undo", undo_enabled && undo_name);
SET_SENSITIVE ("edit-redo", undo_enabled && redo_name);
SET_SENSITIVE ("edit-strong-undo", undo_enabled && undo_name);
SET_SENSITIVE ("edit-strong-redo", undo_enabled && redo_name);
SET_SENSITIVE ("edit-undo-clear", undo_enabled && (undo_name || redo_name));
SET_SENSITIVE ("edit-fade", fade_enabled && fade_name);
g_free (undo_name);
g_free (redo_name);

View File

@ -48,6 +48,7 @@
#include "widgets/gimpmessagedialog.h"
#include "dialogs/dialogs.h"
#include "dialogs/fade-dialog.h"
#include "actions.h"
#include "edit-commands.h"
@ -290,6 +291,27 @@ edit_named_cut_cmd_callback (GtkAction *action,
gtk_widget_show (dialog);
}
void
edit_fade_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
GtkWidget *widget;
GtkWidget *dialog;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
dialog = fade_dialog_new (image, widget);
if (dialog)
{
g_signal_connect_object (image, "disconnect",
G_CALLBACK (gtk_widget_destroy),
dialog, G_CONNECT_SWAPPED);
gtk_widget_show (dialog);
}
}
void
edit_named_copy_cmd_callback (GtkAction *action,
gpointer data)

View File

@ -30,6 +30,8 @@ void edit_strong_redo_cmd_callback (GtkAction *action,
gpointer data);
void edit_undo_clear_cmd_callback (GtkAction *action,
gpointer data);
void edit_fade_cmd_callback (GtkAction *action,
gpointer data);
void edit_cut_cmd_callback (GtkAction *action,
gpointer data);
void edit_copy_cmd_callback (GtkAction *action,

View File

@ -100,6 +100,9 @@ gimp_layer_mode_effects_get_type (void)
{ GIMP_GRAIN_EXTRACT_MODE, "GIMP_GRAIN_EXTRACT_MODE", "grain-extract-mode" },
{ GIMP_GRAIN_MERGE_MODE, "GIMP_GRAIN_MERGE_MODE", "grain-merge-mode" },
{ GIMP_COLOR_ERASE_MODE, "GIMP_COLOR_ERASE_MODE", "color-erase-mode" },
{ GIMP_ERASE_MODE, "GIMP_ERASE_MODE", "erase-mode" },
{ GIMP_REPLACE_MODE, "GIMP_REPLACE_MODE", "replace-mode" },
{ GIMP_ANTI_ERASE_MODE, "GIMP_ANTI_ERASE_MODE", "anti-erase-mode" },
{ 0, NULL, NULL }
};
@ -128,6 +131,9 @@ gimp_layer_mode_effects_get_type (void)
{ GIMP_GRAIN_EXTRACT_MODE, N_("Grain extract"), NULL },
{ GIMP_GRAIN_MERGE_MODE, N_("Grain merge"), NULL },
{ GIMP_COLOR_ERASE_MODE, N_("Color erase"), NULL },
{ GIMP_ERASE_MODE, N_("Erase"), NULL },
{ GIMP_REPLACE_MODE, N_("Replace"), NULL },
{ GIMP_ANTI_ERASE_MODE, N_("Anti Erase"), NULL },
{ 0, NULL, NULL }
};

View File

@ -67,32 +67,32 @@ GType gimp_layer_mode_effects_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_NORMAL_MODE, /*< desc="Normal" >*/
GIMP_DISSOLVE_MODE, /*< desc="Dissolve" >*/
GIMP_BEHIND_MODE, /*< desc="Behind" >*/
GIMP_MULTIPLY_MODE, /*< desc="Multiply" >*/
GIMP_SCREEN_MODE, /*< desc="Screen" >*/
GIMP_OVERLAY_MODE, /*< desc="Overlay" >*/
GIMP_DIFFERENCE_MODE, /*< desc="Difference" >*/
GIMP_ADDITION_MODE, /*< desc="Addition" >*/
GIMP_SUBTRACT_MODE, /*< desc="Subtract" >*/
GIMP_DARKEN_ONLY_MODE, /*< desc="Darken only" >*/
GIMP_LIGHTEN_ONLY_MODE, /*< desc="Lighten only" >*/
GIMP_HUE_MODE, /*< desc="Hue" >*/
GIMP_SATURATION_MODE, /*< desc="Saturation" >*/
GIMP_COLOR_MODE, /*< desc="Color" >*/
GIMP_VALUE_MODE, /*< desc="Value" >*/
GIMP_DIVIDE_MODE, /*< desc="Divide" >*/
GIMP_DODGE_MODE, /*< desc="Dodge" >*/
GIMP_BURN_MODE, /*< desc="Burn" >*/
GIMP_HARDLIGHT_MODE, /*< desc="Hard light" >*/
GIMP_SOFTLIGHT_MODE, /*< desc="Soft light" >*/
GIMP_GRAIN_EXTRACT_MODE, /*< desc="Grain extract" >*/
GIMP_GRAIN_MERGE_MODE, /*< desc="Grain merge" >*/
GIMP_COLOR_ERASE_MODE, /*< desc="Color erase" >*/
GIMP_ERASE_MODE, /*< pdb-skip, skip >*/
GIMP_REPLACE_MODE, /*< pdb-skip, skip >*/
GIMP_ANTI_ERASE_MODE /*< pdb-skip, skip >*/
GIMP_NORMAL_MODE, /*< desc="Normal" >*/
GIMP_DISSOLVE_MODE, /*< desc="Dissolve" >*/
GIMP_BEHIND_MODE, /*< desc="Behind" >*/
GIMP_MULTIPLY_MODE, /*< desc="Multiply" >*/
GIMP_SCREEN_MODE, /*< desc="Screen" >*/
GIMP_OVERLAY_MODE, /*< desc="Overlay" >*/
GIMP_DIFFERENCE_MODE, /*< desc="Difference" >*/
GIMP_ADDITION_MODE, /*< desc="Addition" >*/
GIMP_SUBTRACT_MODE, /*< desc="Subtract" >*/
GIMP_DARKEN_ONLY_MODE, /*< desc="Darken only" >*/
GIMP_LIGHTEN_ONLY_MODE, /*< desc="Lighten only" >*/
GIMP_HUE_MODE, /*< desc="Hue" >*/
GIMP_SATURATION_MODE, /*< desc="Saturation" >*/
GIMP_COLOR_MODE, /*< desc="Color" >*/
GIMP_VALUE_MODE, /*< desc="Value" >*/
GIMP_DIVIDE_MODE, /*< desc="Divide" >*/
GIMP_DODGE_MODE, /*< desc="Dodge" >*/
GIMP_BURN_MODE, /*< desc="Burn" >*/
GIMP_HARDLIGHT_MODE, /*< desc="Hard light" >*/
GIMP_SOFTLIGHT_MODE, /*< desc="Soft light" >*/
GIMP_GRAIN_EXTRACT_MODE, /*< desc="Grain extract" >*/
GIMP_GRAIN_MERGE_MODE, /*< desc="Grain merge" >*/
GIMP_COLOR_ERASE_MODE, /*< desc="Color erase" >*/
GIMP_ERASE_MODE, /*< pdb-skip, desc="Erase" >*/
GIMP_REPLACE_MODE, /*< pdb-skip, desc="Replace" >*/
GIMP_ANTI_ERASE_MODE /*< pdb-skip, desc="Anti erase" >*/
} GimpLayerModeEffects;

View File

@ -38,6 +38,7 @@
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimplayer.h"
@ -474,6 +475,52 @@ gimp_edit_fill (GimpImage *image,
undo_desc);
}
gboolean
gimp_edit_fade (GimpImage *image,
GimpContext *context)
{
GimpDrawableUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
if (undo && undo->src2_tiles)
{
GimpDrawable *drawable;
TileManager *src2_tiles;
PixelRegion src2PR;
drawable = GIMP_DRAWABLE (GIMP_ITEM_UNDO (undo)->item);
g_object_ref (undo);
src2_tiles = tile_manager_ref (undo->src2_tiles);
gimp_image_undo (image);
pixel_region_init (&src2PR, src2_tiles,
0, 0, undo->width, undo->height,
FALSE);
gimp_drawable_apply_region (drawable, &src2PR,
TRUE,
gimp_object_get_name (GIMP_OBJECT (undo)),
gimp_context_get_opacity (context),
gimp_context_get_paint_mode (context),
NULL,
undo->x,
undo->y);
tile_manager_unref (src2_tiles);
g_object_unref (undo);
return TRUE;
}
return FALSE;
}
/* private functions */

View File

@ -60,5 +60,8 @@ gboolean gimp_edit_fill (GimpImage *image,
GimpContext *context,
GimpFillType fill_type);
gboolean gimp_edit_fade (GimpImage *image,
GimpContext *context);
#endif /* __GIMP_EDIT_H__ */

View File

@ -23,12 +23,15 @@
#include "core-types.h"
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "paint-funcs/paint-funcs.h"
#include "gimpchannel.h"
#include "gimpdrawable-combine.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
void
@ -98,7 +101,34 @@ gimp_drawable_real_apply_region (GimpDrawable *drawable,
/* If the calling procedure specified an undo step... */
if (push_undo)
gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE);
{
GimpDrawableUndo *undo;
gimp_drawable_push_undo (drawable, undo_desc, x1, y1, x2, y2, NULL, FALSE);
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
if (undo)
{
PixelRegion tmp_srcPR;
PixelRegion tmp_destPR;
undo->paint_mode = mode;
undo->opacity = opacity;
undo->src2_tiles = tile_manager_new (x2 - x1, y2 - y1,
src2PR->bytes);
tmp_srcPR = *src2PR;
pixel_region_resize (&tmp_srcPR,
src2PR->x + (x1 - x), src2PR->y + (y1 - y),
x2 - x1, y2 - y1);
pixel_region_init (&tmp_destPR, undo->src2_tiles,
0, 0,
x2 - x1, y2 - y1, TRUE);
copy_region (&tmp_srcPR, &tmp_destPR);
}
}
/* configure the pixel regions
* If an alternative to using the drawable's data as src1 was provided...

View File

@ -245,4 +245,10 @@ gimp_drawable_undo_free (GimpUndo *undo,
tile_manager_unref (drawable_undo->tiles);
drawable_undo->tiles = NULL;
}
if (drawable_undo->src2_tiles)
{
tile_manager_unref (drawable_undo->src2_tiles);
drawable_undo->src2_tiles = NULL;
}
}

View File

@ -43,6 +43,11 @@ struct _GimpDrawableUndo
gint y;
gint width;
gint height;
/* stuff for "Fade" */
TileManager *src2_tiles;
GimpLayerModeEffects paint_mode;
gdouble opacity;
};
struct _GimpDrawableUndoClass

View File

@ -26,13 +26,12 @@
#include "gimp.h"
#include "gimp-utils.h"
#include "gimpdrawableundo.h"
#include "gimpimage.h"
#include "gimpimage-undo.h"
#include "gimpitem.h"
#include "gimpitemundo.h"
#include "gimplist.h"
#include "gimpundostack.h"
#include "gimpundo.h"
/* local function prototypes */
@ -361,6 +360,31 @@ gimp_image_undo_can_compress (GimpImage *image,
return NULL;
}
GimpUndo *
gimp_image_undo_get_fadeable (GimpImage *image)
{
GimpUndo *undo;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
undo = gimp_undo_stack_peek (image->undo_stack);
if (GIMP_IS_UNDO_STACK (undo) && undo->undo_type == GIMP_UNDO_GROUP_PAINT)
{
GimpUndoStack *stack = GIMP_UNDO_STACK (undo);
if (gimp_undo_stack_get_depth (stack) == 2)
{
undo = gimp_undo_stack_peek (stack);
}
}
if (GIMP_IS_DRAWABLE_UNDO (undo))
return undo;
return NULL;
}
/* private functions */

View File

@ -48,5 +48,7 @@ GimpUndo * gimp_image_undo_can_compress (GimpImage *image,
GType object_type,
GimpUndoType undo_type);
GimpUndo * gimp_image_undo_get_fadeable (GimpImage *image);
#endif /* __GIMP_IMAGE_UNDO_H__ */

View File

@ -30,6 +30,8 @@ libappdialogs_a_sources = \
convert-dialog.h \
desaturate-dialog.c \
desaturate-dialog.h \
fade-dialog.c \
fade-dialog.h \
file-open-dialog.c \
file-open-dialog.h \
file-open-location-dialog.c \

208
app/dialogs/fade-dialog.c Normal file
View File

@ -0,0 +1,208 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "dialogs-types.h"
#include "core/gimp-edit.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawableundo.h"
#include "core/gimpundostack.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpviewabledialog.h"
#include "fade-dialog.h"
#include "gimp-intl.h"
typedef struct _FadeDialog FadeDialog;
struct _FadeDialog
{
GimpImage *image;
GimpDrawable *drawable;
GimpContext *context;
gboolean applied;
GimpLayerModeEffects orig_paint_mode;
gdouble orig_opacity;
};
static void fade_dialog_response (GtkWidget *dialog,
gint response_id,
FadeDialog *private);
static void fade_dialog_context_changed (FadeDialog *private);
/* public functions */
GtkWidget *
fade_dialog_new (GimpImage *image,
GtkWidget *parent)
{
FadeDialog *private;
GimpDrawableUndo *undo;
GimpDrawable *drawable;
GimpItem *item;
GtkWidget *dialog;
GtkWidget *main_vbox;
GtkWidget *table;
GtkWidget *menu;
GtkWidget *label;
gchar *title;
gint table_row = 0;
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (parent), NULL);
undo = GIMP_DRAWABLE_UNDO (gimp_image_undo_get_fadeable (image));
if (! (undo && undo->src2_tiles))
return NULL;
item = GIMP_ITEM_UNDO (undo)->item;
drawable = GIMP_DRAWABLE (item);
private = g_new0 (FadeDialog, 1);
private->image = image;
private->drawable = drawable;
private->context = gimp_context_new (image->gimp, "fade-dialog", NULL);
private->applied = FALSE;
private->orig_paint_mode = undo->paint_mode;
private->orig_opacity = undo->opacity;
g_object_set (private->context,
"paint-mode", undo->paint_mode,
"opacity", undo->opacity,
NULL);
title = g_strdup_printf (_("Fade %s"),
gimp_object_get_name (GIMP_OBJECT (undo)));
dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (drawable),
private->context,
title, "gimp-edit-fade",
GTK_STOCK_UNDO, title,
parent,
gimp_standard_help_func,
GIMP_HELP_EDIT_FADE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
g_free (title);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
g_object_weak_ref (G_OBJECT (dialog), (GWeakNotify) g_free, private);
g_signal_connect (dialog, "response",
G_CALLBACK (fade_dialog_response),
private);
main_vbox = gtk_vbox_new (FALSE, 12);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 12);
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), main_vbox);
gtk_widget_show (main_vbox);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 0);
gtk_widget_show (table);
/* the paint mode menu */
menu = gimp_prop_paint_mode_menu_new (G_OBJECT (private->context),
"paint-mode", TRUE, TRUE);
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Mode:"), 0.0, 0.5,
menu, 2, FALSE);
/* the opacity scale */
gimp_prop_opacity_entry_new (G_OBJECT (private->context), "opacity",
GTK_TABLE (table), 0, table_row++,
_("Opacity:"));
g_signal_connect_swapped (private->context, "paint-mode-changed",
G_CALLBACK (fade_dialog_context_changed),
private);
g_signal_connect_swapped (private->context, "opacity-changed",
G_CALLBACK (fade_dialog_context_changed),
private);
return dialog;
}
/* private functions */
static void
fade_dialog_response (GtkWidget *dialog,
gint response_id,
FadeDialog *private)
{
g_signal_handlers_disconnect_by_func (private->context,
fade_dialog_context_changed,
private);
if (response_id != GTK_RESPONSE_OK && private->applied)
{
g_object_set (private->context,
"paint-mode", private->orig_paint_mode,
"opacity", private->orig_opacity,
NULL);
fade_dialog_context_changed (private);
}
g_object_unref (private->context);
gtk_widget_destroy (dialog);
}
static void
fade_dialog_context_changed (FadeDialog *private)
{
if (gimp_edit_fade (private->image, private->context))
{
private->applied = TRUE;
gimp_image_flush (private->image);
}
}

27
app/dialogs/fade-dialog.h Normal file
View File

@ -0,0 +1,27 @@
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __FADE_DIALOG_H__
#define __FADE_DIALOG_H__
GtkWidget * fade_dialog_new (GimpImage *image,
GtkWidget *parent);
#endif /* __FADE_DIALOG_H__ */

View File

@ -99,7 +99,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
g_object_set_data (G_OBJECT (vbox), GIMP_PAINT_OPTIONS_TABLE_KEY, table);
/* the paint mode menu */
menu = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE);
menu = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE);
label = gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
_("Mode:"), 0.0, 0.5,
menu, 2, FALSE);

View File

@ -185,7 +185,7 @@ gimp_brush_select_constructor (GType type,
select);
/* Create the paint mode option menu */
select->paint_mode_menu = gimp_paint_mode_menu_new (TRUE);
select->paint_mode_menu = gimp_paint_mode_menu_new (TRUE, FALSE);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
_("Mode:"), 0.0, 0.5,
select->paint_mode_menu, 2, FALSE);

View File

@ -46,6 +46,7 @@
#define GIMP_HELP_EDIT_STRONG_UNDO "gimp-edit-strong-undo"
#define GIMP_HELP_EDIT_STRONG_REDO "gimp-edit-strong-redo"
#define GIMP_HELP_EDIT_UNDO_CLEAR "gimp-edit-undo-clear"
#define GIMP_HELP_EDIT_FADE "gimp-edit-fade"
#define GIMP_HELP_EDIT_CUT "gimp-edit-cut"
#define GIMP_HELP_EDIT_COPY "gimp-edit-copy"
#define GIMP_HELP_EDIT_COPY_VISIBLE "gimp-edit-copy-visible"

View File

@ -268,7 +268,7 @@ gimp_layer_tree_view_init (GimpLayerTreeView *view)
/* Paint mode menu */
view->paint_mode_menu = gimp_paint_mode_menu_new (FALSE);
view->paint_mode_menu = gimp_paint_mode_menu_new (FALSE, FALSE);
gimp_table_attach_aligned (GTK_TABLE (view->options_box), 0, 0,
_("Mode:"), 0.0, 0.5,
view->paint_mode_menu, 2, FALSE);

View File

@ -125,9 +125,11 @@ static void gimp_prop_paint_menu_notify (GObject *config,
/**
* gimp_prop_paint_mode_menu_new:
* @config: #GimpConfig object to which property is attached.
* @property_name: Name of Enum property.
* @with_behind_mode: Whether to include "Behind" mode in the menu.
* @config: #GimpConfig object to which property is attached.
* @property_name: Name of Enum property.
* @with_behind_mode: Whether to include "Behind" mode in the menu.
* @with_replace_modes: Whether to include the "Replace", "Erase" and
* "Anti Erase" modes in the menu.
*
* Creates a #GimpPaintModeMenu widget to display and set the specified
* Enum property, for which the enum must be #GimpLayerModeEffects.
@ -139,7 +141,8 @@ static void gimp_prop_paint_menu_notify (GObject *config,
GtkWidget *
gimp_prop_paint_mode_menu_new (GObject *config,
const gchar *property_name,
gboolean with_behind_mode)
gboolean with_behind_mode,
gboolean with_replace_modes)
{
GParamSpec *param_spec;
GtkWidget *menu;
@ -154,7 +157,7 @@ gimp_prop_paint_mode_menu_new (GObject *config,
property_name, &value,
NULL);
menu = gimp_paint_mode_menu_new (with_behind_mode);
menu = gimp_paint_mode_menu_new (with_behind_mode, with_replace_modes);
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (menu),
value,

View File

@ -36,7 +36,8 @@ GtkWidget * gimp_prop_expanding_frame_new (GObject *config,
GtkWidget * gimp_prop_paint_mode_menu_new (GObject *config,
const gchar *property_name,
gboolean with_behind_mode);
gboolean with_behind_mode,
gboolean with_replace_modes);
/* GimpParamColor */

View File

@ -20,6 +20,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"
@ -38,21 +39,56 @@ static gboolean gimp_paint_mode_menu_separator_func (GtkTreeModel *model,
/* public functions */
static void
gimp_enum_store_insert_value_after (GimpEnumStore *store,
gint after,
gint insert_value)
{
GtkTreeIter iter;
g_return_if_fail (GIMP_IS_ENUM_STORE (store));
if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
after, &iter))
{
GEnumValue *enum_value;
enum_value = g_enum_get_value (store->enum_class, insert_value);
if (enum_value)
{
GtkTreeIter value_iter;
const gchar *desc;
gtk_list_store_insert_after (GTK_LIST_STORE (store),
&value_iter, &iter);
desc = gimp_enum_value_get_desc (store->enum_class, enum_value);
gtk_list_store_set (GTK_LIST_STORE (store), &value_iter,
GIMP_INT_STORE_VALUE, enum_value->value,
GIMP_INT_STORE_LABEL, desc,
-1);
}
}
}
static void
gimp_int_store_insert_separator_after (GimpIntStore *store,
gint value,
gint after,
gint separator_value)
{
GtkTreeIter value_iter;
GtkTreeIter sep_iter;
GtkTreeIter iter;
g_return_if_fail (GIMP_IS_INT_STORE (store));
if (gimp_int_store_lookup_by_value (GTK_TREE_MODEL (store),
value, &value_iter))
after, &iter))
{
GtkTreeIter sep_iter;
gtk_list_store_insert_after (GTK_LIST_STORE (store),
&sep_iter, &value_iter);
&sep_iter, &iter);
gtk_list_store_set (GTK_LIST_STORE (store), &sep_iter,
GIMP_INT_STORE_VALUE, separator_value,
-1);
@ -60,80 +96,42 @@ gimp_int_store_insert_separator_after (GimpIntStore *store,
}
GtkWidget *
gimp_paint_mode_menu_new (gboolean with_behind_mode)
gimp_paint_mode_menu_new (gboolean with_behind_mode,
gboolean with_replace_modes)
{
GtkListStore *store;
GtkWidget *combo;
if (with_behind_mode)
{
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
23,
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_BEHIND_MODE,
GIMP_COLOR_ERASE_MODE,
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
21,
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_COLOR_ERASE_MODE, -1);
}
else
{
store = gimp_enum_store_new_with_values (GIMP_TYPE_LAYER_MODE_EFFECTS,
21,
GIMP_NORMAL_MODE,
GIMP_DISSOLVE_MODE,
GIMP_MULTIPLY_MODE,
GIMP_DIVIDE_MODE,
GIMP_SCREEN_MODE,
GIMP_OVERLAY_MODE,
GIMP_DODGE_MODE,
GIMP_BURN_MODE,
GIMP_HARDLIGHT_MODE,
GIMP_SOFTLIGHT_MODE,
GIMP_GRAIN_EXTRACT_MODE,
GIMP_GRAIN_MERGE_MODE,
GIMP_DIFFERENCE_MODE,
GIMP_ADDITION_MODE,
GIMP_SUBTRACT_MODE,
GIMP_DARKEN_ONLY_MODE,
GIMP_LIGHTEN_ONLY_MODE,
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_DISSOLVE_MODE, -1);
}
GIMP_HUE_MODE,
GIMP_SATURATION_MODE,
GIMP_COLOR_MODE,
GIMP_VALUE_MODE);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_DISSOLVE_MODE, -1);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_OVERLAY_MODE, -1);
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
@ -141,6 +139,29 @@ gimp_paint_mode_menu_new (gboolean with_behind_mode)
gimp_int_store_insert_separator_after (GIMP_INT_STORE (store),
GIMP_LIGHTEN_ONLY_MODE, -1);
if (with_behind_mode)
{
gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
GIMP_DISSOLVE_MODE,
GIMP_BEHIND_MODE);
gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
GIMP_BEHIND_MODE,
GIMP_COLOR_ERASE_MODE);
}
if (with_replace_modes)
{
gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
GIMP_NORMAL_MODE,
GIMP_REPLACE_MODE);
gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
GIMP_COLOR_ERASE_MODE,
GIMP_ERASE_MODE);
gimp_enum_store_insert_value_after (GIMP_ENUM_STORE (store),
GIMP_ERASE_MODE,
GIMP_ANTI_ERASE_MODE);
}
combo = gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (store));
g_object_unref (store);

View File

@ -20,7 +20,8 @@
#define __GIMP_WIDGETS_CONSTRUCTORS_H__
GtkWidget * gimp_paint_mode_menu_new (gboolean with_behind_mode);
GtkWidget * gimp_paint_mode_menu_new (gboolean with_behind_mode,
gboolean with_replace_modes);
#endif /* __GIMP_WIDGETS_CONSTRUCTORS_H__ */

View File

@ -149,6 +149,7 @@
<placeholder name="Undo">
<menuitem action="edit-undo" />
<menuitem action="edit-redo" />
<menuitem action="edit-fade" />
<menuitem action="dialogs-undo-history" />
</placeholder>
<separator />