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:27:07 -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"
|
2000-01-14 04:41:00 -08:00
|
|
|
|
2012-03-28 12:37:59 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 04:41:00 -08:00
|
|
|
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools-types.h"
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2003-02-05 06:39:40 -08:00
|
|
|
#include "paint/gimpconvolveoptions.h"
|
2002-02-14 11:31:16 -08:00
|
|
|
|
2003-08-21 18:42:57 -07:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2010-11-01 13:48:59 -07:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
2002-12-19 08:33:29 -08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-19 11:17:31 -08:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
#include "gimpconvolvetool.h"
|
2003-06-29 13:40:45 -07:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-14 16:23:52 -07:00
|
|
|
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2006-08-01 16:42:12 -07:00
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_convolve_tool_oper_update (GimpTool *tool,
|
2008-11-01 08:17:36 -07:00
|
|
|
const GimpCoords *coords,
|
2006-08-01 16:42:12 -07:00
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_convolve_tool_status_update (GimpTool *tool,
|
|
|
|
|
GimpConvolveType type);
|
|
|
|
|
|
|
|
|
|
static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options);
|
2000-11-06 04:40:07 -08:00
|
|
|
|
1999-04-08 15:25:54 -07:00
|
|
|
|
2006-08-15 14:46:22 -07:00
|
|
|
G_DEFINE_TYPE (GimpConvolveTool, gimp_convolve_tool, GIMP_TYPE_BRUSH_TOOL)
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
#define parent_class gimp_convolve_tool_parent_class
|
2001-11-20 15:00:47 -08:00
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
void
|
2002-03-28 19:50:29 -08:00
|
|
|
gimp_convolve_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 04:31:08 -07:00
|
|
|
gpointer data)
|
1999-04-08 15:25:54 -07:00
|
|
|
{
|
2002-03-28 19:50:29 -08:00
|
|
|
(* callback) (GIMP_TYPE_CONVOLVE_TOOL,
|
2003-02-05 06:39:40 -08:00
|
|
|
GIMP_TYPE_CONVOLVE_OPTIONS,
|
|
|
|
|
gimp_convolve_options_gui,
|
2003-06-29 13:40:45 -07:00
|
|
|
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
|
2002-03-21 04:17:17 -08:00
|
|
|
"gimp-convolve-tool",
|
2006-09-26 15:58:10 -07:00
|
|
|
_("Blur / Sharpen"),
|
|
|
|
|
_("Blur / Sharpen Tool: Selective blurring or unblurring using a brush"),
|
|
|
|
|
N_("Bl_ur / Sharpen"), "<shift>U",
|
2003-08-21 18:42:57 -07:00
|
|
|
NULL, GIMP_HELP_TOOL_CONVOLVE,
|
2017-03-05 07:01:59 -08:00
|
|
|
GIMP_ICON_TOOL_BLUR,
|
2002-05-03 04:31:08 -07:00
|
|
|
data);
|
1999-04-08 15:25:54 -07:00
|
|
|
}
|
|
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
|
|
|
|
gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
|
|
|
|
|
{
|
2004-05-28 02:34:13 -07:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
tool_class->modifier_key = gimp_convolve_tool_modifier_key;
|
2001-11-08 11:14:51 -08:00
|
|
|
tool_class->cursor_update = gimp_convolve_tool_cursor_update;
|
2006-08-01 16:42:12 -07:00
|
|
|
tool_class->oper_update = gimp_convolve_tool_oper_update;
|
2001-04-19 06:01:44 -07:00
|
|
|
}
|
2000-01-14 04:41:00 -08:00
|
|
|
|
2001-04-19 06:01:44 -07:00
|
|
|
static void
|
|
|
|
|
gimp_convolve_tool_init (GimpConvolveTool *convolve)
|
|
|
|
|
{
|
2004-05-28 02:34:13 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (convolve);
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2002-06-16 10:13:39 -07:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-04 16:08:29 -07:00
|
|
|
GIMP_TOOL_CURSOR_BLUR);
|
2002-06-16 10:13:39 -07:00
|
|
|
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
|
|
|
|
|
GIMP_CURSOR_MODIFIER_MINUS);
|
2006-08-01 16:42:12 -07:00
|
|
|
|
2014-04-29 13:44:58 -07:00
|
|
|
gimp_convolve_tool_status_update (tool, GIMP_CONVOLVE_BLUR);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
1999-04-26 19:09:03 -07:00
|
|
|
static void
|
2001-11-08 11:14:51 -08:00
|
|
|
gimp_convolve_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
2006-04-12 05:49:29 -07:00
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
1999-04-26 19:09:03 -07:00
|
|
|
{
|
2015-10-17 06:31:08 -07:00
|
|
|
GimpConvolveTool *convolve = GIMP_CONVOLVE_TOOL (tool);
|
|
|
|
|
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
|
|
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
2011-03-31 13:41:10 -07:00
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
if (((key == toggle_mask) &&
|
|
|
|
|
! (state & line_mask) && /* leave stuff untouched in line draw mode */
|
2011-03-31 13:41:10 -07:00
|
|
|
press != convolve->toggled)
|
2001-11-20 15:00:47 -08:00
|
|
|
|
2011-03-31 13:41:10 -07:00
|
|
|
||
|
|
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
(key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
|
|
|
|
|
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
|
|
|
|
|
convolve->toggled &&
|
2011-10-06 12:59:07 -07:00
|
|
|
! (state & toggle_mask)))
|
1999-04-26 19:09:03 -07:00
|
|
|
{
|
2011-03-31 13:41:10 -07:00
|
|
|
convolve->toggled = press;
|
|
|
|
|
|
2001-11-20 15:00:47 -08:00
|
|
|
switch (options->type)
|
2001-11-08 11:14:51 -08:00
|
|
|
{
|
2014-04-29 13:44:58 -07:00
|
|
|
case GIMP_CONVOLVE_BLUR:
|
|
|
|
|
g_object_set (options, "type", GIMP_CONVOLVE_SHARPEN, NULL);
|
2001-11-08 11:14:51 -08:00
|
|
|
break;
|
2003-02-07 09:12:21 -08:00
|
|
|
|
2014-04-29 13:44:58 -07:00
|
|
|
case GIMP_CONVOLVE_SHARPEN:
|
|
|
|
|
g_object_set (options, "type", GIMP_CONVOLVE_BLUR, NULL);
|
2001-11-08 11:14:51 -08:00
|
|
|
break;
|
|
|
|
|
}
|
1999-04-26 19:09:03 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-29 09:12:40 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_convolve_tool_cursor_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display)
|
2000-07-29 09:12:40 -07:00
|
|
|
{
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
|
2001-11-20 15:00:47 -08:00
|
|
|
|
2005-11-23 11:14:05 -08:00
|
|
|
gimp_tool_control_set_toggled (tool->control,
|
2014-04-29 13:44:58 -07:00
|
|
|
options->type == GIMP_CONVOLVE_SHARPEN);
|
2000-07-29 09:12:40 -07:00
|
|
|
|
2006-03-28 09:55:52 -08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_convolve_tool_oper_update (GimpTool *tool,
|
|
|
|
|
const GimpCoords *coords,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
gboolean proximity,
|
|
|
|
|
GimpDisplay *display)
|
2006-08-01 16:42:12 -07:00
|
|
|
{
|
2006-09-05 11:25:31 -07:00
|
|
|
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
|
2006-08-27 15:19:35 -07:00
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
gimp_convolve_tool_status_update (tool, options->type);
|
|
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_convolve_tool_status_update (GimpTool *tool,
|
|
|
|
|
GimpConvolveType type)
|
|
|
|
|
{
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
2014-04-29 13:44:58 -07:00
|
|
|
case GIMP_CONVOLVE_BLUR:
|
2006-09-11 23:37:54 -07:00
|
|
|
paint_tool->status = _("Click to blur");
|
|
|
|
|
paint_tool->status_line = _("Click to blur the line");
|
2006-08-01 16:42:12 -07:00
|
|
|
paint_tool->status_ctrl = _("%s to sharpen");
|
|
|
|
|
break;
|
|
|
|
|
|
2014-04-29 13:44:58 -07:00
|
|
|
case GIMP_CONVOLVE_SHARPEN:
|
2006-09-11 23:37:54 -07:00
|
|
|
paint_tool->status = _("Click to sharpen");
|
|
|
|
|
paint_tool->status_line = _("Click to sharpen the line");
|
2006-08-01 16:42:12 -07:00
|
|
|
paint_tool->status_ctrl = _("%s to blur");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2006-08-27 15:19:35 -07:00
|
|
|
|
2002-02-14 11:31:16 -08:00
|
|
|
/* tool options stuff */
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2003-02-09 09:32:52 -08:00
|
|
|
static GtkWidget *
|
2003-02-05 06:39:40 -08:00
|
|
|
gimp_convolve_options_gui (GimpToolOptions *tool_options)
|
2001-04-19 06:01:44 -07:00
|
|
|
{
|
2011-10-06 12:59:07 -07:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
|
|
|
|
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
|
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
GtkWidget *scale;
|
|
|
|
|
gchar *str;
|
|
|
|
|
GdkModifierType toggle_mask;
|
|
|
|
|
|
|
|
|
|
toggle_mask = gimp_get_toggle_behavior_mask ();
|
2001-04-19 06:01:44 -07:00
|
|
|
|
2003-02-07 09:12:21 -08:00
|
|
|
/* the type radio box */
|
2005-09-13 15:17:05 -07:00
|
|
|
str = g_strdup_printf (_("Convolve Type (%s)"),
|
2011-10-06 12:59:07 -07:00
|
|
|
gimp_get_mod_string (toggle_mask));
|
2002-12-19 08:33:29 -08:00
|
|
|
|
2003-02-07 09:12:21 -08:00
|
|
|
frame = gimp_prop_enum_radio_frame_new (config, "type",
|
|
|
|
|
str, 0, 0);
|
2001-04-19 06:01:44 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
|
|
2002-12-19 08:33:29 -08:00
|
|
|
g_free (str);
|
|
|
|
|
|
2002-03-08 10:30:40 -08:00
|
|
|
/* the rate scale */
|
2022-02-18 13:49:45 -08:00
|
|
|
scale = gimp_prop_spin_scale_new (config, "rate",
|
2010-11-01 13:48:59 -07:00
|
|
|
1.0, 10.0, 1);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
2003-02-09 09:32:52 -08:00
|
|
|
|
|
|
|
|
return vbox;
|
2001-04-19 06:01:44 -07:00
|
|
|
}
|