2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 22:05:25 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2014-06-07 23:18:29 -04:00
|
|
|
* Major improvements for interactivity
|
|
|
|
* Copyright (C) 2014 Michael Henning <drawoc@darkrefraction.com>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 22:05:25 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 22:05:25 +00: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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-01 20:30:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
1999-09-02 01:41:18 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
#include <gtk/gtk.h>
|
2014-06-07 23:18:29 -04:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2009-04-22 21:08:42 +02:00
|
|
|
#include "core/gimp-utils.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpdrawable.h"
|
2001-11-09 16:54:56 +00:00
|
|
|
#include "core/gimpdrawable-blend.h"
|
2008-11-12 10:56:06 +00:00
|
|
|
#include "core/gimperror.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpgradient.h"
|
|
|
|
#include "core/gimpimage.h"
|
2014-06-20 11:28:01 -04:00
|
|
|
#include "core/gimpimagemap.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "core/gimpprogress.h"
|
2014-06-20 11:28:01 -04:00
|
|
|
#include "core/gimpprojection.h"
|
2001-05-09 02:32:03 +00:00
|
|
|
|
2016-01-20 12:18:35 +01:00
|
|
|
#include "gegl/gimp-gegl-config.h"
|
2014-06-24 14:23:55 -04:00
|
|
|
|
2003-08-22 01:42:57 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2007-01-21 01:24:51 +00:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2003-08-22 01:42:57 +00:00
|
|
|
|
2011-03-28 11:08:40 +02:00
|
|
|
#include "display/gimpcanvashandle.h"
|
|
|
|
#include "display/gimpcanvasline.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2003-02-05 14:39:40 +00:00
|
|
|
#include "gimpblendoptions.h"
|
2001-03-11 20:01:14 +00:00
|
|
|
#include "gimpblendtool.h"
|
2003-04-15 16:05:52 +00:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-03-11 20:01:14 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 17:27:28 +00:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
#define SHOW_LINE TRUE
|
2014-06-26 12:57:06 -04:00
|
|
|
#define HANDLE_CROSS_DIAMETER 18
|
|
|
|
#define HANDLE_DIAMETER 40
|
1998-07-08 06:41:58 +00:00
|
|
|
|
2014-06-26 12:57:06 -04:00
|
|
|
#define POINT_GRAB_THRESHOLD_SQ (SQR (HANDLE_DIAMETER / 2))
|
|
|
|
#define FULL_HANDLE_THRESHOLD_SQ (POINT_GRAB_THRESHOLD_SQ * 9)
|
2014-10-18 21:03:33 -04:00
|
|
|
#define PARTIAL_HANDLE_THRESHOLD_SQ (FULL_HANDLE_THRESHOLD_SQ * 5)
|
2014-06-07 23:18:29 -04:00
|
|
|
|
2001-03-11 20:01:14 +00:00
|
|
|
/* local function prototypes */
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2007-02-27 18:55:12 +00:00
|
|
|
static gboolean gimp_blend_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error);
|
2014-06-28 22:53:38 -04:00
|
|
|
static void gimp_blend_tool_dispose (GObject *object);
|
2014-06-07 23:18:29 -04:00
|
|
|
static void gimp_blend_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_blend_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
2007-02-27 18:55:12 +00:00
|
|
|
static void gimp_blend_tool_button_press (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2009-06-20 17:37:31 +02:00
|
|
|
GimpButtonPressType press_type,
|
2007-02-27 18:55:12 +00:00
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_blend_tool_button_release (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_blend_tool_motion (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2014-06-24 14:23:55 -04:00
|
|
|
static void gimp_blend_tool_point_motion (GimpBlendTool *blend_tool,
|
|
|
|
gboolean constrain_angle);
|
2014-06-07 23:18:29 -04:00
|
|
|
static gboolean gimp_blend_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *display);
|
2007-02-27 18:55:12 +00:00
|
|
|
static void gimp_blend_tool_active_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_blend_tool_cursor_update (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_blend_tool_draw (GimpDrawTool *draw_tool);
|
2014-10-18 19:05:56 -04:00
|
|
|
static void gimp_blend_tool_update_items (GimpBlendTool *blend_tool);
|
|
|
|
static void gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
|
|
|
|
static GimpBlendToolPoint gimp_blend_tool_get_point_under_cursor (GimpBlendTool *blend_tool);
|
|
|
|
|
2014-09-02 18:49:41 -04:00
|
|
|
static void gimp_blend_tool_start_preview (GimpBlendTool *bt,
|
2014-06-07 23:18:29 -04:00
|
|
|
GimpDisplay *display);
|
2014-09-02 18:49:41 -04:00
|
|
|
static void gimp_blend_tool_halt_preview (GimpBlendTool *bt);
|
2014-06-07 23:18:29 -04:00
|
|
|
static void gimp_blend_tool_commit (GimpBlendTool *bt);
|
2007-02-27 18:55:12 +00:00
|
|
|
|
|
|
|
static void gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2006-09-13 10:06:49 +00:00
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
static void gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_tool);
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
static void gimp_blend_tool_create_graph (GimpBlendTool *blend_tool);
|
|
|
|
static void gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool);
|
2014-06-29 20:40:47 -04:00
|
|
|
static void gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool);
|
2014-06-28 22:53:38 -04:00
|
|
|
static void gimp_blend_tool_set_gradient (GimpBlendTool *blend_tool,
|
|
|
|
GimpGradient *gradient);
|
2014-06-24 14:23:55 -04:00
|
|
|
static void gimp_blend_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec);
|
2014-08-04 12:28:21 -04:00
|
|
|
static gboolean gimp_blend_tool_is_shapeburst (GimpBlendTool *blend_tool);
|
2014-06-20 11:28:01 -04:00
|
|
|
|
|
|
|
static void gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
static void gimp_blend_tool_image_map_flush (GimpImageMap *image_map,
|
|
|
|
GimpTool *tool);
|
|
|
|
|
|
|
|
|
2006-05-15 09:46:31 +00:00
|
|
|
G_DEFINE_TYPE (GimpBlendTool, gimp_blend_tool, GIMP_TYPE_DRAW_TOOL)
|
2005-12-13 09:13:50 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_blend_tool_parent_class
|
1999-04-08 22:25:54 +00:00
|
|
|
|
2001-11-09 16:54:56 +00:00
|
|
|
|
2001-03-11 20:01:14 +00:00
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_blend_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-03-11 20:01:14 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_BLEND_TOOL,
|
2003-02-05 14:39:40 +00:00
|
|
|
GIMP_TYPE_BLEND_OPTIONS,
|
|
|
|
gimp_blend_options_gui,
|
2015-09-08 21:18:49 +02:00
|
|
|
GIMP_CONTEXT_PROP_MASK_FOREGROUND |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_OPACITY |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_PAINT_MODE |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_GRADIENT,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-blend-tool",
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Blend"),
|
2006-09-18 18:00:22 +00:00
|
|
|
_("Blend Tool: Fill selected area with a color gradient"),
|
2004-04-29 13:19:28 +00:00
|
|
|
N_("Blen_d"), "L",
|
2003-08-22 01:42:57 +00:00
|
|
|
NULL, GIMP_HELP_TOOL_BLEND,
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_BLEND,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
1999-04-08 22:25:54 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 20:01:14 +00:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_class_init (GimpBlendToolClass *klass)
|
|
|
|
{
|
2014-06-28 22:53:38 -04:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2005-03-04 11:42:46 +00:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2000-02-13 22:26:41 +00:00
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
object_class->dispose = gimp_blend_tool_dispose;
|
|
|
|
|
2006-09-26 20:55:40 +00:00
|
|
|
tool_class->initialize = gimp_blend_tool_initialize;
|
2014-06-07 23:18:29 -04:00
|
|
|
tool_class->control = gimp_blend_tool_control;
|
|
|
|
tool_class->oper_update = gimp_blend_tool_oper_update;
|
2006-09-12 19:36:05 +00:00
|
|
|
tool_class->button_press = gimp_blend_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_blend_tool_button_release;
|
|
|
|
tool_class->motion = gimp_blend_tool_motion;
|
2014-06-07 23:18:29 -04:00
|
|
|
tool_class->key_press = gimp_blend_tool_key_press;
|
2006-09-12 19:36:05 +00:00
|
|
|
tool_class->active_modifier_key = gimp_blend_tool_active_modifier_key;
|
|
|
|
tool_class->cursor_update = gimp_blend_tool_cursor_update;
|
2014-06-24 14:23:55 -04:00
|
|
|
tool_class->options_notify = gimp_blend_tool_options_notify;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-09-12 19:36:05 +00:00
|
|
|
draw_tool_class->draw = gimp_blend_tool_draw;
|
2001-03-11 20:01:14 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-03-11 20:01:14 +00:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_init (GimpBlendTool *blend_tool)
|
|
|
|
{
|
2005-03-04 11:42:46 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
2002-02-04 17:43:01 +00:00
|
|
|
|
2005-03-04 19:05:40 +00:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
2009-02-20 16:57:26 +00:00
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
GIMP_CURSOR_PRECISION_SUBPIXEL);
|
2005-03-04 19:05:40 +00:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_TOOL_CURSOR_BLEND);
|
2014-04-19 20:09:39 +02:00
|
|
|
gimp_tool_control_set_action_opacity (tool->control,
|
2005-03-04 19:05:40 +00:00
|
|
|
"context/context-opacity-set");
|
|
|
|
gimp_tool_control_set_action_object_1 (tool->control,
|
|
|
|
"context/context-gradient-select-set");
|
2001-03-11 20:01:14 +00:00
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-09-26 20:55:40 +00:00
|
|
|
static gboolean
|
|
|
|
gimp_blend_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error)
|
|
|
|
{
|
2011-04-03 00:32:59 +02:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
|
2006-09-26 20:55:40 +00:00
|
|
|
|
|
|
|
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-28 20:07:14 +02:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
2009-09-03 14:57:18 +02:00
|
|
|
_("Cannot modify the pixels of layer groups."));
|
2009-08-28 20:07:14 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-29 15:27:04 +02:00
|
|
|
if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
|
2009-08-20 17:05:23 +02:00
|
|
|
{
|
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("The active layer's pixels are locked."));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-04-24 16:27:12 +02:00
|
|
|
if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("The active layer is not visible."));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-04-03 00:32:59 +02:00
|
|
|
if (! gimp_context_get_gradient (GIMP_CONTEXT (options)))
|
|
|
|
{
|
|
|
|
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
_("No gradient available for use with this tool."));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-09-26 20:55:40 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (object);
|
|
|
|
gimp_blend_tool_set_gradient (blend_tool, NULL);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_blend_tool_halt_preview (blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
gimp_blend_tool_commit (blend_tool);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
|
|
|
|
|
|
|
blend_tool->mouse_x = coords->x;
|
|
|
|
blend_tool->mouse_y = coords->y;
|
2014-10-18 19:05:56 -04:00
|
|
|
|
|
|
|
gimp_blend_tool_update_item_hilight (blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2009-06-20 17:37:31 +02:00
|
|
|
gimp_blend_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2005-03-04 11:42:46 +00:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2014-06-08 15:10:20 -04:00
|
|
|
blend_tool->mouse_x = coords->x;
|
|
|
|
blend_tool->mouse_y = coords->y;
|
2001-11-09 16:54:56 +00:00
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
if (tool->display && display != tool->display)
|
|
|
|
{
|
|
|
|
gimp_tool_pop_status (tool, tool->display);
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_blend_tool_halt_preview (blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
}
|
|
|
|
|
2014-06-24 20:27:58 -04:00
|
|
|
blend_tool->grabbed_point = gimp_blend_tool_get_point_under_cursor (blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
|
2014-06-24 20:27:58 -04:00
|
|
|
if (blend_tool->grabbed_point == POINT_NONE)
|
|
|
|
{
|
2014-10-18 19:05:56 -04:00
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
|
2014-08-04 17:17:01 -04:00
|
|
|
{
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
|
|
|
|
}
|
2015-04-26 21:38:11 -04:00
|
|
|
else if (gimp_blend_tool_is_shapeburst (blend_tool))
|
2014-08-04 12:28:21 -04:00
|
|
|
{
|
|
|
|
blend_tool->grabbed_point = POINT_FILL_MODE;
|
2015-04-26 21:38:11 -04:00
|
|
|
|
|
|
|
blend_tool->start_x = coords->x;/*XXX*/
|
|
|
|
blend_tool->start_y = coords->y;
|
2014-08-04 12:28:21 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-04 17:17:01 -04:00
|
|
|
blend_tool->grabbed_point = POINT_INIT_MODE;
|
2014-06-07 23:18:29 -04:00
|
|
|
|
2014-08-04 12:28:21 -04:00
|
|
|
blend_tool->start_x = coords->x;
|
|
|
|
blend_tool->start_y = coords->y;
|
|
|
|
}
|
2014-06-07 23:18:29 -04:00
|
|
|
}
|
|
|
|
|
2014-06-24 20:27:58 -04:00
|
|
|
gimp_blend_tool_point_motion (blend_tool,
|
|
|
|
state & gimp_get_constrain_behavior_mask ());
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
tool->display = display;
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_blend_tool_update_items (blend_tool);
|
2002-03-29 03:50:29 +00:00
|
|
|
|
2014-08-04 17:17:01 -04:00
|
|
|
if (blend_tool->grabbed_point != POINT_FILL_MODE &&
|
|
|
|
blend_tool->grabbed_point != POINT_INIT_MODE)
|
2014-08-04 12:28:21 -04:00
|
|
|
{
|
|
|
|
gimp_blend_tool_update_preview_coords (blend_tool);
|
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
|
|
|
}
|
2014-06-20 11:28:01 -04:00
|
|
|
|
2002-05-03 11:31:08 +00:00
|
|
|
gimp_tool_control_activate (tool->control);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2007-01-21 01:24:51 +00:00
|
|
|
gimp_blend_tool_push_status (blend_tool, state, display);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-27 18:55:12 +00:00
|
|
|
gimp_blend_tool_button_release (GimpTool *tool,
|
2008-11-01 15:17:36 +00:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 18:55:12 +00:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2006-09-05 18:25:31 +00:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2014-06-07 23:18:29 -04:00
|
|
|
/* XXX: Push a useful status message */
|
1998-07-26 21:49:42 +00:00
|
|
|
|
2003-01-03 13:59:23 +00:00
|
|
|
gimp_tool_control_halt (tool->control);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
/* XXX: handle cancel properly */
|
|
|
|
/* if (release_type == GIMP_BUTTON_RELEASE_CANCEL) */
|
2014-08-04 12:28:21 -04:00
|
|
|
|
2014-08-04 17:17:01 -04:00
|
|
|
if (blend_tool->grabbed_point == POINT_INIT_MODE)
|
|
|
|
{
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
|
|
|
|
}
|
|
|
|
|
2014-08-04 12:28:21 -04:00
|
|
|
if (blend_tool->grabbed_point == POINT_FILL_MODE)
|
|
|
|
{
|
|
|
|
/* XXX: Temporary, until the handles are working properly for shapebursts */
|
2015-04-26 21:38:11 -04:00
|
|
|
/*gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);*/
|
|
|
|
gimp_blend_tool_precalc_shapeburst (blend_tool);
|
|
|
|
gimp_blend_tool_start_preview (blend_tool, display);
|
2014-08-04 12:28:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
blend_tool->grabbed_point = POINT_NONE;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 15:17:36 +00:00
|
|
|
gimp_blend_tool_motion (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2005-03-04 11:42:46 +00:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2014-06-08 15:10:20 -04:00
|
|
|
/* Save the mouse coordinates from last call */
|
2014-10-18 19:05:56 -04:00
|
|
|
gdouble last_x = blend_tool->mouse_x;
|
|
|
|
gdouble last_y = blend_tool->mouse_y;
|
2014-06-08 15:10:20 -04:00
|
|
|
|
2007-03-08 18:07:38 +00:00
|
|
|
blend_tool->mouse_x = coords->x;
|
|
|
|
blend_tool->mouse_y = coords->y;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2014-08-04 17:17:01 -04:00
|
|
|
if (blend_tool->grabbed_point == POINT_INIT_MODE)
|
|
|
|
{
|
|
|
|
blend_tool->grabbed_point = POINT_END;
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_blend_tool_start_preview (blend_tool, display);
|
2014-08-04 17:17:01 -04:00
|
|
|
}
|
|
|
|
|
2007-03-08 18:07:38 +00:00
|
|
|
/* Move the whole line if alt is pressed */
|
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
2014-06-08 15:10:20 -04:00
|
|
|
gdouble dx = last_x - coords->x;
|
|
|
|
gdouble dy = last_y - coords->y;
|
2006-09-12 19:36:05 +00:00
|
|
|
|
2007-03-08 18:07:38 +00:00
|
|
|
blend_tool->start_x -= dx;
|
|
|
|
blend_tool->start_y -= dy;
|
|
|
|
|
|
|
|
blend_tool->end_x -= dx;
|
|
|
|
blend_tool->end_y -= dy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-06-07 23:18:29 -04:00
|
|
|
gimp_blend_tool_point_motion (blend_tool,
|
|
|
|
state & gimp_get_constrain_behavior_mask ());
|
1999-09-21 09:11:42 +00:00
|
|
|
}
|
1999-07-26 18:13:10 +00:00
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2007-01-21 01:24:51 +00:00
|
|
|
gimp_blend_tool_push_status (blend_tool, state, display);
|
1998-07-26 21:49:42 +00:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_blend_tool_update_items (blend_tool);
|
2014-06-20 11:28:01 -04:00
|
|
|
|
|
|
|
gimp_blend_tool_update_preview_coords (blend_tool);
|
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2006-09-12 19:36:05 +00:00
|
|
|
static void
|
2014-06-07 23:18:29 -04:00
|
|
|
gimp_blend_tool_point_motion (GimpBlendTool *blend_tool,
|
2014-06-24 20:27:58 -04:00
|
|
|
gboolean constrain_angle)
|
2006-09-12 19:36:05 +00:00
|
|
|
{
|
2014-06-07 23:18:29 -04:00
|
|
|
switch (blend_tool->grabbed_point)
|
2006-09-12 19:36:05 +00:00
|
|
|
{
|
2014-06-07 23:18:29 -04:00
|
|
|
case POINT_START:
|
|
|
|
blend_tool->start_x = blend_tool->mouse_x;
|
|
|
|
blend_tool->start_y = blend_tool->mouse_y;
|
|
|
|
|
|
|
|
/* Restrict to multiples of 15 degrees if ctrl is pressed */
|
|
|
|
if (constrain_angle)
|
|
|
|
{
|
|
|
|
gimp_constrain_line (blend_tool->end_x, blend_tool->end_y,
|
|
|
|
&blend_tool->start_x, &blend_tool->start_y,
|
|
|
|
GIMP_CONSTRAIN_LINE_15_DEGREES);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case POINT_END:
|
2007-03-08 18:07:38 +00:00
|
|
|
blend_tool->end_x = blend_tool->mouse_x;
|
|
|
|
blend_tool->end_y = blend_tool->mouse_y;
|
2006-09-12 19:36:05 +00:00
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
if (constrain_angle)
|
2006-09-12 19:36:05 +00:00
|
|
|
{
|
2009-04-22 21:08:42 +02:00
|
|
|
gimp_constrain_line (blend_tool->start_x, blend_tool->start_y,
|
|
|
|
&blend_tool->end_x, &blend_tool->end_y,
|
|
|
|
GIMP_CONSTRAIN_LINE_15_DEGREES);
|
2006-09-12 19:36:05 +00:00
|
|
|
}
|
2014-06-07 23:18:29 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_blend_tool_key_press (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
switch (kevent->keyval)
|
|
|
|
{
|
|
|
|
case GDK_KEY_BackSpace:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case GDK_KEY_Return:
|
|
|
|
case GDK_KEY_KP_Enter:
|
|
|
|
case GDK_KEY_ISO_Enter:
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_COMMIT, display);
|
|
|
|
/* fall thru */
|
|
|
|
|
|
|
|
case GDK_KEY_Escape:
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_active_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
|
|
|
|
|
|
|
if (key == gimp_get_constrain_behavior_mask ())
|
|
|
|
{
|
|
|
|
gimp_blend_tool_point_motion (blend_tool, press);
|
2006-09-12 19:36:05 +00:00
|
|
|
|
2006-09-13 10:06:49 +00:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2007-01-21 01:24:51 +00:00
|
|
|
gimp_blend_tool_push_status (blend_tool, state, display);
|
2006-09-13 10:06:49 +00:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_blend_tool_update_items (blend_tool);
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
gimp_blend_tool_update_preview_coords (blend_tool);
|
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
2006-09-12 19:36:05 +00:00
|
|
|
}
|
2011-10-07 01:25:15 +02:00
|
|
|
else if (key == GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
gimp_tool_pop_status (tool, display);
|
|
|
|
gimp_blend_tool_push_status (blend_tool, state, display);
|
|
|
|
}
|
2006-09-12 19:36:05 +00:00
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2008-11-01 15:17:36 +00:00
|
|
|
gimp_blend_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2014-06-07 23:18:29 -04:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
|
|
|
|
blend_tool->mouse_x = coords->x;
|
|
|
|
blend_tool->mouse_y = coords->y;
|
2009-08-21 19:34:59 +02:00
|
|
|
|
2012-04-30 01:04:19 +02:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
|
2013-04-24 16:27:12 +02:00
|
|
|
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
|
|
|
|
! gimp_item_is_visible (GIMP_ITEM (drawable)))
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2009-08-21 19:34:59 +02:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BAD;
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2014-08-04 12:28:21 -04:00
|
|
|
else if (gimp_blend_tool_is_shapeburst (blend_tool))
|
|
|
|
{
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_PLUS;
|
|
|
|
}
|
2014-06-07 23:18:29 -04:00
|
|
|
else if (gimp_blend_tool_get_point_under_cursor (blend_tool))
|
|
|
|
{
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
|
|
|
}
|
2002-02-04 17:43:01 +00:00
|
|
|
|
2009-08-21 19:34:59 +02:00
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-03-11 20:01:14 +00:00
|
|
|
gimp_blend_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2014-10-18 19:05:56 -04:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (draw_tool);
|
|
|
|
|
|
|
|
blend_tool->line =
|
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
|
|
|
|
gimp_canvas_item_set_visible (blend_tool->line, SHOW_LINE);
|
|
|
|
|
|
|
|
blend_tool->start_handle_circle =
|
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CIRCLE,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y,
|
|
|
|
HANDLE_DIAMETER,
|
|
|
|
HANDLE_DIAMETER,
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
|
|
|
|
|
|
|
blend_tool->start_handle_cross =
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y,
|
|
|
|
HANDLE_CROSS_DIAMETER,
|
|
|
|
HANDLE_CROSS_DIAMETER,
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
blend_tool->end_handle_circle =
|
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CIRCLE,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y,
|
|
|
|
HANDLE_DIAMETER,
|
|
|
|
HANDLE_DIAMETER,
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
|
|
|
|
|
|
|
blend_tool->end_handle_cross =
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
GIMP_HANDLE_CROSS,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y,
|
|
|
|
HANDLE_CROSS_DIAMETER,
|
|
|
|
HANDLE_CROSS_DIAMETER,
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
2014-04-12 22:10:26 +02:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_blend_tool_update_item_hilight (blend_tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_update_items (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
|
2011-03-28 11:08:40 +02:00
|
|
|
{
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_canvas_line_set (blend_tool->line,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
|
|
|
|
gimp_canvas_handle_set_position (blend_tool->start_handle_circle,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y);
|
|
|
|
|
|
|
|
gimp_canvas_handle_set_position (blend_tool->start_handle_cross,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y);
|
|
|
|
|
|
|
|
gimp_canvas_handle_set_position (blend_tool->end_handle_circle,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
|
|
|
|
gimp_canvas_handle_set_position (blend_tool->end_handle_cross,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
|
|
|
|
gimp_blend_tool_update_item_hilight (blend_tool);
|
2014-06-07 23:18:29 -04:00
|
|
|
}
|
2014-10-18 19:05:56 -04:00
|
|
|
}
|
|
|
|
|
2014-10-18 21:03:33 -04:00
|
|
|
static gint
|
|
|
|
calc_handle_diameter (gdouble distance)
|
|
|
|
{
|
|
|
|
/* Calculate the handle size based on distance from the cursor */
|
|
|
|
gdouble size = 1.0 - (distance - FULL_HANDLE_THRESHOLD_SQ) /
|
|
|
|
(PARTIAL_HANDLE_THRESHOLD_SQ - FULL_HANDLE_THRESHOLD_SQ);
|
|
|
|
|
|
|
|
if (size > 1.0) size = 1.0;
|
|
|
|
else if (size < 0.0) size = 0.0;
|
|
|
|
|
|
|
|
return (gint)(size * HANDLE_DIAMETER);
|
|
|
|
}
|
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_update_item_hilight (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool);
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
2014-06-07 23:18:29 -04:00
|
|
|
{
|
2014-10-18 19:05:56 -04:00
|
|
|
GimpBlendToolPoint hilight_point;
|
2014-10-18 21:03:33 -04:00
|
|
|
gboolean start_visible, end_visible;
|
|
|
|
gint start_diameter, end_diameter;
|
2014-06-26 12:57:06 -04:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
/* Calculate handle visibility */
|
|
|
|
if (blend_tool->grabbed_point)
|
|
|
|
{
|
|
|
|
start_visible = FALSE;
|
|
|
|
end_visible = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gdouble dist;
|
|
|
|
dist = gimp_draw_tool_calc_distance_square (draw_tool,
|
|
|
|
draw_tool->display,
|
|
|
|
blend_tool->mouse_x,
|
|
|
|
blend_tool->mouse_y,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y);
|
|
|
|
|
2014-10-18 21:03:33 -04:00
|
|
|
start_diameter = calc_handle_diameter (dist);
|
|
|
|
start_visible = start_diameter > 2;
|
2014-10-18 19:05:56 -04:00
|
|
|
|
|
|
|
dist = gimp_draw_tool_calc_distance_square (draw_tool,
|
|
|
|
draw_tool->display,
|
|
|
|
blend_tool->mouse_x,
|
|
|
|
blend_tool->mouse_y,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
|
2014-10-18 21:03:33 -04:00
|
|
|
end_diameter = calc_handle_diameter (dist);
|
|
|
|
end_visible = end_diameter > 2;
|
2014-10-18 19:05:56 -04:00
|
|
|
}
|
2014-06-07 23:18:29 -04:00
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_canvas_item_set_visible (blend_tool->start_handle_circle,
|
|
|
|
start_visible);
|
|
|
|
gimp_canvas_item_set_visible (blend_tool->end_handle_circle,
|
|
|
|
end_visible);
|
|
|
|
|
|
|
|
/* Update hilights */
|
|
|
|
if (blend_tool->grabbed_point)
|
|
|
|
hilight_point = blend_tool->grabbed_point;
|
|
|
|
else
|
|
|
|
hilight_point = gimp_blend_tool_get_point_under_cursor (blend_tool);
|
|
|
|
|
2014-10-18 21:03:33 -04:00
|
|
|
if (start_visible)
|
|
|
|
{
|
|
|
|
gimp_canvas_item_begin_change (blend_tool->start_handle_circle);
|
|
|
|
g_object_set (blend_tool->start_handle_circle,
|
|
|
|
"width", start_diameter,
|
|
|
|
"height", start_diameter,
|
|
|
|
NULL);
|
|
|
|
gimp_canvas_item_end_change (blend_tool->start_handle_circle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (end_visible)
|
|
|
|
{
|
|
|
|
gimp_canvas_item_begin_change (blend_tool->end_handle_circle);
|
|
|
|
g_object_set (blend_tool->end_handle_circle,
|
|
|
|
"width", end_diameter,
|
|
|
|
"height", end_diameter,
|
|
|
|
NULL);
|
|
|
|
gimp_canvas_item_end_change (blend_tool->end_handle_circle);
|
|
|
|
}
|
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_canvas_item_set_highlight (blend_tool->start_handle_circle,
|
|
|
|
hilight_point == POINT_START);
|
|
|
|
gimp_canvas_item_set_highlight (blend_tool->start_handle_cross,
|
2014-06-26 12:57:06 -04:00
|
|
|
hilight_point == POINT_START);
|
|
|
|
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_canvas_item_set_highlight (blend_tool->end_handle_circle,
|
2014-06-07 23:18:29 -04:00
|
|
|
hilight_point == POINT_END);
|
2014-10-18 19:05:56 -04:00
|
|
|
gimp_canvas_item_set_highlight (blend_tool->end_handle_cross,
|
|
|
|
hilight_point == POINT_END);
|
|
|
|
}
|
2014-06-07 23:18:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static GimpBlendToolPoint
|
|
|
|
gimp_blend_tool_get_point_under_cursor (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (blend_tool);
|
|
|
|
gdouble dist;
|
|
|
|
|
|
|
|
if (!draw_tool->display)
|
|
|
|
return POINT_NONE;
|
|
|
|
|
|
|
|
/* Check the points in the reverse order of drawing */
|
|
|
|
|
|
|
|
/* Check end point */
|
|
|
|
dist = gimp_draw_tool_calc_distance_square (draw_tool,
|
|
|
|
draw_tool->display,
|
|
|
|
blend_tool->mouse_x,
|
|
|
|
blend_tool->mouse_y,
|
|
|
|
blend_tool->end_x,
|
|
|
|
blend_tool->end_y);
|
|
|
|
if (dist < POINT_GRAB_THRESHOLD_SQ)
|
|
|
|
return POINT_END;
|
|
|
|
|
|
|
|
/* Check start point */
|
|
|
|
dist = gimp_draw_tool_calc_distance_square (draw_tool,
|
|
|
|
draw_tool->display,
|
|
|
|
blend_tool->mouse_x,
|
|
|
|
blend_tool->mouse_y,
|
|
|
|
blend_tool->start_x,
|
|
|
|
blend_tool->start_y);
|
|
|
|
if (dist < POINT_GRAB_THRESHOLD_SQ)
|
|
|
|
return POINT_START;
|
|
|
|
|
|
|
|
/* No point found */
|
|
|
|
return POINT_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_blend_tool_start_preview (GimpBlendTool *blend_tool,
|
|
|
|
GimpDisplay *display)
|
2014-06-07 23:18:29 -04:00
|
|
|
{
|
2014-06-24 14:23:55 -04:00
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
2014-06-28 22:53:38 -04:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
2014-06-07 23:18:29 -04:00
|
|
|
|
|
|
|
tool->display = display;
|
|
|
|
tool->drawable = drawable;
|
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
gimp_blend_tool_create_image_map (blend_tool, drawable);
|
2014-06-20 11:28:01 -04:00
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
/* Initially sync all of the properties */
|
|
|
|
gimp_gegl_config_sync_node (GIMP_OBJECT (options), blend_tool->render_node);
|
2014-06-24 14:23:55 -04:00
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
/* Connect signal handlers for the gradient */
|
|
|
|
gimp_blend_tool_set_gradient (blend_tool, context->gradient);
|
2014-06-28 22:53:38 -04:00
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
|
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (blend_tool), display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-09-02 18:49:41 -04:00
|
|
|
gimp_blend_tool_halt_preview (GimpBlendTool *blend_tool)
|
2014-06-07 23:18:29 -04:00
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
if (blend_tool->graph)
|
|
|
|
{
|
|
|
|
g_object_unref (blend_tool->graph);
|
2015-04-26 21:38:11 -04:00
|
|
|
blend_tool->graph = NULL;
|
|
|
|
|
|
|
|
blend_tool->render_node = NULL;
|
|
|
|
blend_tool->subtract_node = NULL;
|
|
|
|
blend_tool->divide_node = NULL;
|
|
|
|
blend_tool->dist_node = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (blend_tool->dist_buffer)
|
|
|
|
{
|
|
|
|
g_object_unref (blend_tool->dist_buffer);
|
|
|
|
blend_tool->dist_buffer = NULL;
|
2014-06-20 11:28:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (blend_tool->image_map)
|
|
|
|
{
|
|
|
|
gimp_image_map_abort (blend_tool->image_map);
|
|
|
|
g_object_unref (blend_tool->image_map);
|
|
|
|
blend_tool->image_map = NULL;
|
|
|
|
|
|
|
|
gimp_image_flush (gimp_display_get_image (tool->display));
|
|
|
|
}
|
|
|
|
|
2014-06-07 23:18:29 -04:00
|
|
|
tool->display = NULL;
|
|
|
|
tool->drawable = NULL;
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
|
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (blend_tool));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_commit (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
|
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool);
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
GimpImage *image = gimp_display_get_image (tool->display);
|
2014-08-04 12:28:21 -04:00
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
GimpProgress *progress;
|
|
|
|
gint off_x;
|
|
|
|
gint off_y;
|
|
|
|
|
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (tool), FALSE,
|
|
|
|
_("Blending"));
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
|
|
|
|
|
|
gimp_drawable_blend (drawable,
|
|
|
|
context,
|
|
|
|
gimp_context_get_gradient (context),
|
|
|
|
gimp_context_get_paint_mode (context),
|
|
|
|
options->gradient_type,
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
options->offset,
|
|
|
|
paint_options->gradient_options->gradient_repeat,
|
|
|
|
paint_options->gradient_options->gradient_reverse,
|
|
|
|
options->supersample,
|
|
|
|
options->supersample_depth,
|
|
|
|
options->supersample_threshold,
|
|
|
|
options->dither,
|
|
|
|
blend_tool->start_x - off_x,
|
|
|
|
blend_tool->start_y - off_y,
|
|
|
|
blend_tool->end_x - off_x,
|
|
|
|
blend_tool->end_y - off_y,
|
|
|
|
progress);
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
2006-09-13 10:06:49 +00:00
|
|
|
|
|
|
|
static void
|
2007-01-21 01:24:51 +00:00
|
|
|
gimp_blend_tool_push_status (GimpBlendTool *blend_tool,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2006-09-13 10:06:49 +00:00
|
|
|
{
|
2008-08-20 16:22:09 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
gchar *status_help;
|
2007-01-21 01:24:51 +00:00
|
|
|
|
|
|
|
status_help = gimp_suggest_modifiers ("",
|
2011-10-06 21:59:07 +02:00
|
|
|
(gimp_get_constrain_behavior_mask () |
|
|
|
|
GDK_MOD1_MASK) &
|
|
|
|
~state,
|
2007-01-21 01:24:51 +00:00
|
|
|
NULL,
|
|
|
|
_("%s for constrained angles"),
|
2007-03-08 23:33:55 +00:00
|
|
|
_("%s to move the whole line"));
|
2008-08-20 16:22:09 +00:00
|
|
|
|
|
|
|
gimp_tool_push_status_coords (tool, display,
|
|
|
|
gimp_tool_control_get_precision (tool->control),
|
2006-09-13 10:06:49 +00:00
|
|
|
_("Blend: "),
|
2007-03-08 18:07:38 +00:00
|
|
|
blend_tool->end_x - blend_tool->start_x,
|
2006-09-13 10:06:49 +00:00
|
|
|
", ",
|
2007-03-08 18:07:38 +00:00
|
|
|
blend_tool->end_y - blend_tool->start_y,
|
2007-01-21 01:24:51 +00:00
|
|
|
status_help);
|
2008-08-20 16:22:09 +00:00
|
|
|
|
2007-01-21 01:24:51 +00:00
|
|
|
g_free (status_help);
|
2006-09-13 10:06:49 +00:00
|
|
|
}
|
2014-06-20 11:28:01 -04:00
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_precalc_shapeburst (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (tool->display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
GeglBuffer *buf = NULL;
|
|
|
|
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
|
|
|
if (blend_tool->dist_buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable), &x, &y, &width, &height))
|
|
|
|
return;
|
|
|
|
|
|
|
|
buf = gimp_drawable_blend_shapeburst_distmap (drawable, FALSE,
|
2015-05-11 21:41:16 -04:00
|
|
|
GEGL_RECTANGLE (x, y, width, height),
|
2015-04-26 21:38:11 -04:00
|
|
|
GIMP_PROGRESS (blend_tool));
|
|
|
|
|
|
|
|
blend_tool->dist_buffer = buf;
|
|
|
|
|
|
|
|
if (blend_tool->dist_node)
|
|
|
|
gegl_node_set (blend_tool->dist_node,
|
|
|
|
"buffer", blend_tool->dist_buffer,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
/* gegl graph stuff */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_create_graph (GimpBlendTool *blend_tool)
|
|
|
|
{
|
2014-06-29 20:40:47 -04:00
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
2015-05-11 21:41:16 -04:00
|
|
|
GeglNode *graph, *output, *render, *shapeburst, *subtract, *divide;
|
2014-06-20 11:28:01 -04:00
|
|
|
|
|
|
|
/* render_node is not supposed to be recreated */
|
|
|
|
g_return_if_fail (blend_tool->graph == NULL);
|
|
|
|
|
|
|
|
graph = gegl_node_new ();
|
|
|
|
|
|
|
|
output = gegl_node_get_output_proxy (graph, "output");
|
|
|
|
|
|
|
|
|
|
|
|
render = gegl_node_new_child (graph,
|
|
|
|
"operation", "gimp:blend",
|
2015-04-26 21:38:11 -04:00
|
|
|
"context", context,
|
2014-06-20 11:28:01 -04:00
|
|
|
NULL);
|
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
subtract = gegl_node_new_child (graph, "operation", "gegl:subtract", NULL);
|
|
|
|
divide = gegl_node_new_child (graph, "operation", "gegl:divide", NULL);
|
2014-06-29 20:40:47 -04:00
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
shapeburst = gegl_node_new_child (graph, "operation", "gegl:buffer-source",
|
|
|
|
"buffer", blend_tool->dist_buffer, NULL);
|
|
|
|
|
2015-05-11 21:41:16 -04:00
|
|
|
gegl_node_link_many (shapeburst, subtract, divide, render, output, NULL);
|
2015-04-26 21:38:11 -04:00
|
|
|
|
|
|
|
blend_tool->graph = graph;
|
|
|
|
blend_tool->render_node = render;
|
|
|
|
blend_tool->subtract_node = subtract;
|
|
|
|
blend_tool->divide_node = divide;
|
|
|
|
blend_tool->dist_node = shapeburst;
|
|
|
|
|
|
|
|
gimp_blend_tool_update_preview_coords (blend_tool);
|
2014-06-20 11:28:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool)
|
|
|
|
{
|
2014-07-22 17:39:58 -04:00
|
|
|
GimpTool *tool = GIMP_TOOL (blend_tool);
|
|
|
|
|
2015-05-11 21:41:16 -04:00
|
|
|
gint off_x, off_y;
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (tool->drawable), &off_x, &off_y);
|
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
if (gimp_blend_tool_is_shapeburst (blend_tool))
|
|
|
|
{
|
|
|
|
gfloat start, end;
|
|
|
|
|
|
|
|
gegl_buffer_get (blend_tool->dist_buffer,
|
2015-05-11 21:41:16 -04:00
|
|
|
GEGL_RECTANGLE (blend_tool->start_x - off_x,
|
|
|
|
blend_tool->start_y - off_y,
|
2015-04-26 21:38:11 -04:00
|
|
|
1, 1),
|
|
|
|
1.0, babl_format("Y float"), &start,
|
|
|
|
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
|
|
|
|
|
|
gegl_buffer_get (blend_tool->dist_buffer,
|
2015-05-11 21:41:16 -04:00
|
|
|
GEGL_RECTANGLE (blend_tool->end_x - off_x,
|
|
|
|
blend_tool->end_y - off_y,
|
2015-04-26 21:38:11 -04:00
|
|
|
1, 1),
|
|
|
|
1.0, babl_format("Y float"), &end,
|
|
|
|
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
|
|
|
|
|
|
if (start != end) {
|
|
|
|
gegl_node_set (blend_tool->subtract_node,
|
|
|
|
"value", (gdouble) start,
|
|
|
|
NULL);
|
|
|
|
gegl_node_set (blend_tool->divide_node,
|
|
|
|
"value", (gdouble) (end - start),
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gegl_node_set (blend_tool->render_node,
|
|
|
|
"start_x", blend_tool->start_x - off_x,
|
|
|
|
"start_y", blend_tool->start_y - off_y,
|
|
|
|
"end_x", blend_tool->end_x - off_x,
|
|
|
|
"end_y", blend_tool->end_y - off_y,
|
|
|
|
NULL);
|
|
|
|
}
|
2014-06-20 11:28:01 -04:00
|
|
|
}
|
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
static void
|
2014-06-29 20:40:47 -04:00
|
|
|
gimp_blend_tool_gradient_dirty (GimpBlendTool *blend_tool)
|
2014-06-28 22:53:38 -04:00
|
|
|
{
|
|
|
|
if (!blend_tool->image_map)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Set a property on the node. Otherwise it will cache and refuse to update */
|
|
|
|
gegl_node_set (blend_tool->render_node,
|
|
|
|
"gradient", blend_tool->gradient,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Update the image_map */
|
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_set_gradient (GimpBlendTool *blend_tool,
|
|
|
|
GimpGradient *gradient)
|
|
|
|
{
|
2014-06-29 20:40:47 -04:00
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
if (blend_tool->gradient)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (blend_tool->gradient,
|
|
|
|
G_CALLBACK (gimp_blend_tool_gradient_dirty),
|
|
|
|
blend_tool);
|
2014-06-29 20:40:47 -04:00
|
|
|
g_signal_handlers_disconnect_by_func (context,
|
|
|
|
G_CALLBACK (gimp_blend_tool_gradient_dirty),
|
|
|
|
blend_tool);
|
2014-06-28 22:53:38 -04:00
|
|
|
g_object_unref (blend_tool->gradient);
|
|
|
|
blend_tool->gradient = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gradient)
|
|
|
|
{
|
|
|
|
blend_tool->gradient = g_object_ref (gradient);
|
2014-06-29 20:40:47 -04:00
|
|
|
g_signal_connect_swapped (blend_tool->gradient, "dirty",
|
|
|
|
G_CALLBACK (gimp_blend_tool_gradient_dirty),
|
|
|
|
blend_tool);
|
|
|
|
|
|
|
|
if (gimp_gradient_has_fg_bg_segments (blend_tool->gradient))
|
|
|
|
{
|
|
|
|
g_signal_connect_swapped (context, "background-changed",
|
|
|
|
G_CALLBACK (gimp_blend_tool_gradient_dirty),
|
|
|
|
blend_tool);
|
|
|
|
g_signal_connect_swapped (context, "foreground-changed",
|
|
|
|
G_CALLBACK (gimp_blend_tool_gradient_dirty),
|
|
|
|
blend_tool);
|
|
|
|
}
|
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
if (blend_tool->render_node)
|
|
|
|
gegl_node_set (blend_tool->render_node,
|
|
|
|
"gradient", blend_tool->gradient,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 14:23:55 -04:00
|
|
|
static void
|
|
|
|
gimp_blend_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
2014-06-24 15:17:45 -04:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
2014-06-24 14:23:55 -04:00
|
|
|
GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
|
|
|
|
|
2014-06-28 22:53:38 -04:00
|
|
|
if (! strcmp (pspec->name, "gradient"))
|
|
|
|
{
|
|
|
|
gimp_blend_tool_set_gradient (blend_tool, context->gradient);
|
|
|
|
|
|
|
|
if (blend_tool->image_map)
|
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
|
|
|
}
|
|
|
|
else if (blend_tool->render_node &&
|
|
|
|
gegl_node_find_property (blend_tool->render_node, pspec->name))
|
2014-06-24 14:23:55 -04:00
|
|
|
{
|
2014-06-28 22:53:38 -04:00
|
|
|
/* Sync any property changes on the config object that match the op */
|
2014-06-24 14:23:55 -04:00
|
|
|
GValue value = G_VALUE_INIT;
|
|
|
|
g_value_init (&value, pspec->value_type);
|
|
|
|
|
|
|
|
g_object_get_property (G_OBJECT (options), pspec->name, &value);
|
|
|
|
gegl_node_set_property (blend_tool->render_node, pspec->name, &value);
|
|
|
|
|
|
|
|
g_value_unset (&value);
|
|
|
|
|
2015-04-26 21:38:11 -04:00
|
|
|
if (! strcmp (pspec->name, "gradient-type"))
|
|
|
|
{
|
|
|
|
if (gimp_blend_tool_is_shapeburst (blend_tool))
|
|
|
|
gimp_blend_tool_precalc_shapeburst (blend_tool);
|
|
|
|
|
|
|
|
gimp_blend_tool_update_preview_coords (blend_tool);
|
|
|
|
}
|
|
|
|
|
2014-06-24 15:17:45 -04:00
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
|
|
|
}
|
|
|
|
else if (blend_tool->image_map &&
|
|
|
|
(! strcmp (pspec->name, "opacity") ||
|
|
|
|
! strcmp (pspec->name, "paint-mode")))
|
|
|
|
{
|
|
|
|
gimp_image_map_set_mode (blend_tool->image_map,
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_context_get_paint_mode (context));
|
|
|
|
|
2014-06-24 14:23:55 -04:00
|
|
|
gimp_image_map_apply (blend_tool->image_map, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-04 12:28:21 -04:00
|
|
|
static gboolean
|
|
|
|
gimp_blend_tool_is_shapeburst (GimpBlendTool *blend_tool)
|
|
|
|
{
|
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
|
|
|
|
|
|
|
return options->gradient_type >= GIMP_GRADIENT_SHAPEBURST_ANGULAR &&
|
|
|
|
options->gradient_type <= GIMP_GRADIENT_SHAPEBURST_DIMPLED;
|
|
|
|
}
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
/* Image map stuff */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
2014-06-24 15:17:45 -04:00
|
|
|
GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
|
2014-06-20 11:28:01 -04:00
|
|
|
if (! blend_tool->graph)
|
|
|
|
gimp_blend_tool_create_graph (blend_tool);
|
|
|
|
|
|
|
|
blend_tool->image_map = gimp_image_map_new (drawable,
|
|
|
|
C_("undo-type", "Blend"),
|
|
|
|
blend_tool->graph,
|
|
|
|
GIMP_STOCK_TOOL_BLEND);
|
|
|
|
|
|
|
|
gimp_image_map_set_region (blend_tool->image_map,
|
|
|
|
GIMP_IMAGE_MAP_REGION_DRAWABLE);
|
|
|
|
|
|
|
|
g_signal_connect (blend_tool->image_map, "flush",
|
|
|
|
G_CALLBACK (gimp_blend_tool_image_map_flush),
|
|
|
|
blend_tool);
|
2014-06-24 15:17:45 -04:00
|
|
|
|
|
|
|
gimp_image_map_set_mode (blend_tool->image_map,
|
|
|
|
gimp_context_get_opacity (context),
|
|
|
|
gimp_context_get_paint_mode (context));
|
2014-06-20 11:28:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_tool_image_map_flush (GimpImageMap *image_map,
|
|
|
|
GimpTool *tool)
|
|
|
|
{
|
|
|
|
GimpImage *image = gimp_display_get_image (tool->display);
|
|
|
|
|
|
|
|
gimp_projection_flush (gimp_image_get_projection (image));
|
|
|
|
}
|