From 73096b9a041f74223c2994df061a3fb2574c199f Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 18 May 2020 00:49:21 +0200 Subject: [PATCH] app: make the text tool multi-layer aware. Multi-drawable selection for text tool only matters for positionning the newly created text layer, if relevant. If a single layer is selected, it will be same as before. With multiple selection, the new layer just ends up to the top in case of layers from different containers. --- app/tools/gimptexttool.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c index 6570d8eb9e..eb557221e3 100644 --- a/app/tools/gimptexttool.c +++ b/app/tools/gimptexttool.c @@ -507,13 +507,25 @@ gimp_text_tool_button_press (GimpTool *tool, if (gimp_image_coords_in_active_pickable (image, coords, FALSE, FALSE, FALSE)) { - GimpDrawable *drawable = gimp_image_get_active_drawable (image); - GimpItem *item = GIMP_ITEM (drawable); - gdouble x = coords->x - gimp_item_get_offset_x (item); - gdouble y = coords->y - gimp_item_get_offset_y (item); + GList *drawables = gimp_image_get_selected_drawables (image); + GimpDrawable *drawable = NULL; + gdouble x = coords->x; + gdouble y = coords->y; + + if (g_list_length (drawables) == 1) + { + GimpItem *item = GIMP_ITEM (drawables->data); + + x = coords->x - gimp_item_get_offset_x (item); + y = coords->y - gimp_item_get_offset_y (item); + + drawable = drawables->data; + } + g_list_free (drawables); /* did the user click on a text layer? */ - if (gimp_text_tool_set_drawable (text_tool, drawable, TRUE)) + if (drawable && + gimp_text_tool_set_drawable (text_tool, drawable, TRUE)) { if (press_type == GIMP_BUTTON_PRESS_NORMAL) {