diff --git a/app/actions/text-tool-actions.c b/app/actions/text-tool-actions.c
index 6203c37e6a..c6e4b61d33 100644
--- a/app/actions/text-tool-actions.c
+++ b/app/actions/text-tool-actions.c
@@ -110,7 +110,12 @@ static const GimpActionEntry text_tool_actions[] =
NC_("text-tool-action",
"Bend the text along the currently active path"),
text_tool_text_along_path_cmd_callback,
- GIMP_HELP_TEXT_TOOL_TEXT_ALONG_PATH }
+ GIMP_HELP_TEXT_TOOL_TEXT_ALONG_PATH },
+
+ { "text-tool-restore-on-canvas-editor-position", NULL,
+ NC_("text-tool-action", "Restore On-Canvas Editor Position"), NULL, { NULL }, NULL,
+ text_tool_restore_on_canvas_editor_position_cmd_callback,
+ NULL }
};
static const GimpRadioActionEntry text_tool_direction_actions[] =
@@ -187,6 +192,7 @@ text_tool_actions_update (GimpActionGroup *group,
gboolean clip = FALSE; /* clipboard has text available */
GimpTextDirection direction;
gint i;
+ gdouble x, y;
layers = gimp_image_get_selected_layers (image);
@@ -222,6 +228,9 @@ text_tool_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("text-tool-load", image);
SET_SENSITIVE ("text-tool-text-to-path", text_layer);
SET_SENSITIVE ("text-tool-text-along-path", text_layer && g_list_length (paths) == 1);
+ SET_SENSITIVE ("text-tool-restore-on-canvas-editor-position",
+ text_layer &&
+ gimp_text_layer_get_style_overlay_position (text_tool->layer, &x, &y));
direction = gimp_text_tool_get_direction (text_tool);
for (i = 0; i < G_N_ELEMENTS (text_tool_direction_actions); i++)
diff --git a/app/actions/text-tool-commands.c b/app/actions/text-tool-commands.c
index 559ff0ce97..daa20d29c2 100644
--- a/app/actions/text-tool-commands.c
+++ b/app/actions/text-tool-commands.c
@@ -36,7 +36,10 @@
#include "display/gimpdisplay.h"
+#include "text/gimptextlayer.h"
+
#include "tools/gimptexttool.h"
+#include "tools/gimptexttool-editor.h"
#include "dialogs/dialogs.h"
@@ -246,6 +249,20 @@ text_tool_direction_cmd_callback (GimpAction *action,
NULL);
}
+void
+text_tool_restore_on_canvas_editor_position_cmd_callback (GimpAction *action,
+ GVariant *value,
+ gpointer data)
+{
+ GimpTextTool *text_tool = GIMP_TEXT_TOOL (data);
+
+ if (text_tool->layer)
+ gimp_text_layer_set_style_overlay_position (text_tool->layer, FALSE, 0, 0);
+
+ gimp_text_tool_editor_position (text_tool);
+}
+
+
/* private functions */
diff --git a/app/actions/text-tool-commands.h b/app/actions/text-tool-commands.h
index ef14b68b32..7a96871767 100644
--- a/app/actions/text-tool-commands.h
+++ b/app/actions/text-tool-commands.h
@@ -59,3 +59,7 @@ void text_tool_text_along_path_cmd_callback (GimpAction *action,
void text_tool_direction_cmd_callback (GimpAction *action,
GVariant *value,
gpointer data);
+void text_tool_restore_on_canvas_editor_position_cmd_callback
+ (GimpAction *action,
+ GVariant *value,
+ gpointer data);
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index acceac0ec5..060e957311 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -296,6 +296,17 @@ gimp_text_tool_editor_position (GimpTextTool *text_tool)
}
else
{
+ GimpOverlayChild *child_overlay;
+
+ /*
+ * Set 'relative_to_shell' to FALSE to allow the overlay to be positioned
+ * independently from the shell. This enables the overlay to be moved freely
+ * and later restored to its original position on screen.
+ */
+ child_overlay = gimp_overlay_child_find (GIMP_OVERLAY_BOX (shell->canvas),
+ text_tool->style_overlay);
+ gimp_overlay_child_set_relative_to_shell (child_overlay, FALSE);
+
gimp_display_shell_move_overlay (shell,
text_tool->style_overlay,
x, y, GIMP_HANDLE_ANCHOR_SOUTH_WEST,
diff --git a/menus/text-tool-menu.ui b/menus/text-tool-menu.ui
index e35313e6d8..a8be332fcd 100644
--- a/menus/text-tool-menu.ui
+++ b/menus/text-tool-menu.ui
@@ -15,6 +15,7 @@
- text-tool.text-tool-toggle-italic
- text-tool.text-tool-toggle-underline
+ - text-tool.text-tool-restore-on-canvas-editor-position
- text-tool.text-tool-load
- text-tool.text-tool-clear