[gimp] app: Add initial support for configurable editing of non-visible layers (Issue #2713)
- From: Alexandre Prokoudine <aprokoudine src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Add initial support for configurable editing of non-visible layers (Issue #2713)
- Date: Sun, 23 Jun 2019 13:16:21 +0000 (UTC)
commit 39c71c6fb3e12f5f17846b342dcd8c3a1c20e9c0
Author: woob <thetoastcaper gmail com>
Date: Wed Feb 6 15:22:27 2019 -0500
app: Add initial support for configurable editing of non-visible layers (Issue #2713)
Add a "edit-non-visible" configuration option, found under
Edit->Preferences->Tool Options as "Allow editing on non-visible layers"
app/config/gimpguiconfig.c | 14 ++++++++++++++
app/config/gimpguiconfig.h | 1 +
app/config/gimprc-blurbs.h | 3 +++
app/dialogs/preferences-dialog.c | 4 ++++
app/tools/gimpbucketfilltool.c | 8 ++++++--
app/tools/gimpcagetool.c | 13 +++++++++----
app/tools/gimpfiltertool.c | 3 ++-
app/tools/gimpforegroundselecttool.c | 5 ++++-
app/tools/gimpgradienttool.c | 13 +++++++++----
app/tools/gimppainttool.c | 7 +++++--
app/tools/gimptransformtool.c | 4 ++++
app/tools/gimpwarptool.c | 5 ++++-
12 files changed, 65 insertions(+), 15 deletions(-)
---
diff --git a/app/config/gimpguiconfig.c b/app/config/gimpguiconfig.c
index 3848828a45..c88af9fef1 100644
--- a/app/config/gimpguiconfig.c
+++ b/app/config/gimpguiconfig.c
@@ -46,6 +46,7 @@
enum
{
PROP_0,
+ PROP_EDIT_NON_VISIBLE,
PROP_MOVE_TOOL_CHANGES_ACTIVE,
PROP_FILTER_TOOL_MAX_RECENT,
PROP_FILTER_TOOL_USE_LAST_SETTINGS,
@@ -129,6 +130,13 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
object_class->set_property = gimp_gui_config_set_property;
object_class->get_property = gimp_gui_config_get_property;
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_EDIT_NON_VISIBLE,
+ "edit-non-visible",
+ "Non-visible layers can be edited",
+ EDIT_NON_VISIBLE_BLURB,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_MOVE_TOOL_CHANGES_ACTIVE,
"move-tool-changes-active",
"Move tool changes active layer",
@@ -550,6 +558,9 @@ gimp_gui_config_set_property (GObject *object,
switch (property_id)
{
+ case PROP_EDIT_NON_VISIBLE:
+ gui_config->edit_non_visible = g_value_get_boolean (value);
+ break;
case PROP_MOVE_TOOL_CHANGES_ACTIVE:
gui_config->move_tool_changes_active = g_value_get_boolean (value);
break;
@@ -716,6 +727,9 @@ gimp_gui_config_get_property (GObject *object,
switch (property_id)
{
+ case PROP_EDIT_NON_VISIBLE:
+ g_value_set_boolean (value, gui_config->edit_non_visible);
+ break;
case PROP_MOVE_TOOL_CHANGES_ACTIVE:
g_value_set_boolean (value, gui_config->move_tool_changes_active);
break;
diff --git a/app/config/gimpguiconfig.h b/app/config/gimpguiconfig.h
index 5f3e46c044..98bf0698be 100644
--- a/app/config/gimpguiconfig.h
+++ b/app/config/gimpguiconfig.h
@@ -41,6 +41,7 @@ struct _GimpGuiConfig
{
GimpDisplayConfig parent_instance;
+ gboolean edit_non_visible;
gboolean move_tool_changes_active;
gint filter_tool_max_recent;
gboolean filter_tool_use_last_settings;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index f63b27f5db..9b64a19fdb 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -272,6 +272,9 @@ _("Sets the monitor's vertical resolution, in dots per inch. If set to " \
"0, forces the X server to be queried for both horizontal and vertical " \
"resolution information.")
+#define EDIT_NON_VISIBLE_BLURB \
+_("When enabled, non-visible layers can be edited as normal.")
+
#define MOVE_TOOL_CHANGES_ACTIVE_BLURB \
_("If enabled, the move tool sets the edited layer or path as active. " \
"This used to be the default behaviour in older versions.")
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 98514394d6..5f297733ab 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1636,6 +1636,10 @@ prefs_dialog_new (Gimp *gimp,
/* General */
vbox2 = prefs_frame_new (_("General"), GTK_CONTAINER (vbox), FALSE);
+ prefs_check_button_add (object, "edit-non-visible",
+ _("Allow _editing on non-visible layers"),
+ GTK_BOX (vbox2));
+
prefs_check_button_add (object, "save-tool-options",
_("_Save tool options on exit"),
GTK_BOX (vbox2));
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 8248850d14..217794f6da 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -24,6 +24,8 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "core/gimp.h"
#include "core/gimpasync.h"
#include "core/gimpcancelable.h"
@@ -471,6 +473,7 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
{
GimpBucketFillTool *bucket_tool = GIMP_BUCKET_FILL_TOOL (tool);
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
gboolean sample_merged;
@@ -489,7 +492,7 @@ gimp_bucket_fill_tool_button_press (GimpTool *tool,
return;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
gimp_tool_message_literal (tool, display,
_("The active layer is not visible."));
@@ -757,6 +760,7 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
GimpDisplay *display)
{
GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD;
GimpImage *image = gimp_display_get_image (display);
gboolean sample_merged;
@@ -770,7 +774,7 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool,
if (! gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) &&
! gimp_item_is_content_locked (GIMP_ITEM (drawable)) &&
- gimp_item_is_visible (GIMP_ITEM (drawable)))
+ (gimp_item_is_visible (GIMP_ITEM (drawable)) || config->edit_non_visible))
{
switch (options->fill_mode)
{
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index 854490a55c..ffd2a120cc 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -30,10 +30,13 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "gegl/gimp-gegl-utils.h"
#include "operations/gimpcageconfig.h"
+#include "core/gimp.h"
#include "core/gimpdrawablefilter.h"
#include "core/gimperror.h"
#include "core/gimpimage.h"
@@ -211,8 +214,9 @@ gimp_cage_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (! drawable)
return FALSE;
@@ -233,7 +237,7 @@ gimp_cage_tool_initialize (GimpTool *tool,
return FALSE;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer is not visible."));
@@ -666,6 +670,7 @@ gimp_cage_tool_cursor_update (GimpTool *tool,
{
GimpCageTool *ct = GIMP_CAGE_TOOL (tool);
GimpCageOptions *options = GIMP_CAGE_TOOL_GET_OPTIONS (ct);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_PLUS;
if (tool->display)
@@ -692,7 +697,7 @@ gimp_cage_tool_cursor_update (GimpTool *tool,
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
- ! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ ! (gimp_item_is_visible (GIMP_ITEM (drawable)) || config->edit_non_visible))
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
}
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 38eb45f0a2..471794a5f1 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -263,6 +263,7 @@ gimp_filter_tool_initialize (GimpTool *tool,
{
GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
GimpToolInfo *tool_info = tool->tool_info;
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpDisplayShell *shell = gimp_display_get_shell (display);
@@ -286,7 +287,7 @@ gimp_filter_tool_initialize (GimpTool *tool,
return FALSE;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer is not visible."));
diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c
index 6ee56c3d32..2e769bdb7c 100644
--- a/app/tools/gimpforegroundselecttool.c
+++ b/app/tools/gimpforegroundselecttool.c
@@ -33,6 +33,8 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "gegl/gimp-gegl-loops.h"
#include "gegl/gimp-gegl-mask.h"
@@ -277,6 +279,7 @@ gimp_foreground_select_tool_initialize (GimpTool *tool,
GError **error)
{
GimpForegroundSelectTool *fg_select = GIMP_FOREGROUND_SELECT_TOOL (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpDisplayShell *shell = gimp_display_get_shell (display);
@@ -284,7 +287,7 @@ gimp_foreground_select_tool_initialize (GimpTool *tool,
if (! drawable)
return FALSE;
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer is not visible."));
diff --git a/app/tools/gimpgradienttool.c b/app/tools/gimpgradienttool.c
index cbc7cc5c95..b3567b394d 100644
--- a/app/tools/gimpgradienttool.c
+++ b/app/tools/gimpgradienttool.c
@@ -28,10 +28,13 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "operations/gimp-operation-config.h"
#include "operations/layer-modes/gimp-layer-modes.h"
+#include "core/gimp.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-gradient.h"
#include "core/gimpdrawablefilter.h"
@@ -236,6 +239,7 @@ gimp_gradient_tool_initialize (GimpTool *tool,
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpGradientOptions *options = GIMP_GRADIENT_TOOL_GET_OPTIONS (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
@@ -258,7 +262,7 @@ gimp_gradient_tool_initialize (GimpTool *tool,
return FALSE;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer is not visible."));
@@ -443,12 +447,13 @@ gimp_gradient_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
- ! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ ! (gimp_item_is_visible (GIMP_ITEM (drawable)) || config->edit_non_visible))
{
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index f9ee67332a..e529e566cf 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -26,6 +26,7 @@
#include "tools-types.h"
#include "config/gimpdisplayconfig.h"
+#include "config/gimpguiconfig.h"
#include "core/gimp.h"
#include "core/gimp-utils.h"
@@ -261,6 +262,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpDisplayShell *shell = gimp_display_get_shell (display);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
@@ -308,7 +310,7 @@ gimp_paint_tool_button_press (GimpTool *tool,
return;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
gimp_tool_message_literal (tool, display,
_("The active layer is not visible."));
@@ -473,6 +475,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
GimpDisplay *display)
{
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpCursorModifier modifier;
GimpCursorModifier toggle_modifier;
GimpCursorModifier old_modifier;
@@ -492,7 +495,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
! gimp_paint_tool_check_alpha (paint_tool, drawable, display, NULL) ||
- ! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ ! (gimp_item_is_visible (GIMP_ITEM (drawable)) || config->edit_non_visible))
{
modifier = GIMP_CURSOR_MODIFIER_BAD;
toggle_modifier = GIMP_CURSOR_MODIFIER_BAD;
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index f3b1e2e13d..8d9785c25d 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -25,6 +25,8 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "core/gimp.h"
#include "core/gimpdrawable-transform.h"
#include "core/gimperror.h"
@@ -520,6 +522,7 @@ gimp_transform_tool_check_active_item (GimpTransformTool *tr_tool,
GimpItem *item;
const gchar *null_message = NULL;
const gchar *locked_message = NULL;
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
g_return_val_if_fail (GIMP_IS_TRANSFORM_TOOL (tr_tool), NULL);
g_return_val_if_fail (GIMP_IS_DISPLAY (display), NULL);
@@ -542,6 +545,7 @@ gimp_transform_tool_check_active_item (GimpTransformTool *tr_tool,
locked_message = _("The active layer's position and size are locked.");
if (! gimp_item_is_visible (item) &&
+ ! config->edit_non_visible &&
item != tr_tool->item) /* see bug #759194 */
{
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index adc9a8994b..64412ec07b 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -29,6 +29,8 @@
#include "tools-types.h"
+#include "config/gimpguiconfig.h"
+
#include "gegl/gimp-gegl-apply-operation.h"
#include "core/gimp.h"
@@ -658,6 +660,7 @@ gimp_warp_tool_can_stroke (GimpWarpTool *wt,
{
GimpTool *tool = GIMP_TOOL (wt);
GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt);
+ GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
@@ -685,7 +688,7 @@ gimp_warp_tool_can_stroke (GimpWarpTool *wt,
return FALSE;
}
- if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
+ if (! gimp_item_is_visible (GIMP_ITEM (drawable)) && ! config->edit_non_visible)
{
if (show_message)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]