2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2007-12-31 01:47:37 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
#include "base/gimplut.h"
|
|
|
|
#include "base/lut-funcs.h"
|
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
#include "gegl/gimpbrightnesscontrastconfig.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2008-05-18 01:57:39 +08:00
|
|
|
#include "widgets/gimpwidgets-constructors.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
#include "gimpbrightnesscontrasttool.h"
|
2004-02-22 22:28:53 +08:00
|
|
|
#include "gimpimagemapoptions.h"
|
2005-06-01 03:33:14 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2003-03-26 00: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-15 07:23:52 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#define SLIDER_WIDTH 200
|
|
|
|
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
static void gimp_brightness_contrast_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
static gboolean gimp_brightness_contrast_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static void gimp_brightness_contrast_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_brightness_contrast_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_brightness_contrast_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
2007-12-31 01:47:37 +08:00
|
|
|
static GeglNode *
|
2008-01-31 02:31:43 +08:00
|
|
|
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *image_map_tool,
|
|
|
|
GObject **config);
|
2007-02-28 02:55:12 +08:00
|
|
|
static void gimp_brightness_contrast_tool_map (GimpImageMapTool *image_map_tool);
|
|
|
|
static void gimp_brightness_contrast_tool_dialog (GimpImageMapTool *image_map_tool);
|
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
static void brightness_contrast_config_notify (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpBrightnessContrastTool *bc_tool);
|
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
static void brightness_contrast_brightness_changed (GtkAdjustment *adj,
|
|
|
|
GimpBrightnessContrastTool *bc_tool);
|
|
|
|
static void brightness_contrast_contrast_changed (GtkAdjustment *adj,
|
|
|
|
GimpBrightnessContrastTool *bc_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-05-18 01:57:39 +08:00
|
|
|
static void brightness_contrast_to_levels_callback (GtkWidget *widget,
|
|
|
|
GimpBrightnessContrastTool *bc_tool);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpBrightnessContrastTool, gimp_brightness_contrast_tool,
|
2006-05-15 17:46:31 +08:00
|
|
|
GIMP_TYPE_IMAGE_MAP_TOOL)
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_brightness_contrast_tool_parent_class
|
2001-05-25 07:57:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_brightness_contrast_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_BRIGHTNESS_CONTRAST_TOOL,
|
2004-02-22 22:28:53 +08:00
|
|
|
GIMP_TYPE_IMAGE_MAP_OPTIONS, NULL,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-brightness-contrast-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Brightness-Contrast"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Brightness/Contrast Tool: Adjust brightness and contrast"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("B_rightness-Contrast..."), NULL,
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_BRIGHTNESS_CONTRAST,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_BRIGHTNESS_CONTRAST,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_brightness_contrast_tool_class_init (GimpBrightnessContrastToolClass *klass)
|
|
|
|
{
|
2005-12-13 17:13:50 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-05-22 19:00:50 +08:00
|
|
|
object_class->finalize = gimp_brightness_contrast_tool_finalize;
|
|
|
|
|
|
|
|
tool_class->initialize = gimp_brightness_contrast_tool_initialize;
|
|
|
|
tool_class->button_press = gimp_brightness_contrast_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_brightness_contrast_tool_button_release;
|
|
|
|
tool_class->motion = gimp_brightness_contrast_tool_motion;
|
|
|
|
|
|
|
|
im_tool_class->shell_desc = _("Adjust Brightness and Contrast");
|
|
|
|
im_tool_class->settings_name = "brightness-contrast";
|
|
|
|
im_tool_class->import_dialog_title = _("Import Brightness-Contrast settings");
|
|
|
|
im_tool_class->export_dialog_title = _("Export Brightness-Contrast settings");
|
|
|
|
|
|
|
|
im_tool_class->get_operation = gimp_brightness_contrast_tool_get_operation;
|
|
|
|
im_tool_class->map = gimp_brightness_contrast_tool_map;
|
|
|
|
im_tool_class->dialog = gimp_brightness_contrast_tool_dialog;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
|
|
|
gimp_brightness_contrast_tool_init (GimpBrightnessContrastTool *bc_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-09 09:06:46 +08:00
|
|
|
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (bc_tool);
|
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
bc_tool->lut = gimp_lut_new ();
|
2008-01-09 09:06:46 +08:00
|
|
|
|
|
|
|
im_tool->apply_func = (GimpImageMapApplyFunc) gimp_lut_process;
|
|
|
|
im_tool->apply_data = bc_tool->lut;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_brightness_contrast_tool_finalize (GObject *object)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-11-13 19:23:01 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (object);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
|
|
|
if (bc_tool->lut)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2002-08-26 19:35:56 +08:00
|
|
|
gimp_lut_free (bc_tool->lut);
|
|
|
|
bc_tool->lut = NULL;
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2004-01-22 00:07:48 +08:00
|
|
|
static gboolean
|
2006-09-27 04:55:40 +08:00
|
|
|
gimp_brightness_contrast_tool_initialize (GimpTool *tool,
|
|
|
|
GimpDisplay *display,
|
|
|
|
GError **error)
|
2002-08-26 19:35:56 +08:00
|
|
|
{
|
2003-11-13 19:23:01 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
|
2007-07-19 22:59:51 +08:00
|
|
|
drawable = gimp_image_get_active_drawable (display->image);
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2003-11-13 19:23:01 +08:00
|
|
|
if (! drawable)
|
2004-01-22 00:07:48 +08:00
|
|
|
return FALSE;
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2003-11-13 19:23:01 +08:00
|
|
|
if (gimp_drawable_is_indexed (drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-27 04:55:40 +08:00
|
|
|
g_set_error (error, 0, 0,
|
|
|
|
_("Brightness-Contrast does not operate on indexed layers."));
|
2004-01-22 00:07:48 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-09-27 04:55:40 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-22 00:07:48 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2007-12-31 01:47:37 +08:00
|
|
|
static GeglNode *
|
2008-01-31 02:31:43 +08:00
|
|
|
gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
|
|
|
|
GObject **config)
|
2007-12-31 01:47:37 +08:00
|
|
|
{
|
2008-01-29 02:45:53 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
|
|
|
|
|
|
|
|
bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL);
|
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
*config = G_OBJECT (bc_tool->config);
|
|
|
|
|
|
|
|
g_signal_connect_object (bc_tool->config, "notify",
|
|
|
|
G_CALLBACK (brightness_contrast_config_notify),
|
|
|
|
G_OBJECT (bc_tool), 0);
|
|
|
|
|
2008-01-04 03:36:23 +08:00
|
|
|
return g_object_new (GEGL_TYPE_NODE,
|
|
|
|
"operation", "brightness-contrast",
|
|
|
|
NULL);
|
2007-12-31 01:47:37 +08:00
|
|
|
}
|
|
|
|
|
2001-05-25 07:57:08 +08:00
|
|
|
static void
|
2005-12-13 17:13:50 +08:00
|
|
|
gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool)
|
2001-05-25 07:57:08 +08:00
|
|
|
{
|
2005-12-13 17:13:50 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
|
2008-01-10 21:12:44 +08:00
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
gimp_brightness_contrast_config_set_node (bc_tool->config,
|
|
|
|
im_tool->operation);
|
2007-12-31 01:47:37 +08:00
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
brightness_contrast_lut_setup (bc_tool->lut,
|
2008-01-29 02:45:53 +08:00
|
|
|
bc_tool->config->brightness / 2.0,
|
|
|
|
bc_tool->config->contrast,
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_drawable_bytes (im_tool->drawable));
|
2001-05-25 07:57:08 +08:00
|
|
|
}
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
|
2005-06-01 03:33:14 +08:00
|
|
|
static void
|
|
|
|
gimp_brightness_contrast_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2005-06-01 03:33:14 +08:00
|
|
|
{
|
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
|
|
|
|
|
2008-01-29 02:45:53 +08:00
|
|
|
bc_tool->x = coords->x - bc_tool->config->contrast * 127.0;
|
|
|
|
bc_tool->y = coords->y + bc_tool->config->brightness * 127.0;
|
|
|
|
bc_tool->dx = bc_tool->config->contrast * 127.0;
|
|
|
|
bc_tool->dy = - bc_tool->config->brightness * 127.0;
|
2005-06-01 03:33:14 +08:00
|
|
|
|
|
|
|
gimp_tool_control_activate (tool->control);
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2005-06-01 03:33:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
gimp_brightness_contrast_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
2005-06-01 03:33:14 +08:00
|
|
|
{
|
2005-12-13 17:13:50 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
|
|
|
|
GimpImageMapTool *im_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
2005-06-01 03:33:14 +08:00
|
|
|
|
|
|
|
gimp_tool_control_halt (tool->control);
|
|
|
|
|
|
|
|
if (bc_tool->dx == 0 && bc_tool->dy == 0)
|
|
|
|
return;
|
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
|
2008-01-31 02:31:43 +08:00
|
|
|
gimp_config_reset (GIMP_CONFIG (bc_tool->config));
|
2005-06-01 03:33:14 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
gimp_image_map_tool_preview (im_tool);
|
2005-06-01 03:33:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_brightness_contrast_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2005-06-01 03:33:14 +08:00
|
|
|
{
|
2005-12-13 17:13:50 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
|
2005-06-01 03:33:14 +08:00
|
|
|
|
|
|
|
gimp_tool_control_pause (tool->control);
|
|
|
|
|
|
|
|
bc_tool->dx = (coords->x - bc_tool->x);
|
|
|
|
bc_tool->dy = - (coords->y - bc_tool->y);
|
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
g_object_set (bc_tool->config,
|
|
|
|
"brightness", CLAMP (bc_tool->dy, -127.0, 127.0) / 127.0,
|
|
|
|
"contrast", CLAMP (bc_tool->dx, -127.0, 127.0) / 127.0,
|
|
|
|
NULL);
|
2005-06-01 03:33:14 +08:00
|
|
|
|
|
|
|
gimp_tool_control_resume (tool->control);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/********************************/
|
|
|
|
/* Brightness Contrast dialog */
|
|
|
|
/********************************/
|
|
|
|
|
2002-08-26 19:35:56 +08:00
|
|
|
static void
|
2005-12-13 17:13:50 +08:00
|
|
|
gimp_brightness_contrast_tool_dialog (GimpImageMapTool *im_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-31 02:31:43 +08:00
|
|
|
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
|
|
|
|
GimpBrightnessContrastConfig *config = bc_tool->config;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *slider;
|
2008-05-18 01:57:39 +08:00
|
|
|
GtkWidget *button;
|
2008-01-31 02:31:43 +08:00
|
|
|
GtkObject *data;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* The table containing sliders */
|
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
1999-11-22 19:14:29 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
2005-12-13 17:13:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), table,
|
2002-08-26 19:35:56 +08:00
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the brightness scale widget */
|
2002-08-26 19:35:56 +08:00
|
|
|
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("_Brightness:"), SLIDER_WIDTH, -1,
|
2008-01-31 02:31:43 +08:00
|
|
|
config->brightness * 127.0,
|
2002-08-26 19:35:56 +08:00
|
|
|
-127.0, 127.0, 1.0, 10.0, 0,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
NULL, NULL);
|
|
|
|
bc_tool->brightness_data = GTK_ADJUSTMENT (data);
|
2002-08-29 03:47:07 +08:00
|
|
|
slider = GIMP_SCALE_ENTRY_SCALE (data);
|
2005-09-03 23:45:04 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (data, "value-changed",
|
2007-02-28 02:55:12 +08:00
|
|
|
G_CALLBACK (brightness_contrast_brightness_changed),
|
2002-08-26 19:35:56 +08:00
|
|
|
bc_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Create the contrast scale widget */
|
2002-08-26 19:35:56 +08:00
|
|
|
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 1,
|
2002-09-07 04:44:47 +08:00
|
|
|
_("Con_trast:"), SLIDER_WIDTH, -1,
|
2008-01-31 02:31:43 +08:00
|
|
|
config->contrast * 127.0,
|
2002-08-26 19:35:56 +08:00
|
|
|
-127.0, 127.0, 1.0, 10.0, 0,
|
|
|
|
TRUE, 0.0, 0.0,
|
|
|
|
NULL, NULL);
|
|
|
|
bc_tool->contrast_data = GTK_ADJUSTMENT (data);
|
2002-08-29 03:47:07 +08:00
|
|
|
slider = GIMP_SCALE_ENTRY_SCALE (data);
|
2005-09-03 23:45:04 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
|
1999-11-22 19:14:29 +08:00
|
|
|
|
2005-05-28 00:51:39 +08:00
|
|
|
g_signal_connect (data, "value-changed",
|
2007-02-28 02:55:12 +08:00
|
|
|
G_CALLBACK (brightness_contrast_contrast_changed),
|
2002-08-26 19:35:56 +08:00
|
|
|
bc_tool);
|
2008-05-18 01:57:39 +08:00
|
|
|
|
|
|
|
button = gimp_stock_button_new (GIMP_STOCK_TOOL_LEVELS,
|
2008-05-20 14:14:53 +08:00
|
|
|
_("Edit these Settings as Levels"));
|
2008-05-18 01:57:39 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), button,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
g_signal_connect (button, "clicked",
|
|
|
|
G_CALLBACK (brightness_contrast_to_levels_callback),
|
|
|
|
bc_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-01-31 02:31:43 +08:00
|
|
|
brightness_contrast_config_notify (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpBrightnessContrastTool *bc_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-31 02:31:43 +08:00
|
|
|
GimpBrightnessContrastConfig *config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (object);
|
1999-06-23 23:24:46 +08:00
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
if (! bc_tool->brightness_data)
|
|
|
|
return;
|
1999-06-26 19:16:47 +08:00
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
if (! strcmp (pspec->name, "brightness"))
|
|
|
|
{
|
|
|
|
gtk_adjustment_set_value (bc_tool->brightness_data,
|
|
|
|
config->brightness * 127.0);
|
|
|
|
}
|
|
|
|
else if (! strcmp (pspec->name, "contrast"))
|
|
|
|
{
|
|
|
|
gtk_adjustment_set_value (bc_tool->contrast_data,
|
|
|
|
config->contrast * 127.0);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2008-01-31 02:31:43 +08:00
|
|
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (bc_tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
brightness_contrast_brightness_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpBrightnessContrastTool *bc_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-29 02:45:53 +08:00
|
|
|
GimpBrightnessContrastConfig *config = bc_tool->config;
|
|
|
|
gdouble value = adjustment->value / 127.0;
|
|
|
|
|
|
|
|
if (config->brightness != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-29 02:45:53 +08:00
|
|
|
g_object_set (config,
|
|
|
|
"brightness", value,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
brightness_contrast_contrast_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpBrightnessContrastTool *bc_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-29 02:45:53 +08:00
|
|
|
GimpBrightnessContrastConfig *config = bc_tool->config;
|
|
|
|
gdouble value = adjustment->value / 127.0;
|
|
|
|
|
|
|
|
if (config->contrast != value)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-01-29 02:45:53 +08:00
|
|
|
g_object_set (config,
|
|
|
|
"contrast", value,
|
|
|
|
NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
2008-05-18 01:57:39 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
brightness_contrast_to_levels_callback (GtkWidget *widget,
|
|
|
|
GimpBrightnessContrastTool *bc_tool)
|
|
|
|
{
|
|
|
|
GimpLevelsConfig *levels;
|
|
|
|
|
|
|
|
levels = gimp_brightness_contrast_config_to_levels_config (bc_tool->config);
|
|
|
|
|
|
|
|
gimp_image_map_tool_edit_as (GIMP_IMAGE_MAP_TOOL (bc_tool),
|
|
|
|
"gimp-levels-tool",
|
|
|
|
GIMP_CONFIG (levels));
|
|
|
|
|
|
|
|
g_object_unref (levels);
|
|
|
|
}
|