1998-03-09 09:45:26 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-02-22 23:14:54 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-07-23 06:18:01 +08:00
|
|
|
#include <string.h> /* memcpy */
|
2001-01-16 22:47:09 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2002-06-08 20:15:11 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-03-15 01:07:02 +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-03 20:45:22 +08:00
|
|
|
#warning FIXME #include "gui/gui-types.h"
|
2002-05-11 07:30:09 +08:00
|
|
|
#endif
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "gui/gui-types.h"
|
|
|
|
|
2001-07-07 20:17:23 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gimpdnd.h"
|
|
|
|
#include "gimptoolbox.h"
|
|
|
|
#include "gimptoolbox-color-area.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
|
2002-03-15 01:07:02 +08:00
|
|
|
#include "gui/color-notebook.h"
|
2001-07-07 20:17:23 +08:00
|
|
|
|
2000-12-25 04:27:04 +08:00
|
|
|
#ifdef DISPLAY_FILTERS
|
|
|
|
#include "gdisplay_color.h"
|
|
|
|
#endif /* DISPLAY_FILTERS */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
FORE_AREA,
|
|
|
|
BACK_AREA,
|
|
|
|
SWAP_AREA,
|
2002-06-08 20:15:11 +08:00
|
|
|
DEFAULT_AREA,
|
1999-08-22 19:45:31 +08:00
|
|
|
INVALID_AREA
|
|
|
|
} ColorAreaTarget;
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
/* local function prototypes */
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
static ColorAreaTarget color_area_target (gint x,
|
|
|
|
gint y);
|
2002-06-08 20:15:11 +08:00
|
|
|
static void color_area_draw_rect (GdkDrawable *drawable,
|
2001-10-29 19:47:11 +08:00
|
|
|
GdkGC *gc,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
guchar r,
|
|
|
|
guchar g,
|
|
|
|
guchar b);
|
2002-06-08 20:15:11 +08:00
|
|
|
static void color_area_draw (GimpContext *context);
|
|
|
|
static void color_area_select_callback (ColorNotebook *color_notebook,
|
2001-10-29 19:47:11 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data);
|
2002-06-08 20:15:11 +08:00
|
|
|
static void color_area_edit (GimpContext *context);
|
|
|
|
static void color_area_drop_color (GtkWidget *widget,
|
2001-10-29 19:47:11 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data);
|
2002-06-08 20:15:11 +08:00
|
|
|
static void color_area_drag_color (GtkWidget *widget,
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpRGB *color,
|
|
|
|
gpointer data);
|
2002-06-08 20:15:11 +08:00
|
|
|
static gboolean color_area_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
2001-10-29 19:47:11 +08:00
|
|
|
gpointer data);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Global variables */
|
2001-10-29 19:47:11 +08:00
|
|
|
gint active_color = FOREGROUND;
|
|
|
|
GimpDisplay *color_area_gdisp = NULL;
|
2000-01-02 08:16:47 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Static variables */
|
2002-06-08 20:15:11 +08:00
|
|
|
static GtkWidget *color_area = NULL;
|
2000-02-22 23:14:54 +08:00
|
|
|
static ColorNotebook *color_notebook = NULL;
|
2000-02-14 07:42:19 +08:00
|
|
|
static gboolean color_notebook_active = FALSE;
|
|
|
|
static gint edit_color;
|
2001-01-15 09:48:53 +08:00
|
|
|
static GimpRGB revert_fg;
|
|
|
|
static GimpRGB revert_bg;
|
1999-08-22 19:45:31 +08:00
|
|
|
|
1999-08-23 22:19:26 +08:00
|
|
|
/* dnd stuff */
|
1999-08-22 19:45:31 +08:00
|
|
|
static GtkTargetEntry color_area_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_COLOR
|
|
|
|
};
|
2001-10-20 00:41:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GtkWidget *
|
2002-03-15 01:07:02 +08:00
|
|
|
gimp_toolbox_color_area_create (GimpToolbox *toolbox,
|
|
|
|
gint width,
|
2002-06-08 20:15:11 +08:00
|
|
|
gint height)
|
2001-10-29 19:47:11 +08:00
|
|
|
{
|
2002-03-15 01:07:02 +08:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_TOOLBOX (toolbox), NULL);
|
|
|
|
|
|
|
|
context = GIMP_DOCK (toolbox)->context;
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
color_area = gtk_drawing_area_new ();
|
2001-12-29 21:26:29 +08:00
|
|
|
gtk_widget_set_size_request (color_area, width, height);
|
2001-10-29 19:47:11 +08:00
|
|
|
gtk_widget_set_events (color_area,
|
|
|
|
GDK_EXPOSURE_MASK |
|
|
|
|
GDK_BUTTON_PRESS_MASK |
|
|
|
|
GDK_BUTTON_RELEASE_MASK |
|
2002-06-08 20:15:11 +08:00
|
|
|
GDK_ENTER_NOTIFY_MASK |
|
2001-10-29 19:47:11 +08:00
|
|
|
GDK_LEAVE_NOTIFY_MASK);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (color_area, "event",
|
2001-10-29 19:47:11 +08:00
|
|
|
G_CALLBACK (color_area_events),
|
|
|
|
context);
|
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
gtk_drag_source_set (color_area,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
|
|
|
color_area_target_table,
|
|
|
|
G_N_ELEMENTS (color_area_target_table),
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
|
|
gimp_dnd_color_source_set (color_area, color_area_drag_color, context);
|
|
|
|
|
2002-09-02 22:39:08 +08:00
|
|
|
gimp_dnd_color_dest_add (color_area, color_area_drop_color, context);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (context, "foreground_changed",
|
2002-06-08 20:15:11 +08:00
|
|
|
G_CALLBACK (gtk_widget_queue_draw),
|
|
|
|
color_area);
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_swapped (context, "background_changed",
|
2002-06-08 20:15:11 +08:00
|
|
|
G_CALLBACK (gtk_widget_queue_draw),
|
|
|
|
color_area);
|
2001-10-29 19:47:11 +08:00
|
|
|
|
|
|
|
#ifdef DISPLAY_FILTERS
|
|
|
|
/* display filter dummy gdisplay */
|
|
|
|
color_area_gdisp = g_new (GimpDisplay, 1);
|
|
|
|
color_area_gdisp->cd_list = NULL;
|
|
|
|
color_area_gdisp->cd_ui = NULL;
|
|
|
|
color_area_gdisp->gimage = g_new (GimpImage, 1);
|
|
|
|
color_area_gdisp->gimage->base_type = RGB;
|
|
|
|
#endif /* DISPLAY_FILTERS */
|
|
|
|
|
|
|
|
return color_area;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
static ColorAreaTarget
|
|
|
|
color_area_target (gint x,
|
|
|
|
gint y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
gint rect_w, rect_h;
|
|
|
|
gint width, height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
width = color_area->allocation.width;
|
|
|
|
height = color_area->allocation.height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
rect_w = (width * 2) / 3;
|
|
|
|
rect_h = (height * 2) / 3;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* foreground active */
|
2002-06-08 20:15:11 +08:00
|
|
|
if (x > 0 && x < rect_w && y > 0 && y < rect_h)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FORE_AREA;
|
2002-06-08 20:15:11 +08:00
|
|
|
else if (x > (width - rect_w) && x < width &&
|
1997-11-25 06:05:25 +08:00
|
|
|
y > (height - rect_h) && y < height)
|
|
|
|
return BACK_AREA;
|
2002-06-08 20:15:11 +08:00
|
|
|
else if (x > 0 && x < (width - rect_w) &&
|
1997-11-25 06:05:25 +08:00
|
|
|
y > rect_h && y < height)
|
2002-06-08 20:15:11 +08:00
|
|
|
return DEFAULT_AREA;
|
1997-11-25 06:05:25 +08:00
|
|
|
else if (x > rect_w && x < width &&
|
2002-06-08 20:15:11 +08:00
|
|
|
y > 0 && y < (height - rect_h))
|
1997-11-25 06:05:25 +08:00
|
|
|
return SWAP_AREA;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
static void
|
1998-09-01 06:22:23 +08:00
|
|
|
color_area_draw_rect (GdkDrawable *drawable,
|
2002-06-08 20:15:11 +08:00
|
|
|
GdkGC *gc,
|
1999-08-22 19:45:31 +08:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
guchar r,
|
|
|
|
guchar g,
|
|
|
|
guchar b)
|
1998-09-01 06:22:23 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
static guchar *color_area_rgb_buf = NULL;
|
2000-02-22 23:14:54 +08:00
|
|
|
static gint color_area_rgb_buf_size;
|
|
|
|
static gint rowstride;
|
|
|
|
gint xx, yy;
|
1999-08-22 19:45:31 +08:00
|
|
|
guchar *bp;
|
2000-12-25 04:27:04 +08:00
|
|
|
#ifdef DISPLAY_FILTERS
|
2000-02-22 23:14:54 +08:00
|
|
|
GList *list;
|
2000-12-25 04:27:04 +08:00
|
|
|
#endif /* DISPLAY_FILTERS */
|
1998-09-01 06:22:23 +08:00
|
|
|
|
|
|
|
rowstride = 3 * ((width + 3) & -4);
|
2000-01-02 08:16:47 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
if (!color_area_rgb_buf || color_area_rgb_buf_size < height * rowstride)
|
1998-09-01 06:22:23 +08:00
|
|
|
{
|
2002-06-08 20:15:11 +08:00
|
|
|
color_area_rgb_buf_size = rowstride * height;
|
2001-07-28 00:08:05 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
g_free (color_area_rgb_buf);
|
|
|
|
color_area_rgb_buf = g_malloc (color_area_rgb_buf_size);
|
1998-09-01 06:22:23 +08:00
|
|
|
}
|
2000-01-02 08:16:47 +08:00
|
|
|
|
1998-09-01 06:22:23 +08:00
|
|
|
bp = color_area_rgb_buf;
|
|
|
|
for (xx = 0; xx < width; xx++)
|
|
|
|
{
|
|
|
|
*bp++ = r;
|
|
|
|
*bp++ = g;
|
|
|
|
*bp++ = b;
|
|
|
|
}
|
2000-01-02 08:16:47 +08:00
|
|
|
|
1998-09-01 06:22:23 +08:00
|
|
|
bp = color_area_rgb_buf;
|
2000-01-02 08:16:47 +08:00
|
|
|
|
2000-12-25 04:27:04 +08:00
|
|
|
#ifdef DISPLAY_FILTERS
|
2000-02-22 23:14:54 +08:00
|
|
|
for (list = color_area_gdisp->cd_list; list; list = g_list_next (list))
|
2000-01-02 08:16:47 +08:00
|
|
|
{
|
|
|
|
ColorDisplayNode *node = (ColorDisplayNode *) list->data;
|
2000-02-22 23:14:54 +08:00
|
|
|
|
2000-01-02 08:16:47 +08:00
|
|
|
node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride);
|
|
|
|
}
|
2000-12-25 04:27:04 +08:00
|
|
|
#endif /* DISPLAY_FILTERS */
|
2000-01-02 08:16:47 +08:00
|
|
|
|
1998-09-01 06:22:23 +08:00
|
|
|
for (yy = 1; yy < height; yy++)
|
|
|
|
{
|
|
|
|
bp += rowstride;
|
|
|
|
memcpy (bp, color_area_rgb_buf, rowstride);
|
|
|
|
}
|
2000-01-02 08:16:47 +08:00
|
|
|
|
1998-09-01 06:22:23 +08:00
|
|
|
gdk_draw_rgb_image (drawable, gc, x, y, width, height,
|
|
|
|
GDK_RGB_DITHER_MAX,
|
|
|
|
color_area_rgb_buf,
|
|
|
|
rowstride);
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-10-29 19:47:11 +08:00
|
|
|
color_area_draw (GimpContext *context)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-06-08 20:15:11 +08:00
|
|
|
gint rect_w, rect_h;
|
|
|
|
gint width, height;
|
|
|
|
gint w, h;
|
|
|
|
GimpRGB color;
|
|
|
|
guchar r, g, b;
|
|
|
|
GdkPixbuf *pixbuf;
|
|
|
|
|
|
|
|
if (!GTK_WIDGET_DRAWABLE (color_area))
|
1997-12-18 14:30:11 +08:00
|
|
|
return;
|
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
width = color_area->allocation.width;
|
|
|
|
height = color_area->allocation.height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
rect_w = (width * 2) / 3;
|
|
|
|
rect_h = (height * 2) / 3;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-22 23:14:54 +08:00
|
|
|
/* draw the background area */
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_background (context, &color);
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
2002-06-08 20:15:11 +08:00
|
|
|
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
1998-09-01 06:22:23 +08:00
|
|
|
(width - rect_w), (height - rect_h), rect_w, rect_h,
|
|
|
|
r, g, b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (active_color == FOREGROUND)
|
2002-06-08 20:15:11 +08:00
|
|
|
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
2001-12-29 21:26:29 +08:00
|
|
|
GTK_SHADOW_OUT,
|
|
|
|
NULL, color_area, NULL,
|
|
|
|
(width - rect_w), (height - rect_h),
|
|
|
|
rect_w, rect_h);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2002-06-08 20:15:11 +08:00
|
|
|
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
2001-12-29 21:26:29 +08:00
|
|
|
GTK_SHADOW_IN,
|
|
|
|
NULL, color_area, NULL,
|
|
|
|
(width - rect_w), (height - rect_h),
|
|
|
|
rect_w, rect_h);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-22 23:14:54 +08:00
|
|
|
/* draw the foreground area */
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_foreground (context, &color);
|
2001-01-15 09:48:53 +08:00
|
|
|
gimp_rgb_get_uchar (&color, &r, &g, &b);
|
2002-06-08 20:15:11 +08:00
|
|
|
color_area_draw_rect (color_area->window, color_area->style->fg_gc[0],
|
|
|
|
0, 0, rect_w, rect_h,
|
1998-09-01 06:22:23 +08:00
|
|
|
r, g, b);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (active_color == FOREGROUND)
|
2002-06-08 20:15:11 +08:00
|
|
|
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
2001-12-29 21:26:29 +08:00
|
|
|
GTK_SHADOW_IN,
|
|
|
|
NULL, color_area, NULL,
|
|
|
|
0, 0,
|
|
|
|
rect_w, rect_h);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2002-06-08 20:15:11 +08:00
|
|
|
gtk_paint_shadow (color_area->style, color_area->window, GTK_STATE_NORMAL,
|
2001-12-29 21:26:29 +08:00
|
|
|
GTK_SHADOW_OUT,
|
|
|
|
NULL, color_area, NULL,
|
|
|
|
0, 0,
|
|
|
|
rect_w, rect_h);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-08 20:15:11 +08:00
|
|
|
/* draw the default colors pixbuf */
|
|
|
|
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_DEFAULT_COLORS,
|
2002-06-09 23:29:43 +08:00
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
2002-06-08 20:15:11 +08:00
|
|
|
w = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
h = gdk_pixbuf_get_height (pixbuf);
|
2003-02-22 09:33:42 +08:00
|
|
|
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
|
|
|
0, 0, 0, height - h, w, h,
|
|
|
|
GDK_RGB_DITHER_MAX, 0, 0);
|
2002-06-08 20:15:11 +08:00
|
|
|
g_object_unref (pixbuf);
|
|
|
|
|
|
|
|
/* draw the swap colors pixbuf */
|
|
|
|
pixbuf = gtk_widget_render_icon (color_area, GIMP_STOCK_SWAP_COLORS,
|
2002-06-09 23:29:43 +08:00
|
|
|
GTK_ICON_SIZE_MENU, NULL);
|
2002-06-08 20:15:11 +08:00
|
|
|
w = gdk_pixbuf_get_width (pixbuf);
|
|
|
|
h = gdk_pixbuf_get_height (pixbuf);
|
2003-02-22 09:33:42 +08:00
|
|
|
gdk_draw_pixbuf (color_area->window, NULL, pixbuf,
|
|
|
|
0, 0, width - w, 0, w, h,
|
|
|
|
GDK_RGB_DITHER_MAX, 0, 0);
|
2002-06-08 20:15:11 +08:00
|
|
|
g_object_unref (pixbuf);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-21 21:41:07 +08:00
|
|
|
color_area_select_callback (ColorNotebook *color_notebook,
|
|
|
|
const GimpRGB *color,
|
1999-08-22 19:45:31 +08:00
|
|
|
ColorNotebookState state,
|
2001-10-29 19:47:11 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (data);
|
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
if (color_notebook)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_OK:
|
|
|
|
color_notebook_hide (color_notebook);
|
|
|
|
color_notebook_active = FALSE;
|
|
|
|
/* Fallthrough */
|
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
|
|
|
if (edit_color == FOREGROUND)
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_foreground (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
else
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_background (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
break;
|
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
|
|
|
color_notebook_hide (color_notebook);
|
|
|
|
color_notebook_active = FALSE;
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_foreground (context, &revert_fg);
|
|
|
|
gimp_context_set_background (context, &revert_bg);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-10-29 19:47:11 +08:00
|
|
|
color_area_edit (GimpContext *context)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpRGB color;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-01-15 09:48:53 +08:00
|
|
|
if (! color_notebook_active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_foreground (context, &revert_fg);
|
|
|
|
gimp_context_get_background (context, &revert_bg);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-08-23 22:19:26 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (active_color == FOREGROUND)
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_foreground (context, &color);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_background (context, &color);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1999-08-23 22:19:26 +08:00
|
|
|
edit_color = active_color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-09-08 17:26:45 +08:00
|
|
|
#define FG_TITLE _("Change Foreground Color")
|
|
|
|
#define BG_TITLE _("Change Background Color")
|
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
if (! color_notebook)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-09-08 17:26:45 +08:00
|
|
|
color_notebook = color_notebook_new (active_color == FOREGROUND ?
|
|
|
|
FG_TITLE : BG_TITLE,
|
2001-01-21 21:41:07 +08:00
|
|
|
(const GimpRGB *) &color,
|
2001-01-08 05:07:14 +08:00
|
|
|
color_area_select_callback,
|
2001-10-29 19:47:11 +08:00
|
|
|
context, TRUE, FALSE);
|
1999-08-22 19:45:31 +08:00
|
|
|
color_notebook_active = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-08 17:26:45 +08:00
|
|
|
color_notebook_set_title (color_notebook,
|
|
|
|
active_color == FOREGROUND ?
|
|
|
|
FG_TITLE : BG_TITLE);
|
|
|
|
color_notebook_set_color (color_notebook, &color);
|
|
|
|
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
if (! color_notebook_active)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
|
|
|
color_notebook_show (color_notebook);
|
|
|
|
color_notebook_active = TRUE;
|
|
|
|
}
|
2001-01-09 09:23:54 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
color_notebook_show (color_notebook);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2002-09-08 17:26:45 +08:00
|
|
|
|
|
|
|
#undef FG_TITLE
|
|
|
|
#undef BG_TITLE
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
color_area_events (GtkWidget *widget,
|
2001-10-29 19:47:11 +08:00
|
|
|
GdkEvent *event,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpContext *context;
|
1999-08-22 19:45:31 +08:00
|
|
|
GdkEventButton *bevent;
|
|
|
|
ColorAreaTarget target;
|
|
|
|
|
|
|
|
static ColorAreaTarget press_target = INVALID_AREA;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-10-29 19:47:11 +08:00
|
|
|
context = GIMP_CONTEXT (data);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case GDK_EXPOSE:
|
2002-06-08 20:15:11 +08:00
|
|
|
color_area_draw (context);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
if (bevent->button == 1)
|
1999-08-23 22:19:26 +08:00
|
|
|
{
|
|
|
|
target = color_area_target (bevent->x, bevent->y);
|
|
|
|
press_target = INVALID_AREA;
|
|
|
|
|
|
|
|
switch (target)
|
|
|
|
{
|
|
|
|
case FORE_AREA:
|
|
|
|
case BACK_AREA:
|
|
|
|
if (target != active_color)
|
|
|
|
{
|
|
|
|
active_color = target;
|
2001-10-29 19:47:11 +08:00
|
|
|
color_area_draw (context);
|
1999-08-23 22:19:26 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
press_target = target;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SWAP_AREA:
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_swap_colors (context);
|
1999-08-23 22:19:26 +08:00
|
|
|
break;
|
2002-06-08 20:15:11 +08:00
|
|
|
case DEFAULT_AREA:
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_default_colors (context);
|
1999-08-23 22:19:26 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GDK_BUTTON_RELEASE:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (bevent->button == 1)
|
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
target = color_area_target (bevent->x, bevent->y);
|
|
|
|
|
|
|
|
if (target == press_target)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
switch (target)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
case FORE_AREA:
|
|
|
|
case BACK_AREA:
|
2001-10-29 19:47:11 +08:00
|
|
|
color_area_edit (context);
|
1999-08-22 19:45:31 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
press_target = INVALID_AREA;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
case GDK_LEAVE_NOTIFY:
|
|
|
|
press_target = INVALID_AREA;
|
|
|
|
break;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
static void
|
1999-08-24 08:36:57 +08:00
|
|
|
color_area_drag_color (GtkWidget *widget,
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB *color,
|
1999-08-24 08:36:57 +08:00
|
|
|
gpointer data)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (data);
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
if (active_color == FOREGROUND)
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_foreground (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
else
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_get_background (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-20 23:37:26 +08:00
|
|
|
color_area_drop_color (GtkWidget *widget,
|
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2001-10-29 19:47:11 +08:00
|
|
|
GimpContext *context;
|
|
|
|
|
|
|
|
context = GIMP_CONTEXT (data);
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
if (color_notebook_active &&
|
|
|
|
active_color == edit_color)
|
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
color_notebook_set_color (color_notebook, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (active_color == FOREGROUND)
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_foreground (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
else
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_context_set_background (context, color);
|
1999-08-22 19:45:31 +08:00
|
|
|
}
|
|
|
|
}
|