2000-12-17 05:37:03 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2002-01-30 22:54:27 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning GTK_DISABLE_DEPRECATED
|
|
|
|
#endif
|
|
|
|
#undef GTK_DISABLE_DEPRECATED
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2001-01-08 07:59:46 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 02:49:44 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
#include "widgets-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2002-05-11 07:30:09 +08:00
|
|
|
#ifdef __GNUC__
|
2002-05-08 00:23:14 +08:00
|
|
|
#warning FIXME #include "display/display-types.h"
|
2002-05-11 07:30:09 +08:00
|
|
|
#endif
|
2002-05-08 00:23:14 +08:00
|
|
|
#include "display/display-types.h"
|
|
|
|
|
2003-03-04 22:35:56 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2003-03-04 22:35:56 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-03-18 21:49:02 +08:00
|
|
|
#include "core/gimpimage-colormap.h"
|
2001-11-23 07:46:13 +08:00
|
|
|
#include "core/gimpmarshal.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-11-02 17:31:21 +08:00
|
|
|
#include "display/gimpdisplayshell-render.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
#include "gimpcolormapeditor.h"
|
|
|
|
#include "gimpdnd.h"
|
2003-09-19 19:40:12 +08:00
|
|
|
#include "gimpdialogfactory.h"
|
|
|
|
#include "gimphelp-ids.h"
|
2003-01-11 01:55:53 +08:00
|
|
|
#include "gimpmenufactory.h"
|
2003-09-26 21:33:54 +08:00
|
|
|
#include "gimpwidgets-utils.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
#include "gui/color-notebook.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* Add these features:
|
|
|
|
*
|
|
|
|
* load/save colormaps
|
|
|
|
* requantize
|
|
|
|
* add color--by clicking in the checked region
|
|
|
|
* all changes need to flush colormap lookup cache
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SELECTED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
#define HAVE_COLORMAP(gimage) \
|
|
|
|
(gimage != NULL && \
|
|
|
|
gimp_image_base_type (gimage) == GIMP_INDEXED && \
|
|
|
|
gimp_image_get_colormap (gimage) != NULL)
|
|
|
|
|
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
static void gimp_colormap_editor_class_init (GimpColormapEditorClass *klass);
|
|
|
|
static void gimp_colormap_editor_init (GimpColormapEditor *colormap_editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
static GObject * gimp_colormap_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void gimp_colormap_editor_destroy (GtkObject *object);
|
|
|
|
static void gimp_colormap_editor_unmap (GtkWidget *widget);
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
static void gimp_colormap_editor_set_image (GimpImageEditor *editor,
|
|
|
|
GimpImage *gimage);
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void gimp_colormap_editor_draw (GimpColormapEditor *editor);
|
|
|
|
static void gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
|
|
|
|
gint col);
|
|
|
|
static void gimp_colormap_editor_clear (GimpColormapEditor *editor,
|
|
|
|
gint start_row);
|
|
|
|
static void gimp_colormap_editor_update_entries (GimpColormapEditor *editor);
|
|
|
|
static void gimp_colormap_editor_set_index (GimpColormapEditor *editor,
|
|
|
|
gint i);
|
|
|
|
|
|
|
|
static void gimp_colormap_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *allocation,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
static gboolean
|
|
|
|
gimp_colormap_preview_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
static void gimp_colormap_preview_drag_color (GtkWidget *widget,
|
|
|
|
GimpRGB *color,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_colormap_preview_drop_color (GtkWidget *widget,
|
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data);
|
|
|
|
|
|
|
|
static void gimp_colormap_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
static void gimp_colormap_hex_entry_activate (GtkEntry *entry,
|
|
|
|
GimpColormapEditor *editor);
|
2003-09-19 19:40:12 +08:00
|
|
|
static gboolean gimp_colormap_hex_entry_focus_out (GtkEntry *entry,
|
2002-03-17 21:52:25 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
|
2003-09-19 19:40:12 +08:00
|
|
|
static void gimp_colormap_edit_clicked (GtkWidget *widget,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void gimp_colormap_image_mode_changed (GimpImage *gimage,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
static void gimp_colormap_image_colormap_changed (GimpImage *gimage,
|
|
|
|
gint ncol,
|
|
|
|
GimpColormapEditor *editor);
|
|
|
|
|
|
|
|
|
|
|
|
static guint editor_signals[LAST_SIGNAL] = { 0 };
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
static GimpImageEditorClass *parent_class = NULL;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
|
2001-09-26 01:44:03 +08:00
|
|
|
GType
|
2002-03-17 01:58:19 +08:00
|
|
|
gimp_colormap_editor_get_type (void)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2004-05-13 23:50:55 +08:00
|
|
|
static GType type = 0;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
if (! type)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2004-05-13 23:50:55 +08:00
|
|
|
static const GTypeInfo info =
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
sizeof (GimpColormapEditorClass),
|
2004-05-13 23:50:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_colormap_editor_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpColormapEditor),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_colormap_editor_init,
|
2001-01-08 07:59:46 +08:00
|
|
|
};
|
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
type = g_type_register_static (GIMP_TYPE_IMAGE_EDITOR,
|
|
|
|
"GimpColormapEditor",
|
|
|
|
&info, 0);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
return type;
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 01:58:19 +08:00
|
|
|
gimp_colormap_editor_class_init (GimpColormapEditorClass* klass)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2004-05-13 23:50:55 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
GimpImageEditorClass *image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
|
2002-03-17 21:52:25 +08:00
|
|
|
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
editor_signals[SELECTED] =
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
g_signal_new ("selected",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
2002-03-17 01:58:19 +08:00
|
|
|
G_STRUCT_OFFSET (GimpColormapEditorClass, selected),
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
NULL, NULL,
|
2004-03-03 22:44:34 +08:00
|
|
|
gimp_marshal_VOID__FLAGS,
|
2003-09-26 21:33:54 +08:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
GDK_TYPE_MODIFIER_TYPE);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-05-13 23:50:55 +08:00
|
|
|
object_class->constructor = gimp_colormap_editor_constructor;
|
|
|
|
|
|
|
|
gtk_object_class->destroy = gimp_colormap_editor_destroy;
|
2003-02-20 23:40:15 +08:00
|
|
|
|
|
|
|
widget_class->unmap = gimp_colormap_editor_unmap;
|
2002-03-17 21:52:25 +08:00
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
image_editor_class->set_image = gimp_colormap_editor_set_image;
|
2002-03-17 21:52:25 +08:00
|
|
|
|
2003-09-26 21:33:54 +08:00
|
|
|
klass->selected = NULL;
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-09-19 19:40:12 +08:00
|
|
|
gimp_colormap_editor_init (GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-09-19 19:40:12 +08:00
|
|
|
editor->col_index = 0;
|
|
|
|
editor->dnd_col_index = 0;
|
|
|
|
editor->palette = NULL;
|
|
|
|
editor->xn = 0;
|
|
|
|
editor->yn = 0;
|
|
|
|
editor->cellsize = 0;
|
|
|
|
editor->index_adjustment = NULL;
|
|
|
|
editor->index_spinbutton = NULL;
|
|
|
|
editor->color_entry = NULL;
|
|
|
|
editor->color_notebook = NULL;
|
2004-05-13 23:50:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GObject *
|
|
|
|
gimp_colormap_editor_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
|
|
|
{
|
|
|
|
GObject *object;
|
|
|
|
GimpColormapEditor *editor;
|
|
|
|
gchar *str;
|
|
|
|
|
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
|
|
|
|
|
|
|
editor = GIMP_COLORMAP_EDITOR (object);
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
editor->edit_button =
|
|
|
|
gimp_editor_add_button (GIMP_EDITOR (editor),
|
2004-06-24 06:44:04 +08:00
|
|
|
GIMP_STOCK_EDIT, _("Edit color"),
|
2003-09-19 19:40:12 +08:00
|
|
|
GIMP_HELP_INDEXED_PALETTE_EDIT,
|
|
|
|
G_CALLBACK (gimp_colormap_edit_clicked),
|
|
|
|
NULL,
|
|
|
|
editor);
|
|
|
|
|
2004-06-24 06:44:04 +08:00
|
|
|
str = g_strdup_printf (_("Add color from FG\n%s from BG"),
|
2004-06-29 07:30:57 +08:00
|
|
|
gimp_get_mod_string (GDK_CONTROL_MASK));
|
2003-09-19 19:40:12 +08:00
|
|
|
editor->add_button =
|
2004-05-13 23:50:55 +08:00
|
|
|
gimp_editor_add_action_button (GIMP_EDITOR (editor), "colormap-editor",
|
|
|
|
"colormap-editor-add-color-from-fg",
|
|
|
|
"colormap-editor-add-color-from-bg",
|
|
|
|
GDK_CONTROL_MASK,
|
|
|
|
NULL);
|
|
|
|
gimp_help_set_help_data (editor->add_button, str,
|
|
|
|
GIMP_HELP_INDEXED_PALETTE_ADD);
|
2003-09-26 21:33:54 +08:00
|
|
|
g_free (str);
|
2004-05-13 23:50:55 +08:00
|
|
|
|
|
|
|
return object;
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_editor_destroy (GtkObject *object)
|
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (object);
|
2002-03-17 21:52:25 +08:00
|
|
|
|
|
|
|
if (editor->color_notebook)
|
|
|
|
{
|
|
|
|
color_notebook_free (editor->color_notebook);
|
|
|
|
editor->color_notebook = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_colormap_editor_unmap (GtkWidget *widget)
|
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (widget);
|
2002-03-17 21:52:25 +08:00
|
|
|
|
|
|
|
if (editor->color_notebook)
|
2003-01-11 01:55:53 +08:00
|
|
|
color_notebook_hide (editor->color_notebook);
|
2002-03-17 21:52:25 +08:00
|
|
|
|
|
|
|
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
|
|
|
}
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_editor_set_image (GimpImageEditor *image_editor,
|
|
|
|
GimpImage *gimage)
|
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpColormapEditor *editor = GIMP_COLORMAP_EDITOR (image_editor);
|
2003-02-20 23:40:15 +08:00
|
|
|
|
|
|
|
if (image_editor->gimage)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->gimage,
|
|
|
|
gimp_colormap_image_mode_changed,
|
|
|
|
editor);
|
|
|
|
g_signal_handlers_disconnect_by_func (image_editor->gimage,
|
|
|
|
gimp_colormap_image_colormap_changed,
|
|
|
|
editor);
|
|
|
|
|
|
|
|
if (editor->color_notebook)
|
|
|
|
color_notebook_hide (editor->color_notebook);
|
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (! HAVE_COLORMAP (gimage))
|
2003-02-20 23:40:15 +08:00
|
|
|
{
|
|
|
|
editor->index_adjustment->upper = 0;
|
|
|
|
gtk_adjustment_changed (editor->index_adjustment);
|
|
|
|
|
|
|
|
if (GTK_WIDGET_MAPPED (GTK_WIDGET (editor)))
|
|
|
|
gimp_colormap_editor_clear (editor, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_IMAGE_EDITOR_CLASS (parent_class)->set_image (image_editor, gimage);
|
|
|
|
|
|
|
|
editor->col_index = 0;
|
|
|
|
editor->dnd_col_index = 0;
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
g_signal_connect (gimage, "mode_changed",
|
|
|
|
G_CALLBACK (gimp_colormap_image_mode_changed),
|
|
|
|
editor);
|
|
|
|
g_signal_connect (gimage, "colormap_changed",
|
|
|
|
G_CALLBACK (gimp_colormap_image_colormap_changed),
|
|
|
|
editor);
|
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage))
|
2003-02-20 23:40:15 +08:00
|
|
|
{
|
|
|
|
gimp_colormap_editor_draw (editor);
|
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
editor->index_adjustment->upper =
|
|
|
|
gimp_image_get_colormap_size (gimage) - 1;
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
gtk_adjustment_changed (editor->index_adjustment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_colormap_editor_update_entries (editor);
|
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
GtkWidget *
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_colormap_editor_new (GimpImage *gimage,
|
|
|
|
GimpMenuFactory *menu_factory)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
GimpColormapEditor *editor;
|
2001-07-15 22:32:44 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *table;
|
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
g_return_val_if_fail (gimage == NULL || GIMP_IS_IMAGE (gimage), NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_MENU_FACTORY (menu_factory), NULL);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-05-13 02:36:33 +08:00
|
|
|
editor = g_object_new (GIMP_TYPE_COLORMAP_EDITOR,
|
|
|
|
"menu-factory", menu_factory,
|
|
|
|
"menu-identifier", "<ColormapEditor>",
|
|
|
|
"ui-path", "/colormap-editor-popup",
|
|
|
|
NULL);
|
2003-01-11 01:55:53 +08:00
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
/* The palette frame */
|
|
|
|
frame = gtk_frame_new (NULL);
|
|
|
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
|
2001-07-15 22:32:44 +08:00
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->palette = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_widget_set_size_request (editor->palette, -1, 60);
|
|
|
|
gtk_preview_set_expand (GTK_PREVIEW (editor->palette), TRUE);
|
|
|
|
gtk_widget_add_events (editor->palette, GDK_BUTTON_PRESS_MASK);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), editor->palette);
|
|
|
|
gtk_widget_show (editor->palette);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_after (editor->palette, "size_allocate",
|
2002-03-17 21:52:25 +08:00
|
|
|
G_CALLBACK (gimp_colormap_preview_size_allocate),
|
2002-03-17 01:58:19 +08:00
|
|
|
editor);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->palette, "button_press_event",
|
2002-03-17 21:52:25 +08:00
|
|
|
G_CALLBACK (gimp_colormap_preview_button_press),
|
2002-03-17 01:58:19 +08:00
|
|
|
editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-11-21 00:26:15 +08:00
|
|
|
gimp_dnd_color_source_add (editor->palette, gimp_colormap_preview_drag_color,
|
2002-03-17 21:52:25 +08:00
|
|
|
editor);
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_color_dest_add (editor->palette, gimp_colormap_preview_drop_color,
|
2002-03-17 21:52:25 +08:00
|
|
|
editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
/* some helpful hints */
|
2001-07-15 22:32:44 +08:00
|
|
|
table = gtk_table_new (2, 2, FALSE);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 2);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (editor), table, FALSE, FALSE, 0);
|
2001-07-15 22:32:44 +08:00
|
|
|
gtk_widget_show (table);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->index_spinbutton =
|
|
|
|
gimp_spin_button_new ((GtkObject **) &editor->index_adjustment,
|
2001-01-08 07:59:46 +08:00
|
|
|
0, 0, 0, 1, 10, 10, 1.0, 0);
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2004-06-24 06:44:04 +08:00
|
|
|
_("Color index:"), 0.0, 0.5,
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->index_spinbutton, 1, TRUE);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->index_adjustment, "value_changed",
|
2002-03-17 21:52:25 +08:00
|
|
|
G_CALLBACK (gimp_colormap_adjustment_changed),
|
2002-03-17 01:58:19 +08:00
|
|
|
editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->color_entry = gtk_entry_new ();
|
2003-09-19 20:05:28 +08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (editor->color_entry), 8);
|
|
|
|
gtk_entry_set_max_length (GTK_ENTRY (editor->color_entry), 6);
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2004-06-24 06:44:04 +08:00
|
|
|
_("He_x triplet:"), 0.0, 0.5,
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->color_entry, 1, TRUE);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->color_entry, "activate",
|
2002-03-17 21:52:25 +08:00
|
|
|
G_CALLBACK (gimp_colormap_hex_entry_activate),
|
|
|
|
editor);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (editor->color_entry, "focus_out_event",
|
2002-03-17 21:52:25 +08:00
|
|
|
G_CALLBACK (gimp_colormap_hex_entry_focus_out),
|
2002-03-17 01:58:19 +08:00
|
|
|
editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
if (gimage)
|
|
|
|
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
return GTK_WIDGET (editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-09-26 21:33:54 +08:00
|
|
|
gimp_colormap_editor_selected (GimpColormapEditor *editor,
|
|
|
|
GdkModifierType state)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
g_return_if_fail (GIMP_IS_COLORMAP_EDITOR (editor));
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-09-26 21:33:54 +08:00
|
|
|
g_signal_emit (editor, editor_signals[SELECTED], 0, state);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
gint
|
2002-03-17 01:58:19 +08:00
|
|
|
gimp_colormap_editor_col_index (GimpColormapEditor *editor)
|
2001-07-15 22:32:44 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_COLORMAP_EDITOR (editor), 0);
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
return editor->col_index;
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
#define MIN_CELL_SIZE 4
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_draw (GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2001-07-15 22:32:44 +08:00
|
|
|
gint i, j, k, l, b;
|
|
|
|
gint col;
|
|
|
|
guchar *row;
|
|
|
|
gint cellsize, ncol, xn, yn, width, height;
|
2001-01-08 07:59:46 +08:00
|
|
|
GtkWidget *palette;
|
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
palette = editor->palette;
|
2001-07-15 22:32:44 +08:00
|
|
|
width = palette->allocation.width;
|
|
|
|
height = palette->allocation.height;
|
2003-03-18 21:49:02 +08:00
|
|
|
ncol = gimp_image_get_colormap_size (gimage);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
if (! ncol)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_clear (editor, -1);
|
2001-01-08 07:59:46 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
cellsize = sqrt (width * height / ncol);
|
2001-01-08 07:59:46 +08:00
|
|
|
while (cellsize >= MIN_CELL_SIZE
|
2001-07-15 22:32:44 +08:00
|
|
|
&& (xn = width / cellsize) * (yn = height / cellsize) < ncol)
|
2001-01-08 07:59:46 +08:00
|
|
|
cellsize--;
|
|
|
|
|
|
|
|
if (cellsize < MIN_CELL_SIZE)
|
|
|
|
{
|
|
|
|
cellsize = MIN_CELL_SIZE;
|
|
|
|
xn = yn = ceil (sqrt (ncol));
|
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
yn = ((ncol + xn - 1) / xn);
|
|
|
|
|
2002-05-11 21:25:45 +08:00
|
|
|
/* We used to render just multiples of "cellsize" here, but the
|
|
|
|
* colormap as dockable looks better if it always fills the
|
|
|
|
* available allocation->width (which should always be larger than
|
|
|
|
* "xn * cellsize"). Defensively, we use MAX(width,xn*cellsize)
|
|
|
|
* below --Mitch
|
|
|
|
*
|
|
|
|
|
|
|
|
width = xn * cellsize;
|
|
|
|
height = yn * cellsize; */
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->xn = xn;
|
|
|
|
editor->yn = yn;
|
|
|
|
editor->cellsize = cellsize;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-05-11 21:25:45 +08:00
|
|
|
row = g_new (guchar, MAX (width, xn * cellsize) * 3);
|
2001-01-08 07:59:46 +08:00
|
|
|
col = 0;
|
|
|
|
for (i = 0; i < yn; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < xn && col < ncol; j++, col++)
|
|
|
|
{
|
|
|
|
for (k = 0; k < cellsize; k++)
|
|
|
|
for (b = 0; b < 3; b++)
|
|
|
|
row[(j * cellsize + k) * 3 + b] = gimage->cmap[col * 3 + b];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (k = 0; k < cellsize; k++)
|
|
|
|
{
|
2001-07-15 22:32:44 +08:00
|
|
|
for (l = j * cellsize; l < width; l++)
|
2001-01-08 07:59:46 +08:00
|
|
|
for (b = 0; b < 3; b++)
|
2001-07-15 22:32:44 +08:00
|
|
|
row[l * 3 + b] = (((((i * cellsize + k) & 0x4) ?
|
|
|
|
(l) :
|
|
|
|
(l + 0x4)) & 0x4) ?
|
|
|
|
render_blend_light_check[0] :
|
|
|
|
render_blend_dark_check[0]);
|
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row, 0,
|
2001-07-15 22:32:44 +08:00
|
|
|
i * cellsize + k,
|
|
|
|
width);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
}
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_clear (editor, yn * cellsize);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_draw_cell (editor, editor->col_index);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
g_free (row);
|
2001-07-15 22:32:44 +08:00
|
|
|
gtk_widget_queue_draw (palette);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_draw_cell (GimpColormapEditor *editor,
|
|
|
|
gint col)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-02-20 23:40:15 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
guchar *row;
|
|
|
|
gint cellsize, x, y, k;
|
|
|
|
|
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
cellsize = editor->cellsize;
|
2001-01-15 09:48:53 +08:00
|
|
|
row = g_new (guchar, cellsize * 3);
|
2002-03-17 01:58:19 +08:00
|
|
|
x = (col % editor->xn) * cellsize;
|
|
|
|
y = (col / editor->xn) * cellsize;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
if (col == editor->col_index)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
|
|
|
for(k = 0; k < cellsize; k++)
|
|
|
|
row[k*3] = row[k*3+1] = row[k*3+2] = (k & 1) * 255;
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row, x, y, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
if (!(cellsize & 1))
|
|
|
|
for (k = 0; k < cellsize; k++)
|
|
|
|
row[k*3] = row[k*3+1] = row[k*3+2] = ((x+y+1) & 1) * 255;
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
x, y+cellsize-1, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
row[0]=row[1]=row[2]=255;
|
|
|
|
row[cellsize*3-3] = row[cellsize*3-2] = row[cellsize*3-1]
|
|
|
|
= 255 * (cellsize & 1);
|
|
|
|
for (k = 1; k < cellsize - 1; k++)
|
|
|
|
{
|
2003-02-20 23:40:15 +08:00
|
|
|
row[k*3] = gimage->cmap[col * 3];
|
|
|
|
row[k*3+1] = gimage->cmap[col * 3 + 1];
|
|
|
|
row[k*3+2] = gimage->cmap[col * 3 + 2];
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
for (k = 1; k < cellsize - 1; k+=2)
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
x, y+k, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
|
|
|
row[0] = row[1] = row[2] = 0;
|
|
|
|
row[cellsize*3-3] = row[cellsize*3-2] = row[cellsize*3-1]
|
|
|
|
= 255 * ((cellsize+1) & 1);
|
|
|
|
for (k = 2; k < cellsize - 1; k += 2)
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
x, y+k, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (k = 0; k < cellsize; k++)
|
|
|
|
{
|
2003-02-20 23:40:15 +08:00
|
|
|
row[k*3] = gimage->cmap[col * 3];
|
|
|
|
row[k*3+1] = gimage->cmap[col * 3 + 1];
|
|
|
|
row[k*3+2] = gimage->cmap[col * 3 + 2];
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
for (k = 0; k < cellsize; k++)
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
x, y+k, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
2001-12-29 21:26:29 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_widget_queue_draw_area (editor->palette,
|
2001-12-29 21:26:29 +08:00
|
|
|
x, y,
|
|
|
|
cellsize, cellsize);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
2002-03-17 21:52:25 +08:00
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_clear (GimpColormapEditor *editor,
|
|
|
|
gint start_row)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
gint i, j;
|
|
|
|
gint offset;
|
|
|
|
gint width, height;
|
|
|
|
guchar *row = NULL;
|
2001-01-08 07:59:46 +08:00
|
|
|
GtkWidget *palette;
|
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
palette = editor->palette;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-12-01 20:58:03 +08:00
|
|
|
width = palette->allocation.width;
|
|
|
|
height = palette->allocation.height;
|
2001-07-15 22:32:44 +08:00
|
|
|
|
|
|
|
if (start_row < 0)
|
|
|
|
start_row = 0;
|
|
|
|
|
|
|
|
if (start_row >= height)
|
|
|
|
return;
|
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
if (width > 0)
|
|
|
|
row = g_new (guchar, width * 3);
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
if (start_row & 0x3)
|
|
|
|
{
|
|
|
|
offset = (start_row & 0x4) ? 0x4 : 0x0;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
|
|
|
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
|
|
|
|
((j + offset) & 0x4) ?
|
|
|
|
render_blend_dark_check[0] : render_blend_light_check[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < (4 - (start_row & 0x3)) && start_row + j < height; j++)
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
0, start_row + j, width);
|
|
|
|
|
|
|
|
start_row += (4 - (start_row & 0x3));
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = start_row; i < height; i += 4)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
|
|
|
offset = (i & 0x4) ? 0x4 : 0x0;
|
|
|
|
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
|
|
|
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
|
2001-01-30 11:17:26 +08:00
|
|
|
((j + offset) & 0x4) ?
|
2001-07-15 22:32:44 +08:00
|
|
|
render_blend_dark_check[0] : render_blend_light_check[0];
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
for (j = 0; j < 4 && i + j < height; j++)
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (editor->palette), row,
|
2001-07-15 22:32:44 +08:00
|
|
|
0, i + j, width);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
if (width > 0)
|
|
|
|
g_free (row);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_queue_draw (palette);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_update_entries (GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (! HAVE_COLORMAP (gimage))
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_widget_set_sensitive (editor->index_spinbutton, FALSE);
|
|
|
|
gtk_widget_set_sensitive (editor->color_entry, FALSE);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_adjustment_set_value (editor->index_adjustment, 0);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (editor->color_entry), "");
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GIMP_EDITOR (editor)->button_box, FALSE);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-15 22:32:44 +08:00
|
|
|
gchar *string;
|
2001-01-08 07:59:46 +08:00
|
|
|
guchar *col;
|
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_adjustment_set_value (editor->index_adjustment, editor->col_index);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
col = &gimage->cmap[editor->col_index * 3];
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2003-09-19 20:05:28 +08:00
|
|
|
string = g_strdup_printf ("%02x%02x%02x", col[0], col[1], col[2]);
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (editor->color_entry), string);
|
2001-01-08 07:59:46 +08:00
|
|
|
g_free (string);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
gtk_widget_set_sensitive (editor->index_spinbutton, TRUE);
|
|
|
|
gtk_widget_set_sensitive (editor->color_entry, TRUE);
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
gtk_widget_set_sensitive (GIMP_EDITOR (editor)->button_box, TRUE);
|
|
|
|
|
|
|
|
gtk_widget_set_sensitive (editor->add_button,
|
|
|
|
gimp_image_get_colormap_size (gimage) < 256);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_set_index (GimpColormapEditor *editor,
|
|
|
|
gint i)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
if (i != editor->col_index)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 01:58:19 +08:00
|
|
|
gint old = editor->col_index;
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2002-03-17 01:58:19 +08:00
|
|
|
editor->col_index = i;
|
|
|
|
editor->dnd_col_index = i;
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_draw_cell (editor, old);
|
|
|
|
gimp_colormap_editor_draw_cell (editor, i);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_update_entries (editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_preview_size_allocate (GtkWidget *widget,
|
|
|
|
GtkAllocation *alloc,
|
|
|
|
GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage))
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_editor_draw (editor);
|
|
|
|
else
|
|
|
|
gimp_colormap_editor_clear (editor, -1);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gimp_colormap_preview_button_press (GtkWidget *widget,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 21:52:25 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
guint col;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-02-20 23:40:15 +08:00
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (! HAVE_COLORMAP (gimage))
|
2002-03-17 21:52:25 +08:00
|
|
|
return TRUE;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
if (!(bevent->y < editor->cellsize * editor->yn
|
|
|
|
&& bevent->x < editor->cellsize * editor->xn))
|
|
|
|
return TRUE;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
col = (editor->xn * ((gint) bevent->y / editor->cellsize) +
|
|
|
|
((gint) bevent->x / editor->cellsize));
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
if (col >= gimp_image_get_colormap_size (gimage))
|
2002-03-17 21:52:25 +08:00
|
|
|
return TRUE;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
switch (bevent->button)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 21:52:25 +08:00
|
|
|
case 1:
|
|
|
|
gimp_colormap_editor_set_index (editor, col);
|
2003-09-26 21:33:54 +08:00
|
|
|
gimp_colormap_editor_selected (editor, bevent->state);
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
if (bevent->type == GDK_2BUTTON_PRESS)
|
|
|
|
gimp_colormap_edit_clicked (editor->edit_button, editor);
|
|
|
|
|
|
|
|
return TRUE;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
case 2:
|
|
|
|
editor->dnd_col_index = col;
|
|
|
|
break;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
case 3:
|
2003-01-11 01:55:53 +08:00
|
|
|
gimp_colormap_editor_set_index (editor, col);
|
2004-05-17 21:38:03 +08:00
|
|
|
gimp_editor_popup_menu (GIMP_EDITOR (editor), NULL, NULL);
|
2002-06-01 05:50:52 +08:00
|
|
|
return TRUE;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-06-01 05:50:52 +08:00
|
|
|
return FALSE;
|
2002-03-17 21:52:25 +08:00
|
|
|
}
|
2002-03-19 03:34:06 +08:00
|
|
|
|
2001-01-08 07:59:46 +08:00
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_preview_drag_color (GtkWidget *widget,
|
|
|
|
GimpRGB *color,
|
|
|
|
gpointer data)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 21:52:25 +08:00
|
|
|
GimpColormapEditor *editor;
|
|
|
|
GimpImage *gimage;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
editor = GIMP_COLORMAP_EDITOR (data);
|
2003-02-20 23:40:15 +08:00
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage))
|
|
|
|
gimp_image_get_colormap_entry (gimage, editor->dnd_col_index, color);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_preview_drop_color (GtkWidget *widget,
|
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2002-03-17 21:52:25 +08:00
|
|
|
GimpColormapEditor *editor;
|
2001-01-08 07:59:46 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
editor = GIMP_COLORMAP_EDITOR (data);
|
2003-02-20 23:40:15 +08:00
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage) && gimp_image_get_colormap_size (gimage) < 256)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-03-18 21:49:02 +08:00
|
|
|
gimp_image_add_colormap_entry (gimage, color);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_adjustment_changed (GtkAdjustment *adjustment,
|
|
|
|
GimpColormapEditor *editor)
|
2001-01-08 07:59:46 +08:00
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
|
|
|
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage))
|
2002-03-19 03:34:06 +08:00
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
gimp_colormap_editor_set_index (editor, adjustment->value + 0.5);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
gimp_colormap_editor_update_entries (editor);
|
|
|
|
}
|
2002-03-17 21:52:25 +08:00
|
|
|
}
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_hex_entry_activate (GtkEntry *entry,
|
|
|
|
GimpColormapEditor *editor)
|
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2003-02-20 23:40:15 +08:00
|
|
|
|
|
|
|
if (gimage)
|
2002-03-19 03:34:06 +08:00
|
|
|
{
|
|
|
|
const gchar *s;
|
|
|
|
gulong i;
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-19 03:34:06 +08:00
|
|
|
s = gtk_entry_get_text (entry);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-09-19 20:05:28 +08:00
|
|
|
if (sscanf (s, "%lx", &i))
|
2002-03-19 03:34:06 +08:00
|
|
|
{
|
2003-03-18 21:49:02 +08:00
|
|
|
GimpRGB color;
|
|
|
|
guchar r, g, b;
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
r = (i & 0xFF0000) >> 16;
|
|
|
|
g = (i & 0x00FF00) >> 8;
|
|
|
|
b = (i & 0x0000FF);
|
2003-02-20 23:40:15 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
gimp_rgb_set_uchar (&color, r, g, b);
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
gimp_image_set_colormap_entry (gimage, editor->col_index, &color,
|
|
|
|
TRUE);
|
2003-09-19 19:40:12 +08:00
|
|
|
gimp_image_flush (gimage);
|
2003-03-18 21:49:02 +08:00
|
|
|
}
|
2002-03-19 03:34:06 +08:00
|
|
|
}
|
2002-03-17 21:52:25 +08:00
|
|
|
}
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-09-19 19:40:12 +08:00
|
|
|
static gboolean
|
2002-03-17 21:52:25 +08:00
|
|
|
gimp_colormap_hex_entry_focus_out (GtkEntry *entry,
|
|
|
|
GdkEvent *event,
|
|
|
|
GimpColormapEditor *editor)
|
|
|
|
{
|
|
|
|
gimp_colormap_hex_entry_activate (entry, editor);
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_colormap_color_notebook_callback (ColorNotebook *color_notebook,
|
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpColormapEditor *editor;
|
|
|
|
GimpImage *gimage;
|
|
|
|
|
|
|
|
editor = GIMP_COLORMAP_EDITOR (data);
|
|
|
|
gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_NOTEBOOK_OK:
|
|
|
|
gimp_image_set_colormap_entry (gimage, editor->col_index, color, TRUE);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
/* Fall through */
|
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
|
|
|
color_notebook_hide (editor->color_notebook);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_colormap_edit_clicked (GtkWidget *widget,
|
|
|
|
GimpColormapEditor *editor)
|
|
|
|
{
|
2003-12-01 20:58:03 +08:00
|
|
|
GimpImage *gimage = GIMP_IMAGE_EDITOR (editor)->gimage;
|
2003-09-19 19:40:12 +08:00
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
GimpRGB color;
|
|
|
|
|
|
|
|
gimp_rgba_set_uchar (&color,
|
|
|
|
gimage->cmap[editor->col_index * 3],
|
|
|
|
gimage->cmap[editor->col_index * 3 + 1],
|
|
|
|
gimage->cmap[editor->col_index * 3 + 2],
|
|
|
|
OPAQUE_OPACITY);
|
|
|
|
|
|
|
|
if (! editor->color_notebook)
|
|
|
|
{
|
|
|
|
GimpDialogFactory *toplevel_factory;
|
|
|
|
|
|
|
|
toplevel_factory = gimp_dialog_factory_from_name ("toplevel");
|
|
|
|
|
|
|
|
editor->color_notebook =
|
2003-11-11 01:55:44 +08:00
|
|
|
color_notebook_new (GIMP_VIEWABLE (gimage),
|
|
|
|
_("Edit Indexed Color"),
|
|
|
|
GIMP_STOCK_CONVERT_INDEXED,
|
2004-06-24 06:44:04 +08:00
|
|
|
_("Edit indexed image palette color"),
|
2003-11-11 01:55:44 +08:00
|
|
|
GTK_WIDGET (editor),
|
|
|
|
toplevel_factory,
|
|
|
|
"gimp-colormap-editor-color-dialog",
|
|
|
|
(const GimpRGB *) &color,
|
|
|
|
gimp_colormap_color_notebook_callback,
|
|
|
|
editor,
|
|
|
|
FALSE, FALSE);
|
2003-09-19 19:40:12 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
color_notebook_set_viewable (editor->color_notebook,
|
|
|
|
GIMP_VIEWABLE (gimage));
|
|
|
|
color_notebook_show (editor->color_notebook);
|
|
|
|
color_notebook_set_color (editor->color_notebook, &color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_image_mode_changed (GimpImage *gimage,
|
|
|
|
GimpColormapEditor *editor)
|
|
|
|
{
|
|
|
|
gimp_colormap_image_colormap_changed (gimage, -1, editor);
|
|
|
|
}
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
static void
|
|
|
|
gimp_colormap_image_colormap_changed (GimpImage *gimage,
|
|
|
|
gint ncol,
|
|
|
|
GimpColormapEditor *editor)
|
|
|
|
{
|
2004-02-12 20:13:21 +08:00
|
|
|
if (HAVE_COLORMAP (gimage))
|
2002-03-17 21:52:25 +08:00
|
|
|
{
|
|
|
|
if (ncol < 0)
|
|
|
|
{
|
|
|
|
gimp_colormap_editor_draw (editor);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_colormap_editor_draw_cell (editor, ncol);
|
|
|
|
}
|
2001-01-08 07:59:46 +08:00
|
|
|
|
2003-03-18 21:49:02 +08:00
|
|
|
if (editor->index_adjustment->upper !=
|
|
|
|
(gimp_image_get_colormap_size (gimage) - 1))
|
2002-03-17 21:52:25 +08:00
|
|
|
{
|
2003-03-18 21:49:02 +08:00
|
|
|
editor->index_adjustment->upper =
|
|
|
|
gimp_image_get_colormap_size (gimage) - 1;
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
gtk_adjustment_changed (editor->index_adjustment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_colormap_editor_clear (editor, -1);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|
|
|
|
|
2002-03-17 21:52:25 +08:00
|
|
|
if (ncol == editor->col_index || ncol == -1)
|
|
|
|
gimp_colormap_editor_update_entries (editor);
|
2001-01-08 07:59:46 +08:00
|
|
|
}
|