mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
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
b4b727f6e4
commit
dab374b2bc
5 changed files with 45 additions and 1 deletions
|
@ -89,7 +89,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[] =
|
||||
|
@ -166,6 +171,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);
|
||||
|
||||
|
@ -197,6 +203,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++)
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
@ -206,6 +209,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 */
|
||||
|
||||
|
|
|
@ -46,6 +46,10 @@ 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);
|
||||
|
||||
|
||||
#endif /* __TEXT_TOOL_COMMANDS_H__ */
|
||||
|
|
|
@ -298,6 +298,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,
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
<item><attribute name="action">text-tool.text-tool-copy</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-paste</attribute></item>
|
||||
<item><attribute name="action">text-tool.text-tool-delete</attribute></item>
|
||||
<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-clear</attribute></item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue