2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2001-02-14 12:55:21 +08:00
|
|
|
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +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
|
1997-11-25 06: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-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2017-03-11 07:01:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-24 20:21:50 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2016-05-31 18:51:14 +08:00
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpdrawable.h"
|
2017-07-01 03:23:29 +08:00
|
|
|
#include "core/gimpimage.h"
|
2016-05-31 18:51:14 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-10-15 23:16:50 +08:00
|
|
|
#include "widgets/gimpcolorframe.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2007-01-21 09:24:51 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-03-08 08:27:45 +08:00
|
|
|
|
2003-05-03 02:43:15 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2013-06-07 18:11:59 +08:00
|
|
|
#include "display/gimptoolgui.h"
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpcolorpickeroptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpcolorpickertool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-01-24 20:21:50 +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
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2011-01-13 17:06:07 +08:00
|
|
|
static void gimp_color_picker_tool_constructed (GObject *object);
|
2015-09-09 07:21:57 +08:00
|
|
|
static void gimp_color_picker_tool_dispose (GObject *object);
|
2011-01-13 17:06:07 +08:00
|
|
|
|
|
|
|
static void gimp_color_picker_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_picker_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_color_picker_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_color_picker_tool_picked (GimpColorTool *color_tool,
|
2017-07-01 03:23:29 +08:00
|
|
|
const GimpCoords *coords,
|
|
|
|
GimpDisplay *display,
|
2011-01-13 17:06:07 +08:00
|
|
|
GimpColorPickState pick_state,
|
2012-03-29 03:37:59 +08:00
|
|
|
const Babl *sample_format,
|
2015-08-25 06:05:59 +08:00
|
|
|
gpointer pixel,
|
|
|
|
const GimpRGB *color);
|
2011-01-13 17:06:07 +08:00
|
|
|
|
2017-07-01 03:23:29 +08:00
|
|
|
static void gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
|
|
|
GimpDisplay *display);
|
2013-06-08 05:45:11 +08:00
|
|
|
static void gimp_color_picker_tool_info_response (GimpToolGui *gui,
|
2011-01-13 17:06:07 +08:00
|
|
|
gint response_id,
|
|
|
|
GimpColorPickerTool *picker_tool);
|
|
|
|
static void gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
|
2017-07-01 03:23:29 +08:00
|
|
|
GimpDisplay *display,
|
2015-08-25 06:05:59 +08:00
|
|
|
gboolean sample_average,
|
2012-03-29 03:37:59 +08:00
|
|
|
const Babl *sample_format,
|
2015-08-25 06:05:59 +08:00
|
|
|
gpointer pixel,
|
2017-03-11 07:01:01 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
2003-06-05 04:23:36 +08:00
|
|
|
|
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpColorPickerTool, gimp_color_picker_tool,
|
2006-05-15 17:46:31 +08:00
|
|
|
GIMP_TYPE_COLOR_TOOL)
|
2005-12-13 17:13:50 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_color_picker_tool_parent_class
|
1999-04-09 06:25:54 +08:00
|
|
|
|
|
|
|
|
2001-02-21 20:18:09 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_color_picker_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_COLOR_PICKER_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_COLOR_PICKER_OPTIONS,
|
|
|
|
gimp_color_picker_options_gui,
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_FOREGROUND |
|
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-color-picker-tool",
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Color Picker"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Color Picker Tool: Set colors from image pixels"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("C_olor Picker"), "O",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_COLOR_PICKER,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_COLOR_PICKER,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-02-27 13:21:12 +08:00
|
|
|
gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
2004-06-30 20:10:08 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpColorToolClass *color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2011-01-13 17:06:07 +08:00
|
|
|
object_class->constructed = gimp_color_picker_tool_constructed;
|
2015-09-09 07:21:57 +08:00
|
|
|
object_class->dispose = gimp_color_picker_tool_dispose;
|
2001-02-21 20:18:09 +08:00
|
|
|
|
2003-09-19 20:11:04 +08:00
|
|
|
tool_class->control = gimp_color_picker_tool_control;
|
2003-09-26 21:33:54 +08:00
|
|
|
tool_class->modifier_key = gimp_color_picker_tool_modifier_key;
|
|
|
|
tool_class->oper_update = gimp_color_picker_tool_oper_update;
|
2001-02-27 13:21:12 +08:00
|
|
|
|
2003-09-19 20:11:04 +08:00
|
|
|
color_tool_class->picked = gimp_color_picker_tool_picked;
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-12-11 06:16:06 +08:00
|
|
|
gimp_color_picker_tool_init (GimpColorPickerTool *picker_tool)
|
2001-02-21 20:18:09 +08:00
|
|
|
{
|
2011-12-11 06:16:06 +08:00
|
|
|
GimpColorTool *color_tool = GIMP_COLOR_TOOL (picker_tool);
|
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
color_tool->pick_target = GIMP_COLOR_PICK_TARGET_FOREGROUND;
|
2001-02-21 20:18:09 +08:00
|
|
|
}
|
|
|
|
|
2011-01-13 17:06:07 +08:00
|
|
|
static void
|
|
|
|
gimp_color_picker_tool_constructed (GObject *object)
|
2003-09-19 20:11:04 +08:00
|
|
|
{
|
2011-01-13 17:06:07 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (object);
|
2003-09-19 20:11:04 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2003-09-19 20:11:04 +08:00
|
|
|
|
|
|
|
gimp_color_tool_enable (GIMP_COLOR_TOOL (object),
|
2006-09-06 02:25:31 +08:00
|
|
|
GIMP_COLOR_TOOL_GET_OPTIONS (tool));
|
2003-09-19 20:11:04 +08:00
|
|
|
}
|
|
|
|
|
2015-09-09 07:21:57 +08:00
|
|
|
static void
|
|
|
|
gimp_color_picker_tool_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (object);
|
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&picker_tool->gui);
|
|
|
|
picker_tool->color_area = NULL;
|
|
|
|
picker_tool->color_frame1 = NULL;
|
|
|
|
picker_tool->color_frame2 = NULL;
|
2015-09-09 07:21:57 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2002-02-19 01:00:09 +08:00
|
|
|
gimp_color_picker_tool_control (GimpTool *tool,
|
2004-06-30 20:10:08 +08:00
|
|
|
GimpToolAction action,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-10-15 23:16:50 +08:00
|
|
|
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool);
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
switch (action)
|
|
|
|
{
|
2006-05-22 05:12:01 +08:00
|
|
|
case GIMP_TOOL_ACTION_PAUSE:
|
|
|
|
case GIMP_TOOL_ACTION_RESUME:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_HALT:
|
2013-06-07 18:11:59 +08:00
|
|
|
if (picker_tool->gui)
|
2015-09-09 07:21:57 +08:00
|
|
|
gimp_tool_gui_hide (picker_tool->gui);
|
2001-08-14 22:53:55 +08:00
|
|
|
break;
|
2014-04-05 04:34:26 +08:00
|
|
|
|
|
|
|
case GIMP_TOOL_ACTION_COMMIT:
|
|
|
|
break;
|
2001-08-14 22:53:55 +08:00
|
|
|
}
|
1999-08-24 10:52:40 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-09-26 21:33:54 +08:00
|
|
|
static void
|
|
|
|
gimp_color_picker_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2003-09-26 21:33:54 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
|
2003-09-26 21:33:54 +08:00
|
|
|
|
2015-10-17 21:31:08 +08:00
|
|
|
if (key == gimp_get_extend_selection_mask ())
|
2004-06-30 20:10:08 +08:00
|
|
|
{
|
2005-09-27 00:01:13 +08:00
|
|
|
g_object_set (options, "use-info-window", ! options->use_info_window,
|
2004-06-30 20:10:08 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2011-10-07 03:59:07 +08:00
|
|
|
else if (key == gimp_get_toggle_behavior_mask ())
|
2003-09-26 21:33:54 +08:00
|
|
|
{
|
2018-07-15 20:32:53 +08:00
|
|
|
switch (options->pick_target)
|
2003-09-26 21:33:54 +08:00
|
|
|
{
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
|
|
|
g_object_set (options,
|
|
|
|
"pick-target", GIMP_COLOR_PICK_TARGET_BACKGROUND,
|
2003-09-26 21:33:54 +08:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
|
|
|
g_object_set (options,
|
|
|
|
"pick-target", GIMP_COLOR_PICK_TARGET_FOREGROUND,
|
2003-09-26 21:33:54 +08:00
|
|
|
NULL);
|
|
|
|
break;
|
2005-09-27 00:01:13 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-09-26 21:33:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_color_picker_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2003-09-26 21:33:54 +08:00
|
|
|
{
|
2007-01-21 09:24:51 +08:00
|
|
|
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (tool);
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (tool);
|
2003-09-26 21:33:54 +08:00
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
GIMP_COLOR_TOOL (tool)->pick_target = options->pick_target;
|
2005-03-09 08:23:19 +08:00
|
|
|
|
2007-01-21 09:24:51 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2014-12-01 20:49:40 +08:00
|
|
|
|
2007-01-21 09:24:51 +08:00
|
|
|
if (proximity)
|
|
|
|
{
|
|
|
|
gchar *status_help = NULL;
|
2015-10-17 21:31:08 +08:00
|
|
|
GdkModifierType extend_mask = 0;
|
|
|
|
GdkModifierType toggle_mask;
|
2007-01-21 09:24:51 +08:00
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
if (! picker_tool->gui)
|
2015-10-17 21:31:08 +08:00
|
|
|
extend_mask = gimp_get_extend_selection_mask ();
|
|
|
|
|
|
|
|
toggle_mask = gimp_get_toggle_behavior_mask ();
|
2011-03-20 23:57:23 +08:00
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
switch (options->pick_target)
|
2007-01-21 09:24:51 +08:00
|
|
|
{
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_NONE:
|
2007-01-21 09:24:51 +08:00
|
|
|
status_help = gimp_suggest_modifiers (_("Click in any image to view"
|
|
|
|
" its color"),
|
2015-10-17 21:31:08 +08:00
|
|
|
extend_mask & ~state,
|
2007-01-21 09:24:51 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_FOREGROUND:
|
2007-01-21 09:24:51 +08:00
|
|
|
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
|
|
|
|
" the foreground color"),
|
2015-10-17 21:31:08 +08:00
|
|
|
(extend_mask | toggle_mask) &
|
2011-10-07 03:59:07 +08:00
|
|
|
~state,
|
2007-01-21 09:24:51 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_BACKGROUND:
|
2007-01-21 09:24:51 +08:00
|
|
|
status_help = gimp_suggest_modifiers (_("Click in any image to pick"
|
|
|
|
" the background color"),
|
2015-10-17 21:31:08 +08:00
|
|
|
(extend_mask | toggle_mask) &
|
2011-10-07 03:59:07 +08:00
|
|
|
~state,
|
2007-01-21 09:24:51 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
break;
|
|
|
|
|
2018-07-15 20:32:53 +08:00
|
|
|
case GIMP_COLOR_PICK_TARGET_PALETTE:
|
2007-01-21 09:24:51 +08:00
|
|
|
status_help = gimp_suggest_modifiers (_("Click in any image to add"
|
|
|
|
" the color to the palette"),
|
2015-10-17 21:31:08 +08:00
|
|
|
extend_mask & ~state,
|
2007-01-21 09:24:51 +08:00
|
|
|
NULL, NULL, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-20 23:57:23 +08:00
|
|
|
|
2007-01-21 09:24:51 +08:00
|
|
|
if (status_help != NULL)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_tool_push_status (tool, display, "%s", status_help);
|
2007-01-21 09:24:51 +08:00
|
|
|
g_free (status_help);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-25 22:23:09 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
display);
|
2003-09-26 21:33:54 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2004-06-30 20:10:08 +08:00
|
|
|
gimp_color_picker_tool_picked (GimpColorTool *color_tool,
|
2017-07-01 03:23:29 +08:00
|
|
|
const GimpCoords *coords,
|
|
|
|
GimpDisplay *display,
|
2004-06-30 20:10:08 +08:00
|
|
|
GimpColorPickState pick_state,
|
2012-03-29 03:37:59 +08:00
|
|
|
const Babl *sample_format,
|
2015-08-25 06:05:59 +08:00
|
|
|
gpointer pixel,
|
|
|
|
const GimpRGB *color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-06-30 20:10:08 +08:00
|
|
|
GimpColorPickerTool *picker_tool = GIMP_COLOR_PICKER_TOOL (color_tool);
|
2003-06-05 04:23:36 +08:00
|
|
|
GimpColorPickerOptions *options;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-09-06 02:25:31 +08:00
|
|
|
options = GIMP_COLOR_PICKER_TOOL_GET_OPTIONS (color_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
if (options->use_info_window && ! picker_tool->gui)
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_color_picker_tool_info_create (picker_tool, display);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2015-09-20 06:37:05 +08:00
|
|
|
if (picker_tool->gui &&
|
|
|
|
(options->use_info_window ||
|
|
|
|
gimp_tool_gui_get_visible (picker_tool->gui)))
|
|
|
|
{
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_color_picker_tool_info_update (picker_tool, display,
|
2015-09-20 06:37:05 +08:00
|
|
|
GIMP_COLOR_OPTIONS (options)->sample_average,
|
2017-03-11 07:01:01 +08:00
|
|
|
sample_format, pixel, color,
|
2017-07-01 03:23:29 +08:00
|
|
|
(gint) floor (coords->x),
|
|
|
|
(gint) floor (coords->y));
|
2015-09-20 06:37:05 +08:00
|
|
|
}
|
2003-06-04 23:48:17 +08:00
|
|
|
|
2017-07-01 03:23:29 +08:00
|
|
|
GIMP_COLOR_TOOL_CLASS (parent_class)->picked (color_tool,
|
|
|
|
coords, display, pick_state,
|
|
|
|
sample_format, pixel, color);
|
2001-12-12 09:16:39 +08:00
|
|
|
}
|
|
|
|
|
2003-10-15 23:16:50 +08:00
|
|
|
static void
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_color_picker_tool_info_create (GimpColorPickerTool *picker_tool,
|
|
|
|
GimpDisplay *display)
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2017-07-01 03:23:29 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (picker_tool);
|
2017-11-13 03:33:42 +08:00
|
|
|
GimpToolOptions *options = GIMP_TOOL_GET_OPTIONS (tool);
|
2017-07-01 03:23:29 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (tool->tool_info->tool_options);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2014-05-02 09:01:23 +08:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GimpRGB color;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
picker_tool->gui = gimp_tool_gui_new (tool->tool_info,
|
2016-01-23 06:41:45 +08:00
|
|
|
NULL,
|
2013-06-07 18:11:59 +08:00
|
|
|
_("Color Picker Information"),
|
2016-01-23 06:41:45 +08:00
|
|
|
NULL, NULL,
|
2014-05-02 09:01:23 +08:00
|
|
|
gimp_widget_get_monitor (GTK_WIDGET (shell)),
|
2014-06-09 09:08:43 +08:00
|
|
|
TRUE,
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2017-02-12 23:06:34 +08:00
|
|
|
_("_Close"), GTK_RESPONSE_CLOSE,
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
NULL);
|
2003-10-21 05:27:34 +08:00
|
|
|
|
2014-06-09 09:08:43 +08:00
|
|
|
gimp_tool_gui_set_auto_overlay (picker_tool->gui, TRUE);
|
2013-06-08 21:34:23 +08:00
|
|
|
gimp_tool_gui_set_focus_on_map (picker_tool->gui, FALSE);
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_tool_gui_set_viewable (picker_tool->gui, GIMP_VIEWABLE (drawable));
|
2013-06-07 18:11:59 +08:00
|
|
|
|
2013-06-08 05:45:11 +08:00
|
|
|
g_signal_connect (picker_tool->gui, "response",
|
2003-11-06 23:27:05 +08:00
|
|
|
G_CALLBACK (gimp_color_picker_tool_info_response),
|
|
|
|
picker_tool);
|
|
|
|
|
2011-09-30 17:29:11 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
2013-06-08 21:34:23 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (picker_tool->gui)),
|
|
|
|
hbox, FALSE, FALSE, 0);
|
2002-11-14 19:54:57 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2003-10-15 23:16:50 +08:00
|
|
|
picker_tool->color_frame1 = gimp_color_frame_new ();
|
2016-10-19 04:48:04 +08:00
|
|
|
gimp_color_frame_set_color_config (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
|
|
|
context->gimp->config->color_management);
|
2017-03-11 07:01:01 +08:00
|
|
|
gimp_color_frame_set_has_coords (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
|
|
|
TRUE);
|
2017-11-13 03:33:42 +08:00
|
|
|
g_object_bind_property (options, "frame1-mode",
|
|
|
|
picker_tool->color_frame1, "mode",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2003-10-15 23:16:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame1,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (picker_tool->color_frame1);
|
|
|
|
|
|
|
|
picker_tool->color_frame2 = gimp_color_frame_new ();
|
2016-10-19 04:48:04 +08:00
|
|
|
gimp_color_frame_set_color_config (GIMP_COLOR_FRAME (picker_tool->color_frame2),
|
|
|
|
context->gimp->config->color_management);
|
2017-11-13 03:33:42 +08:00
|
|
|
g_object_bind_property (options, "frame2-mode",
|
|
|
|
picker_tool->color_frame2, "mode",
|
|
|
|
G_BINDING_BIDIRECTIONAL |
|
|
|
|
G_BINDING_SYNC_CREATE);
|
2003-10-15 23:16:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), picker_tool->color_frame2,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (picker_tool->color_frame2);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
|
|
|
frame = gtk_frame_new (NULL);
|
2015-10-28 04:41:32 +08:00
|
|
|
gimp_widget_set_fully_opaque (frame, TRUE);
|
2002-11-14 19:54:57 +08:00
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2003-03-17 01:40:38 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
2003-10-15 23:16:50 +08:00
|
|
|
gtk_widget_show (frame);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
|
|
|
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
2003-10-15 23:16:50 +08:00
|
|
|
picker_tool->color_area =
|
|
|
|
gimp_color_area_new (&color,
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_drawable_has_alpha (drawable) ?
|
2003-10-15 23:16:50 +08:00
|
|
|
GIMP_COLOR_AREA_LARGE_CHECKS :
|
|
|
|
GIMP_COLOR_AREA_FLAT,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
2016-05-31 18:51:14 +08:00
|
|
|
gimp_color_area_set_color_config (GIMP_COLOR_AREA (picker_tool->color_area),
|
|
|
|
context->gimp->config->color_management);
|
2003-10-15 23:16:50 +08:00
|
|
|
gtk_widget_set_size_request (picker_tool->color_area, 48, -1);
|
|
|
|
gtk_drag_dest_unset (picker_tool->color_area);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), picker_tool->color_area);
|
|
|
|
gtk_widget_show (picker_tool->color_area);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-06-08 05:45:11 +08:00
|
|
|
gimp_color_picker_tool_info_response (GimpToolGui *gui,
|
2003-11-06 23:27:05 +08:00
|
|
|
gint response_id,
|
|
|
|
GimpColorPickerTool *picker_tool)
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2011-04-04 05:32:06 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (picker_tool);
|
2004-04-16 21:50:28 +08:00
|
|
|
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, NULL);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2003-10-15 23:16:50 +08:00
|
|
|
gimp_color_picker_tool_info_update (GimpColorPickerTool *picker_tool,
|
2017-07-01 03:23:29 +08:00
|
|
|
GimpDisplay *display,
|
2015-08-25 06:05:59 +08:00
|
|
|
gboolean sample_average,
|
2012-03-29 03:37:59 +08:00
|
|
|
const Babl *sample_format,
|
2015-08-25 06:05:59 +08:00
|
|
|
gpointer pixel,
|
2017-03-11 07:01:01 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gint x,
|
|
|
|
gint y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-20 05:30:58 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (picker_tool);
|
2017-07-01 03:23:29 +08:00
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
|
2011-05-26 05:03:16 +08:00
|
|
|
|
2018-06-20 05:30:58 +08:00
|
|
|
tool->display = display;
|
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
gimp_tool_gui_set_shell (picker_tool->gui,
|
2017-07-01 03:23:29 +08:00
|
|
|
gimp_display_get_shell (display));
|
2013-06-07 18:11:59 +08:00
|
|
|
gimp_tool_gui_set_viewable (picker_tool->gui,
|
2017-07-01 03:23:29 +08:00
|
|
|
GIMP_VIEWABLE (drawable));
|
2011-05-26 05:03:16 +08:00
|
|
|
|
2005-09-27 00:01:13 +08:00
|
|
|
gimp_color_area_set_color (GIMP_COLOR_AREA (picker_tool->color_area),
|
|
|
|
color);
|
2003-09-19 20:11:04 +08:00
|
|
|
|
2003-10-15 23:16:50 +08:00
|
|
|
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame1),
|
2017-03-11 07:01:01 +08:00
|
|
|
sample_average, sample_format, pixel, color,
|
|
|
|
x, y);
|
2003-10-15 23:16:50 +08:00
|
|
|
gimp_color_frame_set_color (GIMP_COLOR_FRAME (picker_tool->color_frame2),
|
2017-03-11 07:01:01 +08:00
|
|
|
sample_average, sample_format, pixel, color,
|
|
|
|
x, y);
|
2003-06-05 04:23:36 +08:00
|
|
|
|
2013-06-07 18:11:59 +08:00
|
|
|
gimp_tool_gui_show (picker_tool->gui);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|