2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-06-04 23:48:17 +08:00
|
|
|
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-06-04 23:48:17 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-04 23:48:17 +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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-06-04 23:48:17 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-06-04 23:48:17 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2004-07-27 03:56:47 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2006-05-28 22:13:44 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
#include "core/gimp.h"
|
2006-05-28 22:13:44 +08:00
|
|
|
#include "core/gimpdata.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-06-05 04:23:36 +08:00
|
|
|
#include "core/gimpimage-pick-color.h"
|
2005-03-09 08:23:19 +08:00
|
|
|
#include "core/gimpimage-sample-points.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
#include "core/gimpitem.h"
|
2003-06-05 04:23:36 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2007-01-30 18:34:59 +08:00
|
|
|
#include "core/gimpsamplepoint.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2006-05-28 22:13:44 +08:00
|
|
|
#include "widgets/gimpcolormapeditor.h"
|
|
|
|
#include "widgets/gimpdialogfactory.h"
|
|
|
|
#include "widgets/gimpdockable.h"
|
|
|
|
#include "widgets/gimppaletteeditor.h"
|
|
|
|
#include "widgets/gimpsessioninfo.h"
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2010-09-30 08:03:16 +08:00
|
|
|
#include "display/gimpcanvasitem.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2005-03-09 08:23:19 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
#include "display/gimpdisplayshell-appearance.h"
|
2006-09-05 01:18:38 +08:00
|
|
|
#include "display/gimpdisplayshell-selection.h"
|
2005-03-09 08:23:19 +08:00
|
|
|
#include "display/gimpdisplayshell-transform.h"
|
2003-06-04 23:48:17 +08:00
|
|
|
|
|
|
|
#include "gimpcoloroptions.h"
|
|
|
|
#include "gimpcolortool.h"
|
|
|
|
#include "gimptoolcontrol.h"
|
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2010-10-05 03:40:52 +08:00
|
|
|
#define SAMPLE_POINT_POSITION_INVALID G_MININT
|
|
|
|
|
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PICKED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-06-04 23:48:17 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
static void gimp_color_tool_finalize (GObject *object);
|
|
|
|
|
|
|
|
static void gimp_color_tool_button_press (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2009-06-20 23:37:31 +08:00
|
|
|
GimpButtonPressType press_type,
|
2007-02-28 02:55:12 +08:00
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_tool_button_release (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_tool_motion (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_tool_oper_update (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_tool_cursor_update (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_color_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
|
|
|
static gboolean gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImageType *sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint *color_index);
|
|
|
|
static void gimp_color_tool_pick (GimpColorTool *tool,
|
|
|
|
GimpColorPickState pick_state,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
|
|
|
static void gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
|
|
|
GimpColorPickState pick_state,
|
|
|
|
GimpImageType sample_type,
|
2011-04-04 06:08:57 +08:00
|
|
|
const GimpRGB *color,
|
2007-02-28 02:55:12 +08:00
|
|
|
gint color_index);
|
2003-06-05 04:23:36 +08:00
|
|
|
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpColorTool, gimp_color_tool, GIMP_TYPE_DRAW_TOOL);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_color_tool_parent_class
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
static guint gimp_color_tool_signals[LAST_SIGNAL] = { 0 };
|
2003-06-04 23:48:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_tool_class_init (GimpColorToolClass *klass)
|
|
|
|
{
|
2004-06-30 20:10:08 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
gimp_color_tool_signals[PICKED] =
|
|
|
|
g_signal_new ("picked",
|
2005-03-07 19:37:03 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpColorToolClass, picked),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__ENUM_ENUM_BOXED_INT,
|
|
|
|
G_TYPE_NONE, 4,
|
2004-06-30 20:10:08 +08:00
|
|
|
GIMP_TYPE_COLOR_PICK_STATE,
|
2003-06-05 04:23:36 +08:00
|
|
|
GIMP_TYPE_IMAGE_TYPE,
|
2004-07-27 03:56:47 +08:00
|
|
|
GIMP_TYPE_RGB | G_SIGNAL_TYPE_STATIC_SCOPE,
|
2003-06-05 04:23:36 +08:00
|
|
|
G_TYPE_INT);
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
object_class->finalize = gimp_color_tool_finalize;
|
|
|
|
|
2003-06-04 23:48:17 +08:00
|
|
|
tool_class->button_press = gimp_color_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_color_tool_button_release;
|
|
|
|
tool_class->motion = gimp_color_tool_motion;
|
2005-03-09 08:23:19 +08:00
|
|
|
tool_class->oper_update = gimp_color_tool_oper_update;
|
2003-06-04 23:48:17 +08:00
|
|
|
tool_class->cursor_update = gimp_color_tool_cursor_update;
|
|
|
|
|
2005-03-07 19:37:03 +08:00
|
|
|
draw_class->draw = gimp_color_tool_draw;
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
klass->pick = gimp_color_tool_real_pick;
|
2006-05-28 22:13:44 +08:00
|
|
|
klass->picked = gimp_color_tool_real_picked;
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
static void
|
|
|
|
gimp_color_tool_init (GimpColorTool *color_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
|
|
|
|
2006-11-17 21:06:00 +08:00
|
|
|
gimp_tool_control_set_action_value_2 (tool->control,
|
2005-03-09 08:23:19 +08:00
|
|
|
"tools/tools-color-average-radius-set");
|
|
|
|
|
|
|
|
color_tool->enabled = FALSE;
|
|
|
|
color_tool->center_x = 0;
|
|
|
|
color_tool->center_y = 0;
|
|
|
|
color_tool->pick_mode = GIMP_COLOR_PICK_MODE_NONE;
|
|
|
|
|
|
|
|
color_tool->options = NULL;
|
|
|
|
|
|
|
|
color_tool->sample_point = NULL;
|
|
|
|
color_tool->moving_sample_point = FALSE;
|
2010-10-05 03:40:52 +08:00
|
|
|
color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID;
|
|
|
|
color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID;
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
|
|
|
|
2003-06-04 23:48:17 +08:00
|
|
|
static void
|
2003-06-05 23:43:49 +08:00
|
|
|
gimp_color_tool_finalize (GObject *object)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (object);
|
|
|
|
|
|
|
|
if (color_tool->options)
|
|
|
|
{
|
|
|
|
g_object_unref (color_tool->options);
|
|
|
|
color_tool->options = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
|
|
|
|
static void
|
2009-06-20 23:37:31 +08:00
|
|
|
gimp_color_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2005-03-09 08:23:19 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
2009-10-05 01:56:39 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
/* Chain up to activate the tool */
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_press (tool, coords, time, state,
|
2009-06-20 23:37:31 +08:00
|
|
|
press_type, display);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
if (! color_tool->enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (color_tool->sample_point)
|
|
|
|
{
|
|
|
|
color_tool->moving_sample_point = TRUE;
|
|
|
|
color_tool->sample_point_x = color_tool->sample_point->x;
|
|
|
|
color_tool->sample_point_y = color_tool->sample_point->y;
|
|
|
|
|
2008-07-22 22:43:52 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
|
|
|
2010-10-09 20:26:33 +08:00
|
|
|
gimp_display_shell_selection_pause (shell);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2011-04-05 01:20:04 +08:00
|
|
|
if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status_coords (tool, display,
|
2008-08-21 00:22:09 +08:00
|
|
|
gimp_tool_control_get_precision (tool->control),
|
2005-05-07 21:24:47 +08:00
|
|
|
_("Move Sample Point: "),
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point_x,
|
|
|
|
", ",
|
2007-01-21 09:24:51 +08:00
|
|
|
color_tool->sample_point_y,
|
|
|
|
NULL);
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
|
|
|
else
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2010-09-23 07:04:22 +08:00
|
|
|
color_tool->center_x = coords->x;
|
|
|
|
color_tool->center_y = coords->y;
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
2003-06-05 04:23:36 +08:00
|
|
|
|
2004-06-30 20:10:08 +08:00
|
|
|
gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_NEW,
|
|
|
|
coords->x, coords->y);
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
gimp_color_tool_button_release (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2005-03-09 08:23:19 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
2009-10-05 01:56:39 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2009-10-08 01:00:42 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2006-09-12 17:05:41 +08:00
|
|
|
/* Chain up to halt the tool */
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state,
|
2007-02-28 02:55:12 +08:00
|
|
|
release_type, display);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
if (! color_tool->enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (color_tool->moving_sample_point)
|
|
|
|
{
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2008-07-22 22:43:52 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
|
2005-03-09 08:23:19 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
|
|
|
color_tool->moving_sample_point = FALSE;
|
2010-10-05 03:40:52 +08:00
|
|
|
color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID;
|
|
|
|
color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2010-10-09 20:26:33 +08:00
|
|
|
gimp_display_shell_selection_resume (shell);
|
2005-03-09 08:23:19 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
|
|
|
|
2005-03-20 06:04:31 +08:00
|
|
|
if ((color_tool->sample_point_x < x ||
|
|
|
|
color_tool->sample_point_x > (x + width - 1) ||
|
|
|
|
color_tool->sample_point_y < y ||
|
|
|
|
color_tool->sample_point_y > (y + height - 1)))
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
|
|
|
if (color_tool->sample_point)
|
|
|
|
{
|
2009-10-08 01:00:42 +08:00
|
|
|
gimp_image_remove_sample_point (image,
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point, TRUE);
|
|
|
|
color_tool->sample_point = NULL;
|
|
|
|
}
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (color_tool->sample_point)
|
|
|
|
{
|
2009-10-08 01:00:42 +08:00
|
|
|
gimp_image_move_sample_point (image,
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point,
|
|
|
|
color_tool->sample_point_x,
|
|
|
|
color_tool->sample_point_y,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
color_tool->sample_point =
|
2009-10-08 01:00:42 +08:00
|
|
|
gimp_image_add_sample_point_at_pos (image,
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point_x,
|
|
|
|
color_tool->sample_point_y,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-09 20:26:33 +08:00
|
|
|
gimp_display_shell_selection_resume (shell);
|
2009-10-08 01:00:42 +08:00
|
|
|
gimp_image_flush (image);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
color_tool->moving_sample_point = FALSE;
|
2010-10-05 03:40:52 +08:00
|
|
|
color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID;
|
|
|
|
color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID;
|
2010-09-30 07:32:34 +08:00
|
|
|
|
|
|
|
if (color_tool->sample_point)
|
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_color_tool_motion (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2005-03-09 08:23:19 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
2009-10-05 01:56:39 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
if (! color_tool->enabled)
|
|
|
|
return;
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
if (color_tool->moving_sample_point)
|
|
|
|
{
|
|
|
|
gint tx, ty;
|
|
|
|
gboolean delete_point = FALSE;
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
gimp_display_shell_transform_xy (shell,
|
|
|
|
coords->x, coords->y,
|
2010-09-23 16:50:39 +08:00
|
|
|
&tx, &ty);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2005-03-20 06:04:31 +08:00
|
|
|
if (tx < 0 || tx > shell->disp_width ||
|
|
|
|
ty < 0 || ty > shell->disp_height)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2010-10-05 03:40:52 +08:00
|
|
|
color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID;
|
|
|
|
color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID;
|
2003-06-05 04:23:36 +08:00
|
|
|
|
2005-03-09 08:23:19 +08:00
|
|
|
delete_point = TRUE;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gint x, y, width, height;
|
|
|
|
|
2005-03-20 06:04:31 +08:00
|
|
|
color_tool->sample_point_x = floor (coords->x);
|
|
|
|
color_tool->sample_point_y = floor (coords->y);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y,
|
|
|
|
&width, &height);
|
|
|
|
|
2005-03-20 06:04:31 +08:00
|
|
|
if ((color_tool->sample_point_x < x ||
|
|
|
|
color_tool->sample_point_x > (x + width - 1) ||
|
|
|
|
color_tool->sample_point_y < y ||
|
|
|
|
color_tool->sample_point_y > (y + height - 1)))
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
|
|
|
delete_point = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
if (delete_point)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status (tool, display,
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point ?
|
|
|
|
_("Remove Sample Point") :
|
|
|
|
_("Cancel Sample Point"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status_coords (tool, display,
|
2008-08-21 00:22:09 +08:00
|
|
|
gimp_tool_control_get_precision (tool->control),
|
2005-03-09 08:23:19 +08:00
|
|
|
color_tool->sample_point ?
|
|
|
|
_("Move Sample Point: ") :
|
|
|
|
_("Add Sample Point: "),
|
|
|
|
color_tool->sample_point_x,
|
|
|
|
", ",
|
2007-01-21 09:24:51 +08:00
|
|
|
color_tool->sample_point_y,
|
|
|
|
NULL);
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2010-09-23 07:04:22 +08:00
|
|
|
color_tool->center_x = coords->x;
|
|
|
|
color_tool->center_y = coords->y;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
gimp_color_tool_pick (color_tool, GIMP_COLOR_PICK_STATE_UPDATE,
|
|
|
|
coords->x, coords->y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_color_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
2009-10-05 01:56:39 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
2009-10-08 01:00:42 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2005-03-09 08:23:19 +08:00
|
|
|
GimpSamplePoint *sample_point = NULL;
|
|
|
|
|
2011-04-05 01:20:04 +08:00
|
|
|
if (color_tool->enabled &&
|
|
|
|
gimp_display_shell_get_show_sample_points (shell) &&
|
|
|
|
proximity)
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
2011-04-05 01:20:04 +08:00
|
|
|
gint snap_distance = display->config->snap_distance;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
sample_point =
|
2009-10-08 01:00:42 +08:00
|
|
|
gimp_image_find_sample_point (image,
|
2005-03-09 08:23:19 +08:00
|
|
|
coords->x, coords->y,
|
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance));
|
|
|
|
}
|
|
|
|
|
2010-09-30 07:32:34 +08:00
|
|
|
if (color_tool->sample_point != sample_point)
|
|
|
|
{
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2010-09-30 07:32:34 +08:00
|
|
|
gimp_draw_tool_pause (draw_tool);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2010-09-30 07:32:34 +08:00
|
|
|
if (gimp_draw_tool_is_active (draw_tool) &&
|
|
|
|
draw_tool->display != display)
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
color_tool->sample_point = sample_point;
|
|
|
|
|
|
|
|
if (! gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (draw_tool);
|
2010-08-12 19:13:15 +08:00
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_color_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2003-06-06 02:47:23 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
2009-10-08 01:00:42 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
2003-06-06 02:47:23 +08:00
|
|
|
|
|
|
|
if (color_tool->enabled)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2005-03-09 08:23:19 +08:00
|
|
|
if (color_tool->sample_point)
|
2003-06-05 04:23:36 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_set_cursor (tool, display,
|
2005-11-20 06:16:34 +08:00
|
|
|
GIMP_CURSOR_MOUSE,
|
2005-03-09 08:23:19 +08:00
|
|
|
GIMP_TOOL_CURSOR_COLOR_PICKER,
|
|
|
|
GIMP_CURSOR_MODIFIER_MOVE);
|
2003-06-05 04:23:36 +08:00
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
else
|
2003-10-26 03:00:49 +08:00
|
|
|
{
|
2006-06-02 04:30:52 +08:00
|
|
|
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2009-10-08 01:00:42 +08:00
|
|
|
if (gimp_image_coords_in_active_pickable (image, coords,
|
2006-06-03 23:41:40 +08:00
|
|
|
color_tool->options->sample_merged,
|
|
|
|
FALSE))
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
2006-06-02 04:30:52 +08:00
|
|
|
switch (color_tool->pick_mode)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_PICK_MODE_NONE:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_NONE;
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_PICK_MODE_FOREGROUND:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_PICK_MODE_BACKGROUND:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
|
|
|
|
break;
|
|
|
|
case GIMP_COLOR_PICK_MODE_PALETTE:
|
|
|
|
modifier = GIMP_CURSOR_MODIFIER_PLUS;
|
|
|
|
break;
|
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_set_cursor (tool, display,
|
2006-06-02 04:30:52 +08:00
|
|
|
GIMP_CURSOR_COLOR_PICKER,
|
|
|
|
GIMP_TOOL_CURSOR_COLOR_PICKER,
|
2005-09-27 00:01:13 +08:00
|
|
|
modifier);
|
2003-10-26 03:00:49 +08:00
|
|
|
}
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
return; /* don't chain up */
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_color_tool_draw (GimpDrawTool *draw_tool)
|
|
|
|
{
|
2003-07-11 00:01:45 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (draw_tool);
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2007-07-19 17:09:26 +08:00
|
|
|
if (color_tool->enabled)
|
2003-06-05 04:23:36 +08:00
|
|
|
{
|
2010-09-30 07:32:34 +08:00
|
|
|
if (color_tool->sample_point)
|
|
|
|
{
|
|
|
|
GimpImage *image = gimp_display_get_image (draw_tool->display);
|
|
|
|
GimpCanvasItem *item;
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
index = g_list_index (gimp_image_get_sample_points (image),
|
|
|
|
color_tool->sample_point) + 1;
|
|
|
|
|
2010-09-30 08:03:16 +08:00
|
|
|
item = gimp_draw_tool_add_sample_point (draw_tool,
|
|
|
|
color_tool->sample_point->x,
|
|
|
|
color_tool->sample_point->y,
|
|
|
|
index);
|
2010-09-30 07:32:34 +08:00
|
|
|
gimp_canvas_item_set_highlight (item, TRUE);
|
|
|
|
}
|
|
|
|
|
2007-07-19 17:09:26 +08:00
|
|
|
if (color_tool->moving_sample_point)
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
2010-10-05 03:40:52 +08:00
|
|
|
if (color_tool->sample_point_x != SAMPLE_POINT_POSITION_INVALID &&
|
|
|
|
color_tool->sample_point_y != SAMPLE_POINT_POSITION_INVALID)
|
2007-07-19 17:09:26 +08:00
|
|
|
{
|
2010-10-05 04:02:12 +08:00
|
|
|
gimp_draw_tool_add_crosshair (draw_tool,
|
|
|
|
color_tool->sample_point_x,
|
|
|
|
color_tool->sample_point_y);
|
2007-07-19 17:09:26 +08:00
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
2010-09-30 07:32:34 +08:00
|
|
|
else if (color_tool->options->sample_average &&
|
|
|
|
gimp_tool_control_is_active (GIMP_TOOL (draw_tool)->control))
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
2010-09-30 07:32:34 +08:00
|
|
|
gdouble radius = color_tool->options->average_radius;
|
|
|
|
|
|
|
|
gimp_draw_tool_add_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
color_tool->center_x - radius,
|
|
|
|
color_tool->center_y - radius,
|
|
|
|
2 * radius + 1,
|
|
|
|
2 * radius + 1);
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|
2003-06-05 04:23:36 +08:00
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
GimpImageType *sample_type,
|
|
|
|
GimpRGB *color,
|
|
|
|
gint *color_index)
|
2003-06-04 23:48:17 +08:00
|
|
|
{
|
2009-10-08 01:00:42 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
|
|
|
GimpImage *image = gimp_display_get_image (tool->display);
|
2003-06-05 04:23:36 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_val_if_fail (tool->display != NULL, FALSE);
|
2003-06-05 04:23:36 +08:00
|
|
|
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
|
|
|
|
2009-10-08 01:00:42 +08:00
|
|
|
return gimp_image_pick_color (image, tool->drawable, x, y,
|
2003-06-05 23:43:49 +08:00
|
|
|
color_tool->options->sample_merged,
|
|
|
|
color_tool->options->sample_average,
|
|
|
|
color_tool->options->average_radius,
|
2003-06-05 04:23:36 +08:00
|
|
|
sample_type,
|
|
|
|
color,
|
|
|
|
color_index);
|
|
|
|
}
|
|
|
|
|
2006-05-28 22:13:44 +08:00
|
|
|
static void
|
|
|
|
gimp_color_tool_real_picked (GimpColorTool *color_tool,
|
|
|
|
GimpColorPickState pick_state,
|
|
|
|
GimpImageType sample_type,
|
2011-04-04 06:08:57 +08:00
|
|
|
const GimpRGB *color,
|
2006-05-28 22:13:44 +08:00
|
|
|
gint color_index)
|
|
|
|
{
|
2006-08-27 20:19:25 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpContext *context;
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2006-09-06 02:25:31 +08:00
|
|
|
/* use this tool's own options here (NOT color_tool->options) */
|
|
|
|
context = GIMP_CONTEXT (gimp_tool_get_options (tool));
|
|
|
|
|
2006-08-27 20:19:25 +08:00
|
|
|
if (color_tool->pick_mode == GIMP_COLOR_PICK_MODE_FOREGROUND ||
|
|
|
|
color_tool->pick_mode == GIMP_COLOR_PICK_MODE_BACKGROUND)
|
2006-05-28 22:13:44 +08:00
|
|
|
{
|
2006-08-27 20:19:25 +08:00
|
|
|
GimpSessionInfo *info;
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2006-08-27 20:19:25 +08:00
|
|
|
if (GIMP_IMAGE_TYPE_IS_INDEXED (sample_type))
|
|
|
|
{
|
2010-03-01 06:20:57 +08:00
|
|
|
info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
|
2006-08-27 20:19:25 +08:00
|
|
|
"gimp-indexed-palette");
|
2009-09-20 20:51:03 +08:00
|
|
|
if (info && gimp_session_info_get_widget (info))
|
2006-08-27 20:19:25 +08:00
|
|
|
{
|
|
|
|
GimpColormapEditor *editor;
|
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
editor = GIMP_COLORMAP_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2006-08-27 20:19:25 +08:00
|
|
|
gimp_colormap_editor_set_index (editor, color_index, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TRUE)
|
2006-05-28 22:13:44 +08:00
|
|
|
{
|
2010-03-01 06:20:57 +08:00
|
|
|
info = gimp_dialog_factory_find_session_info (gimp_dialog_factory_get_singleton (),
|
2006-08-27 20:19:25 +08:00
|
|
|
"gimp-palette-editor");
|
2009-09-20 20:51:03 +08:00
|
|
|
if (info && gimp_session_info_get_widget (info))
|
2006-08-27 20:19:25 +08:00
|
|
|
{
|
|
|
|
GimpPaletteEditor *editor;
|
|
|
|
gint index;
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2009-09-20 20:51:03 +08:00
|
|
|
editor = GIMP_PALETTE_EDITOR (gtk_bin_get_child (GTK_BIN (gimp_session_info_get_widget (info))));
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2006-08-27 20:19:25 +08:00
|
|
|
index = gimp_palette_editor_get_index (editor, color);
|
|
|
|
if (index != -1)
|
|
|
|
gimp_palette_editor_set_index (editor, index, NULL);
|
|
|
|
}
|
2006-05-28 22:13:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (color_tool->pick_mode)
|
|
|
|
{
|
|
|
|
case GIMP_COLOR_PICK_MODE_NONE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_FOREGROUND:
|
2006-09-06 02:25:31 +08:00
|
|
|
gimp_context_set_foreground (context, color);
|
2006-05-28 22:13:44 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_BACKGROUND:
|
2006-09-06 02:25:31 +08:00
|
|
|
gimp_context_set_background (context, color);
|
2006-05-28 22:13:44 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_COLOR_PICK_MODE_PALETTE:
|
|
|
|
{
|
2009-10-06 01:58:03 +08:00
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
|
|
|
GdkScreen *screen;
|
|
|
|
GtkWidget *dockable;
|
2006-05-28 22:13:44 +08:00
|
|
|
|
2009-10-06 01:58:03 +08:00
|
|
|
screen = gtk_widget_get_screen (GTK_WIDGET (shell));
|
2010-03-01 06:20:57 +08:00
|
|
|
dockable = gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
|
2010-03-01 02:58:37 +08:00
|
|
|
screen,
|
2006-05-28 22:13:44 +08:00
|
|
|
"gimp-palette-editor",
|
|
|
|
-1);
|
|
|
|
if (dockable)
|
|
|
|
{
|
|
|
|
GtkWidget *palette_editor;
|
|
|
|
GimpData *data;
|
|
|
|
|
|
|
|
/* don't blink like mad when updating */
|
|
|
|
if (pick_state == GIMP_COLOR_PICK_STATE_UPDATE)
|
|
|
|
gimp_dockable_blink_cancel (GIMP_DOCKABLE (dockable));
|
|
|
|
|
|
|
|
palette_editor = gtk_bin_get_child (GTK_BIN (dockable));
|
|
|
|
|
|
|
|
data = gimp_data_editor_get_data (GIMP_DATA_EDITOR (palette_editor));
|
|
|
|
|
|
|
|
if (! data)
|
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
data = GIMP_DATA (gimp_context_get_palette (context));
|
2006-05-28 22:13:44 +08:00
|
|
|
|
|
|
|
gimp_data_editor_set_data (GIMP_DATA_EDITOR (palette_editor),
|
|
|
|
data);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_palette_editor_pick_color (GIMP_PALETTE_EDITOR (palette_editor),
|
|
|
|
color, pick_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
static void
|
2004-06-30 20:10:08 +08:00
|
|
|
gimp_color_tool_pick (GimpColorTool *tool,
|
|
|
|
GimpColorPickState pick_state,
|
2005-03-07 19:37:03 +08:00
|
|
|
gint x,
|
|
|
|
gint y)
|
2003-06-05 04:23:36 +08:00
|
|
|
{
|
|
|
|
GimpColorToolClass *klass;
|
|
|
|
GimpImageType sample_type;
|
|
|
|
GimpRGB color;
|
|
|
|
gint color_index;
|
2003-06-04 23:48:17 +08:00
|
|
|
|
|
|
|
klass = GIMP_COLOR_TOOL_GET_CLASS (tool);
|
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
if (klass->pick &&
|
|
|
|
klass->pick (tool, x, y, &sample_type, &color, &color_index))
|
|
|
|
{
|
2004-06-30 20:10:08 +08:00
|
|
|
g_signal_emit (tool, gimp_color_tool_signals[PICKED], 0,
|
|
|
|
pick_state, sample_type, &color, color_index);
|
2003-06-05 04:23:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2003-06-05 23:43:49 +08:00
|
|
|
gimp_color_tool_enable (GimpColorTool *color_tool,
|
|
|
|
GimpColorOptions *options)
|
2003-06-05 04:23:36 +08:00
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_TOOL (color_tool));
|
2003-06-05 23:43:49 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLOR_OPTIONS (options));
|
2003-06-05 04:23:36 +08:00
|
|
|
|
|
|
|
tool = GIMP_TOOL (color_tool);
|
2005-03-07 19:37:03 +08:00
|
|
|
|
2003-06-05 04:23:36 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
|
|
|
{
|
2003-06-05 23:43:49 +08:00
|
|
|
g_warning ("Trying to enable GimpColorTool while it is active.");
|
2003-06-05 04:23:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (color_tool->options)
|
2005-03-07 19:37:03 +08:00
|
|
|
g_object_unref (color_tool->options);
|
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
color_tool->options = g_object_ref (options);
|
|
|
|
|
|
|
|
color_tool->enabled = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_color_tool_disable (GimpColorTool *color_tool)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_TOOL (color_tool));
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (color_tool);
|
2005-03-07 19:37:03 +08:00
|
|
|
|
2003-06-05 23:43:49 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
|
|
|
{
|
|
|
|
g_warning ("Trying to disable GimpColorTool while it is active.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (color_tool->options)
|
|
|
|
{
|
|
|
|
g_object_unref (color_tool->options);
|
|
|
|
color_tool->options = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
color_tool->enabled = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_color_tool_is_enabled (GimpColorTool *color_tool)
|
|
|
|
{
|
|
|
|
return color_tool->enabled;
|
2003-06-04 23:48:17 +08:00
|
|
|
}
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
gimp_color_tool_start_sample_point (GimpTool *tool,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2005-03-09 08:23:19 +08:00
|
|
|
{
|
|
|
|
GimpColorTool *color_tool;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_COLOR_TOOL (tool));
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
color_tool = GIMP_COLOR_TOOL (tool);
|
|
|
|
|
2010-10-09 20:26:33 +08:00
|
|
|
gimp_display_shell_selection_pause (gimp_display_get_shell (display));
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2005-03-09 08:23:19 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
2008-07-22 22:43:52 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2011-04-04 06:01:30 +08:00
|
|
|
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
2010-09-30 07:32:34 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
2005-03-09 08:23:19 +08:00
|
|
|
|
|
|
|
color_tool->sample_point = NULL;
|
|
|
|
color_tool->moving_sample_point = TRUE;
|
2010-10-05 03:40:52 +08:00
|
|
|
color_tool->sample_point_x = SAMPLE_POINT_POSITION_INVALID;
|
|
|
|
color_tool->sample_point_y = SAMPLE_POINT_POSITION_INVALID;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_set_cursor (tool, display,
|
2005-11-20 06:16:34 +08:00
|
|
|
GIMP_CURSOR_MOUSE,
|
2005-03-09 08:23:19 +08:00
|
|
|
GIMP_TOOL_CURSOR_COLOR_PICKER,
|
|
|
|
GIMP_CURSOR_MODIFIER_MOVE);
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
2005-03-09 08:23:19 +08:00
|
|
|
}
|