1997-11-25 06:05:25 +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
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
*/
# include <stdlib.h>
# include <stdio.h>
# include "appenv.h"
1998-01-29 11:13:44 +08:00
# include "actionarea.h"
1997-11-25 06:05:25 +08:00
# include "color_picker.h"
# include "drawable.h"
# include "gdisplay.h"
# include "info_dialog.h"
# include "palette.h"
# include "tools.h"
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
# include "libgimp/gimpintl.h"
1999-04-09 06:25:54 +08:00
/* maximum information buffer size */
1998-03-13 16:57:18 +08:00
# define MAX_INFO_BUF 8
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* the color picker structures */
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
typedef struct _ColorPickerOptions ColorPickerOptions ;
struct _ColorPickerOptions
{
int sample_merged ;
int sample_merged_d ;
GtkWidget * sample_merged_w ;
} ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* the color picker tool options */
static ColorPickerOptions * color_picker_options = NULL ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* the color picker dialog */
1997-11-25 06:05:25 +08:00
static int col_value [ 5 ] = { 0 , 0 , 0 , 0 , 0 } ;
1998-01-22 15:02:57 +08:00
static GimpDrawable * active_drawable ;
1997-11-25 06:05:25 +08:00
static int update_type ;
static int sample_type ;
static InfoDialog * color_picker_info = NULL ;
static char red_buf [ MAX_INFO_BUF ] ;
static char green_buf [ MAX_INFO_BUF ] ;
static char blue_buf [ MAX_INFO_BUF ] ;
static char alpha_buf [ MAX_INFO_BUF ] ;
static char index_buf [ MAX_INFO_BUF ] ;
static char gray_buf [ MAX_INFO_BUF ] ;
1998-03-13 16:53:33 +08:00
static char hex_buf [ MAX_INFO_BUF ] ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* local function prototypes */
static void color_picker_button_press ( Tool * , GdkEventButton * , gpointer ) ;
static void color_picker_button_release ( Tool * , GdkEventButton * , gpointer ) ;
static void color_picker_motion ( Tool * , GdkEventMotion * , gpointer ) ;
static void color_picker_cursor_update ( Tool * , GdkEventMotion * , gpointer ) ;
static void color_picker_control ( Tool * , int , void * ) ;
static void color_picker_info_window_close_callback ( GtkWidget * , gpointer ) ;
static int get_color ( GImage * , GimpDrawable * , int , int , int , int ) ;
static void color_picker_info_update ( Tool * , int ) ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
static Argument * color_picker_invoker ( Argument * ) ;
/* functions */
1997-11-25 06:05:25 +08:00
static void
color_picker_toggle_update ( GtkWidget * w ,
gpointer data )
{
int * toggle_val ;
toggle_val = ( int * ) data ;
if ( GTK_TOGGLE_BUTTON ( w ) - > active )
* toggle_val = TRUE ;
else
* toggle_val = FALSE ;
}
1999-04-09 06:25:54 +08:00
static void
reset_color_picker_options ( void )
{
ColorPickerOptions * options = color_picker_options ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > sample_merged_w ) ,
options - > sample_merged_d ) ;
}
1997-11-25 06:05:25 +08:00
static ColorPickerOptions *
create_color_picker_options ( void )
{
ColorPickerOptions * options ;
1999-04-09 06:25:54 +08:00
GtkWidget * vbox ;
1997-11-25 06:05:25 +08:00
/* the new options structure */
options = ( ColorPickerOptions * ) g_malloc ( sizeof ( ColorPickerOptions ) ) ;
1999-04-09 06:25:54 +08:00
options - > sample_merged = options - > sample_merged_d = FALSE ;
1997-11-25 06:05:25 +08:00
/* the main vbox */
vbox = gtk_vbox_new ( FALSE , 1 ) ;
/* the sample merged toggle button */
1999-04-09 06:25:54 +08:00
options - > sample_merged_w =
gtk_check_button_new_with_label ( _ ( " Sample Merged " ) ) ;
gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( options - > sample_merged_w ) ,
options - > sample_merged_d ) ;
gtk_box_pack_start ( GTK_BOX ( vbox ) , options - > sample_merged_w , FALSE , FALSE , 0 ) ;
gtk_signal_connect ( GTK_OBJECT ( options - > sample_merged_w ) , " toggled " ,
1997-11-25 06:05:25 +08:00
( GtkSignalFunc ) color_picker_toggle_update ,
& options - > sample_merged ) ;
1999-04-09 06:25:54 +08:00
gtk_widget_show ( options - > sample_merged_w ) ;
1997-11-25 06:05:25 +08:00
1999-04-09 06:25:54 +08:00
/* Register this selection options widget with the main tools options dialog
*/
tools_register ( COLOR_PICKER , vbox , _ ( " Color Picker Options " ) ,
reset_color_picker_options ) ;
1997-11-25 06:05:25 +08:00
return options ;
}
1998-01-29 11:13:44 +08:00
static ActionAreaItem action_items [ ] =
{
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
{ N_ ( " Close " ) , color_picker_info_window_close_callback , NULL , NULL } ,
1998-01-29 11:13:44 +08:00
} ;
1997-11-25 06:05:25 +08:00
static void
color_picker_button_press ( Tool * tool ,
GdkEventButton * bevent ,
gpointer gdisp_ptr )
{
GDisplay * gdisp ;
int x , y ;
gdisp = ( GDisplay * ) gdisp_ptr ;
/* If this is the first invocation of the tool, or a different gdisplay,
* create ( or recreate ) the info dialog . . .
*/
if ( tool - > state = = INACTIVE | | gdisp_ptr ! = tool - > gdisp_ptr | |
1998-01-22 15:02:57 +08:00
active_drawable ! = gimage_active_drawable ( gdisp - > gimage ) )
1997-11-25 06:05:25 +08:00
{
/* if the dialog exists, free it */
if ( color_picker_info )
info_dialog_free ( color_picker_info ) ;
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
color_picker_info = info_dialog_new ( _ ( " Color Picker " ) ) ;
1998-01-22 15:02:57 +08:00
active_drawable = gimage_active_drawable ( gdisp - > gimage ) ;
1997-11-25 06:05:25 +08:00
/* if the gdisplay is for a color image, the dialog must have RGB */
1998-01-22 15:02:57 +08:00
switch ( drawable_type ( active_drawable ) )
1997-11-25 06:05:25 +08:00
{
case RGB_GIMAGE : case RGBA_GIMAGE :
1999-04-03 03:46:59 +08:00
info_dialog_add_label ( color_picker_info , _ ( " Red: " ) , red_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Green: " ) , green_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Blue: " ) , blue_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Alpha: " ) , alpha_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Hex Triplet: " ) , hex_buf ) ;
1997-11-25 06:05:25 +08:00
break ;
case INDEXED_GIMAGE : case INDEXEDA_GIMAGE :
1999-04-03 03:46:59 +08:00
info_dialog_add_label ( color_picker_info , _ ( " Index: " ) , index_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Alpha: " ) , alpha_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Red: " ) , red_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Green: " ) , green_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Blue: " ) , blue_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Hex Triplet " ) , hex_buf ) ;
1997-11-25 06:05:25 +08:00
break ;
case GRAY_GIMAGE : case GRAYA_GIMAGE :
1999-04-03 03:46:59 +08:00
info_dialog_add_label ( color_picker_info , _ ( " Intensity: " ) , gray_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Alpha: " ) , alpha_buf ) ;
info_dialog_add_label ( color_picker_info , _ ( " Hex Triplet: " ) , hex_buf ) ;
1997-11-25 06:05:25 +08:00
break ;
default :
break ;
}
1998-01-29 11:13:44 +08:00
/* Create the action area */
action_items [ 0 ] . user_data = color_picker_info ;
build_action_area ( GTK_DIALOG ( color_picker_info - > shell ) , action_items , 1 , 0 ) ;
1997-11-25 06:05:25 +08:00
}
gdk_pointer_grab ( gdisp - > canvas - > window , FALSE ,
( GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON1_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK ) ,
NULL , NULL , bevent - > time ) ;
/* Make the tool active and set the gdisplay which owns it */
tool - > gdisp_ptr = gdisp_ptr ;
tool - > state = ACTIVE ;
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords ( gdisp , bevent - > x , bevent - > y , & x , & y , FALSE , FALSE ) ;
/* if the shift key is down, create a new color.
* otherwise , modify the current color .
*/
if ( bevent - > state & GDK_SHIFT_MASK )
{
1998-01-22 15:02:57 +08:00
color_picker_info_update ( tool , get_color ( gdisp - > gimage , active_drawable , x , y ,
1997-11-25 06:05:25 +08:00
color_picker_options - > sample_merged ,
COLOR_NEW ) ) ;
update_type = COLOR_UPDATE_NEW ;
}
else
{
1998-01-22 15:02:57 +08:00
color_picker_info_update ( tool , get_color ( gdisp - > gimage , active_drawable , x , y ,
1997-11-25 06:05:25 +08:00
color_picker_options - > sample_merged ,
COLOR_UPDATE ) ) ;
update_type = COLOR_UPDATE ;
}
1998-01-29 11:13:44 +08:00
1997-11-25 06:05:25 +08:00
}
static void
color_picker_button_release ( Tool * tool ,
GdkEventButton * bevent ,
gpointer gdisp_ptr )
{
GDisplay * gdisp ;
int x , y ;
gdk_pointer_ungrab ( bevent - > time ) ;
gdk_flush ( ) ;
gdisp = ( GDisplay * ) gdisp_ptr ;
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords ( gdisp , bevent - > x , bevent - > y , & x , & y , FALSE , FALSE ) ;
1998-01-22 15:02:57 +08:00
color_picker_info_update ( tool , get_color ( gdisp - > gimage , active_drawable , x , y ,
1997-11-25 06:05:25 +08:00
color_picker_options - > sample_merged ,
update_type ) ) ;
}
static void
color_picker_motion ( Tool * tool ,
GdkEventMotion * mevent ,
gpointer gdisp_ptr )
{
GDisplay * gdisp ;
int x , y ;
gdisp = ( GDisplay * ) gdisp_ptr ;
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords ( gdisp , mevent - > x , mevent - > y , & x , & y , FALSE , FALSE ) ;
1998-01-22 15:02:57 +08:00
color_picker_info_update ( tool , get_color ( gdisp - > gimage , active_drawable , x , y ,
1997-11-25 06:05:25 +08:00
color_picker_options - > sample_merged ,
update_type ) ) ;
}
static void
color_picker_cursor_update ( Tool * tool ,
GdkEventMotion * mevent ,
gpointer gdisp_ptr )
{
GDisplay * gdisp ;
int x , y ;
gdisp = ( GDisplay * ) gdisp_ptr ;
gdisplay_untransform_coords ( gdisp , mevent - > x , mevent - > y , & x , & y , FALSE , FALSE ) ;
if ( gimage_pick_correlate_layer ( gdisp - > gimage , x , y ) )
gdisplay_install_tool_cursor ( gdisp , GDK_TCROSS ) ;
else
gdisplay_install_tool_cursor ( gdisp , GDK_TOP_LEFT_ARROW ) ;
}
static void
color_picker_control ( Tool * tool ,
int action ,
gpointer gdisp_ptr )
{
}
static int
get_color ( GImage * gimage ,
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ,
1997-11-25 06:05:25 +08:00
int x ,
int y ,
int sample_merged ,
int final )
{
1999-02-16 16:53:54 +08:00
unsigned char * color ;
1997-11-25 06:05:25 +08:00
int offx , offy ;
int has_alpha ;
1999-02-16 16:53:54 +08:00
int is_indexed ;
1998-01-22 15:02:57 +08:00
if ( ! drawable & & ! sample_merged )
return FALSE ;
1997-11-25 06:05:25 +08:00
if ( ! sample_merged )
{
1998-01-22 15:02:57 +08:00
drawable_offsets ( drawable , & offx , & offy ) ;
1997-11-25 06:05:25 +08:00
x - = offx ;
y - = offy ;
1999-02-16 16:53:54 +08:00
if ( ! ( color = gimp_drawable_get_color_at ( drawable , x , y ) ) )
return FALSE ;
sample_type = gimp_drawable_type ( drawable ) ;
is_indexed = gimp_drawable_indexed ( drawable ) ;
1997-11-25 06:05:25 +08:00
}
else
{
1999-02-16 16:53:54 +08:00
if ( ! ( color = gimp_image_get_color_at ( gimage , x , y ) ) )
return FALSE ;
sample_type = gimp_image_composite_type ( gimage ) ;
is_indexed = FALSE ;
1997-11-25 06:05:25 +08:00
}
1999-02-16 16:53:54 +08:00
has_alpha = TYPE_HAS_ALPHA ( sample_type ) ;
1997-11-25 06:05:25 +08:00
1999-02-16 16:53:54 +08:00
col_value [ RED_PIX ] = color [ RED_PIX ] ;
col_value [ GREEN_PIX ] = color [ GREEN_PIX ] ;
col_value [ BLUE_PIX ] = color [ BLUE_PIX ] ;
1997-11-25 06:05:25 +08:00
if ( has_alpha )
{
1999-02-16 16:53:54 +08:00
col_value [ ALPHA_PIX ] = color [ 3 ] ;
1997-11-25 06:05:25 +08:00
}
1999-02-16 16:53:54 +08:00
if ( is_indexed )
col_value [ 4 ] = color [ 4 ] ;
1997-11-25 06:05:25 +08:00
palette_set_active_color ( col_value [ RED_PIX ] , col_value [ GREEN_PIX ] ,
col_value [ BLUE_PIX ] , final ) ;
1999-02-16 16:53:54 +08:00
g_free ( color ) ;
1997-11-25 06:05:25 +08:00
return TRUE ;
}
static void
color_picker_info_update ( Tool * tool ,
int valid )
{
if ( ! valid )
{
1998-12-26 02:22:01 +08:00
g_snprintf ( red_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( green_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( blue_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( alpha_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( index_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( gray_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( hex_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
1997-11-25 06:05:25 +08:00
}
else
{
switch ( sample_type )
{
case RGB_GIMAGE : case RGBA_GIMAGE :
1998-12-26 02:22:01 +08:00
g_snprintf ( red_buf , MAX_INFO_BUF , " %d " , col_value [ RED_PIX ] ) ;
g_snprintf ( green_buf , MAX_INFO_BUF , " %d " , col_value [ GREEN_PIX ] ) ;
g_snprintf ( blue_buf , MAX_INFO_BUF , " %d " , col_value [ BLUE_PIX ] ) ;
1997-11-25 06:05:25 +08:00
if ( sample_type = = RGBA_GIMAGE )
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , " %d " , col_value [ ALPHA_PIX ] ) ;
1997-11-25 06:05:25 +08:00
else
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( hex_buf , MAX_INFO_BUF , " #%.2x%.2x%.2x " ,
col_value [ RED_PIX ] ,
col_value [ GREEN_PIX ] ,
col_value [ BLUE_PIX ] ) ;
1997-11-25 06:05:25 +08:00
break ;
case INDEXED_GIMAGE : case INDEXEDA_GIMAGE :
1998-12-26 02:22:01 +08:00
g_snprintf ( index_buf , MAX_INFO_BUF , " %d " , col_value [ 4 ] ) ;
1997-11-25 06:05:25 +08:00
if ( sample_type = = INDEXEDA_GIMAGE )
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , " %d " , col_value [ ALPHA_PIX ] ) ;
1997-11-25 06:05:25 +08:00
else
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( red_buf , MAX_INFO_BUF , " %d " , col_value [ RED_PIX ] ) ;
g_snprintf ( green_buf , MAX_INFO_BUF , " %d " , col_value [ GREEN_PIX ] ) ;
g_snprintf ( blue_buf , MAX_INFO_BUF , " %d " , col_value [ BLUE_PIX ] ) ;
g_snprintf ( hex_buf , MAX_INFO_BUF , " #%.2x%.2x%.2x " ,
col_value [ RED_PIX ] ,
col_value [ GREEN_PIX ] ,
col_value [ BLUE_PIX ] ) ;
1997-11-25 06:05:25 +08:00
break ;
case GRAY_GIMAGE : case GRAYA_GIMAGE :
1998-12-26 02:22:01 +08:00
g_snprintf ( gray_buf , MAX_INFO_BUF , " %d " , col_value [ GRAY_PIX ] ) ;
1997-11-25 06:05:25 +08:00
if ( sample_type = = GRAYA_GIMAGE )
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , " %d " , col_value [ ALPHA_PIX ] ) ;
1997-11-25 06:05:25 +08:00
else
1998-12-26 02:22:01 +08:00
g_snprintf ( alpha_buf , MAX_INFO_BUF , _ ( " N/A " ) ) ;
g_snprintf ( hex_buf , MAX_INFO_BUF , " #%.2x%.2x%.2x " ,
col_value [ GRAY_PIX ] ,
col_value [ GRAY_PIX ] ,
col_value [ GRAY_PIX ] ) ;
1997-11-25 06:05:25 +08:00
break ;
}
}
info_dialog_update ( color_picker_info ) ;
info_dialog_popup ( color_picker_info ) ;
}
Tool *
tools_new_color_picker ( )
{
Tool * tool ;
if ( ! color_picker_options )
color_picker_options = create_color_picker_options ( ) ;
tool = ( Tool * ) g_malloc ( sizeof ( Tool ) ) ;
tool - > type = COLOR_PICKER ;
tool - > state = INACTIVE ;
tool - > scroll_lock = 0 ; /* Allow scrolling */
tool - > auto_snap_to = TRUE ;
tool - > private = NULL ;
tool - > button_press_func = color_picker_button_press ;
tool - > button_release_func = color_picker_button_release ;
tool - > motion_func = color_picker_motion ;
tool - > arrow_keys_func = standard_arrow_keys_func ;
tool - > cursor_update_func = color_picker_cursor_update ;
tool - > control_func = color_picker_control ;
1998-03-31 15:23:50 +08:00
tool - > preserve = TRUE ;
1997-11-25 06:05:25 +08:00
return tool ;
}
void
tools_free_color_picker ( Tool * tool )
{
if ( color_picker_info )
{
info_dialog_free ( color_picker_info ) ;
color_picker_info = NULL ;
}
}
/* The color_picker procedure definition */
ProcArg color_picker_args [ ] =
{
{ PDB_DRAWABLE ,
" drawable " ,
1998-12-26 02:22:01 +08:00
" the drawable "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_FLOAT ,
" x " ,
1998-12-26 02:22:01 +08:00
" x coordinate of upper-left corner of rectangle "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_FLOAT ,
" y " ,
1998-12-26 02:22:01 +08:00
" y coordinate of upper-left corner of rectangle "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_INT32 ,
" sample_merged " ,
1998-12-26 02:22:01 +08:00
" use the composite image, not the drawable "
1997-11-25 06:05:25 +08:00
} ,
{ PDB_INT32 ,
" save_color " ,
1998-12-26 02:22:01 +08:00
" save the color to the active palette "
1997-11-25 06:05:25 +08:00
}
} ;
ProcArg color_picker_out_args [ ] =
{
{ PDB_COLOR ,
" color " ,
1998-12-26 02:22:01 +08:00
" the return color "
1997-11-25 06:05:25 +08:00
}
} ;
ProcRecord color_picker_proc =
{
" gimp_color_picker " ,
1998-12-26 02:22:01 +08:00
" Determine the color at the given drawable coordinates " ,
" This tool determines the color at the specified coordinates. The returned color is an RGB triplet even for grayscale and indexed drawables. If the coordinates lie outside of the extents of the specified drawable, then an error is returned. If the drawable has an alpha channel, the algorithm examines the alpha value of the drawable at the coordinates. If the alpha value is completely transparent (0), then an error is returned. If the sample_merged parameter is non-zero, the data of the composite image will be used instead of that for the specified drawable. This is equivalent to sampling for colors after merging all visible layers. In the case of a merged sampling, the supplied drawable is ignored. " ,
1997-11-25 06:05:25 +08:00
" Spencer Kimball & Peter Mattis " ,
" Spencer Kimball & Peter Mattis " ,
" 1995-1996 " ,
PDB_INTERNAL ,
/* Input arguments */
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
5 ,
1997-11-25 06:05:25 +08:00
color_picker_args ,
/* Output arguments */
1 ,
color_picker_out_args ,
/* Exec method */
{ { color_picker_invoker } } ,
} ;
static Argument *
color_picker_invoker ( Argument * args )
{
GImage * gimage ;
int success = TRUE ;
1998-01-22 15:02:57 +08:00
GimpDrawable * drawable ;
1997-11-25 06:05:25 +08:00
double x , y ;
int sample_merged ;
int save_color ;
int int_value ;
Argument * return_args ;
unsigned char * color ;
1998-01-22 15:02:57 +08:00
drawable = NULL ;
1997-11-25 06:05:25 +08:00
x = 0 ;
y = 0 ;
sample_merged = FALSE ;
save_color = COLOR_UPDATE ;
/* the drawable */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 0 ] . value . pdb_int ;
1998-01-22 15:02:57 +08:00
drawable = drawable_get_ID ( int_value ) ;
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
if ( drawable = = NULL )
success = FALSE ;
else
gimage = drawable_gimage ( drawable ) ;
1997-11-25 06:05:25 +08:00
}
/* x, y */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
x = args [ 1 ] . value . pdb_float ;
y = args [ 2 ] . value . pdb_float ;
1997-11-25 06:05:25 +08:00
}
/* sample_merged */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 3 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
sample_merged = ( int_value ) ? TRUE : FALSE ;
}
/* save_color */
if ( success )
{
API-mega-break-it-all patch part one: removed the unnecessary PDB_IMAGE
* airbrush.c, blend.c, brightness_contrast.c, bucket_fill.c
by_color_select.c, channel_ops.c, clone.c, color_balance.c
color_picker.c, convolve.c, curves.c, desaturate.c, edit_cmds.c
equalize.c, eraser.c, flip_tool.c, fuzzy_select.c,
gimage_mask_cmds.c histogram_tool.c, hue_saturation.c, invert.c,
levels.c, pencil.c paintbrush.c, perspective_tool.c, posterize.c,
rotate_tool.c scale_tool.c, shear_tool.c, text_tool.c, threshold.c:
API-mega-break-it-all patch part one: removed the unnecessary
PDB_IMAGE argument from many functions.
Affected functions:
gimp_airbrush gimp_blend gimp_brightness_contrast gimp_bucket_fill
gimp_by_color_select gimp_channel_ops_offset gimp_clone gimp_color_balance
gimp_color_picker gimp_convolve gimp_curves_explicit gimp_curves_spline
gimp_desaturate gimp_edit_clear gimp_edit_copy gimp_edit_cut gimp_edit_fill
gimp_edit_paste gimp_edit_stroke gimp_equalize gimp_eraser
gimp_eraser_extended gimp_flip gimp_fuzzy_select gimp_histogram
gimp_hue_saturation gimp_invert gimp_levels gimp_paintbrush
gimp_paintbrush_extended gimp_pencil gimp_perspective gimp_posterize
gimp_rotate gimp_scale gimp_selection_float gimp_selection_layer_alpha
gimp_selection_load gimp_shear gimp_threshold
1998-11-14 04:40:00 +08:00
int_value = args [ 4 ] . value . pdb_int ;
1997-11-25 06:05:25 +08:00
save_color = ( int_value ) ? COLOR_NEW : COLOR_UPDATE ;
}
/* Make sure that if we're not using the composite, the specified drawable is valid */
if ( success & & ! sample_merged )
1998-01-22 15:02:57 +08:00
if ( ! drawable | | ( drawable_gimage ( drawable ) ) ! = gimage )
1997-11-25 06:05:25 +08:00
success = FALSE ;
/* call the color_picker procedure */
if ( success )
1998-01-22 15:02:57 +08:00
success = get_color ( gimage , drawable , ( int ) x , ( int ) y , sample_merged , save_color ) ;
1997-11-25 06:05:25 +08:00
return_args = procedural_db_return_args ( & color_picker_proc , success ) ;
if ( success )
{
color = ( unsigned char * ) g_malloc ( 3 ) ;
color [ RED_PIX ] = col_value [ RED_PIX ] ;
color [ GREEN_PIX ] = col_value [ GREEN_PIX ] ;
color [ BLUE_PIX ] = col_value [ BLUE_PIX ] ;
return_args [ 1 ] . value . pdb_pointer = color ;
}
return return_args ;
}
1998-01-29 11:13:44 +08:00
static void
color_picker_info_window_close_callback ( GtkWidget * w ,
gpointer client_data )
{
info_dialog_popdown ( ( InfoDialog * ) client_data ) ;
}