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
|
|
|
|
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 13:30:56 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-29 07:22:01 -08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2010-02-21 07:46:39 -08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2007-03-09 05:00:01 -08: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
|
|
|
|
2014-04-12 03:54:08 -07:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
|
2001-07-07 05:17:23 -07:00
|
|
|
#include "core/gimp.h"
|
2009-04-22 12:08:42 -07:00
|
|
|
#include "core/gimp-utils.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpdrawable.h"
|
2009-08-20 08:05:23 -07:00
|
|
|
#include "core/gimperror.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
#include "core/gimplayer.h"
|
2003-08-30 09:41:35 -07:00
|
|
|
#include "core/gimppaintinfo.h"
|
2004-07-13 09:36:29 -07:00
|
|
|
#include "core/gimpprojection.h"
|
2001-12-01 13:02:34 -08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
|
2002-02-14 11:31:16 -08:00
|
|
|
#include "paint/gimppaintcore.h"
|
2003-02-05 06:39:40 -08:00
|
|
|
#include "paint/gimppaintoptions.h"
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2001-12-07 09:39:51 -08:00
|
|
|
#include "widgets/gimpdevices.h"
|
2006-08-01 16:42:12 -07:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2001-12-07 09:39:51 -08:00
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-10-31 13:20:09 -08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2010-10-09 05:07:04 -07:00
|
|
|
#include "display/gimpdisplayshell-selection.h"
|
2017-12-22 02:56:11 -08:00
|
|
|
#include "display/gimpdisplayshell-utils.h"
|
2001-09-25 16:23:09 -07:00
|
|
|
|
2003-06-05 08:43:49 -07:00
|
|
|
#include "gimpcoloroptions.h"
|
2018-12-10 04:51:39 -08:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2001-03-07 17:07:03 -08:00
|
|
|
#include "gimppainttool.h"
|
2018-04-08 06:28:23 -07:00
|
|
|
#include "gimppainttool-paint.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
2018-12-10 05:22:50 -08:00
|
|
|
#include "gimptools-utils.h"
|
2001-03-07 17:07:03 -08:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-03-04 16:06:11 -08:00
|
|
|
|
1999-09-01 11:46:25 -07:00
|
|
|
|
2011-01-13 01:06:07 -08:00
|
|
|
static void gimp_paint_tool_constructed (GObject *object);
|
2007-02-27 10:55:12 -08:00
|
|
|
static void gimp_paint_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
|
|
static void gimp_paint_tool_control (GimpTool *tool,
|
|
|
|
|
GimpToolAction action,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_paint_tool_button_press (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 10:55:12 -08:00
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
2009-06-20 08:37:31 -07:00
|
|
|
GimpButtonPressType press_type,
|
2007-02-27 10:55:12 -08:00
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_paint_tool_button_release (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 10:55:12 -08:00
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_paint_tool_motion (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 10:55:12 -08:00
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
2009-08-21 10:34:59 -07:00
|
|
|
static void gimp_paint_tool_cursor_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
2007-02-27 10:55:12 -08:00
|
|
|
static void gimp_paint_tool_oper_update (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 10:55:12 -08:00
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
|
|
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2014-04-12 06:03:15 -07:00
|
|
|
static GimpCanvasItem *
|
|
|
|
|
gimp_paint_tool_get_outline (GimpPaintTool *paint_tool,
|
|
|
|
|
GimpDisplay *display,
|
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y);
|
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
static gboolean gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
|
|
|
|
|
GimpDrawable *drawable,
|
2018-12-10 05:22:50 -08:00
|
|
|
GimpDisplay *display,
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
GError **error);
|
|
|
|
|
|
2008-08-20 09:22:09 -07:00
|
|
|
static void gimp_paint_tool_hard_notify (GimpPaintOptions *options,
|
|
|
|
|
const GParamSpec *pspec,
|
2019-01-31 03:15:53 -08:00
|
|
|
GimpPaintTool *paint_tool);
|
2014-04-12 03:54:08 -07:00
|
|
|
static void gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GimpPaintTool *paint_tool);
|
2008-08-20 09:22:09 -07:00
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-05-15 02:46:31 -07:00
|
|
|
G_DEFINE_TYPE (GimpPaintTool, gimp_paint_tool, GIMP_TYPE_COLOR_TOOL)
|
2001-02-27 11:18:01 -08:00
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
#define parent_class gimp_paint_tool_parent_class
|
2001-02-26 21:21:12 -08:00
|
|
|
|
|
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
2001-02-26 21:21:12 -08:00
|
|
|
{
|
2006-05-28 07:13:44 -07:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-02-27 11:18:01 -08:00
|
|
|
|
2011-01-13 01:06:07 -08:00
|
|
|
object_class->constructed = gimp_paint_tool_constructed;
|
2002-02-13 06:50:37 -08:00
|
|
|
object_class->finalize = gimp_paint_tool_finalize;
|
|
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
tool_class->control = gimp_paint_tool_control;
|
2001-02-27 11:18:01 -08:00
|
|
|
tool_class->button_press = gimp_paint_tool_button_press;
|
|
|
|
|
tool_class->button_release = gimp_paint_tool_button_release;
|
|
|
|
|
tool_class->motion = gimp_paint_tool_motion;
|
2003-06-05 08:43:49 -07:00
|
|
|
tool_class->modifier_key = gimp_paint_tool_modifier_key;
|
2009-08-21 10:34:59 -07:00
|
|
|
tool_class->cursor_update = gimp_paint_tool_cursor_update;
|
2003-06-05 08:43:49 -07:00
|
|
|
tool_class->oper_update = gimp_paint_tool_oper_update;
|
2001-02-27 11:18:01 -08:00
|
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_paint_tool_draw;
|
2001-02-26 21:21:12 -08:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2002-02-05 03:35:03 -08:00
|
|
|
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
2001-02-27 11:18:01 -08:00
|
|
|
{
|
2003-06-05 08:43:49 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
2002-02-05 03:35:03 -08:00
|
|
|
|
2008-08-20 09:22:09 -07:00
|
|
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
|
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
2014-04-19 11:09:39 -07:00
|
|
|
gimp_tool_control_set_action_opacity (tool->control,
|
2006-12-03 11:23:50 -08:00
|
|
|
"context/context-opacity-set");
|
2002-06-16 10:13:39 -07:00
|
|
|
|
2019-01-31 03:15:53 -08:00
|
|
|
paint_tool->active = TRUE;
|
2014-04-09 06:24:20 -07:00
|
|
|
paint_tool->pick_colors = FALSE;
|
|
|
|
|
paint_tool->draw_line = FALSE;
|
2014-04-12 03:54:08 -07:00
|
|
|
|
|
|
|
|
paint_tool->show_cursor = TRUE;
|
2014-04-12 06:03:15 -07:00
|
|
|
paint_tool->draw_brush = TRUE;
|
2014-11-18 13:41:09 -08:00
|
|
|
paint_tool->draw_fallback = FALSE;
|
|
|
|
|
paint_tool->fallback_size = 0.0;
|
2014-04-09 06:24:20 -07:00
|
|
|
paint_tool->draw_circle = FALSE;
|
2014-11-18 13:41:09 -08:00
|
|
|
paint_tool->circle_size = 0.0;
|
2003-07-10 09:01:45 -07:00
|
|
|
|
2006-09-11 23:37:54 -07:00
|
|
|
paint_tool->status = _("Click to paint");
|
|
|
|
|
paint_tool->status_line = _("Click to draw the line");
|
2006-08-01 16:42:12 -07:00
|
|
|
paint_tool->status_ctrl = _("%s to pick a color");
|
|
|
|
|
|
2003-08-30 09:41:35 -07:00
|
|
|
paint_tool->core = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-13 01:06:07 -08:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_constructed (GObject *object)
|
2003-08-30 09:41:35 -07:00
|
|
|
{
|
2014-04-12 03:54:08 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (object);
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
|
|
|
|
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
GimpDisplayConfig *display_config;
|
|
|
|
|
GimpPaintInfo *paint_info;
|
2003-08-30 09:41:35 -07:00
|
|
|
|
2012-11-12 12:51:22 -08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2003-08-30 09:41:35 -07:00
|
|
|
|
2018-02-11 13:23:10 -08:00
|
|
|
gimp_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
|
|
|
|
|
gimp_assert (GIMP_IS_PAINT_INFO (tool->tool_info->paint_info));
|
2003-08-30 09:41:35 -07:00
|
|
|
|
2014-04-12 03:54:08 -07:00
|
|
|
display_config = GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config);
|
|
|
|
|
|
2006-09-03 06:16:58 -07:00
|
|
|
paint_info = tool->tool_info->paint_info;
|
|
|
|
|
|
2018-02-11 13:23:10 -08:00
|
|
|
gimp_assert (g_type_is_a (paint_info->paint_type, GIMP_TYPE_PAINT_CORE));
|
2006-09-03 06:16:58 -07:00
|
|
|
|
|
|
|
|
paint_tool->core = g_object_new (paint_info->paint_type,
|
|
|
|
|
"undo-desc", paint_info->blurb,
|
2003-08-30 09:41:35 -07:00
|
|
|
NULL);
|
|
|
|
|
|
2008-08-20 09:22:09 -07:00
|
|
|
g_signal_connect_object (options, "notify::hard",
|
|
|
|
|
G_CALLBACK (gimp_paint_tool_hard_notify),
|
2019-01-31 03:15:53 -08:00
|
|
|
paint_tool, 0);
|
2008-08-20 09:22:09 -07:00
|
|
|
|
2019-01-31 03:15:53 -08:00
|
|
|
gimp_paint_tool_hard_notify (options, NULL, paint_tool);
|
2014-04-12 03:54:08 -07:00
|
|
|
|
|
|
|
|
paint_tool->show_cursor = display_config->show_paint_tool_cursor;
|
2014-04-12 06:03:15 -07:00
|
|
|
paint_tool->draw_brush = display_config->show_brush_outline;
|
2014-04-12 03:54:08 -07:00
|
|
|
|
|
|
|
|
g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
|
|
|
|
|
G_CALLBACK (gimp_paint_tool_cursor_notify),
|
|
|
|
|
paint_tool, 0);
|
2014-04-12 06:03:15 -07:00
|
|
|
g_signal_connect_object (display_config, "notify::show-brush-outline",
|
|
|
|
|
G_CALLBACK (gimp_paint_tool_cursor_notify),
|
|
|
|
|
paint_tool, 0);
|
2002-02-13 06:50:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_finalize (GObject *object)
|
|
|
|
|
{
|
2003-06-05 08:43:49 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
2002-02-13 06:50:37 -08:00
|
|
|
|
2002-02-14 11:31:16 -08:00
|
|
|
if (paint_tool->core)
|
2002-02-13 06:50:37 -08:00
|
|
|
{
|
2003-01-05 14:07:10 -08:00
|
|
|
g_object_unref (paint_tool->core);
|
2002-02-14 11:31:16 -08:00
|
|
|
paint_tool->core = NULL;
|
2002-02-13 06:50:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-02-27 11:18:01 -08:00
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2002-02-18 09:00:09 -08:00
|
|
|
gimp_paint_tool_control (GimpTool *tool,
|
2006-04-12 05:49:29 -07:00
|
|
|
GimpToolAction action,
|
|
|
|
|
GimpDisplay *display)
|
2001-02-27 11:18:01 -08:00
|
|
|
{
|
2004-05-25 13:41:09 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2001-02-27 11:18:01 -08:00
|
|
|
|
|
|
|
|
switch (action)
|
1999-05-13 04:12:32 -07:00
|
|
|
{
|
2006-05-21 14:12:01 -07:00
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2002-02-14 11:31:16 -08:00
|
|
|
gimp_paint_core_cleanup (paint_tool->core);
|
2001-02-27 11:18:01 -08:00
|
|
|
break;
|
2014-04-04 13:34:26 -07:00
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
|
break;
|
1999-05-13 04:12:32 -07:00
|
|
|
}
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2001-02-27 11:18:01 -08:00
|
|
|
}
|
1999-05-13 04:12:32 -07:00
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2009-06-20 08:37:31 -07:00
|
|
|
gimp_paint_tool_button_press (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
|
GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2018-04-09 09:09:51 -07:00
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2018-12-10 04:51:39 -08:00
|
|
|
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2018-04-09 09:09:51 -07:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
|
gboolean constrain;
|
2006-09-26 13:55:40 -07:00
|
|
|
GError *error = NULL;
|
2001-02-26 21:21:12 -08:00
|
|
|
|
2018-12-22 10:09:34 -08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2006-09-12 02:05:41 -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-09-12 02:05:41 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2009-08-28 11:07:14 -07:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)))
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_message_literal (tool, display,
|
2009-09-03 05:57:18 -07:00
|
|
|
_("Cannot paint on layer groups."));
|
2009-08-28 11:07:14 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-29 06:27:04 -07:00
|
|
|
if (gimp_item_is_content_locked (GIMP_ITEM (drawable)))
|
2009-08-21 02:55:18 -07:00
|
|
|
{
|
|
|
|
|
gimp_tool_message_literal (tool, display,
|
|
|
|
|
_("The active layer's pixels are locked."));
|
2018-12-10 05:22:50 -08:00
|
|
|
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
|
2009-08-21 02:55:18 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-10 05:22:50 -08:00
|
|
|
if (! gimp_paint_tool_check_alpha (paint_tool, drawable, display, &error))
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
{
|
2018-12-10 04:51:39 -08:00
|
|
|
GtkWidget *options_gui;
|
|
|
|
|
GtkWidget *mode_box;
|
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
gimp_tool_message_literal (tool, display, error->message);
|
2018-12-10 04:51:39 -08:00
|
|
|
|
|
|
|
|
options_gui = gimp_tools_get_tool_options_gui (
|
|
|
|
|
GIMP_TOOL_OPTIONS (options));
|
|
|
|
|
mode_box = gimp_paint_options_gui_get_paint_mode_box (options_gui);
|
|
|
|
|
|
|
|
|
|
if (gtk_widget_is_sensitive (mode_box))
|
|
|
|
|
gimp_widget_blink (mode_box);
|
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
g_clear_error (&error);
|
2018-12-10 04:51:39 -08:00
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-24 07:27:12 -07:00
|
|
|
if (! gimp_item_is_visible (GIMP_ITEM (drawable)))
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_message_literal (tool, display,
|
|
|
|
|
_("The active layer is not visible."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2004-06-23 05:19:28 -07:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
2009-10-07 10:00:42 -07:00
|
|
|
if (tool->display &&
|
2006-03-28 09:55:52 -08:00
|
|
|
tool->display != display &&
|
2009-10-07 10:00:42 -07:00
|
|
|
gimp_display_get_image (tool->display) == image)
|
2002-02-18 09:00:09 -08:00
|
|
|
{
|
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
|
* same image.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
tool->display = display;
|
2002-02-18 09:00:09 -08:00
|
|
|
}
|
|
|
|
|
|
2018-04-09 09:09:51 -07:00
|
|
|
constrain = (state & gimp_get_constrain_behavior_mask ()) != 0;
|
|
|
|
|
|
|
|
|
|
if (! gimp_paint_tool_paint_start (paint_tool,
|
|
|
|
|
display, coords, time, constrain,
|
|
|
|
|
&error))
|
2006-09-26 13:55:40 -07:00
|
|
|
{
|
2008-11-04 04:33:09 -08:00
|
|
|
gimp_tool_message_literal (tool, display, error->message);
|
2006-09-26 13:55:40 -07:00
|
|
|
g_clear_error (&error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2017-06-30 07:39:28 -07:00
|
|
|
tool->display = display;
|
|
|
|
|
tool->drawable = drawable;
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2002-02-05 03:35:03 -08:00
|
|
|
/* pause the current selection */
|
2010-10-09 05:26:33 -07:00
|
|
|
gimp_display_shell_selection_pause (shell);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
2017-06-30 07:39:28 -07:00
|
|
|
|
|
|
|
|
gimp_tool_control_activate (tool->control);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2007-02-27 10:55:12 -08:00
|
|
|
gimp_paint_tool_button_release (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2007-02-27 10:55:12 -08:00
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
|
GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2018-04-09 09:09:51 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
gboolean cancel;
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2018-12-22 10:09:34 -08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2006-09-12 02:05:41 -07:00
|
|
|
{
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time,
|
2007-02-27 10:55:12 -08:00
|
|
|
state, release_type,
|
|
|
|
|
display);
|
2006-09-12 02:05:41 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2018-04-09 09:09:51 -07:00
|
|
|
cancel = (release_type == GIMP_BUTTON_RELEASE_CANCEL);
|
|
|
|
|
|
|
|
|
|
gimp_paint_tool_paint_end (paint_tool, time, cancel);
|
2018-04-08 06:28:23 -07:00
|
|
|
|
2017-06-30 07:39:28 -07:00
|
|
|
gimp_tool_control_halt (tool->control);
|
|
|
|
|
|
2004-06-28 04:36:00 -07:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
2002-02-15 09:44:05 -08:00
|
|
|
/* resume the current selection */
|
2010-10-09 05:26:33 -07:00
|
|
|
gimp_display_shell_selection_resume (shell);
|
2002-02-15 09:44:05 -08:00
|
|
|
|
2009-10-07 10:00:42 -07:00
|
|
|
gimp_image_flush (image);
|
2004-06-28 04:36:00 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_paint_tool_motion (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
guint32 time,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2018-04-09 09:09:51 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2009-05-25 11:49:34 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, display);
|
|
|
|
|
|
2018-12-22 10:09:34 -08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2009-05-25 11:49:34 -07:00
|
|
|
return;
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2018-04-09 09:09:51 -07:00
|
|
|
gimp_paint_tool_paint_motion (paint_tool, coords, time);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
2003-06-05 08:43:49 -07:00
|
|
|
gimp_paint_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
2003-06-05 08:43:49 -07:00
|
|
|
{
|
2004-06-14 08:26:29 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
2003-07-10 09:01:45 -07:00
|
|
|
|
|
|
|
|
if (paint_tool->pick_colors && ! paint_tool->draw_line)
|
2003-06-05 08:43:49 -07:00
|
|
|
{
|
2016-11-16 04:16:24 -08:00
|
|
|
if ((state & gimp_get_all_modifiers_mask ()) ==
|
|
|
|
|
gimp_get_constrain_behavior_mask ())
|
2003-06-05 08:43:49 -07:00
|
|
|
{
|
2016-11-16 04:16:24 -08:00
|
|
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2003-09-18 06:51:10 -07:00
|
|
|
{
|
2016-11-16 04:16:24 -08:00
|
|
|
GimpToolInfo *info = gimp_get_tool_info (display->gimp,
|
|
|
|
|
"gimp-color-picker-tool");
|
2006-09-05 11:25:31 -07:00
|
|
|
|
2016-11-16 04:16:24 -08:00
|
|
|
if (GIMP_IS_TOOL_INFO (info))
|
2006-08-01 16:42:12 -07:00
|
|
|
{
|
2016-11-16 04:16:24 -08:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
|
|
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
|
|
|
|
GIMP_COLOR_OPTIONS (info->tool_options));
|
|
|
|
|
|
2018-07-15 05:32:53 -07:00
|
|
|
switch (GIMP_COLOR_TOOL (tool)->pick_target)
|
2016-11-16 04:16:24 -08:00
|
|
|
{
|
2018-07-15 05:32:53 -07:00
|
|
|
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
2016-11-16 04:16:24 -08:00
|
|
|
gimp_tool_push_status (tool, display,
|
|
|
|
|
_("Click in any image to pick the "
|
|
|
|
|
"foreground color"));
|
|
|
|
|
break;
|
|
|
|
|
|
2018-07-15 05:32:53 -07:00
|
|
|
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
2016-11-16 04:16:24 -08:00
|
|
|
gimp_tool_push_status (tool, display,
|
|
|
|
|
_("Click in any image to pick the "
|
|
|
|
|
"background color"));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2006-08-01 16:42:12 -07:00
|
|
|
}
|
2003-09-18 06:51:10 -07:00
|
|
|
}
|
2003-06-05 08:43:49 -07:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2003-09-18 06:51:10 -07:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2006-07-30 13:15:07 -07:00
|
|
|
{
|
|
|
|
|
gimp_tool_pop_status (tool, display);
|
|
|
|
|
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
|
|
|
|
}
|
2003-06-05 08:43:49 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-21 10:34:59 -07:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_cursor_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
2014-04-12 03:54:08 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
2009-08-21 10:34:59 -07:00
|
|
|
GimpCursorModifier modifier;
|
|
|
|
|
GimpCursorModifier toggle_modifier;
|
|
|
|
|
GimpCursorModifier old_modifier;
|
|
|
|
|
GimpCursorModifier old_toggle_modifier;
|
|
|
|
|
|
|
|
|
|
modifier = tool->control->cursor_modifier;
|
|
|
|
|
toggle_modifier = tool->control->toggle_cursor_modifier;
|
|
|
|
|
|
|
|
|
|
old_modifier = modifier;
|
|
|
|
|
old_toggle_modifier = toggle_modifier;
|
|
|
|
|
|
2018-12-22 10:09:34 -08:00
|
|
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2009-08-21 10:34:59 -07:00
|
|
|
{
|
2009-10-07 10:00:42 -07:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2009-08-21 10:34:59 -07:00
|
|
|
|
2018-12-10 05:22:50 -08:00
|
|
|
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
|
|
|
|
|
gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
|
|
|
|
|
! gimp_paint_tool_check_alpha (paint_tool, drawable, display, NULL) ||
|
2013-04-24 07:27:12 -07:00
|
|
|
! gimp_item_is_visible (GIMP_ITEM (drawable)))
|
2009-08-21 10:34:59 -07:00
|
|
|
{
|
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BAD;
|
|
|
|
|
toggle_modifier = GIMP_CURSOR_MODIFIER_BAD;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-12 03:54:08 -07:00
|
|
|
if (! paint_tool->show_cursor &&
|
|
|
|
|
modifier != GIMP_CURSOR_MODIFIER_BAD)
|
|
|
|
|
{
|
|
|
|
|
gimp_tool_set_cursor (tool, display,
|
|
|
|
|
GIMP_CURSOR_NONE,
|
|
|
|
|
GIMP_TOOL_CURSOR_NONE,
|
|
|
|
|
GIMP_CURSOR_MODIFIER_NONE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-21 10:34:59 -07:00
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control,
|
|
|
|
|
modifier);
|
|
|
|
|
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
|
|
|
|
|
toggle_modifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state,
|
|
|
|
|
display);
|
|
|
|
|
|
2018-03-24 13:49:01 -07:00
|
|
|
/* reset old stuff here so we are not interfering with the modifiers
|
2009-08-21 10:34:59 -07:00
|
|
|
* set by our subclasses
|
|
|
|
|
*/
|
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control,
|
|
|
|
|
old_modifier);
|
|
|
|
|
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
|
|
|
|
|
old_toggle_modifier);
|
|
|
|
|
}
|
|
|
|
|
|
2003-06-05 08:43:49 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_paint_tool_oper_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
2006-09-12 02:05:41 -07:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
2009-10-04 10:56:39 -07:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2009-10-07 10:00:42 -07:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2018-12-22 10:09:34 -08:00
|
|
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
2003-07-10 09:01:45 -07:00
|
|
|
{
|
2006-03-25 06:23:09 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state,
|
2006-03-28 09:55:52 -08:00
|
|
|
proximity, display);
|
2003-07-10 09:01:45 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-11 13:26:52 -07:00
|
|
|
gimp_draw_tool_pause (draw_tool);
|
|
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool) &&
|
|
|
|
|
draw_tool->display != display)
|
2002-02-07 03:33:01 -08:00
|
|
|
gimp_draw_tool_stop (draw_tool);
|
2000-03-04 16:06:11 -08:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
1999-05-14 17:02:47 -07:00
|
|
|
|
2008-07-08 23:45:47 -07:00
|
|
|
if (tool->display &&
|
2006-03-28 09:55:52 -08:00
|
|
|
tool->display != display &&
|
2009-10-07 10:00:42 -07:00
|
|
|
gimp_display_get_image (tool->display) == image)
|
2002-02-18 09:00:09 -08:00
|
|
|
{
|
|
|
|
|
/* if this is a different display, but the same image, HACK around
|
|
|
|
|
* in tool internals AFTER stopping the current draw_tool, so
|
|
|
|
|
* straight line drawing works across different views of the
|
|
|
|
|
* same image.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
tool->display = display;
|
2002-02-18 09:00:09 -08:00
|
|
|
}
|
|
|
|
|
|
2006-03-25 06:23:09 -08:00
|
|
|
if (drawable && proximity)
|
1998-01-21 23:02:57 -08:00
|
|
|
{
|
2017-12-22 13:26:13 -08:00
|
|
|
gchar *status;
|
|
|
|
|
gboolean constrain_mask = gimp_get_constrain_behavior_mask ();
|
|
|
|
|
gint off_x, off_y;
|
2014-04-09 06:24:20 -07:00
|
|
|
|
|
|
|
|
core->cur_coords = *coords;
|
|
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
|
|
|
|
|
|
|
|
|
core->cur_coords.x -= off_x;
|
|
|
|
|
core->cur_coords.y -= off_y;
|
2011-10-06 12:59:07 -07:00
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
if (display == tool->display && (state & GIMP_PAINT_TOOL_LINE_MASK))
|
2003-07-10 09:01:45 -07:00
|
|
|
{
|
2002-02-15 09:44:05 -08:00
|
|
|
/* If shift is down and this is not the first paint stroke,
|
2005-04-04 14:03:21 -07:00
|
|
|
* draw a line.
|
2002-02-15 09:44:05 -08:00
|
|
|
*/
|
2011-10-06 12:59:07 -07:00
|
|
|
gchar *status_help;
|
2018-07-15 14:58:55 -07:00
|
|
|
gdouble offset_angle;
|
|
|
|
|
gdouble xres, yres;
|
1999-05-14 17:36:42 -07:00
|
|
|
|
2018-07-15 14:58:55 -07:00
|
|
|
gimp_display_shell_get_constrained_line_params (shell,
|
|
|
|
|
&offset_angle,
|
|
|
|
|
&xres, &yres);
|
|
|
|
|
|
|
|
|
|
gimp_paint_core_round_line (core, paint_options,
|
|
|
|
|
(state & constrain_mask) != 0,
|
|
|
|
|
offset_angle, xres, yres);
|
1999-06-17 13:34:50 -07:00
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
status_help = gimp_suggest_modifiers (paint_tool->status_line,
|
2011-10-06 12:59:07 -07:00
|
|
|
constrain_mask & ~state,
|
2006-08-01 16:42:12 -07:00
|
|
|
NULL,
|
|
|
|
|
_("%s for constrained angles"),
|
|
|
|
|
NULL);
|
2006-07-30 13:15:07 -07:00
|
|
|
|
2017-12-22 13:26:13 -08:00
|
|
|
status = gimp_display_shell_get_line_status (shell, status_help,
|
|
|
|
|
". ",
|
|
|
|
|
core->last_coords.x,
|
2018-01-28 14:25:24 -08:00
|
|
|
core->last_coords.y,
|
|
|
|
|
core->cur_coords.x,
|
|
|
|
|
core->cur_coords.y);
|
2006-08-01 16:42:12 -07:00
|
|
|
g_free (status_help);
|
2003-07-10 09:01:45 -07:00
|
|
|
paint_tool->draw_line = TRUE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-08-02 07:41:24 -07:00
|
|
|
GdkModifierType modifiers = 0;
|
|
|
|
|
|
|
|
|
|
/* HACK: A paint tool may set status_ctrl to NULL to indicate that
|
|
|
|
|
* it ignores the Ctrl modifier (temporarily or permanently), so
|
|
|
|
|
* it should not be suggested. This is different from how
|
2006-09-28 04:07:55 -07:00
|
|
|
* gimp_suggest_modifiers() would interpret this parameter.
|
|
|
|
|
*/
|
2006-08-02 07:41:24 -07:00
|
|
|
if (paint_tool->status_ctrl != NULL)
|
2011-10-06 12:59:07 -07:00
|
|
|
modifiers |= constrain_mask;
|
2006-09-28 04:07:55 -07:00
|
|
|
|
|
|
|
|
/* suggest drawing lines only after the first point is set
|
|
|
|
|
*/
|
2006-03-28 09:55:52 -08:00
|
|
|
if (display == tool->display)
|
2015-10-17 06:31:08 -07:00
|
|
|
modifiers |= GIMP_PAINT_TOOL_LINE_MASK;
|
2006-08-02 07:41:24 -07:00
|
|
|
|
|
|
|
|
status = gimp_suggest_modifiers (paint_tool->status,
|
|
|
|
|
modifiers & ~state,
|
|
|
|
|
_("%s for a straight line"),
|
|
|
|
|
paint_tool->status_ctrl,
|
|
|
|
|
NULL);
|
2003-07-10 09:01:45 -07:00
|
|
|
paint_tool->draw_line = FALSE;
|
|
|
|
|
}
|
2017-12-22 13:26:13 -08:00
|
|
|
gimp_tool_push_status (tool, display, "%s", status);
|
|
|
|
|
g_free (status);
|
2003-07-10 09:01:45 -07:00
|
|
|
|
2010-10-11 13:26:52 -07:00
|
|
|
if (! gimp_draw_tool_is_active (draw_tool))
|
|
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
|
|
|
|
}
|
|
|
|
|
else if (gimp_draw_tool_is_active (draw_tool))
|
|
|
|
|
{
|
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
2002-02-04 09:43:01 -08:00
|
|
|
}
|
2001-02-24 11:29:47 -08:00
|
|
|
|
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);
|
2010-10-11 13:26:52 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (draw_tool);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2001-02-27 11:18:01 -08:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2019-01-31 03:15:53 -08:00
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (paint_tool->active &&
|
|
|
|
|
! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
2002-02-07 03:33:01 -08:00
|
|
|
{
|
2014-04-12 06:03:15 -07:00
|
|
|
GimpPaintCore *core = paint_tool->core;
|
|
|
|
|
GimpImage *image = gimp_display_get_image (draw_tool->display);
|
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
|
|
|
|
GimpCanvasItem *outline = NULL;
|
2014-04-12 06:26:11 -07:00
|
|
|
gboolean line_drawn = FALSE;
|
|
|
|
|
gdouble cur_x, cur_y;
|
2014-04-12 06:03:15 -07:00
|
|
|
gint off_x, off_y;
|
2014-04-09 06:24:20 -07:00
|
|
|
|
|
|
|
|
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
|
2003-07-10 09:01:45 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
if (gimp_paint_tool_paint_is_active (paint_tool))
|
|
|
|
|
{
|
|
|
|
|
cur_x = paint_tool->paint_x + off_x;
|
|
|
|
|
cur_y = paint_tool->paint_y + off_y;
|
|
|
|
|
}
|
|
|
|
|
else
|
2003-07-10 09:01:45 -07:00
|
|
|
{
|
2018-06-08 00:14:17 -07:00
|
|
|
cur_x = core->cur_coords.x + off_x;
|
|
|
|
|
cur_y = core->cur_coords.y + off_y;
|
2014-04-12 13:10:26 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
if (paint_tool->draw_line &&
|
|
|
|
|
! gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control))
|
|
|
|
|
{
|
|
|
|
|
GimpCanvasGroup *group;
|
|
|
|
|
gdouble last_x, last_y;
|
|
|
|
|
|
|
|
|
|
last_x = core->last_coords.x + off_x;
|
|
|
|
|
last_y = core->last_coords.y + off_y;
|
2010-09-23 05:55:38 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
group = gimp_draw_tool_add_stroke_group (draw_tool);
|
|
|
|
|
gimp_draw_tool_push_group (draw_tool, group);
|
2003-07-10 09:01:45 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
|
GIMP_HANDLE_CIRCLE,
|
|
|
|
|
last_x, last_y,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
|
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
2014-04-12 13:10:26 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
gimp_draw_tool_add_line (draw_tool,
|
|
|
|
|
last_x, last_y,
|
|
|
|
|
cur_x, cur_y);
|
2014-04-12 06:26:11 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
|
GIMP_HANDLE_CIRCLE,
|
|
|
|
|
cur_x, cur_y,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CIRCLE,
|
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
2014-04-12 13:10:26 -07:00
|
|
|
|
2018-06-08 00:14:17 -07:00
|
|
|
gimp_draw_tool_pop_group (draw_tool);
|
|
|
|
|
|
|
|
|
|
line_drawn = TRUE;
|
|
|
|
|
}
|
2003-07-10 09:01:45 -07:00
|
|
|
}
|
2014-04-09 06:24:20 -07:00
|
|
|
|
Bug 795257 - Segmentation fault crash using the clone tool
Commit f5cb1fed85341a9d0a46fb1391b19fa9ea3ccb42, which performed
brush outline generation in GimpPaintTool in synchrony with the
paint thread, wasn't enough, since GimpSourceTool could still call
gimp_brush_tool_create_outline() directly during its
GimpDrawTool::draw() method, leading to the same race condition
when executed concurrently with the paint thread.
Partially revert the above commit, so that outline generation is
handled as before, as far as GimpPaintTool is concenered. Instead,
add GimpPaintTool::{start,end,flush}_paint() virtual functions; the
first two are called when starting/ending painting using the paint
thread, while the third is called during the display-update
timeout, while the main thread and the paint thread are
synchronized. This allows subclasses to perform non-thread-safe
actions while the threads are synchronized.
Override these functions in GimpBrushTool, and cache the brush
boundary in the flush() function. Use the cached boundary in
gimp_brush_tool_create_outline() while painting, to avoid the above
race condition, both when this function is called through
GimpPaintTool, and through GimpSourceTool.
2018-04-14 06:48:10 -07:00
|
|
|
gimp_paint_tool_set_draw_fallback (paint_tool, FALSE, 0.0);
|
|
|
|
|
|
|
|
|
|
if (paint_tool->draw_brush)
|
|
|
|
|
outline = gimp_paint_tool_get_outline (paint_tool,
|
|
|
|
|
draw_tool->display,
|
|
|
|
|
cur_x, cur_y);
|
2014-04-12 06:03:15 -07:00
|
|
|
|
|
|
|
|
if (outline)
|
|
|
|
|
{
|
|
|
|
|
gimp_draw_tool_add_item (draw_tool, outline);
|
|
|
|
|
g_object_unref (outline);
|
|
|
|
|
}
|
2014-11-18 13:41:09 -08:00
|
|
|
else if (paint_tool->draw_fallback)
|
2014-04-09 06:24:20 -07:00
|
|
|
{
|
2014-11-18 14:06:43 -08:00
|
|
|
/* Lets make a sensible fallback cursor
|
2014-11-18 05:40:32 -08:00
|
|
|
*
|
|
|
|
|
* Sensible cursor is
|
|
|
|
|
* * crossed to indicate draw point
|
|
|
|
|
* * reactive to options alterations
|
2014-11-18 14:06:43 -08:00
|
|
|
* * not a full circle that would be in the way
|
|
|
|
|
*/
|
2014-11-18 13:41:09 -08:00
|
|
|
gint size = (gint) paint_tool->fallback_size;
|
2014-11-18 05:40:32 -08:00
|
|
|
|
|
|
|
|
#define TICKMARK_ANGLE 48
|
|
|
|
|
#define ROTATION_ANGLE G_PI / 4
|
2014-11-18 14:06:43 -08:00
|
|
|
|
2014-11-18 05:40:32 -08:00
|
|
|
/* marks for indicating full size */
|
|
|
|
|
gimp_draw_tool_add_arc (draw_tool,
|
|
|
|
|
FALSE,
|
|
|
|
|
cur_x - (size / 2.0),
|
|
|
|
|
cur_y - (size / 2.0),
|
|
|
|
|
size, size,
|
|
|
|
|
ROTATION_ANGLE - (2.0 * G_PI) / (TICKMARK_ANGLE * 2),
|
|
|
|
|
(2.0 * G_PI) / TICKMARK_ANGLE);
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_add_arc (draw_tool,
|
|
|
|
|
FALSE,
|
|
|
|
|
cur_x - (size / 2.0),
|
|
|
|
|
cur_y - (size / 2.0),
|
|
|
|
|
size, size,
|
|
|
|
|
ROTATION_ANGLE + G_PI / 2 - (2.0 * G_PI) / (TICKMARK_ANGLE * 2),
|
|
|
|
|
(2.0 * G_PI) / TICKMARK_ANGLE);
|
2014-04-09 06:24:20 -07:00
|
|
|
|
2014-04-20 12:42:18 -07:00
|
|
|
gimp_draw_tool_add_arc (draw_tool,
|
|
|
|
|
FALSE,
|
|
|
|
|
cur_x - (size / 2.0),
|
|
|
|
|
cur_y - (size / 2.0),
|
|
|
|
|
size, size,
|
2014-11-18 05:40:32 -08:00
|
|
|
ROTATION_ANGLE + G_PI - (2.0 * G_PI) / (TICKMARK_ANGLE * 2),
|
|
|
|
|
(2.0 * G_PI) / TICKMARK_ANGLE);
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_add_arc (draw_tool,
|
|
|
|
|
FALSE,
|
|
|
|
|
cur_x - (size / 2.0),
|
|
|
|
|
cur_y - (size / 2.0),
|
|
|
|
|
size, size,
|
|
|
|
|
ROTATION_ANGLE + 3 * G_PI / 2 - (2.0 * G_PI) / (TICKMARK_ANGLE * 2),
|
|
|
|
|
(2.0 * G_PI) / TICKMARK_ANGLE);
|
2014-11-18 13:41:09 -08:00
|
|
|
}
|
|
|
|
|
else if (paint_tool->draw_circle)
|
|
|
|
|
{
|
|
|
|
|
gint size = (gint) paint_tool->circle_size;
|
|
|
|
|
|
|
|
|
|
/* draw an indicatory circle */
|
|
|
|
|
gimp_draw_tool_add_arc (draw_tool,
|
|
|
|
|
FALSE,
|
|
|
|
|
cur_x - (size / 2.0),
|
|
|
|
|
cur_y - (size / 2.0),
|
|
|
|
|
size, size,
|
|
|
|
|
0.0, (2.0 * G_PI));
|
2014-04-09 06:24:20 -07:00
|
|
|
}
|
2014-11-19 10:55:22 -08:00
|
|
|
|
|
|
|
|
if (! outline &&
|
|
|
|
|
! line_drawn &&
|
|
|
|
|
! paint_tool->show_cursor &&
|
|
|
|
|
! paint_tool->draw_circle)
|
2014-04-12 06:03:15 -07:00
|
|
|
{
|
|
|
|
|
/* don't leave the user without any indication and draw
|
|
|
|
|
* a fallback crosshair
|
|
|
|
|
*/
|
2014-11-19 10:55:22 -08:00
|
|
|
gimp_draw_tool_add_handle (draw_tool,
|
|
|
|
|
GIMP_HANDLE_CROSSHAIR,
|
|
|
|
|
cur_x, cur_y,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
|
|
|
|
|
GIMP_TOOL_HANDLE_SIZE_CROSSHAIR,
|
|
|
|
|
GIMP_HANDLE_ANCHOR_CENTER);
|
2014-04-12 06:03:15 -07:00
|
|
|
}
|
2002-02-07 03:33:01 -08:00
|
|
|
}
|
2003-06-05 08:43:49 -07:00
|
|
|
|
|
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
2001-11-08 11:14:51 -08:00
|
|
|
}
|
2008-08-20 09:22:09 -07:00
|
|
|
|
2014-04-12 06:03:15 -07:00
|
|
|
static GimpCanvasItem *
|
|
|
|
|
gimp_paint_tool_get_outline (GimpPaintTool *paint_tool,
|
|
|
|
|
GimpDisplay *display,
|
|
|
|
|
gdouble x,
|
|
|
|
|
gdouble y)
|
|
|
|
|
{
|
Bug 795257 - Segmentation fault crash using the clone tool
Commit f5cb1fed85341a9d0a46fb1391b19fa9ea3ccb42, which performed
brush outline generation in GimpPaintTool in synchrony with the
paint thread, wasn't enough, since GimpSourceTool could still call
gimp_brush_tool_create_outline() directly during its
GimpDrawTool::draw() method, leading to the same race condition
when executed concurrently with the paint thread.
Partially revert the above commit, so that outline generation is
handled as before, as far as GimpPaintTool is concenered. Instead,
add GimpPaintTool::{start,end,flush}_paint() virtual functions; the
first two are called when starting/ending painting using the paint
thread, while the third is called during the display-update
timeout, while the main thread and the paint thread are
synchronized. This allows subclasses to perform non-thread-safe
actions while the threads are synchronized.
Override these functions in GimpBrushTool, and cache the brush
boundary in the flush() function. Use the cached boundary in
gimp_brush_tool_create_outline() while painting, to avoid the above
race condition, both when this function is called through
GimpPaintTool, and through GimpSourceTool.
2018-04-14 06:48:10 -07:00
|
|
|
if (GIMP_PAINT_TOOL_GET_CLASS (paint_tool)->get_outline)
|
|
|
|
|
return GIMP_PAINT_TOOL_GET_CLASS (paint_tool)->get_outline (paint_tool,
|
|
|
|
|
display, x, y);
|
2014-04-12 06:03:15 -07:00
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
|
|
|
|
|
GimpDrawable *drawable,
|
2018-12-10 05:22:50 -08:00
|
|
|
GimpDisplay *display,
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
GimpPaintToolClass *klass = GIMP_PAINT_TOOL_GET_CLASS (paint_tool);
|
|
|
|
|
|
|
|
|
|
if (klass->is_alpha_only && klass->is_alpha_only (paint_tool, drawable))
|
|
|
|
|
{
|
|
|
|
|
if (! gimp_drawable_has_alpha (drawable))
|
|
|
|
|
{
|
|
|
|
|
g_set_error_literal (
|
|
|
|
|
error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
|
_("The active layer does not have an alpha channel."));
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GIMP_IS_LAYER (drawable) &&
|
|
|
|
|
gimp_layer_get_lock_alpha (GIMP_LAYER (drawable)))
|
|
|
|
|
{
|
|
|
|
|
g_set_error_literal (
|
|
|
|
|
error, GIMP_ERROR, GIMP_FAILED,
|
|
|
|
|
_("The active layer's alpha channel is locked."));
|
|
|
|
|
|
2018-12-10 05:22:50 -08:00
|
|
|
if (error)
|
|
|
|
|
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
|
|
|
|
|
|
app: warn when alpha-only painting has no effect
Add a GimpPaintTool::is_alpha_only() virtual function, which
subclasses can override to indicate whether painting only affects
the alpha channel (assuming FALSE by default). Override the
function in Gimp{PaintBrush,Ink,Clone}Tool, returning TRUE when the
current paint mode only affects the alpha (as per
gimp_layer_mode_is_alpha_only(); see the previous commit,) and in
GimpEraserTool, returning TRUE when the target drawable has an
alpha channel.
When the function returns TRUE, and the target drawable doesn't
have an alpha channel, or the alpha channel is locked, show a BAD
cursor modifier, and raise an appropriate warning when attempting
to paint.
2018-05-07 13:40:27 -07:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-20 09:22:09 -07:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_hard_notify (GimpPaintOptions *options,
|
|
|
|
|
const GParamSpec *pspec,
|
2019-01-31 03:15:53 -08:00
|
|
|
GimpPaintTool *paint_tool)
|
2008-08-20 09:22:09 -07:00
|
|
|
{
|
2019-01-31 03:15:53 -08:00
|
|
|
if (paint_tool->active)
|
|
|
|
|
{
|
|
|
|
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
|
|
|
|
|
|
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
|
options->hard ?
|
|
|
|
|
GIMP_CURSOR_PRECISION_PIXEL_CENTER :
|
|
|
|
|
GIMP_CURSOR_PRECISION_SUBPIXEL);
|
|
|
|
|
}
|
2008-08-20 09:22:09 -07:00
|
|
|
}
|
2014-04-09 06:24:20 -07:00
|
|
|
|
2014-04-12 03:54:08 -07:00
|
|
|
static void
|
|
|
|
|
gimp_paint_tool_cursor_notify (GimpDisplayConfig *config,
|
|
|
|
|
GParamSpec *pspec,
|
|
|
|
|
GimpPaintTool *paint_tool)
|
|
|
|
|
{
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (paint_tool));
|
|
|
|
|
|
|
|
|
|
paint_tool->show_cursor = config->show_paint_tool_cursor;
|
2014-04-12 06:03:15 -07:00
|
|
|
paint_tool->draw_brush = config->show_brush_outline;
|
2014-04-12 03:54:08 -07:00
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 03:15:53 -08:00
|
|
|
void
|
|
|
|
|
gimp_paint_tool_set_active (GimpPaintTool *tool,
|
|
|
|
|
gboolean active)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
|
|
|
|
if (active != tool->active)
|
|
|
|
|
{
|
|
|
|
|
GimpPaintOptions *options = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
|
|
tool->active = active;
|
|
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
|
gimp_paint_tool_hard_notify (options, NULL, tool);
|
|
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-09 06:24:20 -07:00
|
|
|
/**
|
|
|
|
|
* gimp_paint_tool_enable_color_picker:
|
2018-07-15 05:32:53 -07:00
|
|
|
* @tool: a #GimpPaintTool
|
|
|
|
|
* @target: the #GimpColorPickTarget to set
|
2014-04-09 06:24:20 -07:00
|
|
|
*
|
|
|
|
|
* This is a convenience function used from the init method of paint
|
|
|
|
|
* tools that want the color picking functionality. The @mode that is
|
|
|
|
|
* set here is used to decide what cursor modifier to draw and if the
|
|
|
|
|
* picked color goes to the foreground or background color.
|
|
|
|
|
**/
|
|
|
|
|
void
|
2018-07-15 05:32:53 -07:00
|
|
|
gimp_paint_tool_enable_color_picker (GimpPaintTool *tool,
|
|
|
|
|
GimpColorPickTarget target)
|
2014-04-09 06:24:20 -07:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
|
|
|
|
tool->pick_colors = TRUE;
|
|
|
|
|
|
2018-07-15 05:32:53 -07:00
|
|
|
GIMP_COLOR_TOOL (tool)->pick_target = target;
|
2014-04-09 06:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
2014-11-18 13:41:09 -08:00
|
|
|
void
|
|
|
|
|
gimp_paint_tool_set_draw_fallback (GimpPaintTool *tool,
|
|
|
|
|
gboolean draw_fallback,
|
|
|
|
|
gint fallback_size)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
|
|
|
|
tool->draw_fallback = draw_fallback;
|
2017-06-30 07:39:28 -07:00
|
|
|
tool->fallback_size = fallback_size;
|
2014-11-18 13:41:09 -08:00
|
|
|
}
|
|
|
|
|
|
2014-04-09 06:24:20 -07:00
|
|
|
void
|
|
|
|
|
gimp_paint_tool_set_draw_circle (GimpPaintTool *tool,
|
|
|
|
|
gboolean draw_circle,
|
2014-11-18 13:41:09 -08:00
|
|
|
gint circle_size)
|
2014-04-09 06:24:20 -07:00
|
|
|
{
|
|
|
|
|
g_return_if_fail (GIMP_IS_PAINT_TOOL (tool));
|
|
|
|
|
|
2014-11-18 13:41:09 -08:00
|
|
|
tool->draw_circle = draw_circle;
|
|
|
|
|
tool->circle_size = circle_size;
|
2014-04-09 06:24:20 -07:00
|
|
|
}
|