2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14:05:25 -08:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2000-04-27 10:27:28 -07:00
|
|
|
#include "config.h"
|
1999-10-26 11:27:27 -07:00
|
|
|
|
2012-03-28 12:37:59 -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
|
|
|
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 10:49:44 -08:00
|
|
|
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools-types.h"
|
2000-12-16 13:37:03 -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
|
|
|
#include "operations/layer-modes/gimp-layer-modes.h"
|
|
|
|
|
|
2003-02-05 06:39:40 -08:00
|
|
|
#include "paint/gimppaintoptions.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
|
2003-08-21 18:42:57 -07:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
|
|
|
|
|
2001-03-07 17:07:03 -08:00
|
|
|
#include "gimppaintbrushtool.h"
|
2003-06-29 13:40:45 -07:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 10:27:28 -07:00
|
|
|
|
1999-07-19 15:42:49 -07: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
|
|
|
static gboolean gimp_paintbrush_tool_is_alpha_only (GimpPaintTool *paint_tool,
|
|
|
|
|
GimpDrawable *drawable);
|
|
|
|
|
|
|
|
|
|
|
2006-08-15 14:46:22 -07:00
|
|
|
G_DEFINE_TYPE (GimpPaintbrushTool, gimp_paintbrush_tool, GIMP_TYPE_BRUSH_TOOL)
|
2001-02-27 11:18:01 -08:00
|
|
|
|
2000-12-29 07:22:01 -08:00
|
|
|
|
2001-03-11 20:40:17 -08:00
|
|
|
void
|
2002-03-28 19:50:29 -08:00
|
|
|
gimp_paintbrush_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 04:31:08 -07:00
|
|
|
gpointer data)
|
2001-03-11 20:40:17 -08:00
|
|
|
{
|
2002-03-28 19:50:29 -08:00
|
|
|
(* callback) (GIMP_TYPE_PAINTBRUSH_TOOL,
|
2003-02-05 06:39:40 -08:00
|
|
|
GIMP_TYPE_PAINT_OPTIONS,
|
|
|
|
|
gimp_paint_options_gui,
|
2003-06-29 13:40:45 -07:00
|
|
|
GIMP_PAINT_OPTIONS_CONTEXT_MASK |
|
2015-09-08 12:18:49 -07:00
|
|
|
GIMP_CONTEXT_PROP_MASK_GRADIENT,
|
2002-03-21 04:17:17 -08:00
|
|
|
"gimp-paintbrush-tool",
|
2001-11-20 15:00:47 -08:00
|
|
|
_("Paintbrush"),
|
2006-09-18 11:00:22 -07:00
|
|
|
_("Paintbrush Tool: Paint smooth strokes using a brush"),
|
2004-04-29 06:19:28 -07:00
|
|
|
N_("_Paintbrush"), "P",
|
2003-08-21 18:42:57 -07:00
|
|
|
NULL, GIMP_HELP_TOOL_PAINTBRUSH,
|
2017-03-05 07:01:59 -08:00
|
|
|
GIMP_ICON_TOOL_PAINTBRUSH,
|
2002-05-03 04:31:08 -07:00
|
|
|
data);
|
2001-03-11 20:40:17 -08:00
|
|
|
}
|
|
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
static void
|
|
|
|
|
gimp_paintbrush_tool_class_init (GimpPaintbrushToolClass *klass)
|
2001-02-26 21:21:12 -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
|
|
|
GimpPaintToolClass *paint_tool_class = GIMP_PAINT_TOOL_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
paint_tool_class->is_alpha_only = gimp_paintbrush_tool_is_alpha_only;
|
2001-02-26 21:21:12 -08:00
|
|
|
}
|
|
|
|
|
|
2001-03-11 20:40:17 -08:00
|
|
|
static void
|
|
|
|
|
gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2003-10-25 12:00:49 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (paintbrush);
|
1999-09-08 18:47:54 -07:00
|
|
|
|
2003-06-05 08:43:49 -07:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-04 16:08:29 -07:00
|
|
|
GIMP_TOOL_CURSOR_PAINTBRUSH);
|
2002-03-28 19:50:29 -08:00
|
|
|
|
2003-10-25 12:00:49 -07:00
|
|
|
gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (paintbrush),
|
2018-07-15 05:32:53 -07:00
|
|
|
GIMP_COLOR_PICK_TARGET_FOREGROUND);
|
1997-11-24 14:05:25 -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
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gimp_paintbrush_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);
|
|
|
|
|
}
|