app: fix use of Clone tool with "sample merged" across images

In GimpSourceCore, when "sample merged" is enabled, derive the
source pickable from the source drawable's image according to the
paint-core's show-all flag manually, instead of using
gimp_paint_core_get_image_pickable(), which uses the destination
image, and would therefore only work when the source and
destination images are the same.

In GimpSourceTool, override GimpPaintTool::paint_prepare() to set
the paint-core's show-all flag according to the source display,
rather than the destination display.
This commit is contained in:
Ell 2019-10-02 17:08:45 +03:00
parent ffd6c2eda2
commit aa02f1f35c
2 changed files with 48 additions and 13 deletions

View File

@ -408,9 +408,18 @@ gimp_source_core_motion (GimpSourceCore *source_core,
if (options->sample_merged)
{
gint off_x, off_y;
GimpImage *src_image = gimp_pickable_get_image (src_pickable);
gint off_x, off_y;
src_pickable = gimp_paint_core_get_image_pickable (paint_core);
if (! gimp_paint_core_get_show_all (paint_core))
{
src_pickable = GIMP_PICKABLE (src_image);
}
else
{
src_pickable = GIMP_PICKABLE (
gimp_image_get_projection (src_image));
}
gimp_item_get_offset (GIMP_ITEM (source_core->src_drawable),
&off_x, &off_y);

View File

@ -35,6 +35,7 @@
#include "display/gimpcanvashandle.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
#include "display/gimpdisplayshell-items.h"
#include "gimpsourcetool.h"
@ -78,6 +79,9 @@ static void gimp_source_tool_oper_update (GimpTool *tool,
static void gimp_source_tool_draw (GimpDrawTool *draw_tool);
static void gimp_source_tool_paint_prepare (GimpPaintTool *paint_tool,
GimpDisplay *display);
static void gimp_source_tool_set_src_display (GimpSourceTool *source_tool,
GimpDisplay *display);
@ -90,19 +94,22 @@ G_DEFINE_TYPE (GimpSourceTool, gimp_source_tool, GIMP_TYPE_BRUSH_TOOL)
static void
gimp_source_tool_class_init (GimpSourceToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
GimpPaintToolClass *paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
tool_class->has_display = gimp_source_tool_has_display;
tool_class->has_image = gimp_source_tool_has_image;
tool_class->control = gimp_source_tool_control;
tool_class->button_press = gimp_source_tool_button_press;
tool_class->motion = gimp_source_tool_motion;
tool_class->modifier_key = gimp_source_tool_modifier_key;
tool_class->oper_update = gimp_source_tool_oper_update;
tool_class->cursor_update = gimp_source_tool_cursor_update;
tool_class->has_display = gimp_source_tool_has_display;
tool_class->has_image = gimp_source_tool_has_image;
tool_class->control = gimp_source_tool_control;
tool_class->button_press = gimp_source_tool_button_press;
tool_class->motion = gimp_source_tool_motion;
tool_class->modifier_key = gimp_source_tool_modifier_key;
tool_class->oper_update = gimp_source_tool_oper_update;
tool_class->cursor_update = gimp_source_tool_cursor_update;
draw_tool_class->draw = gimp_source_tool_draw;
draw_tool_class->draw = gimp_source_tool_draw;
paint_tool_class->paint_prepare = gimp_source_tool_paint_prepare;
}
static void
@ -461,6 +468,25 @@ gimp_source_tool_draw (GimpDrawTool *draw_tool)
}
}
static void
gimp_source_tool_paint_prepare (GimpPaintTool *paint_tool,
GimpDisplay *display)
{
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (paint_tool);
if (GIMP_PAINT_TOOL_CLASS (parent_class)->paint_prepare)
GIMP_PAINT_TOOL_CLASS (parent_class)->paint_prepare (paint_tool, display);
if (source_tool->src_display)
{
GimpDisplayShell *src_shell;
src_shell = gimp_display_get_shell (source_tool->src_display);
gimp_paint_core_set_show_all (paint_tool->core, src_shell->show_all);
}
}
static void
gimp_source_tool_set_src_display (GimpSourceTool *source_tool,
GimpDisplay *display)