From 875af9c5cd69fbd75d6602d6ac35b5d768bc6a12 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Sat, 13 May 2006 19:48:18 +0000 Subject: [PATCH] Added some new text layer actions and menu items (bug #316299). 2006-05-13 Michael Natterer Added some new text layer actions and menu items (bug #316299). * app/actions/layers-actions.c: added actions for "Text to Path", "Text along Path" and "Text to Selection" (use the alpha to selection callback for text to selection) * app/actions/layers-commands.[ch]: added layers_text_to_vectors_cmd_callback() and layers_text_along_vectors_cmd_callback(). * app/widgets/gimphelp-ids.h: help IDs for the new actions. * menus/image-menu.xml.in * menus/layers-menu.xml: added them to the layers menus in the image window and the layers dialog. --- ChangeLog | 18 ++++++++ app/actions/layers-actions.c | 78 +++++++++++++++++++++++++++++------ app/actions/layers-commands.c | 56 +++++++++++++++++++++++++ app/actions/layers-commands.h | 4 ++ app/widgets/gimphelp-ids.h | 6 +++ menus/image-menu.xml.in | 11 +++++ menus/layers-menu.xml | 4 ++ 7 files changed, 164 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 051b724042..cb2e54a25a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2006-05-13 Michael Natterer + + Added some new text layer actions and menu items (bug #316299). + + * app/actions/layers-actions.c: added actions for "Text to Path", + "Text along Path" and "Text to Selection" (use the alpha to + selection callback for text to selection) + + * app/actions/layers-commands.[ch]: added + layers_text_to_vectors_cmd_callback() and + layers_text_along_vectors_cmd_callback(). + + * app/widgets/gimphelp-ids.h: help IDs for the new actions. + + * menus/image-menu.xml.in + * menus/layers-menu.xml: added them to the layers menus in the + image window and the layers dialog. + 2006-05-13 Hans Breuer * **/makefile.msc app/gimpcore.def : updated diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c index cd436a4903..37f6a66d92 100644 --- a/app/actions/layers-actions.c +++ b/app/actions/layers-actions.c @@ -48,14 +48,15 @@ static const GimpActionEntry layers_actions[] = N_("Layers Menu"), NULL, NULL, NULL, GIMP_HELP_LAYER_DIALOG }, - { "layers-menu", NULL, N_("_Layer") }, - { "layers-stack-menu", NULL, N_("Stac_k") }, - { "layers-mask-menu", NULL, N_("_Mask") }, - { "layers-transparency-menu", NULL, N_("Tr_ansparency") }, - { "layers-transform-menu", NULL, N_("_Transform") }, - { "layers-properties-menu", GTK_STOCK_PROPERTIES, N_("_Properties") }, - { "layers-opacity-menu", GIMP_STOCK_TRANSPARENCY, N_("_Opacity") }, - { "layers-mode-menu", GIMP_STOCK_TOOL_PENCIL, N_("Layer _Mode") }, + { "layers-menu", NULL, N_("_Layer") }, + { "layers-stack-menu", NULL, N_("Stac_k") }, + { "layers-text-to-selection-menu", GIMP_STOCK_TOOL_TEXT, N_("Te_xt to Selection") }, + { "layers-mask-menu", NULL, N_("_Mask") }, + { "layers-transparency-menu", NULL, N_("Tr_ansparency") }, + { "layers-transform-menu", NULL, N_("_Transform") }, + { "layers-properties-menu", GTK_STOCK_PROPERTIES, N_("_Properties") }, + { "layers-opacity-menu", GIMP_STOCK_TRANSPARENCY, N_("_Opacity") }, + { "layers-mode-menu", GIMP_STOCK_TOOL_PENCIL, N_("Layer _Mode") }, { "layers-text-tool", GIMP_STOCK_TOOL_TEXT, N_("Te_xt Tool"), NULL, @@ -147,6 +148,18 @@ static const GimpActionEntry layers_actions[] = G_CALLBACK (layers_text_discard_cmd_callback), GIMP_HELP_LAYER_TEXT_DISCARD }, + { "layers-text-to-vectors", GIMP_STOCK_TOOL_TEXT, + N_("Text to _Path"), NULL, + N_("Create a path from this text layer"), + G_CALLBACK (layers_text_to_vectors_cmd_callback), + GIMP_HELP_LAYER_TEXT_TO_PATH }, + + { "layers-text-along-vectors", GIMP_STOCK_TOOL_TEXT, + N_("Text alon_g Path"), NULL, + N_("Warp this layer's text along the current path"), + G_CALLBACK (layers_text_along_vectors_cmd_callback), + GIMP_HELP_LAYER_TEXT_ALONG_PATH }, + { "layers-resize", GIMP_STOCK_RESIZE, N_("Layer B_oundary Size..."), NULL, N_("Adjust the layer dimensions"), @@ -289,6 +302,33 @@ static const GimpEnumActionEntry layers_alpha_to_selection_actions[] = GIMP_HELP_LAYER_ALPHA_SELECTION_INTERSECT } }; +static const GimpEnumActionEntry layers_text_to_selection_actions[] = +{ + { "layers-text-selection-replace", GIMP_STOCK_SELECTION_REPLACE, + N_("_Text to Selection"), NULL, + N_("Replace the selection with the text layer's outline"), + GIMP_CHANNEL_OP_REPLACE, FALSE, + GIMP_HELP_LAYER_TEXT_SELECTION_REPLACE }, + + { "layers-text-selection-add", GIMP_STOCK_SELECTION_ADD, + N_("A_dd to Selection"), NULL, + N_("Add the text layer's outline to the current selection"), + GIMP_CHANNEL_OP_ADD, FALSE, + GIMP_HELP_LAYER_TEXT_SELECTION_ADD }, + + { "layers-text-selection-subtract", GIMP_STOCK_SELECTION_SUBTRACT, + N_("_Subtract from Selection"), NULL, + N_("Subtract the text layer's outline from the current selection"), + GIMP_CHANNEL_OP_SUBTRACT, FALSE, + GIMP_HELP_LAYER_TEXT_SELECTION_SUBTRACT }, + + { "layers-text-selection-intersect", GIMP_STOCK_SELECTION_INTERSECT, + N_("_Intersect with Selection"), NULL, + N_("Intersect the text layer's outline with the current selection"), + GIMP_CHANNEL_OP_INTERSECT, FALSE, + GIMP_HELP_LAYER_TEXT_SELECTION_INTERSECT } +}; + static const GimpEnumActionEntry layers_select_actions[] = { { "layers-select-top", NULL, @@ -391,6 +431,11 @@ layers_actions_setup (GimpActionGroup *group) G_N_ELEMENTS (layers_alpha_to_selection_actions), G_CALLBACK (layers_alpha_to_selection_cmd_callback)); + gimp_action_group_add_enum_actions (group, + layers_text_to_selection_actions, + G_N_ELEMENTS (layers_alpha_to_selection_actions), + G_CALLBACK (layers_alpha_to_selection_cmd_callback)); + gimp_action_group_add_enum_actions (group, layers_select_actions, G_N_ELEMENTS (layers_select_actions), @@ -479,11 +524,18 @@ layers_actions_update (GimpActionGroup *group, SET_SENSITIVE ("layers-lower", layer && !fs && !ac && next); SET_SENSITIVE ("layers-lower-to-bottom", layer && !fs && !ac && next); - SET_SENSITIVE ("layers-anchor", layer && fs && !ac); - SET_SENSITIVE ("layers-merge-down", layer && !fs && !ac && next); - SET_SENSITIVE ("layers-merge-layers", layer && !fs && !ac); - SET_SENSITIVE ("layers-flatten-image", layer && !fs && !ac); - SET_VISIBLE ("layers-text-discard", text_layer && !ac); + SET_SENSITIVE ("layers-anchor", layer && fs && !ac); + SET_SENSITIVE ("layers-merge-down", layer && !fs && !ac && next); + SET_SENSITIVE ("layers-merge-layers", layer && !fs && !ac); + SET_SENSITIVE ("layers-flatten-image", layer && !fs && !ac); + + SET_VISIBLE ("layers-text-discard", text_layer && !ac); + SET_VISIBLE ("layers-text-to-vectors", text_layer && !ac); + SET_VISIBLE ("layers-text-along-vectors", text_layer && !ac); + SET_VISIBLE ("layers-text-selection-replace", text_layer && !ac); + SET_VISIBLE ("layers-text-selection-add", text_layer && !ac); + SET_VISIBLE ("layers-text-selection-subtract", text_layer && !ac); + SET_VISIBLE ("layers-text-selection-intersect", text_layer && !ac); SET_SENSITIVE ("layers-resize", layer && !ac); SET_SENSITIVE ("layers-resize-to-image", layer && !ac); diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c index a2ac42a833..6dac1b000f 100644 --- a/app/actions/layers-commands.c +++ b/app/actions/layers-commands.c @@ -47,8 +47,11 @@ #include "core/gimpprogress.h" #include "text/gimptext.h" +#include "text/gimptext-vectors.h" #include "text/gimptextlayer.h" +#include "vectors/gimpvectors-warp.h" + #include "widgets/gimpaction.h" #include "widgets/gimpdock.h" #include "widgets/gimphelp-ids.h" @@ -455,6 +458,59 @@ layers_text_discard_cmd_callback (GtkAction *action, gimp_text_layer_discard (GIMP_TEXT_LAYER (layer)); } +void +layers_text_to_vectors_cmd_callback (GtkAction *action, + gpointer data) +{ + GimpImage *image; + GimpLayer *layer; + return_if_no_layer (image, layer, data); + + if (GIMP_IS_TEXT_LAYER (layer)) + { + GimpVectors *vectors; + gint x, y; + + vectors = gimp_text_vectors_new (image, GIMP_TEXT_LAYER (layer)->text); + + gimp_item_offsets (GIMP_ITEM (layer), &x, &y); + gimp_item_translate (GIMP_ITEM (vectors), x, y, FALSE); + + gimp_image_add_vectors (image, vectors, -1); + gimp_image_set_active_vectors (image, vectors); + + gimp_image_flush (image); + } +} + +void +layers_text_along_vectors_cmd_callback (GtkAction *action, + gpointer data) +{ + GimpImage *image; + GimpLayer *layer; + GimpVectors *vectors; + return_if_no_layer (image, layer, data); + return_if_no_vectors (image, vectors, data); + + if (GIMP_IS_TEXT_LAYER (layer)) + { + GimpVectors *new_vectors; + + new_vectors = gimp_text_vectors_new (image, GIMP_TEXT_LAYER (layer)->text); + + gimp_vectors_warp_vectors (vectors, new_vectors, + 0.5 * gimp_item_height (GIMP_ITEM (layer))); + + gimp_item_set_visible (GIMP_ITEM (new_vectors), TRUE, FALSE); + + gimp_image_add_vectors (image, new_vectors, -1); + gimp_image_set_active_vectors (image, new_vectors); + + gimp_image_flush (image); + } +} + void layers_resize_cmd_callback (GtkAction *action, gpointer data) diff --git a/app/actions/layers-commands.h b/app/actions/layers-commands.h index db2a45727b..1f13f9a8bb 100644 --- a/app/actions/layers-commands.h +++ b/app/actions/layers-commands.h @@ -52,6 +52,10 @@ void layers_delete_cmd_callback (GtkAction *action, gpointer data); void layers_text_discard_cmd_callback (GtkAction *action, gpointer data); +void layers_text_to_vectors_cmd_callback (GtkAction *action, + gpointer data); +void layers_text_along_vectors_cmd_callback (GtkAction *action, + gpointer data); void layers_resize_cmd_callback (GtkAction *action, gpointer data); diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h index 716740d4f1..7c230d1be4 100644 --- a/app/widgets/gimphelp-ids.h +++ b/app/widgets/gimphelp-ids.h @@ -137,6 +137,12 @@ #define GIMP_HELP_LAYER_MERGE_DOWN "gimp-layer-merge-down" #define GIMP_HELP_LAYER_DELETE "gimp-layer-delete" #define GIMP_HELP_LAYER_TEXT_DISCARD "gimp-layer-text-discard" +#define GIMP_HELP_LAYER_TEXT_TO_PATH "gimp-layer-text-to-path" +#define GIMP_HELP_LAYER_TEXT_ALONG_PATH "gimp-layer-text-along-path" +#define GIMP_HELP_LAYER_TEXT_SELECTION_REPLACE "gimp-layer-text-selection-replace" +#define GIMP_HELP_LAYER_TEXT_SELECTION_ADD "gimp-layer-text-selection-add" +#define GIMP_HELP_LAYER_TEXT_SELECTION_SUBTRACT "gimp-layer-text-selection-subtract" +#define GIMP_HELP_LAYER_TEXT_SELECTION_INTERSECT "gimp-layer-text-selection-intersect" #define GIMP_HELP_LAYER_PREVIOUS "gimp-layer-previous" #define GIMP_HELP_LAYER_NEXT "gimp-layer-next" #define GIMP_HELP_LAYER_TOP "gimp-layer-top" diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in index bc67d90b1b..7621345217 100644 --- a/menus/image-menu.xml.in +++ b/menus/image-menu.xml.in @@ -329,7 +329,18 @@ + + + + + + + + + + + diff --git a/menus/layers-menu.xml b/menus/layers-menu.xml index c5f8e486e7..e9a5a4d299 100644 --- a/menus/layers-menu.xml +++ b/menus/layers-menu.xml @@ -17,7 +17,11 @@ + + + +