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.
This commit is contained in:
Michael Natterer 2003-09-26 13:33:54 +00:00 committed by Michael Natterer
parent a1d495b99c
commit e13afaf260
30 changed files with 446 additions and 284 deletions

View file

@ -1,3 +1,57 @@
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> 2003-09-26 Simon Budig <simon@gimp.org>
* app/core/gimpscanconvert.[ch]: Add some parameters to * app/core/gimpscanconvert.[ch]: Add some parameters to

View file

@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h" #include "gui-types.h"
#include "widgets/gimpcolormapeditor.h" #include "widgets/gimpcolormapeditor.h"
@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data); GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button)) 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);
} }

View file

@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h" #include "gui-types.h"
#include "widgets/gimpcolormapeditor.h" #include "widgets/gimpcolormapeditor.h"
@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data); GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button)) 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);
} }

View file

@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h" #include "gui-types.h"
#include "widgets/gimppaletteeditor.h" #include "widgets/gimppaletteeditor.h"
@ -30,7 +32,7 @@
/* public functions */ /* public functions */
void void
palette_editor_new_color_cmd_callback (GtkWidget *widget, palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
@ -41,14 +43,15 @@ palette_editor_new_color_cmd_callback (GtkWidget *widget,
} }
void void
palette_editor_edit_color_cmd_callback (GtkWidget *widget, palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data); GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->edit_button)) if (GTK_WIDGET_SENSITIVE (editor->new_button))
gtk_button_clicked (GTK_BUTTON (editor->edit_button)); gimp_button_extended_clicked (GIMP_BUTTON (editor->new_button),
action ? GDK_CONTROL_MASK : 0);
} }
void void

View file

@ -20,10 +20,10 @@
#define __PALETTE_EDITOR_COMMANDS_H__ #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, gpointer data,
guint action); guint action);
void palette_editor_edit_color_cmd_callback (GtkWidget *widget, void palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action); guint action);
void palette_editor_delete_color_cmd_callback (GtkWidget *widget, void palette_editor_delete_color_cmd_callback (GtkWidget *widget,

View file

@ -31,6 +31,7 @@
#include "core/gimpchannel.h" #include "core/gimpchannel.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
@ -65,7 +66,6 @@
#include "widgets/gimpselectioneditor.h" #include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h" #include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h" #include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpundoeditor.h" #include "widgets/gimpundoeditor.h"
#include "widgets/gimpvectorstreeview.h" #include "widgets/gimpvectorstreeview.h"
@ -94,6 +94,7 @@
/* local function prototypes */ /* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor, static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable); GimpDockable *dockable);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable, static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
@ -1103,32 +1104,26 @@ dialogs_edit_palette_func (GimpData *data)
static void static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor, dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable) GimpDockable *dockable)
{ {
GimpContext *context;
context = (GimpContext *) g_object_get_data (G_OBJECT (editor),
"gimp-dialogs-context");
if (context)
{
GimpImage *gimage; GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{
GimpRGB color; GimpRGB color;
gint index; gint index;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor); index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color, gimp_image_get_colormap_entry (gimage, index, &color);
gimage->cmap[index * 3],
gimage->cmap[index * 3 + 1],
gimage->cmap[index * 3 + 2],
255);
if (active_color == FOREGROUND) if (state & GDK_CONTROL_MASK)
gimp_context_set_foreground (context, &color); gimp_context_set_background (dockable->context, &color);
else if (active_color == BACKGROUND) else
gimp_context_set_background (context, &color); gimp_context_set_foreground (dockable->context, &color);
} }
} }

View file

@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h" #include "gui-types.h"
#include "widgets/gimpcolormapeditor.h" #include "widgets/gimpcolormapeditor.h"
@ -48,5 +50,6 @@ colormap_editor_add_color_cmd_callback (GtkWidget *widget,
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data); GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->add_button)) 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);
} }

View file

@ -43,10 +43,15 @@ GimpItemFactoryEntry colormap_editor_menu_entries[] =
"<StockItem>", GIMP_STOCK_EDIT }, "<StockItem>", GIMP_STOCK_EDIT },
NULL, NULL,
GIMP_HELP_INDEXED_PALETTE_EDIT, NULL }, GIMP_HELP_INDEXED_PALETTE_EDIT, NULL },
{ { N_("/_Add Color"), "", { { N_("/_Add Color from FG"), "",
colormap_editor_add_color_cmd_callback, 0, colormap_editor_add_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_ADD }, "<StockItem>", GTK_STOCK_ADD },
NULL, 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 } GIMP_HELP_INDEXED_PALETTE_ADD, NULL }
}; };
@ -75,7 +80,8 @@ colormap_editor_menu_update (GtkItemFactory *factory,
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0) gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/Edit Color...", gimage && indexed); SET_SENSITIVE ("/Edit Color...", gimage && indexed);
SET_SENSITIVE ("/Add Color", gimage && indexed && num_colors < 256); 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 #undef SET_SENSITIVE
} }

View file

@ -31,6 +31,7 @@
#include "core/gimpchannel.h" #include "core/gimpchannel.h"
#include "core/gimpcontext.h" #include "core/gimpcontext.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimplayer.h" #include "core/gimplayer.h"
#include "core/gimptoolinfo.h" #include "core/gimptoolinfo.h"
@ -65,7 +66,6 @@
#include "widgets/gimpselectioneditor.h" #include "widgets/gimpselectioneditor.h"
#include "widgets/gimptemplateview.h" #include "widgets/gimptemplateview.h"
#include "widgets/gimptoolbox.h" #include "widgets/gimptoolbox.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpundoeditor.h" #include "widgets/gimpundoeditor.h"
#include "widgets/gimpvectorstreeview.h" #include "widgets/gimpvectorstreeview.h"
@ -94,6 +94,7 @@
/* local function prototypes */ /* local function prototypes */
static void dialogs_indexed_palette_selected (GimpColormapEditor *editor, static void dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable); GimpDockable *dockable);
static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable, static GtkWidget * dialogs_viewable_preview_func (GimpDockable *dockable,
@ -1103,32 +1104,26 @@ dialogs_edit_palette_func (GimpData *data)
static void static void
dialogs_indexed_palette_selected (GimpColormapEditor *editor, dialogs_indexed_palette_selected (GimpColormapEditor *editor,
GdkModifierType state,
GimpDockable *dockable) GimpDockable *dockable)
{ {
GimpContext *context;
context = (GimpContext *) g_object_get_data (G_OBJECT (editor),
"gimp-dialogs-context");
if (context)
{
GimpImage *gimage; GimpImage *gimage;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (gimage)
{
GimpRGB color; GimpRGB color;
gint index; gint index;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
index = gimp_colormap_editor_col_index (editor); index = gimp_colormap_editor_col_index (editor);
gimp_rgba_set_uchar (&color, gimp_image_get_colormap_entry (gimage, index, &color);
gimage->cmap[index * 3],
gimage->cmap[index * 3 + 1],
gimage->cmap[index * 3 + 2],
255);
if (active_color == FOREGROUND) if (state & GDK_CONTROL_MASK)
gimp_context_set_foreground (context, &color); gimp_context_set_background (dockable->context, &color);
else if (active_color == BACKGROUND) else
gimp_context_set_background (context, &color); gimp_context_set_foreground (dockable->context, &color);
} }
} }

View file

@ -20,6 +20,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpwidgets/gimpwidgets.h"
#include "gui-types.h" #include "gui-types.h"
#include "widgets/gimppaletteeditor.h" #include "widgets/gimppaletteeditor.h"
@ -30,7 +32,7 @@
/* public functions */ /* public functions */
void void
palette_editor_new_color_cmd_callback (GtkWidget *widget, palette_editor_edit_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
@ -41,14 +43,15 @@ palette_editor_new_color_cmd_callback (GtkWidget *widget,
} }
void void
palette_editor_edit_color_cmd_callback (GtkWidget *widget, palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action) guint action)
{ {
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data); GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
if (GTK_WIDGET_SENSITIVE (editor->edit_button)) if (GTK_WIDGET_SENSITIVE (editor->new_button))
gtk_button_clicked (GTK_BUTTON (editor->edit_button)); gimp_button_extended_clicked (GIMP_BUTTON (editor->new_button),
action ? GDK_CONTROL_MASK : 0);
} }
void void

View file

@ -20,10 +20,10 @@
#define __PALETTE_EDITOR_COMMANDS_H__ #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, gpointer data,
guint action); guint action);
void palette_editor_edit_color_cmd_callback (GtkWidget *widget, void palette_editor_new_color_cmd_callback (GtkWidget *widget,
gpointer data, gpointer data,
guint action); guint action);
void palette_editor_delete_color_cmd_callback (GtkWidget *widget, void palette_editor_delete_color_cmd_callback (GtkWidget *widget,

View file

@ -45,11 +45,16 @@ GimpItemFactoryEntry palette_editor_menu_entries[] =
MENU_SEPARATOR ("/---"), MENU_SEPARATOR ("/---"),
{ { N_("/_New Color"), "", { { N_("/_New Color from FG"), "",
palette_editor_new_color_cmd_callback, 0, palette_editor_new_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_NEW }, "<StockItem>", GTK_STOCK_NEW },
NULL, NULL,
GIMP_HELP_PALETTE_EDITOR_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"), "", { { N_("/_Delete Color"), "",
palette_editor_delete_color_cmd_callback, 0, palette_editor_delete_color_cmd_callback, 0,
"<StockItem>", GTK_STOCK_DELETE }, "<StockItem>", GTK_STOCK_DELETE },
@ -96,7 +101,8 @@ palette_editor_menu_update (GtkItemFactory *factory,
gimp_item_factory_set_sensitive (factory, menu, (condition) != 0) gimp_item_factory_set_sensitive (factory, menu, (condition) != 0)
SET_SENSITIVE ("/Edit Color...", editable && editor->color); SET_SENSITIVE ("/Edit Color...", editable && editor->color);
SET_SENSITIVE ("/New Color", editable); SET_SENSITIVE ("/New Color from FG", editable);
SET_SENSITIVE ("/New Color from BG", editable);
SET_SENSITIVE ("/Delete Color", editable && editor->color); SET_SENSITIVE ("/Delete Color", editable && editor->color);
SET_SENSITIVE ("/Zoom Out", data_editor->data); SET_SENSITIVE ("/Zoom Out", data_editor->data);

View file

@ -27,6 +27,7 @@
#include "config/gimpconfig-params.h" #include "config/gimpconfig-params.h"
#include "widgets/gimppropwidgets.h" #include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
#include "gimpcolorpickeroptions.h" #include "gimpcolorpickeroptions.h"
@ -36,10 +37,8 @@
enum enum
{ {
PROP_0, PROP_0,
PROP_SAMPLE_MERGED, PROP_UPDATE_TOOLBOX,
PROP_SAMPLE_AVERAGE, PROP_PICK_MODE
PROP_AVERAGE_RADIUS,
PROP_UPDATE_ACTIVE
}; };
@ -99,10 +98,15 @@ gimp_color_picker_options_class_init (GimpColorPickerOptionsClass *klass)
object_class->set_property = gimp_color_picker_options_set_property; object_class->set_property = gimp_color_picker_options_set_property;
object_class->get_property = gimp_color_picker_options_get_property; object_class->get_property = gimp_color_picker_options_get_property;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_UPDATE_ACTIVE, GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_UPDATE_TOOLBOX,
"update-active", NULL, "update-toolbox", NULL,
TRUE, TRUE,
0); 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 static void
@ -122,8 +126,11 @@ gimp_color_picker_options_set_property (GObject *object,
switch (property_id) switch (property_id)
{ {
case PROP_UPDATE_ACTIVE: case PROP_UPDATE_TOOLBOX:
options->update_active = g_value_get_boolean (value); options->update_toolbox = g_value_get_boolean (value);
break;
case PROP_PICK_MODE:
options->pick_mode = g_value_get_enum (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); 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) switch (property_id)
{ {
case PROP_UPDATE_ACTIVE: case PROP_UPDATE_TOOLBOX:
g_value_set_boolean (value, options->update_active); g_value_set_boolean (value, options->update_toolbox);
break;
case PROP_PICK_MODE:
g_value_set_enum (value, options->pick_mode);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@ -155,10 +165,14 @@ gimp_color_picker_options_get_property (GObject *object,
GtkWidget * GtkWidget *
gimp_color_picker_options_gui (GimpToolOptions *tool_options) gimp_color_picker_options_gui (GimpToolOptions *tool_options)
{ {
GimpColorPickerOptions *options;
GObject *config; GObject *config;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *button; GtkWidget *button;
GtkWidget *frame;
gchar *str;
options = GIMP_COLOR_PICKER_OPTIONS (tool_options);
config = G_OBJECT (tool_options); config = G_OBJECT (tool_options);
vbox = gimp_color_options_gui (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_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button); gtk_widget_show (button);
/* the update active color toggle button */ /* the update toolbox color toggle button */
button = gimp_prop_check_button_new (config, "update-active", button = gimp_prop_check_button_new (config, "update-toolbox",
_("Update Active Color")); _("Update Toolbox Color"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button); 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; return vbox;
} }

View file

@ -38,7 +38,8 @@ struct _GimpColorPickerOptions
{ {
GimpColorOptions parent_instance; GimpColorOptions parent_instance;
gboolean update_active; gboolean update_toolbox;
GimpColorPickMode pick_mode;
}; };

View file

@ -38,7 +38,6 @@
#include "widgets/gimpdialogfactory.h" #include "widgets/gimpdialogfactory.h"
#include "widgets/gimphelp-ids.h" #include "widgets/gimphelp-ids.h"
#include "widgets/gimppaletteeditor.h" #include "widgets/gimppaletteeditor.h"
#include "widgets/gimptoolbox-color-area.h"
#include "widgets/gimpviewabledialog.h" #include "widgets/gimpviewabledialog.h"
#include "display/gimpdisplay.h" #include "display/gimpdisplay.h"
@ -67,6 +66,16 @@ static void gimp_color_picker_tool_finalize (GObject *o
static void gimp_color_picker_tool_control (GimpTool *tool, static void gimp_color_picker_tool_control (GimpTool *tool,
GimpToolAction action, GimpToolAction action,
GimpDisplay *gdisp); 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, static void gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpImageType sample_type, GimpImageType sample_type,
GimpRGB *color, GimpRGB *color,
@ -154,6 +163,8 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
object_class->finalize = gimp_color_picker_tool_finalize; object_class->finalize = gimp_color_picker_tool_finalize;
tool_class->control = gimp_color_picker_tool_control; 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; color_tool_class->picked = gimp_color_picker_tool_picked;
} }
@ -162,11 +173,6 @@ static void
gimp_color_picker_tool_init (GimpColorPickerTool *tool) gimp_color_picker_tool_init (GimpColorPickerTool *tool)
{ {
gimp_tool_control_set_preserve (GIMP_TOOL (tool)->control, FALSE); 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 * static GObject *
@ -223,6 +229,51 @@ gimp_color_picker_tool_control (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp); 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 static void
gimp_color_picker_tool_picked (GimpColorTool *color_tool, gimp_color_picker_tool_picked (GimpColorTool *color_tool,
GimpImageType sample_type, GimpImageType sample_type,
@ -241,7 +292,7 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options); options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options);
if (options->update_active) if (options->update_toolbox)
{ {
GimpContext *user_context; 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); gimp_palette_editor_update_color (user_context, color, update_state);
#endif #endif
if (active_color == FOREGROUND) switch (options->pick_mode)
{
case GIMP_COLOR_PICK_MODE_FOREGROUND:
gimp_context_set_foreground (user_context, color); gimp_context_set_foreground (user_context, color);
else if (active_color == BACKGROUND) break;
case GIMP_COLOR_PICK_MODE_BACKGROUND:
gimp_context_set_background (user_context, color); gimp_context_set_background (user_context, color);
break;
}
} }
} }

View file

@ -175,6 +175,7 @@ gimp_color_tool_init (GimpColorTool *color_tool)
color_tool->enabled = FALSE; color_tool->enabled = FALSE;
color_tool->center_x = 0; color_tool->center_x = 0;
color_tool->center_y = 0; color_tool->center_y = 0;
color_tool->pick_mode = GIMP_COLOR_PICK_MODE_FOREGROUND;
color_tool->options = NULL; color_tool->options = NULL;
} }
@ -262,12 +263,8 @@ gimp_color_tool_cursor_update (GimpTool *tool,
{ {
GdkCursorType cursor = GIMP_BAD_CURSOR; GdkCursorType cursor = GIMP_BAD_CURSOR;
if (gdisp->gimage && if (coords->x > 0 && coords->x < gdisp->gimage->width &&
coords->y > 0 && coords->y < gdisp->gimage->height &&
coords->x > 0 &&
coords->x < gdisp->gimage->width &&
coords->y > 0 &&
coords->y < gdisp->gimage->height &&
(color_tool->options->sample_merged || (color_tool->options->sample_merged ||
gimp_display_coords_in_active_drawable (gdisp, coords))) gimp_display_coords_in_active_drawable (gdisp, coords)))
@ -278,7 +275,10 @@ gimp_color_tool_cursor_update (GimpTool *tool,
gimp_tool_set_cursor (tool, gdisp, gimp_tool_set_cursor (tool, gdisp,
cursor, cursor,
GIMP_COLOR_PICKER_TOOL_CURSOR, GIMP_COLOR_PICKER_TOOL_CURSOR,
GIMP_CURSOR_MODIFIER_NONE); color_tool->pick_mode ==
GIMP_COLOR_PICK_MODE_FOREGROUND ?
GIMP_CURSOR_MODIFIER_FOREGROUND :
GIMP_CURSOR_MODIFIER_BACKGROUND);
return; /* don't chain up */ return; /* don't chain up */
} }

View file

@ -40,6 +40,7 @@ struct _GimpColorTool
gboolean enabled; gboolean enabled;
gint center_x; gint center_x;
gint center_y; gint center_y;
GimpColorPickMode pick_mode;
GimpColorOptions *options; GimpColorOptions *options;
}; };

View file

@ -9,6 +9,25 @@
/* enumerations from "./tools-enums.h" */ /* enumerations from "./tools-enums.h" */
static const GEnumValue gimp_color_pick_mode_enum_values[] =
{
{ GIMP_COLOR_PICK_MODE_FOREGROUND, N_("Pick Foreground Color"), "foreground" },
{ GIMP_COLOR_PICK_MODE_BACKGROUND, N_("Pick Background Color"), "background" },
{ 0, NULL, NULL }
};
GType
gimp_color_pick_mode_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpColorPickMode", gimp_color_pick_mode_enum_values);
return enum_type;
}
static const GEnumValue gimp_crop_type_enum_values[] = static const GEnumValue gimp_crop_type_enum_values[] =
{ {
{ GIMP_CROP, N_("Crop"), "crop" }, { GIMP_CROP, N_("Crop"), "crop" },

View file

@ -36,6 +36,17 @@
* these enums that are registered with the type system * these enums that are registered with the type system
*/ */
#define GIMP_TYPE_COLOR_PICK_MODE (gimp_color_pick_mode_get_type ())
GType gimp_color_pick_mode_get_type (void) G_GNUC_CONST;
typedef enum /*< pdb-skip >*/
{
GIMP_COLOR_PICK_MODE_FOREGROUND, /*< desc="Pick Foreground Color" >*/
GIMP_COLOR_PICK_MODE_BACKGROUND /*< desc="Pick Background Color" >*/
} GimpColorPickMode;
#define GIMP_TYPE_CROP_TYPE (gimp_crop_type_get_type ()) #define GIMP_TYPE_CROP_TYPE (gimp_crop_type_get_type ())
GType gimp_crop_type_get_type (void) G_GNUC_CONST; GType gimp_crop_type_get_type (void) G_GNUC_CONST;
@ -47,39 +58,6 @@ typedef enum /*< pdb-skip >*/
} GimpCropType; } GimpCropType;
/*
* non-registered enums; register them if needed
*/
typedef enum /*< pdb-skip, skip >*/
{
SELECTION_ADD = GIMP_CHANNEL_OP_ADD,
SELECTION_SUBTRACT = GIMP_CHANNEL_OP_SUBTRACT,
SELECTION_REPLACE = GIMP_CHANNEL_OP_REPLACE,
SELECTION_INTERSECT = GIMP_CHANNEL_OP_INTERSECT,
SELECTION_MOVE_MASK,
SELECTION_MOVE,
SELECTION_MOVE_COPY,
SELECTION_ANCHOR
} SelectOps;
/* Tool control actions */
typedef enum /*< pdb-skip, skip >*/
{
PAUSE,
RESUME,
HALT
} GimpToolAction;
/* Motion event report modes */
typedef enum /*< pdb-skip, skip >*/
{
GIMP_MOTION_MODE_EXACT,
GIMP_MOTION_MODE_HINT,
GIMP_MOTION_MODE_COMPRESS
} GimpMotionMode;
#define GIMP_TYPE_RECT_SELECT_MODE (gimp_rect_select_mode_get_type ()) #define GIMP_TYPE_RECT_SELECT_MODE (gimp_rect_select_mode_get_type ())
GType gimp_rect_select_mode_get_type (void) G_GNUC_CONST; GType gimp_rect_select_mode_get_type (void) G_GNUC_CONST;
@ -128,6 +106,38 @@ typedef enum /*< pdb-skip >*/
} GimpTransformGridType; } GimpTransformGridType;
/*
* non-registered enums; register them if needed
*/
typedef enum /*< pdb-skip, skip >*/
{
SELECTION_ADD = GIMP_CHANNEL_OP_ADD,
SELECTION_SUBTRACT = GIMP_CHANNEL_OP_SUBTRACT,
SELECTION_REPLACE = GIMP_CHANNEL_OP_REPLACE,
SELECTION_INTERSECT = GIMP_CHANNEL_OP_INTERSECT,
SELECTION_MOVE_MASK,
SELECTION_MOVE,
SELECTION_MOVE_COPY,
SELECTION_ANCHOR
} SelectOps;
/* Tool control actions */
typedef enum /*< pdb-skip, skip >*/
{
PAUSE,
RESUME,
HALT
} GimpToolAction;
/* Motion event report modes */
typedef enum /*< pdb-skip, skip >*/
{
GIMP_MOTION_MODE_EXACT,
GIMP_MOTION_MODE_HINT,
GIMP_MOTION_MODE_COMPRESS
} GimpMotionMode;
/* Possible transform functions */ /* Possible transform functions */
typedef enum /*< pdb-skip, skip >*/ typedef enum /*< pdb-skip, skip >*/
{ {

View file

@ -56,7 +56,7 @@
#include "gimphelp-ids.h" #include "gimphelp-ids.h"
#include "gimpitemfactory.h" #include "gimpitemfactory.h"
#include "gimpmenufactory.h" #include "gimpmenufactory.h"
#include "gimptoolbox-color-area.h" #include "gimpwidgets-utils.h"
#include "gui/color-notebook.h" #include "gui/color-notebook.h"
@ -88,7 +88,6 @@ static void gimp_colormap_editor_unmap (GtkWidget *widget);
static void gimp_colormap_editor_set_image (GimpImageEditor *editor, static void gimp_colormap_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage); GimpImage *gimage);
static void gimp_colormap_editor_real_selected (GimpColormapEditor *editor);
static void gimp_colormap_editor_draw (GimpColormapEditor *editor); static void gimp_colormap_editor_draw (GimpColormapEditor *editor);
static void gimp_colormap_editor_draw_cell (GimpColormapEditor *editor, static void gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
gint col); gint col);
@ -124,6 +123,9 @@ static void gimp_colormap_edit_clicked (GtkWidget *widget,
GimpColormapEditor *editor); GimpColormapEditor *editor);
static void gimp_colormap_add_clicked (GtkWidget *widget, static void gimp_colormap_add_clicked (GtkWidget *widget,
GimpColormapEditor *editor); GimpColormapEditor *editor);
static void gimp_colormap_add_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpColormapEditor *editor);
static void gimp_colormap_image_mode_changed (GimpImage *gimage, static void gimp_colormap_image_mode_changed (GimpImage *gimage,
GimpColormapEditor *editor); GimpColormapEditor *editor);
@ -189,8 +191,9 @@ gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpColormapEditorClass, selected), G_STRUCT_OFFSET (GimpColormapEditorClass, selected),
NULL, NULL, NULL, NULL,
gimp_marshal_VOID__VOID, gimp_marshal_VOID__ENUM,
G_TYPE_NONE, 0); G_TYPE_NONE, 1,
GDK_TYPE_MODIFIER_TYPE);
object_class->destroy = gimp_colormap_editor_destroy; object_class->destroy = gimp_colormap_editor_destroy;
@ -198,12 +201,14 @@ gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
image_editor_class->set_image = gimp_colormap_editor_set_image; image_editor_class->set_image = gimp_colormap_editor_set_image;
klass->selected = gimp_colormap_editor_real_selected; klass->selected = NULL;
} }
static void static void
gimp_colormap_editor_init (GimpColormapEditor *editor) gimp_colormap_editor_init (GimpColormapEditor *editor)
{ {
gchar *str;
editor->col_index = 0; editor->col_index = 0;
editor->dnd_col_index = 0; editor->dnd_col_index = 0;
editor->palette = NULL; editor->palette = NULL;
@ -223,14 +228,16 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
NULL, NULL,
editor); editor);
str = g_strdup_printf (_("Add Color from FG\n%s from BG"),
gimp_get_mod_name_control ());
editor->add_button = editor->add_button =
gimp_editor_add_button (GIMP_EDITOR (editor), gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_ADD, _("Add Color"), GTK_STOCK_ADD, str,
GIMP_HELP_INDEXED_PALETTE_ADD, GIMP_HELP_INDEXED_PALETTE_ADD,
G_CALLBACK (gimp_colormap_add_clicked), G_CALLBACK (gimp_colormap_add_clicked),
NULL, G_CALLBACK (gimp_colormap_add_ext_clicked),
editor); editor);
g_free (str);
} }
static void static void
@ -411,11 +418,12 @@ gimp_colormap_editor_new (GimpImage *gimage,
} }
void void
gimp_colormap_editor_selected (GimpColormapEditor *editor) gimp_colormap_editor_selected (GimpColormapEditor *editor,
GdkModifierType state)
{ {
g_return_if_fail (GIMP_IS_COLORMAP_EDITOR (editor)); g_return_if_fail (GIMP_IS_COLORMAP_EDITOR (editor));
g_signal_emit (editor, editor_signals[SELECTED], 0); g_signal_emit (editor, editor_signals[SELECTED], 0, state);
} }
gint gint
@ -429,29 +437,6 @@ gimp_colormap_editor_col_index (GimpColormapEditor *editor)
/* private functions */ /* private functions */
static void
gimp_colormap_editor_real_selected (GimpColormapEditor *editor)
{
GimpContext *user_context;
GimpImage *gimage;
GimpRGB color;
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
if (!gimage)
return;
user_context = gimp_get_user_context (gimage->gimp);
gimp_image_get_colormap_entry (gimage, editor->col_index, &color);
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, &color);
}
#define MIN_CELL_SIZE 4 #define MIN_CELL_SIZE 4
static void static void
@ -770,7 +755,7 @@ gimp_colormap_preview_button_press (GtkWidget *widget,
{ {
case 1: case 1:
gimp_colormap_editor_set_index (editor, col); gimp_colormap_editor_set_index (editor, col);
gimp_colormap_editor_selected (editor); gimp_colormap_editor_selected (editor, bevent->state);
if (bevent->type == GDK_2BUTTON_PRESS) if (bevent->type == GDK_2BUTTON_PRESS)
gimp_colormap_edit_clicked (editor->edit_button, editor); gimp_colormap_edit_clicked (editor->edit_button, editor);
@ -963,6 +948,14 @@ gimp_colormap_edit_clicked (GtkWidget *widget,
static void static void
gimp_colormap_add_clicked (GtkWidget *widget, gimp_colormap_add_clicked (GtkWidget *widget,
GimpColormapEditor *editor) GimpColormapEditor *editor)
{
gimp_colormap_add_ext_clicked (widget, 0, editor);
}
static void
gimp_colormap_add_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpColormapEditor *editor)
{ {
GimpImage *gimage; GimpImage *gimage;
@ -970,12 +963,15 @@ gimp_colormap_add_clicked (GtkWidget *widget,
if (gimage && gimage->num_cols < 256) if (gimage && gimage->num_cols < 256)
{ {
GimpContext *context;
GimpRGB color; GimpRGB color;
gimp_rgb_set_uchar (&color, context = gimp_get_user_context (gimage->gimp);
gimage->cmap[editor->col_index * 3],
gimage->cmap[editor->col_index * 3 + 1], if (state & GDK_CONTROL_MASK)
gimage->cmap[editor->col_index * 3 + 2]); gimp_context_get_background (context, &color);
else
gimp_context_get_foreground (context, &color);
gimp_image_add_colormap_entry (gimage, &color); gimp_image_add_colormap_entry (gimage, &color);
} }

View file

@ -60,7 +60,8 @@ struct _GimpColormapEditorClass
{ {
GimpImageEditorClass parent_class; GimpImageEditorClass parent_class;
void (* selected) (GimpColormapEditor *editor); void (* selected) (GimpColormapEditor *editor,
GdkModifierType state);
}; };
@ -69,7 +70,8 @@ GType gimp_colormap_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_colormap_editor_new (GimpImage *gimage, GtkWidget * gimp_colormap_editor_new (GimpImage *gimage,
GimpMenuFactory *menu_factory); GimpMenuFactory *menu_factory);
void gimp_colormap_editor_selected (GimpColormapEditor *editor); void gimp_colormap_editor_selected (GimpColormapEditor *editor,
GdkModifierType state);
gint gimp_colormap_editor_col_index (GimpColormapEditor *editor); gint gimp_colormap_editor_col_index (GimpColormapEditor *editor);

View file

@ -353,52 +353,52 @@ static GimpBitmapCursor gimp_modifier_cursors[] =
{ {
plus_bits, plus_mask_bits, plus_bits, plus_mask_bits,
plus_width, plus_height, plus_width, plus_height,
plus_x_hot, plus_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
minus_bits, minus_mask_bits, minus_bits, minus_mask_bits,
minus_width, minus_height, minus_width, minus_height,
minus_x_hot, minus_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
intersect_bits, intersect_mask_bits, intersect_bits, intersect_mask_bits,
intersect_width, intersect_height, intersect_width, intersect_height,
intersect_x_hot, intersect_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
move_bits, move_mask_bits, move_bits, move_mask_bits,
move_width, move_height, move_width, move_height,
move_x_hot, move_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
resize_bits, resize_mask_bits, resize_bits, resize_mask_bits,
resize_width, resize_height, resize_width, resize_height,
resize_x_hot, resize_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
control_bits, control_mask_bits, control_bits, control_mask_bits,
control_width, control_height, control_width, control_height,
control_x_hot, control_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
anchor_bits, anchor_mask_bits, anchor_bits, anchor_mask_bits,
anchor_width, anchor_height, anchor_width, anchor_height,
anchor_x_hot, anchor_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
foreground_bits, foreground_mask_bits, foreground_bits, foreground_mask_bits,
foreground_width, foreground_height, foreground_width, foreground_height,
foreground_x_hot, foreground_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
background_bits, background_mask_bits, background_bits, background_mask_bits,
background_width, background_height, background_width, background_height,
background_x_hot, background_y_hot, NULL, NULL 0, 0, NULL, NULL
}, },
{ {
pattern_bits, pattern_mask_bits, pattern_bits, pattern_mask_bits,
pattern_width, pattern_height, pattern_width, pattern_height,
pattern_x_hot, pattern_y_hot, NULL, NULL 0, 0, NULL, NULL
} }
}; };

View file

@ -44,6 +44,7 @@
#include "gimppaletteeditor.h" #include "gimppaletteeditor.h"
#include "gimppreview.h" #include "gimppreview.h"
#include "gimptoolbox-color-area.h" #include "gimptoolbox-color-area.h"
#include "gimpwidgets-utils.h"
#include "gui/color-notebook.h" #include "gui/color-notebook.h"
@ -96,6 +97,9 @@ static void palette_editor_columns_changed (GtkAdjustment *adj,
static void palette_editor_new_clicked (GtkWidget *widget, static void palette_editor_new_clicked (GtkWidget *widget,
GimpPaletteEditor *editor); GimpPaletteEditor *editor);
static void palette_editor_new_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpPaletteEditor *editor);
static void palette_editor_edit_clicked (GtkWidget *widget, static void palette_editor_edit_clicked (GtkWidget *widget,
GimpPaletteEditor *editor); GimpPaletteEditor *editor);
static void palette_editor_delete_clicked (GtkWidget *widget, static void palette_editor_delete_clicked (GtkWidget *widget,
@ -192,6 +196,7 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *label; GtkWidget *label;
GtkWidget *spinbutton; GtkWidget *spinbutton;
gchar *str;
editor->zoom_factor = 1.0; editor->zoom_factor = 1.0;
editor->columns = COLUMNS; editor->columns = COLUMNS;
@ -283,13 +288,16 @@ gimp_palette_editor_init (GimpPaletteEditor *editor)
NULL, NULL,
editor); editor);
str = g_strdup_printf (_("New Color from FG\n%s from BG"),
gimp_get_mod_name_control ());
editor->new_button = editor->new_button =
gimp_editor_add_button (GIMP_EDITOR (editor), gimp_editor_add_button (GIMP_EDITOR (editor),
GTK_STOCK_NEW, _("New Color"), GTK_STOCK_NEW, str,
GIMP_HELP_PALETTE_EDITOR_NEW, GIMP_HELP_PALETTE_EDITOR_NEW,
G_CALLBACK (palette_editor_new_clicked), G_CALLBACK (palette_editor_new_clicked),
NULL, G_CALLBACK (palette_editor_new_ext_clicked),
editor); editor);
g_free (str);
editor->delete_button = editor->delete_button =
gimp_editor_add_button (GIMP_EDITOR (editor), gimp_editor_add_button (GIMP_EDITOR (editor),
@ -547,8 +555,6 @@ palette_editor_color_area_button_press (GtkWidget *widget,
palette_editor_select_entry (editor, list ? list->data : NULL); palette_editor_select_entry (editor, list ? list->data : NULL);
if (list) if (list)
{
if (active_color == FOREGROUND)
{ {
if (bevent->state & GDK_CONTROL_MASK) if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_background (user_context, gimp_context_set_background (user_context,
@ -556,16 +562,6 @@ palette_editor_color_area_button_press (GtkWidget *widget,
else else
gimp_context_set_foreground (user_context, gimp_context_set_foreground (user_context,
&editor->color->color); &editor->color->color);
}
else if (active_color == BACKGROUND)
{
if (bevent->state & GDK_CONTROL_MASK)
gimp_context_set_foreground (user_context,
&editor->color->color);
else
gimp_context_set_background (user_context,
&editor->color->color);
}
palette_editor_draw_entries (editor, row, col); palette_editor_draw_entries (editor, row, col);
@ -1026,6 +1022,14 @@ palette_editor_edit_clicked (GtkWidget *widget,
static void static void
palette_editor_new_clicked (GtkWidget *widget, palette_editor_new_clicked (GtkWidget *widget,
GimpPaletteEditor *editor) GimpPaletteEditor *editor)
{
palette_editor_new_ext_clicked (widget, 0, editor);
}
static void
palette_editor_new_ext_clicked (GtkWidget *widget,
GdkModifierType state,
GimpPaletteEditor *editor)
{ {
GimpDataEditor *data_editor; GimpDataEditor *data_editor;
GimpPalette *palette; GimpPalette *palette;
@ -1041,10 +1045,10 @@ palette_editor_new_clicked (GtkWidget *widget,
user_context = gimp_get_user_context (data_editor->gimp); user_context = gimp_get_user_context (data_editor->gimp);
if (active_color == FOREGROUND) if (state & GDK_CONTROL_MASK)
gimp_context_get_foreground (user_context, &color);
else if (active_color == BACKGROUND)
gimp_context_get_background (user_context, &color); gimp_context_get_background (user_context, &color);
else
gimp_context_get_foreground (user_context, &color);
editor->color = gimp_palette_add_entry (palette, NULL, &color); editor->color = gimp_palette_add_entry (palette, NULL, &color);
} }
@ -1229,13 +1233,6 @@ palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
if (editor->color) if (editor->color)
{ {
editor->color->color = *color; editor->color->color = *color;
/* Update either foreground or background colors */
if (active_color == FOREGROUND)
gimp_context_set_foreground (user_context, color);
else if (active_color == BACKGROUND)
gimp_context_set_background (user_context, color);
gimp_data_dirty (GIMP_DATA (palette)); gimp_data_dirty (GIMP_DATA (palette));
} }

View file

@ -58,6 +58,9 @@ typedef enum
INVALID_AREA INVALID_AREA
} ColorAreaTarget; } ColorAreaTarget;
#define FOREGROUND 0
#define BACKGROUND 1
/* local function prototypes */ /* local function prototypes */
@ -90,13 +93,13 @@ static gboolean color_area_events (GtkWidget *widget,
/* Global variables */ /* Global variables */
gint active_color = FOREGROUND;
GimpDisplay *color_area_gdisp = NULL; GimpDisplay *color_area_gdisp = NULL;
/* Static variables */ /* Static variables */
static GtkWidget *color_area = NULL; static GtkWidget *color_area = NULL;
static ColorNotebook *color_notebook = NULL; static ColorNotebook *color_notebook = NULL;
static gboolean color_notebook_active = FALSE; static gboolean color_notebook_active = FALSE;
static gint active_color = FOREGROUND;
static gint edit_color; static gint edit_color;
static GimpRGB revert_fg; static GimpRGB revert_fg;
static GimpRGB revert_bg; static GimpRGB revert_bg;

View file

@ -20,14 +20,6 @@
#define __GIMP_TOOLBOX_COLOR_AREA_H__ #define __GIMP_TOOLBOX_COLOR_AREA_H__
#define FOREGROUND 0
#define BACKGROUND 1
/*
* Global variables
*/
extern gint active_color; /* foreground (= 0) or background (= 1) */
#ifdef DISPLAY_FILTERS #ifdef DISPLAY_FILTERS
extern GimpDisplay *color_area_gdisp; /* hack for color displays */ extern GimpDisplay *color_area_gdisp; /* hack for color displays */
#endif /* DISPLAY_FILTERS */ #endif /* DISPLAY_FILTERS */

View file

@ -1,13 +1,10 @@
/* Created with The GIMP */
#define background_width 32 #define background_width 32
#define background_height 32 #define background_height 32
#define background_x_hot 0
#define background_y_hot 0
static unsigned char background_bits[] = { static unsigned char background_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07,
0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0xf8, 0x01, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0xe0, 0x47,
0x00, 0x00, 0xf8, 0x11, 0x00, 0x00, 0xf8, 0x11, 0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0xe0, 0x47, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x41,
0x00, 0x00, 0x40, 0x10, 0x00, 0x00, 0xc0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -1,13 +1,10 @@
/* Created with The GIMP */
#define background_mask_width 32 #define background_mask_width 32
#define background_mask_height 32 #define background_mask_height 32
#define background_mask_x_hot 0
#define background_mask_y_hot 0
static unsigned char background_mask_bits[] = { static unsigned char background_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf0, 0x0f,
0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0xf0, 0xff,
0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, 0x80, 0xff,
0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -1,13 +1,10 @@
/* Created with The GIMP */
#define foreground_width 32 #define foreground_width 32
#define foreground_height 32 #define foreground_height 32
#define foreground_x_hot 0
#define foreground_y_hot 0
static unsigned char foreground_bits[] = { static unsigned char foreground_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf0, 0x07,
0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf0, 0x3f, 0x00, 0x00, 0xf0, 0x27,
0x00, 0x00, 0xfc, 0x09, 0x00, 0x00, 0xfc, 0x09, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0xf0, 0x27, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3f,
0x00, 0x00, 0xc0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -1,13 +1,10 @@
/* Created with The GIMP */
#define foreground_mask_width 32 #define foreground_mask_width 32
#define foreground_mask_height 32 #define foreground_mask_height 32
#define foreground_mask_x_hot 0
#define foreground_mask_y_hot 0
static unsigned char foreground_mask_bits[] = { static unsigned char foreground_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf8, 0x0f,
0x00, 0x00, 0xfe, 0x03, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xf8, 0x7f,
0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x80, 0x7f,
0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0xe0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

Binary file not shown.