Commit e13afaf2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Cleaned up all places which pick colors to work consistently: the concept

2003-09-26  Michael Natterer  <mitch@gimp.org>

	Cleaned up all places which pick colors to work consistently: the
	concept of an "active color" has disappeared, instead <ctrl> picks
	the BG color all over the place (fixes bug #122931).

	* app/tools/tools-enums.[ch]: added enum GimpColorPickMode which
	can be one of { FOREGROUND, BACKGROUND }. Reordered enums so
	non-registered ones are at the end of the file. Removed trailing
	whitespace.

	* app/tools/gimpcolorpickeroptions.[ch]: added a "pick-mode"
	property and a GUI for it. Renamed the "update-active" property to
	"update-toolbox".

	* app/tools/gimpcolorpickertool.c: honor the new option. Toggle
	pick-mode on <ctrl>.

	* app/tools/gimpcolortool.[ch]: added pick_mode member and change
	the cursor accordingly.

	* app/widgets/gimpcolormapeditor.[ch]: added "GdkModifierType
	state" to the "selected" signal. Removed the signal's default
	implementation.

	* app/gui/dialogs-constructors.c: fixed the signal handler which
	lives here and set BG if <ctrl> was pressed.

	* app/widgets/gimppaletteeditor.c: removed weird <ctrl> <->
	active_color interaction and pick BG on <ctrl>. Don't change the
	toolbox color when editing a color in the palette.

	* app/widgets/gimptoolbox-color-area.[ch]: made the whole
	active_color stuff private. Will remove these artefacts soon...

	* app/gui/colormap-editor-menu.c
	* app/gui/palette-editor-menu.c: added separate menu entries
	for adding a color from the current FG and BG.

	* app/gui/colormap-editor-commands.c
	* app/gui/palette-editor-commands.[ch]: changed callbacks
	accordingly.

	* cursors/background.xbm
	* cursors/background_mask.xbm
	* cursors/foreground.xbm
	* cursors/foreground_mask.xbm
	* cursors/gimp-tool-cursors.xcf: moved the FG/BG cursor modifiers
	closer to the upper right corner.

	* app/widgets/gimpcursor.c: ignore the cursor modifiers' hotspots
	since they are not relevant and I didn't save the hotspot in the
	updated cursor files for that reason.
parent a1d495b9
2003-09-26 Michael Natterer <mitch@gimp.org>
Cleaned up all places which pick colors to work consistently: the
concept of an "active color" has disappeared, instead <ctrl> picks
the BG color all over the place (fixes bug #122931).
* app/tools/tools-enums.[ch]: added enum GimpColorPickMode which
can be one of { FOREGROUND, BACKGROUND }. Reordered enums so
non-registered ones are at the end of the file. Removed trailing
whitespace.
* app/tools/gimpcolorpickeroptions.[ch]: added a "pick-mode"
property and a GUI for it. Renamed the "update-active" property to
"update-toolbox".
* app/tools/gimpcolorpickertool.c: honor the new option. Toggle
pick-mode on <ctrl>.
* app/tools/gimpcolortool.[ch]: added pick_mode member and change
the cursor accordingly.
* app/widgets/gimpcolormapeditor.[ch]: added "GdkModifierType
state" to the "selected" signal. Removed the signal's default
implementation.
* app/gui/dialogs-constructors.c: fixed the signal handler which
lives here and set BG if <ctrl> was pressed.
* app/widgets/gimppaletteeditor.c: removed weird <ctrl> <->
active_color interaction and pick BG on <ctrl>. Don't change the
toolbox color when editing a color in the palette.
* app/widgets/gimptoolbox-color-area.[ch]: made the whole
active_color stuff private. Will remove these artefacts soon...
* app/gui/colormap-editor-menu.c
* app/gui/palette-editor-menu.c: added separate menu entries
for adding a color from the current FG and BG.
* app/gui/colormap-editor-commands.c
* app/gui/palette-editor-commands.[ch]: changed callbacks
accordingly.
* cursors/background.xbm
* cursors/background_mask.xbm
* cursors/foreground.xbm
* cursors/foreground_mask.xbm
* cursors/gimp-tool-cursors.xcf: moved the FG/BG cursor modifiers
closer to the upper right corner.
* app/widgets/gimpcursor.c: ignore the cursor modifiers' hotspots
since they are not relevant and I didn't save the hotspot in the
updated cursor files for that reason.
2003-09-26 Simon Budig <simon@gimp.org>
* app/core/gimpscanconvert.[ch]: Add some parameters to
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimpcolormapeditor.h"
......@@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button))
gtk_button_clicked (GTK_BUTTON (editor->add_button));
gimp_button_extended_clicked (GIMP_BUTTON (editor->add_button),
action ? GDK_CONTROL_MASK : 0);
}
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimpcolormapeditor.h"
......@@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button))
gtk_button_clicked (GTK_BUTTON (editor->add_button));
gimp_button_extended_clicked (GIMP_BUTTON (editor->add_button),
action ? GDK_CONTROL_MASK : 0);
}
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimppaletteeditor.h"
......@@ -30,9 +32,9 @@
/* public functions */
void
palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
......@@ -41,14 +43,15 @@ palette_editor_new_color_cmd_callback (GtkWidget *widget,
}
void
palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->edit_button))
gtk_button_clicked (GTK_BUTTON (editor->edit_button));
if (GTK_WIDGET_SENSITIVE (editor->new_button))
gimp_button_extended_clicked (GIMP_BUTTON (editor->new_button),
action ? GDK_CONTROL_MASK : 0);
}
void
......
......@@ -20,10 +20,10 @@
#define __PALETTE_EDITOR_COMMANDS_H__
void palette_editor_new_color_cmd_callback (GtkWidget *widget,
void palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_edit_color_cmd_callback (GtkWidget *widget,
void palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_delete_color_cmd_callback (GtkWidget *widget,
......
......@@ -31,6 +31,7 @@
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
......@@ -65,7 +66,6 @@
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpundoeditor.h"
#include "widgets/gimpvectorstreeview.h"
......@@ -94,6 +94,7 @@
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
......@@ -1103,32 +1104,26 @@ dialogs_edit_palette_func (GimpData *data)
static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable)
{
GimpContext *context;
GimpImage *gimage;
context = (GimpContext *) g_object_get_data (G_OBJECT (editor),
"gimp-dialogs-context");
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (context)
if (gimage)
{
GimpImage *gimage;
GimpRGB color;
gint index;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color,
gimage->cmap[index * 3],
gimage->cmap[index * 3 + 1],
gimage->cmap[index * 3 + 2],
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (context, &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (context, &color);
GimpRGB color;
gint index;
index = gimp_colormap_editor_col_index (editor);
gimp_image_get_colormap_entry (gimage, index, &color);
if (state & GDK_CONTROL_MASK)
gimp_context_set_background (dockable->context, &color);
else
gimp_context_set_foreground (dockable->context, &color);
}
}
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimpcolormapeditor.h"
......@@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button))
gtk_button_clicked (GTK_BUTTON (editor->add_button));
gimp_button_extended_clicked (GIMP_BUTTON (editor->add_button),
action ? GDK_CONTROL_MASK : 0);
}
......@@ -43,10 +43,15 @@ GimpItemFactoryEntry colormap_editor_menu_entries[] =
"<StockItem>", GIMP_STOCK_EDIT },
NULL,
GIMP_HELP_INDEXED_PALETTE_EDIT, NULL },
{ { N_("/_Add Color"), "",
{ { N_("/_Add Color from FG"), "",
colormap_editor_add_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ADD },
NULL,
GIMP_HELP_INDEXED_PALETTE_ADD, NULL },
{ { N_("/_Add Color from BG"), "",
colormap_editor_add_color_cmd_callback, TRUE,
"<StockItem>", GTK_STOCK_ADD },
NULL,
GIMP_HELP_INDEXED_PALETTE_ADD, NULL }
};
......@@ -74,8 +79,9 @@ colormap_editor_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/Edit Color...", gimage && indexed);
SET_SENSITIVE ("/Add Color", gimage && indexed && num_colors < 256);
SET_SENSITIVE ("/Edit Color...", gimage && indexed);
SET_SENSITIVE ("/Add Color from FG", gimage && indexed && num_colors < 256);
SET_SENSITIVE ("/Add Color from BG", gimage && indexed && num_colors < 256);
#undef SET_SENSITIVE
}
......@@ -31,6 +31,7 @@
#include "core/gimpchannel.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h"
#include "core/gimptoolinfo.h"
......@@ -65,7 +66,6 @@
#include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpundoeditor.h"
#include "widgets/gimpvectorstreeview.h"
......@@ -94,6 +94,7 @@
/* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
......@@ -1103,32 +1104,26 @@ dialogs_edit_palette_func (GimpData *data)
static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable)
{
GimpContext *context;
GimpImage *gimage;
context = (GimpContext *) g_object_get_data (G_OBJECT (editor),
"gimp-dialogs-context");
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (context)
if (gimage)
{
GimpImage *gimage;
GimpRGB color;
gint index;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color,
gimage->cmap[index * 3],
gimage->cmap[index * 3 + 1],
gimage->cmap[index * 3 + 2],
255);
if (active_color == FOREGROUND)
gimp_context_set_foreground (context, &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (context, &color);
GimpRGB color;
gint index;
index = gimp_colormap_editor_col_index (editor);
gimp_image_get_colormap_entry (gimage, index, &color);
if (state & GDK_CONTROL_MASK)
gimp_context_set_background (dockable->context, &color);
else
gimp_context_set_foreground (dockable->context, &color);
}
}
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h"
#include "widgets/gimppaletteeditor.h"
......@@ -30,9 +32,9 @@
/* public functions */
void
palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
......@@ -41,14 +43,15 @@ palette_editor_new_color_cmd_callback (GtkWidget *widget,
}
void
palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action)
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->edit_button))
gtk_button_clicked (GTK_BUTTON (editor->edit_button));
if (GTK_WIDGET_SENSITIVE (editor->new_button))
gimp_button_extended_clicked (GIMP_BUTTON (editor->new_button),
action ? GDK_CONTROL_MASK : 0);
}
void
......
......@@ -20,10 +20,10 @@
#define __PALETTE_EDITOR_COMMANDS_H__
void palette_editor_new_color_cmd_callback (GtkWidget *widget,
void palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_edit_color_cmd_callback (GtkWidget *widget,
void palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data,
guint action);
void palette_editor_delete_color_cmd_callback (GtkWidget *widget,
......
......@@ -45,11 +45,16 @@ GimpItemFactoryEntry palette_editor_menu_entries[] =
MENU_SEPARATOR ("/---"),
{ { N_("/_New Color"), "",
{ { N_("/_New Color from FG"), "",
palette_editor_new_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_NEW },
NULL,
GIMP_HELP_PALETTE_EDITOR_NEW, NULL },
{ { N_("/_New Color from BG"), "",
palette_editor_new_color_cmd_callback, TRUE,
"<StockItem>", GTK_STOCK_NEW },
NULL,
GIMP_HELP_PALETTE_EDITOR_NEW, NULL },
{ { N_("/_Delete Color"), "",
palette_editor_delete_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_DELETE },
......@@ -95,9 +100,10 @@ palette_editor_menu_update (GtkItemFactory *factory,
#define SET_SENSITIVE(menu,condition) \
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/Edit Color...", editable && editor->color);
SET_SENSITIVE ("/New Color", editable);
SET_SENSITIVE ("/Delete Color", editable && editor->color);
SET_SENSITIVE ("/Edit Color...", editable && editor->color);
SET_SENSITIVE ("/New Color from FG", editable);
SET_SENSITIVE ("/New Color from BG", editable);
SET_SENSITIVE ("/Delete Color", editable && editor->color);
SET_SENSITIVE ("/Zoom Out", data_editor->data);
SET_SENSITIVE ("/Zoom In", data_editor->data);
......
......@@ -27,6 +27,7 @@
#include "config/gimpconfig-params.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcolorpickeroptions.h"
......@@ -36,10 +37,8 @@
enum
{
PROP_0,
PROP_SAMPLE_MERGED,
PROP_SAMPLE_AVERAGE,
PROP_AVERAGE_RADIUS,
PROP_UPDATE_ACTIVE
PROP_UPDATE_TOOLBOX,
PROP_PICK_MODE
};
......@@ -87,7 +86,7 @@ gimp_color_picker_options_get_type (void)
return type;
}
static void
static void
gimp_color_picker_options_class_init (GimpColorPickerOptionsClass *klass)
{
GObjectClass *object_class;
......@@ -99,10 +98,15 @@ gimp_color_picker_options_class_init (GimpColorPickerOptionsClass *klass)
object_class->set_property = gimp_color_picker_options_set_property;
object_class->get_property = gimp_color_picker_options_get_property;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_UPDATE_ACTIVE,
"update-active", NULL,
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_UPDATE_TOOLBOX,
"update-toolbox", NULL,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PICK_MODE,
"pick-mode", NULL,
GIMP_TYPE_COLOR_PICK_MODE,
GIMP_COLOR_PICK_MODE_FOREGROUND,
0);
}
static void
......@@ -122,8 +126,11 @@ gimp_color_picker_options_set_property (GObject *object,
switch (property_id)
{
case PROP_UPDATE_ACTIVE:
options->update_active = g_value_get_boolean (value);
case PROP_UPDATE_TOOLBOX:
options->update_toolbox = g_value_get_boolean (value);
break;
case PROP_PICK_MODE:
options->pick_mode = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -143,8 +150,11 @@ gimp_color_picker_options_get_property (GObject *object,
switch (property_id)
{
case PROP_UPDATE_ACTIVE:
g_value_set_boolean (value, options->update_active);
case PROP_UPDATE_TOOLBOX:
g_value_set_boolean (value, options->update_toolbox);
break;
case PROP_PICK_MODE:
g_value_set_enum (value, options->pick_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -155,11 +165,15 @@ gimp_color_picker_options_get_property (GObject *object,
GtkWidget *
gimp_color_picker_options_gui (GimpToolOptions *tool_options)
{
GObject *config;
GtkWidget *vbox;
GtkWidget *button;
GimpColorPickerOptions *options;
GObject *config;
GtkWidget *vbox;
GtkWidget *button;
GtkWidget *frame;
gchar *str;
config = G_OBJECT (tool_options);
options = GIMP_COLOR_PICKER_OPTIONS (tool_options);
config = G_OBJECT (tool_options);
vbox = gimp_color_options_gui (tool_options);
......@@ -169,11 +183,22 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the update active color toggle button */
button = gimp_prop_check_button_new (config, "update-active",
_("Update Active Color"));
/* the update toolbox color toggle button */
button = gimp_prop_check_button_new (config, "update-toolbox",
_("Update Toolbox Color"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* the pick FG/BG frame */
str = g_strdup_printf (_("Pick Mode %s"), gimp_get_mod_name_control ());
frame = gimp_prop_enum_radio_frame_new (config, "pick-mode", str, -1, -1);
g_free (str);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gtk_widget_set_sensitive (frame, options->update_toolbox);
g_object_set_data (G_OBJECT (button), "set_sensitive", frame);
return vbox;
}
......@@ -38,7 +38,8 @@ struct _GimpColorPickerOptions
{
GimpColorOptions parent_instance;
gboolean update_active;
gboolean update_toolbox;
GimpColorPickMode pick_mode;
};
......
......@@ -38,7 +38,6 @@
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h"
......@@ -57,20 +56,30 @@
/* local function prototypes */
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
static void gimp_color_picker_tool_init (GimpColorPickerTool *tool);
static GObject * gimp_color_picker_tool_constructor(GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_color_picker_tool_finalize (GObject *object);
static void gimp_color_picker_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
static void gimp_color_picker_tool_init (GimpColorPickerTool *tool);
static GObject * gimp_color_picker_tool_constructor(GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_color_picker_tool_finalize (GObject *object);
static void gimp_color_picker_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *gdisp);
static void gimp_color_picker_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_color_picker_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp);
static void gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpImageType sample_type,
GimpRGB *color,
gint color_index);
static InfoDialog * gimp_color_picker_tool_info_create (GimpTool *tool);
static void gimp_color_picker_tool_info_close (GtkWidget *widget,
......@@ -154,6 +163,8 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
object_class->finalize = gimp_color_picker_tool_finalize;
tool_class->control = gimp_color_picker_tool_control;
tool_class->modifier_key = gimp_color_picker_tool_modifier_key;
tool_class->oper_update = gimp_color_picker_tool_oper_update;
color_tool_class->picked = gimp_color_picker_tool_picked;
}
......@@ -162,11 +173,6 @@ static void
gimp_color_picker_tool_init (GimpColorPickerTool *tool)
{
gimp_tool_control_set_preserve (GIMP_TOOL (tool)->control, FALSE);
gimp_tool_control_set_cursor (GIMP_TOOL (tool)->control,
GIMP_COLOR_PICKER_CURSOR);
gimp_tool_control_set_tool_cursor (GIMP_TOOL (tool)->control,
GIMP_COLOR_PICKER_TOOL_CURSOR);
}
static GObject *
......@@ -223,6 +229,51 @@ gimp_color_picker_tool_control (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
}
static void
gimp_color_picker_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpColorPickerOptions *options;
options = GIMP_COLOR_PICKER_OPTIONS (tool->tool_info->tool_options);
if (key == GDK_CONTROL_MASK)
{
switch (options->pick_mode)
{
case GIMP_COLOR_PICK_MODE_FOREGROUND:
g_object_set (options, "pick-mode", GIMP_COLOR_PICK_MODE_BACKGROUND,
NULL);
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
g_object_set (options, "pick-mode", GIMP_COLOR_PICK_MODE_FOREGROUND,
NULL);
break;
default:
break;
}
}
}
static void
gimp_color_picker_tool_oper_update (GimpTool *tool,
GimpCoords *coords,
GdkModifierType state,
GimpDisplay *gdisp)
{
GimpColorPickerOptions *options;
options = GIMP_COLOR_PICKER_OPTIONS (tool->tool_info->tool_options);
GIMP_COLOR_TOOL (tool)->pick_mode = options->pick_mode;
}
static void
gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpImageType sample_type,
......@@ -241,7 +292,7 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options);
if (options->update_active)
if (options->update_toolbox)
{
GimpContext *user_context;
......@@ -251,10 +302,16 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
gimp_palette_editor_update_color (user_context, color, update_state);
#endif
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, color);
switch (options->pick_mode)
{
case GIMP_COLOR_PICK_MODE_FOREGROUND:
gimp_context_set_foreground (user_context, color);
break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
gimp_context_set_background (user_context, color);
break;
}
}
}
......
......@@ -172,10 +172,11 @@ gimp_color_tool_finalize (GObject *object)
static void
gimp_color_tool_init (GimpColorTool *color_tool)
{
color_tool->enabled = FALSE;
color_tool->center_x = 0;
color_tool->center_y = 0;
color_tool->options = NULL;
color_tool->enabled = FALSE;
color_tool->center_x = 0;
color_tool->center_y = 0;
color_tool->pick_mode = GIMP_COLOR_PICK_MODE_FOREGROUND;
color_tool->options = NULL;
}
static void
......@@ -262,12 +263,8 @@ gimp_color_tool_cursor_update (GimpTool *tool,
{
GdkCursorType cursor = GIMP_BAD_CURSOR;
if (gdisp->gimage &&
coords->x > 0 &&
coords->x < gdisp->gimage->width &&
coords->y > 0 &&
coords->y < gdisp->gimage->height &&
if (coords->x > 0 && coords->x < gdisp->gimage->width &&
coords->y > 0 && coords->y < gdisp->gimage->height &&