2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1999-07-01 09:52:50 -07: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
|
1999-07-01 09:52:50 -07: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
|
1999-07-01 09:52:50 -07: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/>.
|
1999-07-01 09:52:50 -07:00
|
|
|
*/
|
2000-12-29 07:22:01 -08:00
|
|
|
|
1999-07-26 17:14:14 -07:00
|
|
|
#include "config.h"
|
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
|
|
|
|
2012-03-28 12:37:59 -07:00
|
|
|
#include <gegl.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
#include <gtk/gtk.h>
|
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
|
|
|
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 15:56:18 -08:00
|
|
|
|
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/gimpdodgeburnoptions.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-18 14:26:41 -08:00
|
|
|
|
2001-03-23 18:27:16 -08:00
|
|
|
#include "gimpdodgeburntool.h"
|
2003-06-29 13:40:45 -07:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
1999-07-01 09:52:50 -07:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-27 10:27:28 -07:00
|
|
|
|
2001-04-07 08:58:26 -07:00
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
static void gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
static void gimp_dodge_burn_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_dodge_burn_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_dodge_burn_tool_status_update (GimpTool *tool,
|
|
|
|
|
GimpDodgeBurnType type);
|
|
|
|
|
|
|
|
|
|
static GtkWidget * gimp_dodge_burn_options_gui (GimpToolOptions *tool_options);
|
1999-07-01 09:52:50 -07:00
|
|
|
|
|
|
|
|
|
2006-08-15 14:46:22 -07:00
|
|
|
G_DEFINE_TYPE (GimpDodgeBurnTool, gimp_dodge_burn_tool, GIMP_TYPE_BRUSH_TOOL)
|
2005-12-13 01:13:50 -08:00
|
|
|
|
|
|
|
|
#define parent_class gimp_dodge_burn_tool_parent_class
|
1999-07-01 09:52:50 -07:00
|
|
|
|
|
|
|
|
|
2001-03-31 07:45:05 -08:00
|
|
|
void
|
2004-04-21 03:55:45 -07:00
|
|
|
gimp_dodge_burn_tool_register (GimpToolRegisterCallback callback,
|
|
|
|
|
gpointer data)
|
2001-03-31 07:45:05 -08:00
|
|
|
{
|
2004-04-21 03:55:45 -07:00
|
|
|
(* callback) (GIMP_TYPE_DODGE_BURN_TOOL,
|
2003-02-05 06:39:40 -08:00
|
|
|
GIMP_TYPE_DODGE_BURN_OPTIONS,
|
|
|
|
|
gimp_dodge_burn_options_gui,
|
2003-06-29 13:40:45 -07:00
|
|
|
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
|
2004-04-21 03:55:45 -07:00
|
|
|
"gimp-dodge-burn-tool",
|
2006-09-26 15:58:10 -07:00
|
|
|
_("Dodge / Burn"),
|
|
|
|
|
_("Dodge / Burn Tool: Selectively lighten or darken using a brush"),
|
|
|
|
|
N_("Dod_ge / Burn"), "<shift>D",
|
2003-08-21 18:42:57 -07:00
|
|
|
NULL, GIMP_HELP_TOOL_DODGE_BURN,
|
2017-03-05 07:01:59 -08:00
|
|
|
GIMP_ICON_TOOL_DODGE,
|
2002-05-03 04:31:08 -07:00
|
|
|
data);
|
2001-03-31 07:45:05 -08:00
|
|
|
}
|
|
|
|
|
|
1999-07-01 09:52:50 -07:00
|
|
|
static void
|
2004-04-21 03:55:45 -07:00
|
|
|
gimp_dodge_burn_tool_class_init (GimpDodgeBurnToolClass *klass)
|
2001-03-23 18:27:16 -08:00
|
|
|
{
|
2006-08-27 15:19:35 -07:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
2001-03-23 18:27:16 -08:00
|
|
|
|
2004-04-21 03:55:45 -07:00
|
|
|
tool_class->modifier_key = gimp_dodge_burn_tool_modifier_key;
|
|
|
|
|
tool_class->cursor_update = gimp_dodge_burn_tool_cursor_update;
|
2006-08-01 16:42:12 -07:00
|
|
|
tool_class->oper_update = gimp_dodge_burn_tool_oper_update;
|
2001-03-31 07:45:05 -08:00
|
|
|
}
|
2001-03-23 18:27:16 -08:00
|
|
|
|
|
|
|
|
static void
|
2004-04-21 03:55:45 -07:00
|
|
|
gimp_dodge_burn_tool_init (GimpDodgeBurnTool *dodgeburn)
|
1999-07-01 09:52:50 -07:00
|
|
|
{
|
2004-05-28 02:34:13 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (dodgeburn);
|
2001-03-23 18:27:16 -08: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_DODGE);
|
2002-06-16 10:13:39 -07:00
|
|
|
gimp_tool_control_set_toggle_tool_cursor (tool->control,
|
2004-06-04 16:08:29 -07:00
|
|
|
GIMP_TOOL_CURSOR_BURN);
|
2006-08-01 16:42:12 -07:00
|
|
|
|
2014-04-29 11:55:08 -07:00
|
|
|
gimp_dodge_burn_tool_status_update (tool, GIMP_DODGE_BURN_TYPE_BURN);
|
1999-07-01 09:52:50 -07:00
|
|
|
}
|
2001-03-31 07:45:05 -08:00
|
|
|
|
1999-07-01 09:52:50 -07:00
|
|
|
static void
|
2004-04-21 03:55:45 -07:00
|
|
|
gimp_dodge_burn_tool_modifier_key (GimpTool *tool,
|
|
|
|
|
GdkModifierType key,
|
|
|
|
|
gboolean press,
|
|
|
|
|
GdkModifierType state,
|
2006-03-28 09:55:52 -08:00
|
|
|
GimpDisplay *display)
|
1999-07-01 09:52:50 -07:00
|
|
|
{
|
2015-10-17 06:31:08 -07:00
|
|
|
GimpDodgeBurnTool *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
|
|
|
|
|
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
|
|
|
|
|
GdkModifierType line_mask = GIMP_PAINT_TOOL_LINE_MASK;
|
|
|
|
|
GdkModifierType toggle_mask = gimp_get_toggle_behavior_mask ();
|
2001-11-20 15:00:47 -08: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 != dodgeburn->toggled)
|
|
|
|
|
|
|
|
|
|
||
|
|
|
|
|
|
2015-10-17 06:31:08 -07:00
|
|
|
(key == line_mask && /* toggle back after keypresses CTRL(hold)-> */
|
|
|
|
|
! press && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
|
|
|
|
|
dodgeburn->toggled &&
|
2011-10-06 12:59:07 -07:00
|
|
|
! (state & toggle_mask)))
|
1999-07-01 09:52:50 -07:00
|
|
|
{
|
2011-03-31 13:41:10 -07:00
|
|
|
dodgeburn->toggled = press;
|
|
|
|
|
|
2001-11-20 15:00:47 -08:00
|
|
|
switch (options->type)
|
2001-11-08 11:14:51 -08:00
|
|
|
{
|
2014-04-29 11:55:08 -07:00
|
|
|
case GIMP_DODGE_BURN_TYPE_DODGE:
|
|
|
|
|
g_object_set (options, "type", GIMP_DODGE_BURN_TYPE_BURN, NULL);
|
2001-11-08 11:14:51 -08:00
|
|
|
break;
|
2003-02-07 09:12:21 -08:00
|
|
|
|
2014-04-29 11:55:08 -07:00
|
|
|
case GIMP_DODGE_BURN_TYPE_BURN:
|
|
|
|
|
g_object_set (options, "type", GIMP_DODGE_BURN_TYPE_DODGE, NULL);
|
2001-11-08 11:14:51 -08:00
|
|
|
break;
|
2003-02-07 09:12:21 -08:00
|
|
|
|
2001-11-08 11:14:51 -08:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-07-01 09:52:50 -07:00
|
|
|
}
|
2000-06-14 07:22:47 -07:00
|
|
|
|
2006-08-27 15:19:35 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
|
|
|
|
|
display);
|
1999-07-01 09:52:50 -07:00
|
|
|
}
|
|
|
|
|
|
2000-07-29 09:12:40 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_dodge_burn_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
|
|
|
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
|
2001-11-20 15:00:47 -08:00
|
|
|
|
2014-04-29 11:55:08 -07:00
|
|
|
gimp_tool_control_set_toggled (tool->control,
|
|
|
|
|
options->type == GIMP_DODGE_BURN_TYPE_BURN);
|
2000-07-29 09:12:40 -07:00
|
|
|
|
2006-08-27 15:19:35 -07:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state,
|
|
|
|
|
display);
|
1999-07-01 09:52:50 -07:00
|
|
|
}
|
|
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
static void
|
2008-11-01 08:17:36 -07:00
|
|
|
gimp_dodge_burn_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
|
|
|
GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
|
2006-08-27 15:19:35 -07:00
|
|
|
|
2006-08-01 16:42:12 -07:00
|
|
|
gimp_dodge_burn_tool_status_update (tool, options->type);
|
|
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
|
|
|
|
display);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_dodge_burn_tool_status_update (GimpTool *tool,
|
|
|
|
|
GimpDodgeBurnType type)
|
|
|
|
|
{
|
|
|
|
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
2014-04-29 11:55:08 -07:00
|
|
|
case GIMP_DODGE_BURN_TYPE_DODGE:
|
2006-09-11 23:37:54 -07:00
|
|
|
paint_tool->status = _("Click to dodge");
|
|
|
|
|
paint_tool->status_line = _("Click to dodge the line");
|
2006-08-01 16:42:12 -07:00
|
|
|
paint_tool->status_ctrl = _("%s to burn");
|
|
|
|
|
break;
|
|
|
|
|
|
2014-04-29 11:55:08 -07:00
|
|
|
case GIMP_DODGE_BURN_TYPE_BURN:
|
2006-09-11 23:37:54 -07:00
|
|
|
paint_tool->status = _("Click to burn");
|
|
|
|
|
paint_tool->status_line = _("Click to burn the line");
|
2006-08-01 16:42:12 -07:00
|
|
|
paint_tool->status_ctrl = _("%s to dodge");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-07 04:01:22 -07:00
|
|
|
|
|
|
|
|
/* tool options stuff */
|
|
|
|
|
|
2003-02-09 09:32:52 -08:00
|
|
|
static GtkWidget *
|
2003-02-05 06:39:40 -08:00
|
|
|
gimp_dodge_burn_options_gui (GimpToolOptions *tool_options)
|
1999-07-01 09:52:50 -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 ();
|
2000-12-30 20:07:42 -08:00
|
|
|
|
2001-04-07 04:01:22 -07:00
|
|
|
/* the type (dodge or burn) */
|
2005-09-13 15:17:05 -07:00
|
|
|
str = g_strdup_printf (_("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-07 04:01:22 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
2002-12-19 08:33:29 -08:00
|
|
|
g_free (str);
|
|
|
|
|
|
2001-04-07 04:01:22 -07:00
|
|
|
/* mode (highlights, midtones, or shadows) */
|
2016-02-11 14:44:07 -08:00
|
|
|
frame = gimp_prop_enum_radio_frame_new (config, "mode", NULL,
|
|
|
|
|
0, 0);
|
2001-04-07 04:01:22 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
2002-03-08 10:30:40 -08:00
|
|
|
/* the exposure scale */
|
2016-02-11 14:44:07 -08:00
|
|
|
scale = gimp_prop_spin_scale_new (config, "exposure", NULL,
|
2010-11-01 13:48:59 -07:00
|
|
|
1.0, 10.0, 1);
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
|
|
|
|
gtk_widget_show (scale);
|
2003-02-09 09:32:52 -08:00
|
|
|
|
|
|
|
|
return vbox;
|
2001-03-23 18:27:16 -08:00
|
|
|
}
|