2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-09-08 01:10:22 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2006-09-08 01:10:22 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2006-09-08 01:10:22 +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-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2006-09-08 01:10:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2006-09-08 01:10:22 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2011-04-28 20:23:33 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp-transform-utils.h"
|
2006-09-14 02:00:30 +08:00
|
|
|
#include "core/gimpimage.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
#include "paint/gimpperspectiveclone.h"
|
|
|
|
#include "paint/gimpperspectivecloneoptions.h"
|
|
|
|
|
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
#include "widgets/gimpviewablebox.h"
|
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
|
|
|
|
2010-09-28 01:31:21 +08:00
|
|
|
#include "display/gimpcanvasgroup.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2017-06-20 02:43:46 +08:00
|
|
|
#include "display/gimptooltransformgrid.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
#include "gimpperspectiveclonetool.h"
|
2013-06-03 22:40:24 +08:00
|
|
|
#include "gimpcloneoptions-gui.h"
|
2006-09-08 01:10:22 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2011-03-28 06:50:46 +08:00
|
|
|
/* index into trans_info array */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
X0,
|
|
|
|
Y0,
|
|
|
|
X1,
|
|
|
|
Y1,
|
|
|
|
X2,
|
|
|
|
Y2,
|
|
|
|
X3,
|
2017-06-20 02:43:46 +08:00
|
|
|
Y3,
|
|
|
|
PIVOT_X,
|
|
|
|
PIVOT_Y
|
2011-03-28 06:50:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-01-31 19:18:17 +08:00
|
|
|
static void gimp_perspective_clone_tool_constructed (GObject *object);
|
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
static gboolean gimp_perspective_clone_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static gboolean gimp_perspective_clone_tool_has_display (GimpTool *tool,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static GimpDisplay *
|
|
|
|
gimp_perspective_clone_tool_has_image (GimpTool *tool,
|
|
|
|
GimpImage *image);
|
|
|
|
static void gimp_perspective_clone_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_button_release (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_motion (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2019-01-31 19:18:17 +08:00
|
|
|
static void gimp_perspective_clone_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2017-06-20 02:43:46 +08:00
|
|
|
static void gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec);
|
|
|
|
|
|
|
|
static void gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
|
|
|
static void gimp_perspective_clone_tool_halt (GimpPerspectiveCloneTool *clone_tool);
|
|
|
|
static void gimp_perspective_clone_tool_bounds (GimpPerspectiveCloneTool *clone_tool,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *clone_tool);
|
|
|
|
static void gimp_perspective_clone_tool_recalc_matrix (GimpPerspectiveCloneTool *clone_tool,
|
|
|
|
GimpToolWidget *widget);
|
|
|
|
|
|
|
|
static void gimp_perspective_clone_tool_widget_changed (GimpToolWidget *widget,
|
|
|
|
GimpPerspectiveCloneTool *clone_tool);
|
|
|
|
static void gimp_perspective_clone_tool_widget_status (GimpToolWidget *widget,
|
|
|
|
const gchar *status,
|
|
|
|
GimpPerspectiveCloneTool *clone_tool);
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_perspective_clone_options_gui (GimpToolOptions *tool_options);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpPerspectiveCloneTool, gimp_perspective_clone_tool,
|
|
|
|
GIMP_TYPE_BRUSH_TOOL)
|
|
|
|
|
|
|
|
#define parent_class gimp_perspective_clone_tool_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_perspective_clone_tool_register (GimpToolRegisterCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
(* callback) (GIMP_TYPE_PERSPECTIVE_CLONE_TOOL,
|
|
|
|
GIMP_TYPE_PERSPECTIVE_CLONE_OPTIONS,
|
|
|
|
gimp_perspective_clone_options_gui,
|
|
|
|
GIMP_PAINT_OPTIONS_CONTEXT_MASK |
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_PATTERN,
|
2006-09-08 01:10:22 +08:00
|
|
|
"gimp-perspective-clone-tool",
|
|
|
|
_("Perspective Clone"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Perspective Clone Tool: Clone from an image source "
|
|
|
|
"after applying a perspective transformation"),
|
2006-09-08 16:39:55 +08:00
|
|
|
N_("_Perspective Clone"), NULL,
|
2006-09-08 01:10:22 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_PERSPECTIVE_CLONE,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_PERSPECTIVE_CLONE,
|
2006-09-08 01:10:22 +08:00
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_class_init (GimpPerspectiveCloneToolClass *klass)
|
|
|
|
{
|
2019-01-31 19:18:17 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2006-09-08 01:10:22 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
|
|
|
|
2019-01-31 19:18:17 +08:00
|
|
|
object_class->constructed = gimp_perspective_clone_tool_constructed;
|
|
|
|
|
2007-10-09 05:41:00 +08:00
|
|
|
tool_class->initialize = gimp_perspective_clone_tool_initialize;
|
|
|
|
tool_class->has_display = gimp_perspective_clone_tool_has_display;
|
|
|
|
tool_class->has_image = gimp_perspective_clone_tool_has_image;
|
|
|
|
tool_class->control = gimp_perspective_clone_tool_control;
|
|
|
|
tool_class->button_press = gimp_perspective_clone_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_perspective_clone_tool_button_release;
|
|
|
|
tool_class->motion = gimp_perspective_clone_tool_motion;
|
2019-01-31 19:18:17 +08:00
|
|
|
tool_class->modifier_key = gimp_perspective_clone_tool_modifier_key;
|
2007-10-09 05:41:00 +08:00
|
|
|
tool_class->cursor_update = gimp_perspective_clone_tool_cursor_update;
|
|
|
|
tool_class->oper_update = gimp_perspective_clone_tool_oper_update;
|
2017-06-20 02:43:46 +08:00
|
|
|
tool_class->options_notify = gimp_perspective_clone_tool_options_notify;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2007-10-09 05:41:00 +08:00
|
|
|
draw_tool_class->draw = gimp_perspective_clone_tool_draw;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-09 04:23:51 +08:00
|
|
|
gimp_perspective_clone_tool_init (GimpPerspectiveCloneTool *clone_tool)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2007-10-09 04:23:51 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (clone_tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
gimp_tool_control_set_action_object_2 (tool->control,
|
|
|
|
"context/context-pattern-select-set");
|
|
|
|
|
2007-10-09 04:23:51 +08:00
|
|
|
gimp_matrix3_identity (&clone_tool->transform);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
2019-01-31 19:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (object);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
|
|
|
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
gimp_paint_tool_set_active (GIMP_PAINT_TOOL (object), FALSE);
|
|
|
|
}
|
|
|
|
|
2006-09-08 01:10:22 +08:00
|
|
|
static gboolean
|
2006-09-27 04:55:40 +08:00
|
|
|
gimp_perspective_clone_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2007-10-09 04:23:51 +08:00
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2009-08-20 23:05:23 +08:00
|
|
|
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-08 01:10:22 +08:00
|
|
|
if (display != tool->display)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
gint i;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
tool->display = display;
|
2009-10-07 01:20:44 +08:00
|
|
|
tool->drawable = gimp_image_get_active_drawable (image);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
/* Find the transform bounds initializing */
|
2007-10-09 04:23:51 +08:00
|
|
|
gimp_perspective_clone_tool_bounds (clone_tool, display);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2011-03-28 07:08:24 +08:00
|
|
|
gimp_perspective_clone_tool_prepare (clone_tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
/* Recalculate the transform tool */
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_perspective_clone_tool_recalc_matrix (clone_tool, NULL);
|
|
|
|
|
|
|
|
clone_tool->widget =
|
|
|
|
gimp_tool_transform_grid_new (shell,
|
|
|
|
&clone_tool->transform,
|
|
|
|
clone_tool->x1,
|
|
|
|
clone_tool->y1,
|
|
|
|
clone_tool->x2,
|
2017-06-20 05:06:39 +08:00
|
|
|
clone_tool->y2);
|
2017-06-20 02:43:46 +08:00
|
|
|
|
|
|
|
g_object_set (clone_tool->widget,
|
|
|
|
"pivot-x", (clone_tool->x1 + clone_tool->x2) / 2.0,
|
|
|
|
"pivot-y", (clone_tool->y1 + clone_tool->y2) / 2.0,
|
|
|
|
"inside-function", GIMP_TRANSFORM_FUNCTION_MOVE,
|
|
|
|
"outside-function", GIMP_TRANSFORM_FUNCTION_ROTATE,
|
|
|
|
"use-corner-handles", TRUE,
|
|
|
|
"use-perspective-handles", TRUE,
|
|
|
|
"use-side-handles", TRUE,
|
|
|
|
"use-shear-handles", TRUE,
|
|
|
|
"use-pivot-handle", TRUE,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_signal_connect (clone_tool->widget, "changed",
|
|
|
|
G_CALLBACK (gimp_perspective_clone_tool_widget_changed),
|
|
|
|
clone_tool);
|
|
|
|
g_signal_connect (clone_tool->widget, "status",
|
|
|
|
G_CALLBACK (gimp_perspective_clone_tool_widget_status),
|
|
|
|
clone_tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
/* start drawing the bounding box and handles... */
|
2019-01-31 22:06:22 +08:00
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2006-09-08 01:10:22 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
|
|
|
|
|
|
|
/* Save the current transformation info */
|
2006-11-07 19:09:51 +08:00
|
|
|
for (i = 0; i < TRANS_INFO_SIZE; i++)
|
2007-10-09 04:23:51 +08:00
|
|
|
clone_tool->old_trans_info[i] = clone_tool->trans_info[i];
|
2006-09-12 20:57:55 +08:00
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_perspective_clone_tool_has_display (GimpTool *tool,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
|
|
|
|
return (display == clone_tool->src_display ||
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->has_display (tool, display));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpDisplay *
|
|
|
|
gimp_perspective_clone_tool_has_image (GimpTool *tool,
|
|
|
|
GimpImage *image)
|
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpDisplay *display;
|
|
|
|
|
|
|
|
display = GIMP_TOOL_CLASS (parent_class)->has_image (tool, image);
|
|
|
|
|
|
|
|
if (! display && clone_tool->src_display)
|
|
|
|
{
|
2009-10-07 01:20:44 +08:00
|
|
|
if (image && gimp_display_get_image (clone_tool->src_display) == image)
|
2006-09-08 01:10:22 +08:00
|
|
|
display = clone_tool->src_display;
|
|
|
|
|
|
|
|
/* NULL image means any display */
|
|
|
|
if (! image)
|
|
|
|
display = clone_tool->src_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
2007-10-09 04:23:51 +08:00
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
2008-04-03 02:53:53 +08:00
|
|
|
/* only in the case that "Modify Polygon" mode is set " */
|
2007-10-09 04:23:51 +08:00
|
|
|
gimp_perspective_clone_tool_bounds (clone_tool, display);
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_perspective_clone_tool_recalc_matrix (clone_tool, clone_tool->widget);
|
2006-09-08 01:10:22 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2007-10-09 05:41:00 +08:00
|
|
|
gimp_perspective_clone_tool_halt (clone_tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
break;
|
2014-04-05 04:34:26 +08:00
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
break;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-06-20 23:37:31 +08:00
|
|
|
gimp_perspective_clone_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2006-09-12 20:57:55 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core);
|
|
|
|
GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone);
|
2006-09-08 01:10:22 +08:00
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
2006-09-14 02:00:30 +08:00
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (clone_tool->widget)
|
|
|
|
{
|
|
|
|
gimp_tool_widget_hover (clone_tool->widget, coords, state, TRUE);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
if (gimp_tool_widget_button_press (clone_tool->widget, coords,
|
|
|
|
time, state, press_type))
|
|
|
|
{
|
|
|
|
clone_tool->grab_widget = clone_tool->widget;
|
|
|
|
}
|
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
gimp_tool_control_activate (tool->control);
|
2017-06-20 02:43:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
|
|
|
gdouble nnx, nny;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
if ((state & (toggle_mask | extend_mask)) == toggle_mask)
|
|
|
|
{
|
|
|
|
source_core->set_source = TRUE;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
clone_tool->src_display = display;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
source_core->set_source = FALSE;
|
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
|
|
|
|
press_type, display);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
/* Set the coordinates for the reference cross */
|
|
|
|
gimp_perspective_clone_get_source_point (clone,
|
|
|
|
coords->x, coords->y,
|
|
|
|
&nnx, &nny);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
clone_tool->src_x = floor (nnx);
|
|
|
|
clone_tool->src_y = floor (nny);
|
2007-10-09 05:41:00 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
2007-10-09 05:41:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_button_release (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-10-09 05:41:00 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
2007-10-09 05:41:00 +08:00
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
|
|
|
switch (options->clone_mode)
|
|
|
|
{
|
|
|
|
case GIMP_PERSPECTIVE_CLONE_MODE_ADJUST:
|
|
|
|
gimp_tool_control_halt (tool->control);
|
2017-06-20 02:43:46 +08:00
|
|
|
|
|
|
|
if (clone_tool->grab_widget)
|
|
|
|
{
|
|
|
|
gimp_tool_widget_button_release (clone_tool->grab_widget,
|
|
|
|
coords, time, state, release_type);
|
|
|
|
clone_tool->grab_widget = NULL;
|
|
|
|
}
|
2007-10-09 05:41:00 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_PERSPECTIVE_CLONE_MODE_PAINT:
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
|
|
|
|
release_type, display);
|
|
|
|
break;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_perspective_clone_tool_motion (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2007-09-10 22:48:08 +08:00
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (paint_tool->core);
|
2006-09-08 01:10:22 +08:00
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
2006-09-14 02:00:30 +08:00
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (clone_tool->grab_widget)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_tool_widget_motion (clone_tool->grab_widget, coords, time, state);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
|
|
|
|
{
|
|
|
|
gdouble nnx, nny;
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state,
|
|
|
|
display);
|
|
|
|
|
|
|
|
/* Set the coordinates for the reference cross */
|
|
|
|
gimp_perspective_clone_get_source_point (clone,
|
|
|
|
coords->x, coords->y,
|
|
|
|
&nnx, &nny);
|
|
|
|
|
2017-04-03 23:37:58 +08:00
|
|
|
clone_tool->src_x = floor (nnx);
|
|
|
|
clone_tool->src_y = floor (nny);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-31 19:18:17 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT &&
|
|
|
|
key == gimp_get_toggle_behavior_mask ())
|
|
|
|
{
|
|
|
|
if (press)
|
|
|
|
{
|
|
|
|
clone_tool->saved_precision =
|
|
|
|
gimp_tool_control_get_precision (tool->control);
|
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
clone_tool->saved_precision);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
2006-09-08 01:10:22 +08:00
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_perspective_clone_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpPerspectiveCloneOptions *options;
|
2009-10-07 01:20:44 +08:00
|
|
|
GimpImage *image;
|
2007-05-02 21:24:14 +08:00
|
|
|
GimpToolClass *tool_class;
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpCursorType cursor = GIMP_CURSOR_MOUSE;
|
|
|
|
GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_NONE;
|
|
|
|
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2006-09-14 02:00:30 +08:00
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
image = gimp_display_get_image (display);
|
|
|
|
|
|
|
|
if (gimp_image_coords_in_active_pickable (image, coords,
|
2006-09-08 01:10:22 +08:00
|
|
|
FALSE, TRUE))
|
|
|
|
{
|
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (clone_tool->widget)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (display == tool->display)
|
|
|
|
{
|
|
|
|
gimp_tool_widget_get_cursor (clone_tool->widget,
|
|
|
|
coords, state,
|
|
|
|
&cursor, &tool_cursor, &modifier);
|
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-17 21:31:08 +08:00
|
|
|
GdkModifierType extend_mask = gimp_get_extend_selection_mask ();
|
2012-11-02 04:39:14 +08:00
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
2011-10-07 03:59:07 +08:00
|
|
|
|
2015-10-17 21:31:08 +08:00
|
|
|
if ((state & (toggle_mask | extend_mask)) == toggle_mask)
|
2012-11-02 04:39:14 +08:00
|
|
|
{
|
|
|
|
cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
|
|
|
|
}
|
|
|
|
else if (! GIMP_SOURCE_CORE (GIMP_PAINT_TOOL (tool)->core)->src_drawable)
|
|
|
|
{
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BAD;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
2017-06-20 02:43:46 +08:00
|
|
|
|
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_CLONE;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_tool_control_set_cursor (tool->control, cursor);
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
|
2006-09-08 01:10:22 +08:00
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
|
|
|
|
|
2007-05-02 21:24:14 +08:00
|
|
|
/* If we are in adjust mode, skip the GimpBrushClass when chaining up.
|
|
|
|
* This ensures that the cursor will be set regardless of
|
|
|
|
* GimpBrushTool::show_cursor (see bug #354933).
|
|
|
|
*/
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
tool_class = GIMP_TOOL_CLASS (g_type_class_peek_parent (parent_class));
|
|
|
|
else
|
|
|
|
tool_class = GIMP_TOOL_CLASS (parent_class);
|
|
|
|
|
|
|
|
tool_class->cursor_update (tool, coords, state, display);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_perspective_clone_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
2006-09-14 02:00:30 +08:00
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (clone_tool->widget)
|
2011-03-28 07:08:24 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (display == tool->display)
|
|
|
|
{
|
|
|
|
gimp_tool_widget_hover (clone_tool->widget, coords, state,
|
|
|
|
proximity);
|
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state,
|
|
|
|
proximity, display);
|
|
|
|
|
2012-11-02 04:39:14 +08:00
|
|
|
if (proximity)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2007-10-09 04:23:51 +08:00
|
|
|
GimpPaintCore *core = GIMP_PAINT_TOOL (tool)->core;
|
|
|
|
GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (core);
|
|
|
|
GimpSourceCore *source_core = GIMP_SOURCE_CORE (core);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2006-09-12 20:57:55 +08:00
|
|
|
if (source_core->src_drawable == NULL)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
|
|
|
gimp_tool_replace_status (tool, display,
|
2006-09-12 14:37:54 +08:00
|
|
|
_("Ctrl-Click to set a clone source"));
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2006-09-12 20:57:55 +08:00
|
|
|
clone_tool->src_x = source_core->src_x;
|
|
|
|
clone_tool->src_y = source_core->src_y;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2006-09-12 20:57:55 +08:00
|
|
|
if (! source_core->first_stroke)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2006-09-12 20:57:55 +08:00
|
|
|
if (GIMP_SOURCE_OPTIONS (options)->align_mode ==
|
|
|
|
GIMP_SOURCE_ALIGN_YES)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
|
|
|
gdouble nnx, nny;
|
|
|
|
|
|
|
|
/* Set the coordinates for the reference cross */
|
|
|
|
gimp_perspective_clone_get_source_point (clone,
|
|
|
|
coords->x,
|
|
|
|
coords->y,
|
|
|
|
&nnx, &nny);
|
|
|
|
|
2017-04-03 23:37:58 +08:00
|
|
|
clone_tool->src_x = floor (nnx);
|
|
|
|
clone_tool->src_y = floor (nny);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (tool);
|
2019-01-31 19:18:17 +08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpPerspectiveCloneOptions *clone_options;
|
|
|
|
|
|
|
|
clone_options = GIMP_PERSPECTIVE_CLONE_OPTIONS (options);
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
|
|
|
|
|
|
|
|
if (! strcmp (pspec->name, "clone-mode"))
|
|
|
|
{
|
|
|
|
GimpPerspectiveClone *clone;
|
|
|
|
|
|
|
|
clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core);
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (clone_tool));
|
|
|
|
|
|
|
|
if (clone_options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_PAINT)
|
|
|
|
{
|
|
|
|
gimp_perspective_clone_set_transform (clone, &clone_tool->transform);
|
2019-01-31 19:18:17 +08:00
|
|
|
|
|
|
|
gimp_paint_tool_set_active (paint_tool, TRUE);
|
2017-06-20 02:43:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-01-31 19:18:17 +08:00
|
|
|
gimp_paint_tool_set_active (paint_tool, FALSE);
|
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
GIMP_CURSOR_PRECISION_SUBPIXEL);
|
|
|
|
|
|
|
|
/* start drawing the bounding box and handles... */
|
|
|
|
if (tool->display &&
|
|
|
|
! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (clone_tool)))
|
|
|
|
{
|
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (clone_tool), tool->display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (clone_tool));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-08 01:10:22 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool)
|
|
|
|
{
|
2006-09-12 20:57:55 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (draw_tool);
|
|
|
|
GimpPerspectiveCloneTool *clone_tool = GIMP_PERSPECTIVE_CLONE_TOOL (draw_tool);
|
|
|
|
GimpPerspectiveClone *clone = GIMP_PERSPECTIVE_CLONE (GIMP_PAINT_TOOL (tool)->core);
|
|
|
|
GimpSourceCore *source_core = GIMP_SOURCE_CORE (clone);
|
2006-09-08 01:10:22 +08:00
|
|
|
GimpPerspectiveCloneOptions *options;
|
|
|
|
|
2006-09-14 02:00:30 +08:00
|
|
|
options = GIMP_PERSPECTIVE_CLONE_TOOL_GET_OPTIONS (tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2011-03-28 07:27:02 +08:00
|
|
|
if (options->clone_mode == GIMP_PERSPECTIVE_CLONE_MODE_ADJUST)
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
if (clone_tool->widget)
|
|
|
|
{
|
|
|
|
GimpCanvasItem *item = gimp_tool_widget_get_item (clone_tool->widget);
|
|
|
|
|
|
|
|
gimp_draw_tool_add_item (draw_tool, item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GimpCanvasGroup *stroke_group;
|
|
|
|
|
|
|
|
stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
|
|
|
|
|
|
|
|
/* draw the bounding box */
|
|
|
|
gimp_draw_tool_push_group (draw_tool, stroke_group);
|
|
|
|
|
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
clone_tool->trans_info[X0],
|
|
|
|
clone_tool->trans_info[Y0],
|
|
|
|
clone_tool->trans_info[X1],
|
|
|
|
clone_tool->trans_info[Y1]);
|
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
clone_tool->trans_info[X1],
|
|
|
|
clone_tool->trans_info[Y1],
|
|
|
|
clone_tool->trans_info[X3],
|
|
|
|
clone_tool->trans_info[Y3]);
|
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
clone_tool->trans_info[X2],
|
|
|
|
clone_tool->trans_info[Y2],
|
|
|
|
clone_tool->trans_info[X3],
|
|
|
|
clone_tool->trans_info[Y3]);
|
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
clone_tool->trans_info[X2],
|
|
|
|
clone_tool->trans_info[Y2],
|
|
|
|
clone_tool->trans_info[X0],
|
|
|
|
clone_tool->trans_info[Y0]);
|
|
|
|
|
|
|
|
gimp_draw_tool_pop_group (draw_tool);
|
2011-03-28 07:27:02 +08:00
|
|
|
}
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2012-11-02 04:39:14 +08:00
|
|
|
if (source_core->src_drawable && clone_tool->src_display)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
|
|
|
GimpDisplay *tmp_display;
|
|
|
|
|
|
|
|
tmp_display = draw_tool->display;
|
|
|
|
draw_tool->display = clone_tool->src_display;
|
|
|
|
|
2010-09-26 01:02:22 +08:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
2019-01-31 19:18:17 +08:00
|
|
|
clone_tool->src_x + 0.5,
|
|
|
|
clone_tool->src_y + 0.5,
|
2010-11-09 05:37:00 +08:00
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSS,
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSS,
|
2010-10-19 02:13:09 +08:00
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
|
|
|
draw_tool->display = tmp_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_perspective_clone_tool_halt (GimpPerspectiveCloneTool *clone_tool)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (clone_tool);
|
|
|
|
|
|
|
|
clone_tool->src_display = NULL;
|
|
|
|
|
|
|
|
g_object_set (GIMP_PAINT_TOOL (tool)->core,
|
|
|
|
"src-drawable", NULL,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
g_clear_object (&clone_tool->widget);
|
|
|
|
|
|
|
|
tool->display = NULL;
|
|
|
|
tool->drawable = NULL;
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_perspective_clone_tool_bounds (GimpPerspectiveCloneTool *clone_tool,
|
2006-09-08 01:10:22 +08:00
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
2011-03-28 07:20:16 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2009-10-07 01:20:44 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
clone_tool->x1 = 0;
|
|
|
|
clone_tool->y1 = 0;
|
|
|
|
clone_tool->x2 = gimp_image_get_width (image);
|
|
|
|
clone_tool->y2 = gimp_image_get_height (image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_prepare (GimpPerspectiveCloneTool *clone_tool)
|
|
|
|
{
|
|
|
|
clone_tool->trans_info[PIVOT_X] = (gdouble) (clone_tool->x1 + clone_tool->x2) / 2.0;
|
|
|
|
clone_tool->trans_info[PIVOT_Y] = (gdouble) (clone_tool->y1 + clone_tool->y2) / 2.0;
|
|
|
|
|
|
|
|
clone_tool->trans_info[X0] = clone_tool->x1;
|
|
|
|
clone_tool->trans_info[Y0] = clone_tool->y1;
|
|
|
|
clone_tool->trans_info[X1] = clone_tool->x2;
|
|
|
|
clone_tool->trans_info[Y1] = clone_tool->y1;
|
|
|
|
clone_tool->trans_info[X2] = clone_tool->x1;
|
|
|
|
clone_tool->trans_info[Y2] = clone_tool->y2;
|
|
|
|
clone_tool->trans_info[X3] = clone_tool->x2;
|
|
|
|
clone_tool->trans_info[Y3] = clone_tool->y2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_recalc_matrix (GimpPerspectiveCloneTool *clone_tool,
|
|
|
|
GimpToolWidget *widget)
|
|
|
|
{
|
|
|
|
gimp_matrix3_identity (&clone_tool->transform);
|
|
|
|
gimp_transform_matrix_perspective (&clone_tool->transform,
|
|
|
|
clone_tool->x1,
|
|
|
|
clone_tool->y1,
|
|
|
|
clone_tool->x2 - clone_tool->x1,
|
|
|
|
clone_tool->y2 - clone_tool->y1,
|
|
|
|
clone_tool->trans_info[X0],
|
|
|
|
clone_tool->trans_info[Y0],
|
|
|
|
clone_tool->trans_info[X1],
|
|
|
|
clone_tool->trans_info[Y1],
|
|
|
|
clone_tool->trans_info[X2],
|
|
|
|
clone_tool->trans_info[Y2],
|
|
|
|
clone_tool->trans_info[X3],
|
|
|
|
clone_tool->trans_info[Y3]);
|
|
|
|
|
|
|
|
if (widget)
|
|
|
|
g_object_set (widget,
|
|
|
|
"transform", &clone_tool->transform,
|
|
|
|
"x1", (gdouble) clone_tool->x1,
|
|
|
|
"y1", (gdouble) clone_tool->y1,
|
|
|
|
"x2", (gdouble) clone_tool->x2,
|
|
|
|
"y2", (gdouble) clone_tool->y2,
|
|
|
|
"pivot-x", clone_tool->trans_info[PIVOT_X],
|
|
|
|
"pivot-y", clone_tool->trans_info[PIVOT_Y],
|
|
|
|
NULL);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_perspective_clone_tool_widget_changed (GimpToolWidget *widget,
|
|
|
|
GimpPerspectiveCloneTool *clone_tool)
|
2006-09-08 01:10:22 +08:00
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
GimpMatrix3 *transform;
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
g_object_get (widget,
|
|
|
|
"transform", &transform,
|
|
|
|
"pivot-x", &clone_tool->trans_info[PIVOT_X],
|
|
|
|
"pivot-y", &clone_tool->trans_info[PIVOT_Y],
|
|
|
|
NULL);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
clone_tool->x1, clone_tool->y1,
|
|
|
|
&clone_tool->trans_info[X0],
|
|
|
|
&clone_tool->trans_info[Y0]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
clone_tool->x2, clone_tool->y1,
|
|
|
|
&clone_tool->trans_info[X1],
|
|
|
|
&clone_tool->trans_info[Y1]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
clone_tool->x1, clone_tool->y2,
|
|
|
|
&clone_tool->trans_info[X2],
|
|
|
|
&clone_tool->trans_info[Y2]);
|
|
|
|
gimp_matrix3_transform_point (transform,
|
|
|
|
clone_tool->x2, clone_tool->y2,
|
|
|
|
&clone_tool->trans_info[X3],
|
|
|
|
&clone_tool->trans_info[Y3]);
|
|
|
|
|
|
|
|
g_free (transform);
|
|
|
|
|
|
|
|
gimp_perspective_clone_tool_recalc_matrix (clone_tool, NULL);
|
|
|
|
}
|
2008-08-21 00:22:09 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
static void
|
|
|
|
gimp_perspective_clone_tool_widget_status (GimpToolWidget *widget,
|
|
|
|
const gchar *status,
|
|
|
|
GimpPerspectiveCloneTool *clone_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (clone_tool);
|
2006-09-08 01:10:22 +08:00
|
|
|
|
2017-06-20 02:43:46 +08:00
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
gimp_tool_replace_status (tool, tool->display, "%s", status);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-20 02:43:46 +08:00
|
|
|
gimp_tool_pop_status (tool, tool->display);
|
2006-09-08 01:10:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* tool options stuff */
|
|
|
|
|
|
|
|
static GtkWidget *
|
|
|
|
gimp_perspective_clone_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
|
|
|
GObject *config = G_OBJECT (tool_options);
|
2013-06-03 22:40:24 +08:00
|
|
|
GtkWidget *vbox = gimp_clone_options_gui (tool_options);
|
2006-09-08 01:10:22 +08:00
|
|
|
GtkWidget *mode;
|
|
|
|
|
2016-02-12 06:44:07 +08:00
|
|
|
/* radio buttons to set if you are modifying the perspective plane
|
|
|
|
* or painting
|
|
|
|
*/
|
2008-04-03 02:53:53 +08:00
|
|
|
mode = gimp_prop_enum_radio_box_new (config, "clone-mode", 0, 0);
|
2006-09-08 01:10:22 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), mode, FALSE, FALSE, 0);
|
2013-06-03 22:40:24 +08:00
|
|
|
gtk_box_reorder_child (GTK_BOX (vbox), mode, 0);
|
2006-09-08 01:10:22 +08:00
|
|
|
gtk_widget_show (mode);
|
|
|
|
|
|
|
|
return vbox;
|
|
|
|
}
|