2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1998-06-14 22:42:36 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1998-06-14 22:42:36 +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
|
1998-06-14 22:42:36 +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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1998-06-14 22:42:36 +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"
|
|
|
|
|
2012-03-28 21:37:59 +02:00
|
|
|
#include <gegl.h>
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
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
|
|
|
|
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 16:40:27 -04:00
|
|
|
#include "operations/layer-modes/gimp-layer-modes.h"
|
|
|
|
|
2004-05-26 15:34:45 +00:00
|
|
|
#include "paint/gimpinkoptions.h"
|
2002-02-21 16:02:30 +00:00
|
|
|
|
2003-08-22 01:42:57 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
2004-05-26 15:34:45 +00:00
|
|
|
#include "gimpinkoptions-gui.h"
|
2001-03-08 01:07:03 +00:00
|
|
|
#include "gimpinktool.h"
|
2003-04-15 16:05:52 +00:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2000-12-29 15:22:01 +00:00
|
|
|
|
1998-06-14 22:42:36 +00:00
|
|
|
|
2022-03-14 22:54:26 +01:00
|
|
|
static GimpCanvasItem * gimp_ink_tool_get_outline (GimpPaintTool *paint_tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y);
|
|
|
|
static gboolean gimp_ink_tool_is_alpha_only (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
|
|
|
|
static void gimp_ink_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec);
|
2004-06-04 23:08:29 +00:00
|
|
|
|
2000-12-31 04:07:42 +00: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 16:40:27 -04:00
|
|
|
G_DEFINE_TYPE (GimpInkTool, gimp_ink_tool, GIMP_TYPE_PAINT_TOOL)
|
1999-04-08 22:25:54 +00: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 16:40:27 -04:00
|
|
|
#define parent_class gimp_ink_tool_parent_class
|
2014-04-09 15:26:10 +02:00
|
|
|
|
|
|
|
|
2001-02-28 00:10:58 +00:00
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_ink_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-02-28 00:10:58 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_INK_TOOL,
|
2003-02-05 14:39:40 +00:00
|
|
|
GIMP_TYPE_INK_OPTIONS,
|
|
|
|
gimp_ink_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 |
|
2023-08-18 08:51:46 +05:30
|
|
|
GIMP_CONTEXT_PROP_MASK_PAINT_MODE |
|
2023-08-21 00:48:01 +05:30
|
|
|
GIMP_CONTEXT_PROP_MASK_PATTERN |
|
2023-08-18 08:51:46 +05:30
|
|
|
GIMP_CONTEXT_PROP_MASK_EXPAND,
|
2002-03-21 12:17:17 +00:00
|
|
|
"gimp-ink-tool",
|
2002-10-31 23:06:09 +00:00
|
|
|
_("Ink"),
|
2006-09-18 18:00:22 +00:00
|
|
|
_("Ink Tool: Calligraphy-style painting"),
|
2004-04-29 13:19:28 +00:00
|
|
|
N_("In_k"), "K",
|
2003-08-22 01:42:57 +00:00
|
|
|
NULL, GIMP_HELP_TOOL_INK,
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_TOOL_INK,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-02-28 00:10:58 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 23:08:29 +00:00
|
|
|
static void
|
|
|
|
gimp_ink_tool_class_init (GimpInkToolClass *klass)
|
|
|
|
{
|
2022-03-14 22:54:26 +01:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
2014-04-12 15:03:15 +02:00
|
|
|
GimpPaintToolClass *paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
|
2014-04-09 15:26:10 +02:00
|
|
|
|
2022-03-14 22:54:26 +01:00
|
|
|
tool_class->options_notify = gimp_ink_tool_options_notify;
|
|
|
|
|
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 16:40:27 -04:00
|
|
|
paint_tool_class->get_outline = gimp_ink_tool_get_outline;
|
|
|
|
paint_tool_class->is_alpha_only = gimp_ink_tool_is_alpha_only;
|
2004-06-04 23:08:29 +00:00
|
|
|
}
|
|
|
|
|
2001-02-28 00:10:58 +00:00
|
|
|
static void
|
|
|
|
gimp_ink_tool_init (GimpInkTool *ink_tool)
|
|
|
|
{
|
2004-05-26 15:34:45 +00:00
|
|
|
GimpTool *tool = GIMP_TOOL (ink_tool);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2014-04-19 20:09:39 +02:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_INK);
|
2022-04-02 23:30:03 +02:00
|
|
|
gimp_tool_control_set_action_pixel_size (tool->control,
|
2023-02-26 19:53:24 +01:00
|
|
|
"tools-ink-blob-pixel-size-set");
|
2022-04-02 23:30:03 +02:00
|
|
|
gimp_tool_control_set_action_size (tool->control,
|
2023-02-26 19:53:24 +01:00
|
|
|
"tools-ink-blob-size-set");
|
2022-04-02 23:30:03 +02:00
|
|
|
gimp_tool_control_set_action_aspect (tool->control,
|
2023-02-26 19:53:24 +01:00
|
|
|
"tools-ink-blob-aspect-set");
|
2022-04-02 23:30:03 +02:00
|
|
|
gimp_tool_control_set_action_angle (tool->control,
|
2023-02-26 19:53:24 +01:00
|
|
|
"tools-ink-blob-angle-set");
|
2004-06-09 12:14:55 +00:00
|
|
|
|
|
|
|
gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (ink_tool),
|
2018-07-15 14:32:53 +02:00
|
|
|
GIMP_COLOR_PICK_TARGET_FOREGROUND);
|
2004-06-04 23:08:29 +00:00
|
|
|
}
|
2014-04-09 15:26:10 +02:00
|
|
|
|
2022-03-14 22:54:26 +01:00
|
|
|
static void
|
|
|
|
gimp_ink_tool_options_notify (GimpTool *tool,
|
|
|
|
GimpToolOptions *options,
|
|
|
|
const GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
|
|
|
|
|
|
|
|
if (g_strcmp0 (pspec->name, "size") == 0 &&
|
|
|
|
GIMP_PAINT_TOOL (tool)->draw_brush)
|
|
|
|
{
|
|
|
|
/* This triggers a redraw of the tool pointer, especially useful
|
|
|
|
* here when we change the pen size with on-canvas interaction.
|
|
|
|
*/
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 15:03:15 +02:00
|
|
|
static GimpCanvasItem *
|
|
|
|
gimp_ink_tool_get_outline (GimpPaintTool *paint_tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
2014-04-09 15:26:10 +02:00
|
|
|
{
|
2014-04-12 15:03:15 +02:00
|
|
|
GimpInkOptions *options = GIMP_INK_TOOL_GET_OPTIONS (paint_tool);
|
2014-04-09 15:26:10 +02:00
|
|
|
|
|
|
|
gimp_paint_tool_set_draw_circle (paint_tool, TRUE,
|
|
|
|
options->size);
|
|
|
|
|
2014-04-12 15:03:15 +02:00
|
|
|
return NULL;
|
2014-04-09 15:26:10 +02: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 16:40:27 -04:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_ink_tool_is_alpha_only (GimpPaintTool *paint_tool,
|
|
|
|
GimpDrawable *drawable)
|
|
|
|
{
|
|
|
|
GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (paint_tool);
|
|
|
|
GimpContext *context = GIMP_CONTEXT (paint_options);
|
|
|
|
GimpLayerMode paint_mode = gimp_context_get_paint_mode (context);
|
|
|
|
|
|
|
|
return gimp_layer_mode_is_alpha_only (paint_mode);
|
|
|
|
}
|