tools: implement restore option for on-canvas text editor ...
... to reset its position via right-click menu This commit adds the ability to restore the original position of the on-canvas text editor after it has been moved, by accessing the option from the context menu opened with a right-click on the text box.
This commit is contained in:
parent
83497695fd
commit
a193d45ab8
5 changed files with 43 additions and 1 deletions
|
|
@ -110,7 +110,12 @@ static const GimpActionEntry text_tool_actions[] =
|
||||||
NC_("text-tool-action",
|
NC_("text-tool-action",
|
||||||
"Bend the text along the currently active path"),
|
"Bend the text along the currently active path"),
|
||||||
text_tool_text_along_path_cmd_callback,
|
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[] =
|
static const GimpRadioActionEntry text_tool_direction_actions[] =
|
||||||
|
|
@ -187,6 +192,7 @@ text_tool_actions_update (GimpActionGroup *group,
|
||||||
gboolean clip = FALSE; /* clipboard has text available */
|
gboolean clip = FALSE; /* clipboard has text available */
|
||||||
GimpTextDirection direction;
|
GimpTextDirection direction;
|
||||||
gint i;
|
gint i;
|
||||||
|
gdouble x, y;
|
||||||
|
|
||||||
layers = gimp_image_get_selected_layers (image);
|
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-load", image);
|
||||||
SET_SENSITIVE ("text-tool-text-to-path", text_layer);
|
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-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);
|
direction = gimp_text_tool_get_direction (text_tool);
|
||||||
for (i = 0; i < G_N_ELEMENTS (text_tool_direction_actions); i++)
|
for (i = 0; i < G_N_ELEMENTS (text_tool_direction_actions); i++)
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,10 @@
|
||||||
|
|
||||||
#include "display/gimpdisplay.h"
|
#include "display/gimpdisplay.h"
|
||||||
|
|
||||||
|
#include "text/gimptextlayer.h"
|
||||||
|
|
||||||
#include "tools/gimptexttool.h"
|
#include "tools/gimptexttool.h"
|
||||||
|
#include "tools/gimptexttool-editor.h"
|
||||||
|
|
||||||
#include "dialogs/dialogs.h"
|
#include "dialogs/dialogs.h"
|
||||||
|
|
||||||
|
|
@ -246,6 +249,20 @@ text_tool_direction_cmd_callback (GimpAction *action,
|
||||||
NULL);
|
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 */
|
/* private functions */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,3 +59,7 @@ void text_tool_text_along_path_cmd_callback (GimpAction *action,
|
||||||
void text_tool_direction_cmd_callback (GimpAction *action,
|
void text_tool_direction_cmd_callback (GimpAction *action,
|
||||||
GVariant *value,
|
GVariant *value,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
void text_tool_restore_on_canvas_editor_position_cmd_callback
|
||||||
|
(GimpAction *action,
|
||||||
|
GVariant *value,
|
||||||
|
gpointer data);
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,17 @@ gimp_text_tool_editor_position (GimpTextTool *text_tool)
|
||||||
}
|
}
|
||||||
else
|
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,
|
gimp_display_shell_move_overlay (shell,
|
||||||
text_tool->style_overlay,
|
text_tool->style_overlay,
|
||||||
x, y, GIMP_HANDLE_ANCHOR_SOUTH_WEST,
|
x, y, GIMP_HANDLE_ANCHOR_SOUTH_WEST,
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
<item><attribute name="action">text-tool.text-tool-toggle-italic</attribute></item>
|
<item><attribute name="action">text-tool.text-tool-toggle-italic</attribute></item>
|
||||||
<item><attribute name="action">text-tool.text-tool-toggle-underline</attribute></item>
|
<item><attribute name="action">text-tool.text-tool-toggle-underline</attribute></item>
|
||||||
</section>
|
</section>
|
||||||
|
<item><attribute name="action">text-tool.text-tool-restore-on-canvas-editor-position</attribute></item>
|
||||||
<section>
|
<section>
|
||||||
<item><attribute name="action">text-tool.text-tool-load</attribute></item>
|
<item><attribute name="action">text-tool.text-tool-load</attribute></item>
|
||||||
<item><attribute name="action">text-tool.text-tool-clear</attribute></item>
|
<item><attribute name="action">text-tool.text-tool-clear</attribute></item>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue