From 8cd58f4bae3aef4546ec6aaed9825f397eca60ce Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Thu, 29 Jan 1998 03:13:44 +0000 Subject: [PATCH] Fixed carve-it.scm and circuit.scm (circuit broke due to a plugin update, * Fixed carve-it.scm and circuit.scm (circuit broke due to a plugin update, carve-it broke due to theadd-layer stuff) * Added a close button to the color picker info window * changed index_palette.c a bit...now if you click with MB11, it changes the current active color, clicking with MB3 opens the color in the color selector for editing * Made some of the /Color/* menus sensitive to the image type (gdisplay.c) -adrian CVS: --- ChangeLog | 14 ++++++++++ app/color_picker.c | 19 +++++++++++++ app/core/gimpprojection.c | 13 +++++++++ app/display/gimpdisplay.c | 13 +++++++++ app/gdisplay.c | 13 +++++++++ app/indexed_palette.c | 23 +++++++++++++++ app/tools/color_picker.c | 19 +++++++++++++ plug-ins/script-fu/scripts/carve-it.scm | 37 +++++++++++++++++++++---- plug-ins/script-fu/scripts/circuit.scm | 2 +- 9 files changed, 146 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 135657a98e..dce7c2e37c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Wed Jan 28 22:03:42 EST 1998 Adrian Likins + + * Fixed carve-it.scm and circuit.scm (circuit broke due + to a plugin update, carve-it broke due to theadd-layer stuff) + + * Added a close button to the color picker info window + + * changed index_palette.c a bit...now if you click with + MB11, it changes the current active color, clicking with MB3 + opens the color in the color selector for editing + + * Made some of the /Colr/* menus sensitive to the image + type (gdisplay.c) + Wed Jan 28 13:17:06 1998 Scott Goehring * app/gimage.c (gimage_add_channel): Added safety code for add diff --git a/app/color_picker.c b/app/color_picker.c index e38da0ea82..9440a77a91 100644 --- a/app/color_picker.c +++ b/app/color_picker.c @@ -18,6 +18,7 @@ #include #include #include "appenv.h" +#include "actionarea.h" #include "color_picker.h" #include "drawable.h" #include "gdisplay.h" @@ -38,6 +39,7 @@ 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); @@ -117,6 +119,11 @@ create_color_picker_options (void) return options; } +static ActionAreaItem action_items[] = +{ + { "Close", color_picker_info_window_close_callback, NULL, NULL }, +}; + static void color_picker_button_press (Tool *tool, GdkEventButton *bevent, @@ -166,6 +173,9 @@ color_picker_button_press (Tool *tool, default : break; } + /* 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); } gdk_pointer_grab (gdisp->canvas->window, FALSE, @@ -198,6 +208,8 @@ color_picker_button_press (Tool *tool, COLOR_UPDATE)); update_type = COLOR_UPDATE; } + + } static void @@ -580,3 +592,10 @@ color_picker_invoker (Argument *args) return return_args; } + +static void +color_picker_info_window_close_callback (GtkWidget *w, + gpointer client_data) +{ + info_dialog_popdown ((InfoDialog *) client_data); +} diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index 14c1391d60..2a7c89860b 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -1005,6 +1005,19 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp) menus_set_sensitive ("/Image/Grayscale", (base_type != GRAY)); menus_set_sensitive ("/Image/Indexed", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Threshold", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Posterize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Equalize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Invert", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Color Balance", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Brightness-Contrast", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Hue-Saturation", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Curves", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Levels", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Desaturate", (base_type == RGB)); + menus_set_sensitive ("/Select", lp); menus_set_sensitive ("/Edit/Cut", lp); menus_set_sensitive ("/Edit/Copy", lp); diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index 14c1391d60..2a7c89860b 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -1005,6 +1005,19 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp) menus_set_sensitive ("/Image/Grayscale", (base_type != GRAY)); menus_set_sensitive ("/Image/Indexed", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Threshold", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Posterize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Equalize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Invert", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Color Balance", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Brightness-Contrast", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Hue-Saturation", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Curves", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Levels", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Desaturate", (base_type == RGB)); + menus_set_sensitive ("/Select", lp); menus_set_sensitive ("/Edit/Cut", lp); menus_set_sensitive ("/Edit/Copy", lp); diff --git a/app/gdisplay.c b/app/gdisplay.c index 14c1391d60..2a7c89860b 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -1005,6 +1005,19 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp) menus_set_sensitive ("/Image/Grayscale", (base_type != GRAY)); menus_set_sensitive ("/Image/Indexed", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Threshold", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Posterize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Equalize", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Invert", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Color Balance", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Brightness-Contrast", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Hue-Saturation", (base_type == RGB)); + menus_set_sensitive ("/Image/Colors/Curves", (base_type != INDEXED)); + menus_set_sensitive ("/Image/Colors/Levels", (base_type != INDEXED)); + + menus_set_sensitive ("/Image/Colors/Desaturate", (base_type == RGB)); + menus_set_sensitive ("/Select", lp); menus_set_sensitive ("/Edit/Cut", lp); menus_set_sensitive ("/Edit/Copy", lp); diff --git a/app/indexed_palette.c b/app/indexed_palette.c index a6c8fcc5cc..f70a07be29 100644 --- a/app/indexed_palette.c +++ b/app/indexed_palette.c @@ -24,6 +24,7 @@ #include "buildmenu.h" #include "colormaps.h" #include "color_select.h" +#include "color_area.h" #include "errors.h" #include "gdisplay.h" #include "gimage.h" @@ -32,6 +33,7 @@ #include "image_render.h" #include "interface.h" #include "indexed_palette.h" +#include "palette.h" #include "undo.h" #define EVENT_MASK GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK @@ -117,6 +119,7 @@ indexed_palette_create (int gimage_id) GtkWidget *ops_menu; GtkWidget *menu_bar; GtkWidget *menu_bar_item; + GtkWidget *hbox; GtkAcceleratorTable *table; int default_index; @@ -197,6 +200,14 @@ indexed_palette_create (int gimage_id) gtk_widget_show (indexedP->palette); gtk_widget_show (frame); + /* some helpful hints */ + hbox = gtk_hbox_new(FALSE, 1); + gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 1); + label = gtk_label_new (" Click to select color. Right-click to edit color"); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 1); + + gtk_widget_show (hbox); + gtk_widget_show (label); /* The action area */ action_items[0].user_data = indexedP; build_action_area (GTK_DIALOG (indexedP->shell), action_items, 1, 0); @@ -408,6 +419,18 @@ indexed_palette_area_events (GtkWidget *widget, bevent = (GdkEventButton *) event; if (bevent->button == 1) + { + indexedP->col_index = 16 * ((int)bevent->y / CELL_HEIGHT) + ((int)bevent->x / CELL_WIDTH); + r = gimage->cmap[indexedP->col_index * 3 + 0]; + g = gimage->cmap[indexedP->col_index * 3 + 1]; + b = gimage->cmap[indexedP->col_index * 3 + 2]; + if (active_color == FOREGROUND) + palette_set_foreground (r, g, b); + else if (active_color == BACKGROUND) + palette_set_background (r, g, b); + } + + if (bevent->button == 3) { indexedP->col_index = 16 * ((int)bevent->y / CELL_HEIGHT) + ((int)bevent->x / CELL_WIDTH); r = gimage->cmap[indexedP->col_index * 3 + 0]; diff --git a/app/tools/color_picker.c b/app/tools/color_picker.c index e38da0ea82..9440a77a91 100644 --- a/app/tools/color_picker.c +++ b/app/tools/color_picker.c @@ -18,6 +18,7 @@ #include #include #include "appenv.h" +#include "actionarea.h" #include "color_picker.h" #include "drawable.h" #include "gdisplay.h" @@ -38,6 +39,7 @@ 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); @@ -117,6 +119,11 @@ create_color_picker_options (void) return options; } +static ActionAreaItem action_items[] = +{ + { "Close", color_picker_info_window_close_callback, NULL, NULL }, +}; + static void color_picker_button_press (Tool *tool, GdkEventButton *bevent, @@ -166,6 +173,9 @@ color_picker_button_press (Tool *tool, default : break; } + /* 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); } gdk_pointer_grab (gdisp->canvas->window, FALSE, @@ -198,6 +208,8 @@ color_picker_button_press (Tool *tool, COLOR_UPDATE)); update_type = COLOR_UPDATE; } + + } static void @@ -580,3 +592,10 @@ color_picker_invoker (Argument *args) return return_args; } + +static void +color_picker_info_window_close_callback (GtkWidget *w, + gpointer client_data) +{ + info_dialog_popdown ((InfoDialog *) client_data); +} diff --git a/plug-ins/script-fu/scripts/carve-it.scm b/plug-ins/script-fu/scripts/carve-it.scm index eda69ebf59..d241d8ad01 100644 --- a/plug-ins/script-fu/scripts/carve-it.scm +++ b/plug-ins/script-fu/scripts/carve-it.scm @@ -25,6 +25,18 @@ (cond ((< mean 127) (+ 1.0 (* 0.5 (/ (- 127 mean) 127.0)))) ((>= mean 127) (- 1.0 (* 0.5 (/ (- mean 127) 127.0))))))) + +(define (copy-layer-carve-it dest-image dest-drawable source-image source-drawable) + (gimp-selection-all dest-image) + (gimp-edit-clear dest-image dest-drawable) + (gimp-selection-none dest-image) + (gimp-selection-all source-image) + (gimp-edit-copy source-image source-drawable) + (let ((floating-sel (car (gimp-edit-paste dest-image dest-drawable FALSE)))) + (gimp-floating-sel-anchor floating-sel))) + + + (define (script-fu-carve-it mask-img mask-drawable bg-layer carve-white) (let* ((width (car (gimp-drawable-width mask-drawable))) (height (car (gimp-drawable-height mask-drawable))) @@ -53,13 +65,27 @@ (csl-mask 0) (inset-layer 0) (il-mask 0) - (layer1 (car (gimp-layer-copy bg-layer TRUE))) - (old-fg (car (gimp-palette-get-foreground))) + (bg-height (car (gimp-drawable-height bg-layer))) + (bg-width (car (gimp-drawable-width bg-layer))) + (bg-type (car (gimp-drawable-type bg-layer))) + (bg-image (car (gimp-drawable-image bg-layer))) + (layer1 (car (gimp-layer-new img bg-height bg-width bg-type "Layer1" 100 NORMAL))) + (inset-layer (car (gimp-layer-new img bg-height bg-width bg-type "inset1" 100 NORMAL))) + (old-fg (car (gimp-palette-get-foreground))) (old-bg (car (gimp-palette-get-background))) (old-brush (car (gimp-brushes-get-brush)))) (gimp-image-disable-undo img) + (gimp-selection-all img) + (gimp-edit-clear img inset-layer) + (gimp-edit-clear img layer1) + (gimp-selection-none img) + (copy-layer-carve-it img layer1 bg-image bg-layer) + + (gimp-edit-clear img inset-layer) + (gimp-edit-copy mask-img mask-drawable) (gimp-image-add-channel img mask 0) + (gimp-image-add-layer img layer1 0) (plug-in-tile 1 img layer1 width height FALSE) (set! mask-fs (car (gimp-edit-paste img mask FALSE))) @@ -119,8 +145,8 @@ (gimp-palette-set-background '(255 255 255)) (gimp-edit-fill img csl-mask) - (set! inset-layer (car (gimp-layer-copy layer1 TRUE))) - (gimp-image-add-layer img inset-layer 1) + (set! inset-layer (car (gimp-layer-copy layer1 TRUE))) + (gimp-image-add-layer img inset-layer 1) (set! il-mask (car (gimp-layer-create-mask inset-layer BLACK-MASK))) (gimp-image-add-layer-mask img inset-layer il-mask) @@ -128,9 +154,8 @@ (gimp-palette-set-background '(255 255 255)) (gimp-edit-fill img il-mask) (gimp-selection-none img) - + (gimp-selection-none bg-image) (gimp-levels img inset-layer 0 0 255 inset-gamma 0 255) - (gimp-image-remove-channel img mask) (gimp-image-remove-channel img mask-fat) (gimp-image-remove-channel img mask-highlight) diff --git a/plug-ins/script-fu/scripts/circuit.scm b/plug-ins/script-fu/scripts/circuit.scm index d8973ad5e6..06b83f6ba1 100644 --- a/plug-ins/script-fu/scripts/circuit.scm +++ b/plug-ins/script-fu/scripts/circuit.scm @@ -92,7 +92,7 @@ (gimp-palette-set-foreground '(14 14 14)))) (gimp-selection-load image active-selection) - (plug-in-maze 1 image active-layer 5 seed 57 1) + (plug-in-maze 1 image active-layer 5 TRUE seed 57 1) (plug-in-oilify 1 image active-layer mask-size) (plug-in-edge 1 image active-layer 2 1) (gimp-desaturate image active-layer)