gimp/app/color_area.c

563 lines
14 KiB
C
Raw Normal View History

/* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
#include "config.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <gtk/gtk.h>
#include "apptypes.h"
1997-11-25 06:05:25 +08:00
#include "appenv.h"
#include "color_area.h"
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
#include "color_notebook.h"
#include "gdisplay.h"
1999-10-27 02:27:27 +08:00
#include "gimpcontext.h"
#include "gimpdnd.h"
allocate the tool's paint_core with g_new0. This prevents us from having 2000-06-22 Matt Wilson <msw@redhat.com> * app/paint_core.c (paint_core_new): allocate the tool's paint_core with g_new0. This prevents us from having cruft in unused tools. Systems with sensitive FPUs (Alpha) will raise exception in the paint_core_cursor_update if paint_core->last{x,y} are messy. * app/bezier_select.c (tools_new_bezier_select) * app/blend.c (blend_options_new) * app/brightness_contrast.c (tools_new_brightness_contrast) * app/bucket_fill.c (tools_new_bucket_fill) * app/by_color_select.c (tools_new_by_color_select) * app/color_balance.c (tools_new_color_balance) * app/color_panel.c (color_panel_new) * app/color_picker.c (tools_new_color_picker) * app/crop.c (tools_new_crop) * app/curves.c (tools_new_curves) * app/ellipse_select.c (tools_new_ellipse_select) * app/free_select.c (tools_new_free_select) * app/fuzzy_select.c (tools_new_fuzzy_select) * app/histogram_tool.c (tools_new_histogram_tool) * app/hue_saturation.c (tools_new_hue_saturation) * app/ink.c (tools_new_ink) * app/iscissors.c (tools_new_iscissors) * app/levels.c (tools_new_levels) * app/magnify.c (tools_new_magnify) * app/measure.c (tools_new_measure_tool) * app/move.c (tools_new_move_tool) * app/path_tool.c (tools_new_path_tool) * app/posterize.c (tools_new_posterize) * app/rect_select.c (tools_new_rect_select) * app/resize.c (resize_widget_new) * app/threshold.c (tools_new_threshold) * app/transform_core.c (transform_core_new) * app/xinput_airbrush.c (tools_new_xinput_airbrush): likewise (it can only help and it really isn't slow.) * app/color_area.c: #include <string.h> for memcpy declaration * app/gimphelp.c: #include <string.h> for strlen declaration
2000-06-23 08:14:07 +08:00
#ifdef DISPLAY_FILTERS
#include "gdisplay_color.h"
#endif /* DISPLAY_FILTERS */
1997-11-25 06:05:25 +08:00
typedef enum
{
FORE_AREA,
BACK_AREA,
SWAP_AREA,
DEF_AREA,
INVALID_AREA
} ColorAreaTarget;
/* local function prototypes */
static void color_area_drop_color (GtkWidget *widget,
GimpRGB *color,
gpointer data);
static void color_area_drag_color (GtkWidget *widget,
GimpRGB *color,
gpointer data);
static void color_area_color_changed (GimpContext *context,
GimpRGB *color,
gpointer data);
1997-11-25 06:05:25 +08:00
/* Global variables */
gint active_color = FOREGROUND;
GDisplay *color_area_gdisp = NULL;
1997-11-25 06:05:25 +08:00
/* Static variables */
static GdkGC *color_area_gc = NULL;
static GdkGC *mask_gc = NULL;
static GtkWidget *color_area = NULL;
static GdkPixmap *color_area_pixmap = NULL;
static GdkBitmap *color_area_mask = NULL;
static GdkPixmap *default_pixmap = NULL;
static GdkBitmap *default_mask = NULL;
static GdkPixmap *swap_pixmap = NULL;
static GdkBitmap *swap_mask = NULL;
static ColorNotebook *color_notebook = NULL;
static gboolean color_notebook_active = FALSE;
static gint edit_color;
static GimpRGB revert_fg;
static GimpRGB revert_bg;
/* dnd stuff */
static GtkTargetEntry color_area_target_table[] =
{
GIMP_TARGET_COLOR
};
static guint n_color_area_targets = (sizeof (color_area_target_table) /
sizeof (color_area_target_table[0]));
1997-11-25 06:05:25 +08:00
/* Local functions */
static ColorAreaTarget
color_area_target (gint x,
gint y)
1997-11-25 06:05:25 +08:00
{
gint rect_w, rect_h;
gint width, height;
1997-11-25 06:05:25 +08:00
gdk_window_get_size (color_area_pixmap, &width, &height);
rect_w = width * 0.65;
rect_h = height * 0.65;
/* foreground active */
if (x > 0 && x < rect_w &&
y > 0 && y < rect_h)
return FORE_AREA;
else if (x > (width - rect_w) && x < width &&
y > (height - rect_h) && y < height)
return BACK_AREA;
else if (x > 0 && x < (width - rect_w) &&
y > rect_h && y < height)
return DEF_AREA;
else if (x > rect_w && x < width &&
y > 0 && y < (height - rect_h))
return SWAP_AREA;
else
return -1;
}
void
color_area_draw_rect (GdkDrawable *drawable,
GdkGC *gc,
gint x,
gint y,
gint width,
gint height,
guchar r,
guchar g,
guchar b)
{
static guchar *color_area_rgb_buf = NULL;
static gint color_area_rgb_buf_size;
static gint rowstride;
gint xx, yy;
guchar *bp;
#ifdef DISPLAY_FILTERS
GList *list;
#endif /* DISPLAY_FILTERS */
rowstride = 3 * ((width + 3) & -4);
if (color_area_rgb_buf == NULL ||
color_area_rgb_buf_size < height * rowstride)
{
if (color_area_rgb_buf)
g_free (color_area_rgb_buf);
color_area_rgb_buf = g_malloc (color_area_rgb_buf_size = rowstride * height);
}
bp = color_area_rgb_buf;
for (xx = 0; xx < width; xx++)
{
*bp++ = r;
*bp++ = g;
*bp++ = b;
}
bp = color_area_rgb_buf;
#ifdef DISPLAY_FILTERS
for (list = color_area_gdisp->cd_list; list; list = g_list_next (list))
{
ColorDisplayNode *node = (ColorDisplayNode *) list->data;
node->cd_convert (node->cd_ID, bp, width, 1, 3, rowstride);
}
#endif /* DISPLAY_FILTERS */
for (yy = 1; yy < height; yy++)
{
bp += rowstride;
memcpy (bp, color_area_rgb_buf, rowstride);
}
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
color_area_draw (void)
{
gint rect_w, rect_h;
gint width, height;
gint def_width, def_height;
gint swap_width, swap_height;
GimpRGB color;
guchar r, g, b;
GdkColor mask_pattern;
1997-11-25 06:05:25 +08:00
1998-08-13 23:25:41 +08:00
/* Check we haven't gotten initial expose yet,
* no point in drawing anything
*/
1998-08-13 23:25:41 +08:00
if (!color_area_pixmap || !color_area_gc)
return;
1997-11-25 06:05:25 +08:00
gdk_window_get_size (color_area_pixmap, &width, &height);
rect_w = width * 0.65;
rect_h = height * 0.65;
/* initialize the mask to transparent */
mask_pattern.pixel = 0;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE, 0, 0, -1, -1);
/* set the mask's gc to opaque */
mask_pattern.pixel = 1;
gdk_gc_set_foreground (mask_gc, &mask_pattern);
1997-11-25 06:05:25 +08:00
/* draw the background area */
gimp_context_get_background (gimp_context_get_user (), &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc,
(width - rect_w), (height - rect_h), rect_w, rect_h,
r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
(width - rect_w), (height - rect_h), rect_w, rect_h);
1997-11-25 06:05:25 +08:00
if (active_color == FOREGROUND)
1999-10-27 02:27:27 +08:00
gtk_draw_shadow (color_area->style, color_area_pixmap,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
1997-11-25 06:05:25 +08:00
(width - rect_w), (height - rect_h), rect_w, rect_h);
else
1999-10-27 02:27:27 +08:00
gtk_draw_shadow (color_area->style, color_area_pixmap,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
1997-11-25 06:05:25 +08:00
(width - rect_w), (height - rect_h), rect_w, rect_h);
/* draw the foreground area */
gimp_context_get_foreground (gimp_context_get_user (), &color);
gimp_rgb_get_uchar (&color, &r, &g, &b);
color_area_draw_rect (color_area_pixmap, color_area_gc,
0, 0, rect_w, rect_h,
r, g, b);
gdk_draw_rectangle (color_area_mask, mask_gc, TRUE,
0, 0, rect_w, rect_h);
1997-11-25 06:05:25 +08:00
if (active_color == FOREGROUND)
1999-10-27 02:27:27 +08:00
gtk_draw_shadow (color_area->style, color_area_pixmap,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
1997-11-25 06:05:25 +08:00
0, 0, rect_w, rect_h);
else
1999-10-27 02:27:27 +08:00
gtk_draw_shadow (color_area->style, color_area_pixmap,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
1997-11-25 06:05:25 +08:00
0, 0, rect_w, rect_h);
/* draw the default pixmap */
1997-11-25 06:05:25 +08:00
gdk_window_get_size (default_pixmap, &def_width, &def_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, default_pixmap,
0, 0, 0, height - def_height, def_width, def_height);
gdk_draw_pixmap (color_area_mask, mask_gc, default_mask,
0, 0, 0, height - def_height, def_width, def_height);
1997-11-25 06:05:25 +08:00
/* draw the swap pixmap */
1997-11-25 06:05:25 +08:00
gdk_window_get_size (swap_pixmap, &swap_width, &swap_height);
gdk_draw_pixmap (color_area_pixmap, color_area_gc, swap_pixmap,
0, 0, width - swap_width, 0, swap_width, swap_height);
gdk_draw_pixmap (color_area_mask, mask_gc, swap_mask,
0, 0, width - swap_width, 0, swap_width, swap_height);
1997-11-25 06:05:25 +08:00
/* draw the widget */
gdk_gc_set_clip_mask (color_area_gc, color_area_mask);
gdk_gc_set_clip_origin (color_area_gc, 0, 0);
1997-11-25 06:05:25 +08:00
gdk_draw_pixmap (color_area->window, color_area_gc, color_area_pixmap,
0, 0, 0, 0, width, height);
/* reset the clip mask */
gdk_gc_set_clip_mask (color_area_gc, NULL);
1997-11-25 06:05:25 +08:00
}
static void
color_area_select_callback (GimpRGB *color,
ColorNotebookState state,
gpointer client_data)
1997-11-25 06:05:25 +08:00
{
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
{
switch (state)
{
case COLOR_NOTEBOOK_OK:
color_notebook_hide (color_notebook);
color_notebook_active = FALSE;
/* Fallthrough */
case COLOR_NOTEBOOK_UPDATE:
if (edit_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), color);
else
gimp_context_set_background (gimp_context_get_user (), color);
break;
case COLOR_NOTEBOOK_CANCEL:
color_notebook_hide (color_notebook);
color_notebook_active = FALSE;
gimp_context_set_foreground (gimp_context_get_user (), &revert_fg);
gimp_context_set_background (gimp_context_get_user (), &revert_bg);
}
1997-11-25 06:05:25 +08:00
}
}
static void
color_area_edit (void)
{
1999-10-27 02:27:27 +08:00
GimpContext *user_context;
GimpRGB color;
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
user_context = gimp_context_get_user ();
if (! color_notebook_active)
1997-11-25 06:05:25 +08:00
{
gimp_context_get_foreground (user_context, &revert_fg);
gimp_context_get_background (user_context, &revert_bg);
1997-11-25 06:05:25 +08:00
}
1997-11-25 06:05:25 +08:00
if (active_color == FOREGROUND)
gimp_context_get_foreground (user_context, &color);
1997-11-25 06:05:25 +08:00
else
gimp_context_get_background (user_context, &color);
1999-10-27 02:27:27 +08:00
edit_color = active_color;
1997-11-25 06:05:25 +08:00
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
{
color_notebook = color_notebook_new (&color,
color_area_select_callback,
NULL, TRUE, FALSE);
color_notebook_active = TRUE;
1997-11-25 06:05:25 +08:00
}
else
{
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)
{
color_notebook_show (color_notebook);
color_notebook_active = TRUE;
}
else
{
color_notebook_show (color_notebook);
}
color_notebook_set_color (color_notebook, &color);
1997-11-25 06:05:25 +08:00
}
}
static gint
color_area_events (GtkWidget *widget,
GdkEvent *event)
{
GdkEventButton *bevent;
ColorAreaTarget target;
static ColorAreaTarget press_target = INVALID_AREA;
1997-11-25 06:05:25 +08:00
switch (event->type)
{
case GDK_CONFIGURE:
if (color_area_pixmap)
{
gdk_pixmap_unref (color_area_pixmap);
gdk_bitmap_unref (color_area_mask);
}
color_area_pixmap = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height, -1);
color_area_mask = gdk_pixmap_new (widget->window,
widget->allocation.width,
widget->allocation.height, 1);
break;
1997-11-25 06:05:25 +08:00
case GDK_EXPOSE:
if (GTK_WIDGET_DRAWABLE (widget))
{
if (!color_area_gc)
{
color_area_gc = gdk_gc_new (widget->window);
mask_gc = gdk_gc_new (color_area_mask);
}
color_area_draw ();
}
1997-11-25 06:05:25 +08:00
break;
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
if (bevent->button == 1)
{
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;
color_area_draw ();
}
else
{
press_target = target;
}
break;
case SWAP_AREA:
1999-10-27 02:27:27 +08:00
gimp_context_swap_colors (gimp_context_get_user ());
break;
case DEF_AREA:
1999-10-27 02:27:27 +08:00
gimp_context_set_default_colors (gimp_context_get_user ());
break;
default:
break;
}
}
break;
case GDK_BUTTON_RELEASE:
bevent = (GdkEventButton *) event;
1997-11-25 06:05:25 +08:00
if (bevent->button == 1)
{
target = color_area_target (bevent->x, bevent->y);
if (target == press_target)
1997-11-25 06:05:25 +08:00
{
switch (target)
1997-11-25 06:05:25 +08:00
{
case FORE_AREA:
case BACK_AREA:
color_area_edit ();
break;
default:
break;
1997-11-25 06:05:25 +08:00
}
}
press_target = INVALID_AREA;
1997-11-25 06:05:25 +08:00
}
break;
case GDK_LEAVE_NOTIFY:
press_target = INVALID_AREA;
break;
1997-11-25 06:05:25 +08:00
default:
break;
}
return FALSE;
}
static void
color_area_realize (GtkWidget *widget,
gpointer data)
{
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
}
1997-11-25 06:05:25 +08:00
GtkWidget *
color_area_create (gint width,
gint height,
1997-11-25 06:05:25 +08:00
GdkPixmap *default_pmap,
GdkBitmap *default_msk,
GdkPixmap *swap_pmap,
GdkBitmap *swap_msk)
1997-11-25 06:05:25 +08:00
{
color_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA (color_area), width, height);
gtk_widget_set_events (color_area,
GDK_EXPOSURE_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
1997-11-25 06:05:25 +08:00
gtk_signal_connect (GTK_OBJECT (color_area), "event",
GTK_SIGNAL_FUNC (color_area_events),
1997-11-25 06:05:25 +08:00
NULL);
gtk_signal_connect (GTK_OBJECT (color_area), "realize",
GTK_SIGNAL_FUNC (color_area_realize),
NULL);
1997-11-25 06:05:25 +08:00
default_pixmap = default_pmap;
default_mask = default_msk;
1997-11-25 06:05:25 +08:00
swap_pixmap = swap_pmap;
swap_mask = swap_msk;
1997-11-25 06:05:25 +08:00
/* dnd stuff */
gtk_drag_source_set (color_area,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gimp_dnd_color_source_set (color_area, color_area_drag_color, NULL);
gtk_drag_dest_set (color_area,
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
color_area_target_table, n_color_area_targets,
GDK_ACTION_COPY);
gimp_dnd_color_dest_set (color_area, color_area_drop_color, NULL);
1999-10-27 02:27:27 +08:00
gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()),
"foreground_changed",
GTK_SIGNAL_FUNC (color_area_color_changed),
color_area);
gtk_signal_connect (GTK_OBJECT (gimp_context_get_user ()),
"background_changed",
GTK_SIGNAL_FUNC (color_area_color_changed),
color_area);
1997-11-25 06:05:25 +08:00
#ifdef DISPLAY_FILTERS
/* display filter dummy gdisplay */
color_area_gdisp = g_new (GDisplay, 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 */
1999-10-27 02:27:27 +08:00
return color_area;
1997-11-25 06:05:25 +08:00
}
static void
color_area_drag_color (GtkWidget *widget,
GimpRGB *color,
gpointer data)
{
if (active_color == FOREGROUND)
gimp_context_get_foreground (gimp_context_get_user (), color);
else
gimp_context_get_background (gimp_context_get_user (), color);
}
static void
color_area_drop_color (GtkWidget *widget,
GimpRGB *color,
gpointer data)
{
if (color_notebook_active &&
active_color == edit_color)
{
color_notebook_set_color (color_notebook, color);
}
else
{
if (active_color == FOREGROUND)
gimp_context_set_foreground (gimp_context_get_user (), color);
else
gimp_context_set_background (gimp_context_get_user (), color);
}
}
1999-10-27 02:27:27 +08:00
static void
color_area_color_changed (GimpContext *context,
GimpRGB *color,
1999-10-27 02:27:27 +08:00
gpointer data)
{
color_area_draw ();
}