2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2000-01-14 04:41:00 -08:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
2017-04-03 08:37:58 -07:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools-types.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2003-09-03 08:13:19 -07:00
|
|
|
#include "core/gimpchannel.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
2005-07-11 12:21:52 -07:00
|
|
|
#include "core/gimppickable.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
#include "paint/gimpsourcecore.h"
|
|
|
|
|
#include "paint/gimpsourceoptions.h"
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2004-10-12 05:06:50 -07:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-19 11:17:31 -08:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
#include "display/gimpcanvashandle.h"
|
2003-08-21 18:42:57 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
2011-05-04 14:25:55 -07:00
|
|
|
#include "display/gimpdisplayshell-items.h"
|
2003-08-21 18:42:57 -07:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
#include "gimpsourcetool.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 16:23:52 -07:00
|
|
|
|
2000-12-29 07:22:01 -08:00
|
|
|
|
2009-06-20 08:37:31 -07:00
|
|
|
static gboolean gimp_source_tool_has_display (GimpTool *tool,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static GimpDisplay * gimp_source_tool_has_image (GimpTool *tool,
|
|
|
|
|
GimpImage *image);
|
|
|
|
|
static void gimp_source_tool_control (GimpTool *tool,
|
|
|
|
|
GimpToolAction action,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_source_tool_button_press (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_source_tool_motion (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_source_tool_cursor_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_source_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_source_tool_oper_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
|
|
static void gimp_source_tool_draw (GimpDrawTool *draw_tool);
|
2006-09-03 16:11:35 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
static void gimp_source_tool_set_src_display (GimpSourceTool *source_tool,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpSourceTool, gimp_source_tool, GIMP_TYPE_BRUSH_TOOL)
|
|
|
|
|
|
|
|
|
|
#define parent_class gimp_source_tool_parent_class
|
|
|
|
|
|
1999-04-08 15:25:54 -07:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_class_init (GimpSourceToolClass *klass)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2004-05-28 02:34:13 -07:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
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;
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
draw_tool_class->draw = gimp_source_tool_draw;
|
2001-04-19 06:01:44 -07:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_init (GimpSourceTool *source)
|
2001-04-19 06:01:44 -07:00
|
|
|
{
|
2007-10-22 03:24:41 -07:00
|
|
|
source->show_source_outline = TRUE;
|
2003-08-30 09:41:35 -07:00
|
|
|
}
|
|
|
|
|
|
2006-06-18 12:58:49 -07:00
|
|
|
static gboolean
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_has_display (GimpTool *tool,
|
|
|
|
|
GimpDisplay *display)
|
2006-06-18 12:58:49 -07:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
2006-06-18 12:58:49 -07:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
return (display == source_tool->src_display ||
|
2006-06-18 12:58:49 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->has_display (tool, display));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GimpDisplay *
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_has_image (GimpTool *tool,
|
|
|
|
|
GimpImage *image)
|
2006-06-18 12:58:49 -07:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
|
|
|
|
GimpDisplay *display;
|
2006-06-18 12:58:49 -07:00
|
|
|
|
|
|
|
|
display = GIMP_TOOL_CLASS (parent_class)->has_image (tool, image);
|
|
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
if (! display && source_tool->src_display)
|
2006-06-18 12:58:49 -07:00
|
|
|
{
|
2009-10-06 10:20:44 -07:00
|
|
|
if (image && gimp_display_get_image (source_tool->src_display) == image)
|
2006-09-03 16:11:35 -07:00
|
|
|
display = source_tool->src_display;
|
2006-06-18 12:58:49 -07:00
|
|
|
|
|
|
|
|
/* NULL image means any display */
|
|
|
|
|
if (! image)
|
2006-09-03 16:11:35 -07:00
|
|
|
display = source_tool->src_display;
|
2006-06-18 12:58:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return display;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_control (GimpTool *tool,
|
|
|
|
|
GimpToolAction action,
|
|
|
|
|
GimpDisplay *display)
|
2006-06-18 12:58:49 -07:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
2006-06-18 12:58:49 -07:00
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
|
{
|
|
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2011-05-04 14:25:55 -07:00
|
|
|
gimp_source_tool_set_src_display (source_tool, NULL);
|
2006-06-18 12:58:49 -07:00
|
|
|
g_object_set (GIMP_PAINT_TOOL (tool)->core,
|
|
|
|
|
"src-drawable", NULL,
|
|
|
|
|
NULL);
|
|
|
|
|
break;
|
2014-04-04 13:34:26 -07:00
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
|
break;
|
2006-06-18 12:58:49 -07:00
|
|
|
}
|
2011-04-03 23:19:12 -07:00
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2006-06-18 12:58:49 -07:00
|
|
|
}
|
|
|
|
|
|
1999-02-05 01:55:44 -08:00
|
|
|
static void
|
2009-06-20 08:37:31 -07:00
|
|
|
gimp_source_tool_button_press (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
|
GimpDisplay *display)
|
1999-02-05 01:55:44 -08:00
|
|
|
{
|
2006-09-19 16:14:50 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
|
|
|
|
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
|
2015-10-17 06:31:08 -07:00
|
|
|
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
2011-10-06 12:59:07 -07:00
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
2005-08-28 12:17:44 -07:00
|
|
|
|
2006-05-22 11:35:58 -07:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
if ((state & (toggle_mask | extend_mask)) == toggle_mask)
|
2005-02-16 11:12:08 -08:00
|
|
|
{
|
2006-09-02 15:39:26 -07:00
|
|
|
source->set_source = TRUE;
|
2005-02-16 11:12:08 -08:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
gimp_source_tool_set_src_display (source_tool, display);
|
2005-02-16 11:12:08 -08:00
|
|
|
}
|
2002-02-14 11:31:16 -08:00
|
|
|
else
|
2005-04-04 14:03:21 -07:00
|
|
|
{
|
2006-09-02 15:39:26 -07:00
|
|
|
source->set_source = FALSE;
|
2005-04-04 14:03:21 -07:00
|
|
|
}
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2003-08-30 09:41:35 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
|
2009-06-20 08:37:31 -07:00
|
|
|
press_type, display);
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
source_tool->src_x = source->src_x;
|
|
|
|
|
source_tool->src_y = source->src_y;
|
2006-05-22 11:35:58 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1999-02-05 01:55:44 -08:00
|
|
|
}
|
|
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_source_tool_motion (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpSourceCore *source = GIMP_SOURCE_CORE (paint_tool->core);
|
2006-05-22 11:35:58 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
source_tool->src_x = source->src_x;
|
|
|
|
|
source_tool->src_y = source->src_y;
|
2006-05-22 11:35:58 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
static void
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
2006-08-01 16:42:12 -07:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpSourceOptions *options = GIMP_SOURCE_TOOL_GET_OPTIONS (tool);
|
2006-08-01 16:42:12 -07:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (GIMP_SOURCE_CORE (paint_tool->core),
|
|
|
|
|
options) &&
|
|
|
|
|
key == gimp_get_toggle_behavior_mask ())
|
2006-08-01 16:42:12 -07:00
|
|
|
{
|
2007-10-22 03:24:41 -07:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
2006-09-12 01:33:30 -07:00
|
|
|
if (press)
|
2007-10-22 03:24:41 -07:00
|
|
|
{
|
|
|
|
|
paint_tool->status = source_tool->status_set_source;
|
|
|
|
|
|
|
|
|
|
source_tool->show_source_outline = FALSE;
|
2019-01-31 02:36:26 -08:00
|
|
|
|
|
|
|
|
source_tool->saved_precision =
|
|
|
|
|
gimp_tool_control_get_precision (tool->control);
|
|
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
|
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
|
2007-10-22 03:24:41 -07:00
|
|
|
}
|
2006-09-12 01:33:30 -07:00
|
|
|
else
|
2007-10-22 03:24:41 -07:00
|
|
|
{
|
|
|
|
|
paint_tool->status = source_tool->status_paint;
|
|
|
|
|
|
|
|
|
|
source_tool->show_source_outline = TRUE;
|
2019-01-31 02:36:26 -08:00
|
|
|
|
|
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
|
source_tool->saved_precision);
|
2007-10-22 03:24:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
2006-08-01 16:42:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-04 14:03:21 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_source_tool_cursor_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
1999-05-15 05:13:43 -07:00
|
|
|
{
|
2012-11-01 13:39:14 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpSourceOptions *options = GIMP_SOURCE_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
GimpCursorType cursor = GIMP_CURSOR_MOUSE;
|
|
|
|
|
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
|
2001-10-31 13:20:09 -08:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (GIMP_SOURCE_CORE (paint_tool->core),
|
|
|
|
|
options))
|
2000-01-14 04:41:00 -08:00
|
|
|
{
|
2015-10-17 06:31:08 -07:00
|
|
|
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
2011-10-06 12:59:07 -07:00
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
|
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
if ((state & (toggle_mask | extend_mask)) == toggle_mask)
|
2006-06-01 13:30:52 -07:00
|
|
|
{
|
|
|
|
|
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
|
|
|
|
|
}
|
2006-09-02 15:39:26 -07:00
|
|
|
else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
|
2006-06-01 13:30:52 -07:00
|
|
|
{
|
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BAD;
|
|
|
|
|
}
|
2000-01-14 04:41:00 -08:00
|
|
|
}
|
1999-07-27 01:47:31 -07:00
|
|
|
|
2006-06-01 13:30:52 -07:00
|
|
|
gimp_tool_control_set_cursor (tool->control, cursor);
|
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
|
2002-02-04 09:43:01 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
1999-05-15 05:13:43 -07:00
|
|
|
}
|
|
|
|
|
|
2005-04-04 14:03:21 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_source_tool_oper_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display)
|
2005-04-04 14:03:21 -07:00
|
|
|
{
|
2012-11-01 13:39:14 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (tool);
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpSourceOptions *options = GIMP_SOURCE_TOOL_GET_OPTIONS (tool);
|
2012-11-01 13:39:14 -07:00
|
|
|
GimpSourceCore *source;
|
|
|
|
|
|
|
|
|
|
source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core);
|
2005-04-04 14:20:13 -07:00
|
|
|
|
2006-08-03 02:06:36 -07:00
|
|
|
if (proximity)
|
|
|
|
|
{
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (source, options))
|
2006-09-03 16:11:35 -07:00
|
|
|
paint_tool->status_ctrl = source_tool->status_set_source_ctrl;
|
2006-08-03 02:06:36 -07:00
|
|
|
else
|
|
|
|
|
paint_tool->status_ctrl = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2006-03-25 06:23:09 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
2006-03-28 09:55:52 -08:00
|
|
|
display);
|
2005-04-04 14:03:21 -07:00
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (source, options))
|
2005-04-04 14:20:13 -07:00
|
|
|
{
|
2006-09-02 15:39:26 -07:00
|
|
|
if (source->src_drawable == NULL)
|
2006-05-22 11:35:58 -07:00
|
|
|
{
|
2011-10-06 12:59:07 -07:00
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
|
|
|
|
|
|
|
|
|
if (state & toggle_mask)
|
2008-11-04 04:33:09 -08:00
|
|
|
{
|
|
|
|
|
gimp_tool_replace_status (tool, display, "%s",
|
|
|
|
|
source_tool->status_set_source);
|
|
|
|
|
}
|
2006-08-01 16:42:12 -07:00
|
|
|
else
|
|
|
|
|
{
|
2011-10-06 15:29:52 -07:00
|
|
|
gimp_tool_replace_status (tool, display, "%s-%s",
|
2011-10-06 12:59:07 -07:00
|
|
|
gimp_get_mod_string (toggle_mask),
|
2008-11-04 04:33:09 -08:00
|
|
|
source_tool->status_set_source);
|
2006-08-01 16:42:12 -07:00
|
|
|
}
|
2006-05-22 11:35:58 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
2006-09-03 16:11:35 -07:00
|
|
|
source_tool->src_x = source->src_x;
|
|
|
|
|
source_tool->src_y = source->src_y;
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2006-09-02 15:39:26 -07:00
|
|
|
if (! source->first_stroke)
|
2006-05-22 11:35:58 -07:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
switch (options->align_mode)
|
2006-05-22 11:35:58 -07:00
|
|
|
{
|
2006-09-02 15:39:26 -07:00
|
|
|
case GIMP_SOURCE_ALIGN_YES:
|
2017-04-03 08:37:58 -07:00
|
|
|
source_tool->src_x = floor (coords->x) + source->offset_x;
|
|
|
|
|
source_tool->src_y = floor (coords->y) + source->offset_y;
|
2006-09-02 15:39:26 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIMP_SOURCE_ALIGN_REGISTERED:
|
2017-04-03 08:37:58 -07:00
|
|
|
source_tool->src_x = floor (coords->x);
|
|
|
|
|
source_tool->src_y = floor (coords->y);
|
2006-09-02 15:39:26 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2006-05-22 11:35:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
}
|
2005-04-04 14:20:13 -07:00
|
|
|
}
|
2005-04-04 14:03:21 -07:00
|
|
|
}
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
static void
|
2006-09-03 16:11:35 -07:00
|
|
|
gimp_source_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-09-03 16:11:35 -07:00
|
|
|
GimpSourceTool *source_tool = GIMP_SOURCE_TOOL (draw_tool);
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpSourceOptions *options = GIMP_SOURCE_TOOL_GET_OPTIONS (draw_tool);
|
2007-05-07 03:19:04 -07:00
|
|
|
GimpSourceCore *source;
|
|
|
|
|
|
|
|
|
|
source = GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (draw_tool)->core);
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
|
|
|
|
|
2012-11-01 13:39:14 -07:00
|
|
|
if (gimp_source_core_use_source (source, options) &&
|
|
|
|
|
source->src_drawable && source_tool->src_display)
|
2006-05-21 16:40:59 -07:00
|
|
|
{
|
2011-05-04 14:25:55 -07:00
|
|
|
GimpDisplayShell *src_shell;
|
|
|
|
|
gint off_x;
|
|
|
|
|
gint off_y;
|
2017-04-03 10:00:06 -07:00
|
|
|
gdouble src_x;
|
|
|
|
|
gdouble src_y;
|
2007-05-07 03:19:04 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
src_shell = gimp_display_get_shell (source_tool->src_display);
|
2006-05-22 00:11:15 -07:00
|
|
|
|
2008-11-02 15:03:29 -08:00
|
|
|
gimp_item_get_offset (GIMP_ITEM (source->src_drawable), &off_x, &off_y);
|
2006-05-22 00:11:15 -07:00
|
|
|
|
2017-04-03 10:00:06 -07:00
|
|
|
src_x = source_tool->src_x + off_x + 0.5;
|
|
|
|
|
src_y = source_tool->src_y + off_y + 0.5;
|
|
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
if (source_tool->src_outline)
|
|
|
|
|
{
|
2011-11-16 12:10:43 -08:00
|
|
|
gimp_display_shell_remove_tool_item (src_shell,
|
|
|
|
|
source_tool->src_outline);
|
2011-05-04 14:25:55 -07:00
|
|
|
source_tool->src_outline = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2007-10-22 03:24:41 -07:00
|
|
|
if (source_tool->show_source_outline)
|
2011-05-04 14:25:55 -07:00
|
|
|
{
|
|
|
|
|
source_tool->src_outline =
|
|
|
|
|
gimp_brush_tool_create_outline (GIMP_BRUSH_TOOL (source_tool),
|
|
|
|
|
source_tool->src_display,
|
2017-04-03 10:00:06 -07:00
|
|
|
src_x, src_y);
|
2011-05-05 03:19:25 -07:00
|
|
|
|
|
|
|
|
if (source_tool->src_outline)
|
|
|
|
|
{
|
2011-11-16 12:10:43 -08:00
|
|
|
gimp_display_shell_add_tool_item (src_shell,
|
|
|
|
|
source_tool->src_outline);
|
2011-05-05 03:19:25 -07:00
|
|
|
g_object_unref (source_tool->src_outline);
|
|
|
|
|
}
|
2011-05-04 14:25:55 -07:00
|
|
|
}
|
|
|
|
|
|
2014-04-09 05:30:46 -07:00
|
|
|
if (source_tool->src_outline)
|
2011-05-04 14:25:55 -07:00
|
|
|
{
|
2014-04-09 05:30:46 -07:00
|
|
|
if (source_tool->src_handle)
|
|
|
|
|
{
|
|
|
|
|
gimp_display_shell_remove_tool_item (src_shell,
|
|
|
|
|
source_tool->src_handle);
|
|
|
|
|
source_tool->src_handle = NULL;
|
|
|
|
|
}
|
2011-05-04 14:25:55 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-04-09 05:30:46 -07:00
|
|
|
if (! source_tool->src_handle)
|
|
|
|
|
{
|
|
|
|
|
source_tool->src_handle =
|
|
|
|
|
gimp_canvas_handle_new (src_shell,
|
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER,
|
2017-04-03 10:00:06 -07:00
|
|
|
src_x, src_y,
|
2014-04-09 05:30:46 -07:00
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSS,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSS);
|
|
|
|
|
gimp_display_shell_add_tool_item (src_shell,
|
|
|
|
|
source_tool->src_handle);
|
|
|
|
|
g_object_unref (source_tool->src_handle);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gimp_canvas_handle_set_position (source_tool->src_handle,
|
2017-04-03 10:00:06 -07:00
|
|
|
src_x, src_y);
|
2014-04-09 05:30:46 -07:00
|
|
|
}
|
2011-05-04 14:25:55 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
static void
|
|
|
|
|
gimp_source_tool_set_src_display (GimpSourceTool *source_tool,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
|
|
|
|
if (source_tool->src_display != display)
|
|
|
|
|
{
|
|
|
|
|
if (source_tool->src_display)
|
|
|
|
|
{
|
|
|
|
|
GimpDisplayShell *src_shell;
|
2006-05-22 11:35:58 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
src_shell = gimp_display_get_shell (source_tool->src_display);
|
2004-06-22 08:31:14 -07:00
|
|
|
|
2011-05-04 14:25:55 -07:00
|
|
|
if (source_tool->src_handle)
|
|
|
|
|
{
|
2011-11-16 12:10:43 -08:00
|
|
|
gimp_display_shell_remove_tool_item (src_shell,
|
|
|
|
|
source_tool->src_handle);
|
2011-05-04 14:25:55 -07:00
|
|
|
source_tool->src_handle = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (source_tool->src_outline)
|
|
|
|
|
{
|
2011-11-16 12:10:43 -08:00
|
|
|
gimp_display_shell_remove_tool_item (src_shell,
|
|
|
|
|
source_tool->src_outline);
|
2011-05-04 14:25:55 -07:00
|
|
|
source_tool->src_outline = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
source_tool->src_display = display;
|
|
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|