From f274b139fce93eef5f48c2e4fe4e8b0010bc3e87 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Tue, 12 May 2020 21:10:21 +0200 Subject: [PATCH] Issue #3533 - Tool preset doesn't restore opacity and paint mode There is no non-hackish way of fixing this without adding a new "use-opacity-paint-mode" property to GimpToolPreset and a new toggle in GimpToolPresetEditor. Restoring opacity and paint mode can now be controlled explicitly, and defaults to TRUE. (cherry picked from commit 97b714d4284ec25debffef780deac50e582f88f1) --- app/core/gimptoolpreset.c | 41 ++++++++++++++++++++++++------ app/core/gimptoolpreset.h | 1 + app/widgets/gimptoolpreseteditor.c | 9 +++++++ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/app/core/gimptoolpreset.c b/app/core/gimptoolpreset.c index 607f6b4cd3..6ab2eb7ccb 100644 --- a/app/core/gimptoolpreset.c +++ b/app/core/gimptoolpreset.c @@ -39,14 +39,15 @@ * with gradients, which is why we special case the gradient tool in * gimp_tool_preset_set_options(). */ -#define DEFAULT_USE_FG_BG FALSE -#define DEFAULT_USE_BRUSH TRUE -#define DEFAULT_USE_DYNAMICS TRUE -#define DEFAULT_USE_MYBRUSH TRUE -#define DEFAULT_USE_GRADIENT FALSE -#define DEFAULT_USE_PATTERN TRUE -#define DEFAULT_USE_PALETTE FALSE -#define DEFAULT_USE_FONT TRUE +#define DEFAULT_USE_FG_BG FALSE +#define DEFAULT_USE_OPACITY_PAINT_MODE TRUE +#define DEFAULT_USE_BRUSH TRUE +#define DEFAULT_USE_DYNAMICS TRUE +#define DEFAULT_USE_MYBRUSH TRUE +#define DEFAULT_USE_GRADIENT FALSE +#define DEFAULT_USE_PATTERN TRUE +#define DEFAULT_USE_PALETTE FALSE +#define DEFAULT_USE_FONT TRUE enum { @@ -55,6 +56,7 @@ enum PROP_GIMP, PROP_TOOL_OPTIONS, PROP_USE_FG_BG, + PROP_USE_OPACITY_PAINT_MODE, PROP_USE_BRUSH, PROP_USE_DYNAMICS, PROP_USE_MYBRUSH, @@ -149,6 +151,13 @@ gimp_tool_preset_class_init (GimpToolPresetClass *klass) DEFAULT_USE_FG_BG, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_OPACITY_PAINT_MODE, + "use-opacity-paint-mode", + _("Apply stored opacity/paint mode"), + NULL, + DEFAULT_USE_OPACITY_PAINT_MODE, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_USE_BRUSH, "use-brush", _("Apply stored brush"), @@ -257,6 +266,9 @@ gimp_tool_preset_set_property (GObject *object, case PROP_USE_FG_BG: tool_preset->use_fg_bg = g_value_get_boolean (value); break; + case PROP_USE_OPACITY_PAINT_MODE: + tool_preset->use_opacity_paint_mode = g_value_get_boolean (value); + break; case PROP_USE_BRUSH: tool_preset->use_brush = g_value_get_boolean (value); break; @@ -310,6 +322,9 @@ gimp_tool_preset_get_property (GObject *object, case PROP_USE_FG_BG: g_value_set_boolean (value, tool_preset->use_fg_bg); break; + case PROP_USE_OPACITY_PAINT_MODE: + g_value_set_boolean (value, tool_preset->use_opacity_paint_mode); + break; case PROP_USE_BRUSH: g_value_set_boolean (value, tool_preset->use_brush); break; @@ -535,6 +550,10 @@ gimp_tool_preset_set_options (GimpToolPreset *preset, ! (serialize_props & GIMP_CONTEXT_PROP_MASK_BACKGROUND)) g_object_set (preset, "use-fg-bg", FALSE, NULL); + if (! (serialize_props & GIMP_CONTEXT_PROP_MASK_OPACITY) && + ! (serialize_props & GIMP_CONTEXT_PROP_MASK_PAINT_MODE)) + g_object_set (preset, "use-opacity-paint-mode", FALSE, NULL); + if (! (serialize_props & GIMP_CONTEXT_PROP_MASK_BRUSH)) g_object_set (preset, "use-brush", FALSE, NULL); @@ -655,6 +674,12 @@ gimp_tool_preset_get_prop_mask (GimpToolPreset *preset) use_props |= (GIMP_CONTEXT_PROP_MASK_BACKGROUND & serialize_props); } + if (preset->use_opacity_paint_mode) + { + use_props |= (GIMP_CONTEXT_PROP_MASK_OPACITY & serialize_props); + use_props |= (GIMP_CONTEXT_PROP_MASK_PAINT_MODE & serialize_props); + } + if (preset->use_brush) use_props |= (GIMP_CONTEXT_PROP_MASK_BRUSH & serialize_props); diff --git a/app/core/gimptoolpreset.h b/app/core/gimptoolpreset.h index 757e44abbf..bf2cceb6ca 100644 --- a/app/core/gimptoolpreset.h +++ b/app/core/gimptoolpreset.h @@ -40,6 +40,7 @@ struct _GimpToolPreset GimpToolOptions *tool_options; gboolean use_fg_bg; + gboolean use_opacity_paint_mode; gboolean use_brush; gboolean use_dynamics; gboolean use_mybrush; diff --git a/app/widgets/gimptoolpreseteditor.c b/app/widgets/gimptoolpreseteditor.c index 6f84a63cea..e0d0d0be0b 100644 --- a/app/widgets/gimptoolpreseteditor.c +++ b/app/widgets/gimptoolpreseteditor.c @@ -46,6 +46,7 @@ struct _GimpToolPresetEditorPrivate GtkWidget *tool_label; GtkWidget *fg_bg_toggle; + GtkWidget *opacity_paint_mode_toggle; GtkWidget *brush_toggle; GtkWidget *dynamics_toggle; GtkWidget *mybrush_toggle; @@ -157,6 +158,10 @@ gimp_tool_preset_editor_constructed (GObject *object) gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); gtk_widget_show (button); + button = editor->priv->opacity_paint_mode_toggle = + gimp_prop_check_button_new (G_OBJECT (preset), "use-opacity-paint-mode", NULL); + gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); + button = editor->priv->brush_toggle = gimp_prop_check_button_new (G_OBJECT (preset), "use-brush", NULL); gtk_box_pack_start (GTK_BOX (data_editor), button, FALSE, FALSE, 0); @@ -309,6 +314,10 @@ gimp_tool_preset_editor_sync_data (GimpToolPresetEditor *editor) (serialize_props & (GIMP_CONTEXT_PROP_MASK_FOREGROUND | GIMP_CONTEXT_PROP_MASK_BACKGROUND)) != 0); + gtk_widget_set_sensitive (priv->opacity_paint_mode_toggle, + (serialize_props & + (GIMP_CONTEXT_PROP_MASK_OPACITY | + GIMP_CONTEXT_PROP_MASK_PAINT_MODE)) != 0); gtk_widget_set_sensitive (priv->brush_toggle, (serialize_props & GIMP_CONTEXT_PROP_MASK_BRUSH) != 0);