gimp/app/color_picker.c

761 lines
23 KiB
C
Raw Normal View History

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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1997-11-25 06:05:25 +08:00
*/
#include "appenv.h"
#include "color_panel.h"
1997-11-25 06:05:25 +08:00
#include "color_picker.h"
#include "draw_core.h"
1997-11-25 06:05:25 +08:00
#include "drawable.h"
#include "gdisplay.h"
1999-10-27 02:27:27 +08:00
#include "gimpui.h"
#include "cursorutil.h"
1997-11-25 06:05:25 +08:00
#include "info_dialog.h"
#include "palette.h"
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
#include "tool_options_ui.h"
1997-11-25 06:05:25 +08:00
#include "tools.h"
#include "gimprc.h"
1997-11-25 06:05:25 +08:00
#include "libgimp/gimpintl.h"
/* maximum information buffer size */
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
#define MAX_INFO_BUF 8
1997-11-25 06:05:25 +08:00
/* the color picker structures */
1997-11-25 06:05:25 +08:00
typedef struct _ColorPickerOptions ColorPickerOptions;
1999-10-27 02:27:27 +08:00
struct _ColorPickerOptions
{
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
ToolOptions tool_options;
gboolean sample_merged;
gboolean sample_merged_d;
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
GtkWidget *sample_merged_w;
gboolean sample_average;
gboolean sample_average_d;
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
GtkWidget *sample_average_w;
gdouble average_radius;
gdouble average_radius_d;
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
GtkObject *average_radius_w;
gboolean update_active;
gboolean update_active_d;
GtkWidget *update_active_w;
};
1997-11-25 06:05:25 +08:00
typedef struct _ColorPickerTool ColorPickerTool;
1999-10-27 02:27:27 +08:00
struct _ColorPickerTool
{
DrawCore *core; /* Core select object */
gint centerx; /* starting x coord */
gint centery; /* starting y coord */
};
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
/* the color picker tool options */
static ColorPickerOptions * color_picker_options = NULL;
1997-11-25 06:05:25 +08:00
/* the color value */
gint col_value[5] = { 0, 0, 0, 0, 0 };
/* the color picker dialog */
static gint update_type;
static GimpImageType sample_type;
static InfoDialog *color_picker_info = NULL;
static ColorPanel *color_panel = NULL;
static gchar red_buf [MAX_INFO_BUF];
static gchar green_buf [MAX_INFO_BUF];
static gchar blue_buf [MAX_INFO_BUF];
static gchar alpha_buf [MAX_INFO_BUF];
static gchar index_buf [MAX_INFO_BUF];
static gchar gray_buf [MAX_INFO_BUF];
static gchar hex_buf [MAX_INFO_BUF];
1997-11-25 06:05:25 +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 *, ToolAction, gpointer);
static void color_picker_info_window_close_callback (GtkWidget *, gpointer);
static void color_picker_info_update (Tool *, gboolean);
static gboolean pick_color_do (GimpImage *gimage,
GimpDrawable *drawable,
gint x,
gint y,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
gboolean update_active,
gint final);
/* functions */
1997-11-25 06:05:25 +08:00
static void
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
color_picker_options_reset (void)
{
ColorPickerOptions *options = color_picker_options;
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_merged_w),
options->sample_merged_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_average_w),
options->sample_average_d);
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
gtk_adjustment_set_value (GTK_ADJUSTMENT (options->average_radius_w),
options->average_radius_d);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->update_active_w),
options->update_active_d);
}
1997-11-25 06:05:25 +08:00
static ColorPickerOptions *
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
color_picker_options_new (void)
1997-11-25 06:05:25 +08:00
{
ColorPickerOptions *options;
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
GtkWidget *vbox;
GtkWidget *abox;
GtkWidget *table;
GtkWidget *label;
GtkWidget *scale;
/* the new color picker tool options structure */
options = g_new (ColorPickerOptions, 1);
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
tool_options_init ((ToolOptions *) options,
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
_("Color Picker Options"),
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
color_picker_options_reset);
options->sample_merged = options->sample_merged_d = FALSE;
options->sample_average = options->sample_average_d = FALSE;
options->average_radius = options->average_radius_d = 1.0;
options->update_active = options->update_active_d = TRUE;
1997-11-25 06:05:25 +08:00
/* the main vbox */
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
vbox = options->tool_options.main_vbox;
1997-11-25 06:05:25 +08:00
/* the sample merged toggle button */
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",
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
(GtkSignalFunc) tool_options_toggle_update,
1997-11-25 06:05:25 +08:00
&options->sample_merged);
gtk_widget_show (options->sample_merged_w);
1997-11-25 06:05:25 +08:00
/* the sample average options */
table = gtk_table_new (2, 2, FALSE);
First version of per-tool paint options. No PDB interface yet. The tool 1999-04-22 Michael Natterer <mitschel@cs.tu-berlin.de> First version of per-tool paint options. No PDB interface yet. The tool options dialog got rather big when in per-tool mode, so it will probably have to become a notebook. It's not yet 100% consistent. If switched off, everything should behave exactly like before. * app/Makefile.am * app/paint_options.h: new file * app/tool_options.c: PaintOptions gui. Maintain a list of all paint tools' ToolOptions to enable switching between global and per-tool paint options. * app/brush_select.[ch]: changed packing boxes, tables, ... The paint options in the brush selection can be hidden now. Moved create_paint_mode_menu() to paint_options.h and tool_options.c and renamed it to paint_mode_menu_new(). * app/gimage_mask.c * app/gimpbrush.[ch] * app/gimpbrushlist.[ch] * app/paint_core.c: moved gimp_brush_[set|get]_spacing() from gimpbrushlist.[ch] to gimpbrush.[ch]. Moved gimp_brush_[get|set]_[opacity|paint_mode]() to paint_options.h and tool_options.c and renamed them to paint_options_*_*(). They are "global paint options" now. * app/airbrush.c * app/blend.c * app/bucket_fill.c * app/clone.c * app/convolve.c * app/eraser.c * app/ink.c * app/paintbrush.c * app/pencil.c: all paint tools' options are derived from "PaintOptions" now. Opacity and paint mode are obtained through macros which take into account the current paint options mode. * app/buildmenu.h: #include <gtk/gtk.h> * app/color_picker.c * app/text_tool.c: changed spacings. * app/gimprc.[ch]: new gimprc option "global-paint-options" * app/preferences_dialog.c: Added a "Tool Options" page. Code cleanup. Some work on the convenience constructors test site. * app/tools.c: fixed "unused variable" warning.
1999-04-22 22:34:00 +08:00
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
options->sample_average_w =
gtk_check_button_new_with_label (_("Sample Average"));
gtk_table_attach (GTK_TABLE (table), options->sample_average_w, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, GTK_SHRINK, 0, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->sample_average_w),
options->sample_average_d);
gtk_signal_connect (GTK_OBJECT (options->sample_average_w), "toggled",
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
(GtkSignalFunc) tool_options_toggle_update,
&options->sample_average);
gtk_widget_show (options->sample_average_w);
label = gtk_label_new (_("Radius:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
/* the feather radius scale */
abox = gtk_alignment_new (0.5, 1.0, 1.0, 0.0);
gtk_table_attach (GTK_TABLE (table), abox, 1, 2, 0, 2,
GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (abox);
options->average_radius_w =
gtk_adjustment_new (options->average_radius_d, 1.0, 15.0, 2.0, 2.0, 0.0);
scale = gtk_hscale_new (GTK_ADJUSTMENT (options->average_radius_w));
gtk_scale_set_digits (GTK_SCALE (scale), 0);
gtk_container_add (GTK_CONTAINER (abox), scale);
gtk_widget_set_sensitive (scale, options->sample_average_d);
gtk_object_set_data (GTK_OBJECT (options->sample_average_w), "set_sensitive",
scale);
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
gtk_widget_set_sensitive (label, options->sample_average_d);
gtk_object_set_data (GTK_OBJECT (scale), "set_sensitive",
label);
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_TOP);
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
gtk_signal_connect (GTK_OBJECT (options->average_radius_w), "value_changed",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (tool_options_double_adjustment_update),
&options->average_radius);
gtk_widget_show (scale);
gtk_widget_show (table);
/* the update active color toggle button */
options->update_active_w =
gtk_check_button_new_with_label (_("Update Active Color"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (options->update_active_w),
options->update_active_d);
gtk_box_pack_start (GTK_BOX (vbox), options->update_active_w, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (options->update_active_w), "toggled",
1999-10-27 02:27:27 +08:00
GTK_SIGNAL_FUNC (tool_options_toggle_update),
&options->update_active);
gtk_widget_show (options->update_active_w);
1997-11-25 06:05:25 +08:00
return options;
}
static void
color_picker_button_press (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay * gdisp;
ColorPickerTool *cp_tool;
gint x, y;
1997-11-25 06:05:25 +08:00
gdisp = (GDisplay *) gdisp_ptr;
cp_tool = (ColorPickerTool *) tool->private;
1997-11-25 06:05:25 +08:00
/* Make the tool active and set it's gdisplay & drawable */
tool->gdisp_ptr = gdisp;
tool->drawable = gimage_active_drawable (gdisp->gimage);
tool->state = ACTIVE;
1997-11-25 06:05:25 +08:00
/* create the info dialog if it doesn't exist */
if (! color_picker_info)
{
GtkWidget *hbox;
app/Makefile.am app/gimphelp.[ch] new files 1999-09-27 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimphelp.[ch] * app/gimpui.[ch]: new files * app/interface.[ch] * app/preferences_dialog.[ch] The GIMP Help System part 1: Press "F1" in any dialog to pop up the help page for this dialog. Moved the widget constructors from preferences_dialog.[ch] and the query boxes from interface.[ch] to gimpui.[ch]. The dialog constructors take a help_func and a help_data parameter and install the "F1" accelerator which emits the new "help" signal. The "help" signal callback calls help_func(help_data) which finally has to call gimp_help() which in turn invokes the help browser. Still have to find a proper way to (1) prevent "F1" being assigned to some menu item and (2) to catch "F1" while browsing the menu trees in order to pop up the help for the selected item. * app/menus.c: a <Toolbox>/File/Help... menu item. * app/commands.[ch]: a command callback for the "Help..." menu item. * app/gimprc.[ch]: new boolean gimprc variable "use_help". * app/info_dialog.[ch]: pass a help function and data to the info dialog constructor. * app/tools.[ch]: store the tools help page names in the tool info structure. Export a special tools_help_func() which shows the help page for the active tool. * app/[all files calling a dialog constructor]: pass the dialog's help page to the constructor. Most dialogs are now created by gimp_dialog_new() which also sets up the action_area and the WM delete event callback, so I removed the resp. code from these files. Fixed some minor bugs and did some other stuff but didn't change any logic except dialog creation. * plug-ins/helpbrowser/helpbrowser.c: don't try to call a running help browser and don't install any menu path (all done in app/gimphelp.[ch] now).
1999-09-28 01:58:10 +08:00
color_picker_info = info_dialog_new (_("Color Picker"),
tools_help_func, NULL);
1997-11-25 06:05:25 +08:00
/* if the gdisplay is for a color image, the dialog must have RGB */
switch (drawable_type (tool->drawable))
1997-11-25 06:05:25 +08:00
{
case RGB_GIMAGE: case RGBA_GIMAGE:
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:
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:
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;
}
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_start (GTK_BOX (color_picker_info->vbox), hbox,
FALSE, FALSE, 0);
gtk_widget_show (hbox);
gtk_widget_reparent (color_picker_info->info_table, hbox);
color_panel = color_panel_new (NULL, 48, 64);
gtk_box_pack_start (GTK_BOX (hbox), color_panel->color_panel_widget,
FALSE, FALSE, 0);
gtk_widget_show (color_panel->color_panel_widget);
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
/* create the action area */
1999-10-27 02:27:27 +08:00
gimp_dialog_create_action_area
(GTK_DIALOG (color_picker_info->shell),
_("Close"), color_picker_info_window_close_callback,
color_picker_info, NULL, TRUE, FALSE,
NULL);
1997-11-25 06:05:25 +08:00
}
/* Keep the coordinates of the target */
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y,
&cp_tool->centerx, &cp_tool->centery, FALSE, 1);
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);
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y,
FALSE, FALSE);
1997-11-25 06:05:25 +08:00
/* if the shift key is down, create a new color.
* otherwise, modify the current color.
*/
if (bevent->state & GDK_SHIFT_MASK)
{
color_picker_info_update
(tool, pick_color_do (gdisp->gimage, tool->drawable, x, y,
color_picker_options->sample_merged,
color_picker_options->sample_average,
color_picker_options->average_radius,
color_picker_options->update_active,
COLOR_NEW));
1997-11-25 06:05:25 +08:00
update_type = COLOR_UPDATE_NEW;
}
else
{
color_picker_info_update
(tool, pick_color_do (gdisp->gimage, tool->drawable, x, y,
color_picker_options->sample_merged,
color_picker_options->sample_average,
color_picker_options->average_radius,
color_picker_options->update_active,
COLOR_UPDATE));
1997-11-25 06:05:25 +08:00
update_type = COLOR_UPDATE;
}
/* Start drawing the colorpicker tool */
draw_core_start (cp_tool->core, gdisp->canvas->window, tool);
1997-11-25 06:05:25 +08:00
}
static void
color_picker_button_release (Tool *tool,
GdkEventButton *bevent,
gpointer gdisp_ptr)
{
GDisplay *gdisp;
ColorPickerTool *cp_tool;
gint x, y;
1997-11-25 06:05:25 +08:00
gdk_pointer_ungrab (bevent->time);
gdk_flush ();
gdisp = (GDisplay *) gdisp_ptr;
cp_tool = (ColorPickerTool *) tool->private;
1997-11-25 06:05:25 +08:00
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y,
FALSE, FALSE);
1997-11-25 06:05:25 +08:00
color_picker_info_update
(tool, pick_color_do (gdisp->gimage, tool->drawable, x, y,
color_picker_options->sample_merged,
color_picker_options->sample_average,
color_picker_options->average_radius,
color_picker_options->update_active,
update_type));
draw_core_stop (cp_tool->core, tool);
tool->state = INACTIVE;
1997-11-25 06:05:25 +08:00
}
static void
color_picker_motion (Tool *tool,
GdkEventMotion *mevent,
gpointer gdisp_ptr)
{
GDisplay *gdisp;
ColorPickerTool *cp_tool;
gint x, y;
1997-11-25 06:05:25 +08:00
gdisp = (GDisplay *) gdisp_ptr;
cp_tool = (ColorPickerTool *) tool->private;
/* undraw the current tool */
draw_core_pause (cp_tool->core, tool);
1997-11-25 06:05:25 +08:00
/* First, transform the coordinates to gimp image space */
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
FALSE, FALSE);
1997-11-25 06:05:25 +08:00
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y,
&cp_tool->centerx, &cp_tool->centery,
FALSE, TRUE);
color_picker_info_update
(tool, pick_color_do (gdisp->gimage, tool->drawable, x, y,
color_picker_options->sample_merged,
color_picker_options->sample_average,
color_picker_options->average_radius,
color_picker_options->update_active,
update_type));
/* redraw the current tool */
draw_core_resume (cp_tool->core, tool);
1997-11-25 06:05:25 +08:00
}
static void
color_picker_cursor_update (Tool *tool,
GdkEventMotion *mevent,
gpointer gdisp_ptr)
{
GDisplay *gdisp;
gint x, y;
1997-11-25 06:05:25 +08:00
gdisp = (GDisplay *) gdisp_ptr;
gdisplay_untransform_coords (gdisp, mevent->x, mevent->y, &x, &y,
FALSE, FALSE);
1997-11-25 06:05:25 +08:00
if (gimage_pick_correlate_layer (gdisp->gimage, x, y))
gdisplay_install_tool_cursor (gdisp, GIMP_COLOR_PICKER_CURSOR);
1997-11-25 06:05:25 +08:00
else
gdisplay_install_tool_cursor (gdisp, GDK_TOP_LEFT_ARROW);
}
static void
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
color_picker_control (Tool *tool,
ToolAction action,
gpointer gdisp_ptr)
1997-11-25 06:05:25 +08:00
{
ColorPickerTool * cp_tool;
cp_tool = (ColorPickerTool *) tool->private;
switch (action)
{
case PAUSE :
draw_core_pause (cp_tool->core, tool);
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
case RESUME :
draw_core_resume (cp_tool->core, tool);
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
case HALT :
draw_core_stop (cp_tool->core, tool);
info_dialog_popdown (color_picker_info);
break;
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
default:
break;
}
1997-11-25 06:05:25 +08:00
}
typedef guchar * (*GetColorFunc) (GtkObject *, int, int);
static gboolean
pick_color_do (GimpImage *gimage,
GimpDrawable *drawable,
gint x,
gint y,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
gboolean update_active,
gint final)
1997-11-25 06:05:25 +08:00
{
guchar *color;
gint offx, offy;
gint has_alpha;
gint is_indexed;
GetColorFunc get_color_func;
GtkObject *get_color_obj;
if (!drawable && !sample_merged)
return FALSE;
if (!sample_merged)
1997-11-25 06:05:25 +08:00
{
drawable_offsets (drawable, &offx, &offy);
1997-11-25 06:05:25 +08:00
x -= offx;
y -= offy;
sample_type = gimp_drawable_type (drawable);
1999-10-17 08:07:55 +08:00
is_indexed = gimp_drawable_is_indexed (drawable);
get_color_func = (GetColorFunc) gimp_drawable_get_color_at;
get_color_obj = GTK_OBJECT (drawable);
1997-11-25 06:05:25 +08:00
}
else
{
sample_type = gimp_image_composite_type (gimage);
is_indexed = FALSE;
get_color_func = (GetColorFunc) gimp_image_get_color_at;
get_color_obj = GTK_OBJECT (gimage);
1997-11-25 06:05:25 +08:00
}
has_alpha = TYPE_HAS_ALPHA (sample_type);
if (!(color = (*get_color_func) (get_color_obj, x, y)))
return FALSE;
if (sample_average)
{
gint i, j;
gint count = 0;
gint color_avg[4] = { 0, 0, 0, 0 };
guchar *tmp_color;
gint radius = (gint) average_radius;
for (i = x - radius; i <= x + radius; i++)
for (j = y - radius; j <= y + radius; j++)
if ((tmp_color = (*get_color_func) (get_color_obj, i, j)))
{
count++;
1999-10-27 02:27:27 +08:00
color_avg[RED_PIX] += tmp_color[RED_PIX];
color_avg[GREEN_PIX] += tmp_color[GREEN_PIX];
1999-10-27 02:27:27 +08:00
color_avg[BLUE_PIX] += tmp_color[BLUE_PIX];
if (has_alpha)
color_avg[ALPHA_PIX] += tmp_color[3];
1999-10-27 02:27:27 +08:00
g_free (tmp_color);
}
1999-10-27 02:27:27 +08:00
color[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
color[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
1999-10-27 02:27:27 +08:00
color[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
if (has_alpha)
color[ALPHA_PIX] = (guchar) (color_avg[3] / count);
is_indexed = FALSE;
}
1997-11-25 06:05:25 +08:00
1999-10-27 02:27:27 +08:00
col_value[RED_PIX] = color[RED_PIX];
col_value[GREEN_PIX] = color[GREEN_PIX];
1999-10-27 02:27:27 +08:00
col_value[BLUE_PIX] = color[BLUE_PIX];
1997-11-25 06:05:25 +08:00
if (has_alpha)
col_value[ALPHA_PIX] = color[3];
if (is_indexed)
col_value[4] = color[4];
if (update_active)
1999-10-27 02:27:27 +08:00
palette_set_active_color (col_value [RED_PIX],
col_value [GREEN_PIX],
col_value [BLUE_PIX],
final);
g_free (color);
1997-11-25 06:05:25 +08:00
return TRUE;
}
gboolean
pick_color (GimpImage *gimage,
GimpDrawable *drawable,
gint x,
gint y,
gboolean sample_merged,
gboolean sample_average,
gdouble average_radius,
gint final)
{
return pick_color_do (gimage, drawable,
x, y,
sample_merged,
sample_average,
average_radius,
TRUE,
final);
}
static void
colorpicker_draw (Tool *tool)
{
GDisplay * gdisp;
ColorPickerTool * cp_tool;
gint tx, ty;
gint radiusx, radiusy;
gint cx, cy;
1999-10-27 02:27:27 +08:00
if (! color_picker_options->sample_average)
return;
gdisp = (GDisplay *) tool->gdisp_ptr;
cp_tool = (ColorPickerTool *) tool->private;
gdisplay_transform_coords (gdisp, cp_tool->centerx, cp_tool->centery,
&tx, &ty, TRUE);
radiusx = SCALEX (gdisp, color_picker_options->average_radius);
radiusy = SCALEY (gdisp, color_picker_options->average_radius);
cx = SCALEX (gdisp, 1);
cy = SCALEY (gdisp, 1);
/* Draw the circle around the collecting area */
gdk_draw_rectangle (cp_tool->core->win, cp_tool->core->gc, 0,
tx - radiusx,
ty - radiusy,
2 * radiusx + cx, 2 * radiusy + cy);
if(radiusx > 1 && radiusy > 1)
{
gdk_draw_rectangle (cp_tool->core->win, cp_tool->core->gc, 0,
tx - radiusx + 2,
ty - radiusy + 2,
2 * radiusx + cx - 4, 2 * radiusy + cy - 4);
}
}
1997-11-25 06:05:25 +08:00
static void
color_picker_info_update (Tool *tool,
gboolean valid)
1997-11-25 06:05:25 +08:00
{
if (!valid)
{
if (GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
gtk_widget_set_sensitive (color_panel->color_panel_widget, FALSE);
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
{
guchar col[3];
if (! GTK_WIDGET_IS_SENSITIVE (color_panel->color_panel_widget))
gtk_widget_set_sensitive (color_panel->color_panel_widget, TRUE);
1997-11-25 06:05:25 +08:00
switch (sample_type)
{
case RGB_GIMAGE: case RGBA_GIMAGE:
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)
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
1997-11-25 06:05:25 +08:00
else
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]);
col[0] = col_value [RED_PIX];
col[1] = col_value [GREEN_PIX];
col[2] = col_value [BLUE_PIX];
1997-11-25 06:05:25 +08:00
break;
case INDEXED_GIMAGE: case INDEXEDA_GIMAGE:
g_snprintf (index_buf, MAX_INFO_BUF, "%d", col_value [4]);
1997-11-25 06:05:25 +08:00
if (sample_type == INDEXEDA_GIMAGE)
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
1997-11-25 06:05:25 +08:00
else
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]);
col[0] = col_value [RED_PIX];
col[1] = col_value [GREEN_PIX];
col[2] = col_value [BLUE_PIX];
1997-11-25 06:05:25 +08:00
break;
case GRAY_GIMAGE: case GRAYA_GIMAGE:
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)
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
1997-11-25 06:05:25 +08:00
else
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]);
col[0] = col_value [GRAY_PIX];
col[1] = col_value [GRAY_PIX];
col[2] = col_value [GRAY_PIX];
1997-11-25 06:05:25 +08:00
break;
}
color_panel_set_color (color_panel, col);
1997-11-25 06:05:25 +08:00
}
info_dialog_update (color_picker_info);
info_dialog_popup (color_picker_info);
}
static void
color_picker_info_window_close_callback (GtkWidget *widget,
gpointer client_data)
{
info_dialog_popdown ((InfoDialog *) client_data);
}
1997-11-25 06:05:25 +08:00
Tool *
tools_new_color_picker ()
{
Tool * tool;
ColorPickerTool * private;
1997-11-25 06:05:25 +08:00
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
/* The tool options */
1997-11-25 06:05:25 +08:00
if (! color_picker_options)
app/airbrush.c app/bezier_select.c app/blend.c app/brightness_contrast.c 1999-04-12 Michael Natterer <mitschel@cs.tu-berlin.de> * app/airbrush.c * app/bezier_select.c * app/blend.c * app/brightness_contrast.c * app/bucket_fill.c * app/by_color_select.c * app/clone.c * app/color_balance.c * app/color_picker.c * app/convolve.c * app/crop.c * app/curves.c * app/ellipse_select.c * app/eraser.c * app/flip_tool.c * app/free_select.c * app/fuzzy_select.c * app/histogram_tool.c * app/hue_saturation.c * app/ink.c * app/iscissors.c * app/levels.c * app/magnify.c * app/move.c * app/paintbrush.c * app/pencil.c * app/posterize.c * app/rect_select.[ch] * app/text_tool.c * app/threshold.c * app/transform_tool.c * app/tools.[ch] * app/toolsF.h: again: all tools :( * app/Makefile.am * app/tool_options.[ch] * app/selection_options.h * app/tool_options_ui.h: new files. Ok, this time it's general enough for future extensions: - The tool options structures are organized like the gtk object system to allow derived tool options. - Renamed all create and reset functions to *_options_new() and *_options_reset() to reflect this. - Changed tools_register() again. Now it takes just a pointer to a ToolOptions structure. - Moved almost the entire tool options gui code to tool_options.c. - Visually separated the common selection options from the tool-specific ones. I'd like to do the same with opacity/paint mode in all paint tool options but I think this needs some more discussion. * app/histogram_tool.c: changed packing boxes, label alignments. * app/paintbrush.c: some more sensitive settings. The gradient feature can now be toggled with a button. Hopefully didn't break anything.
1999-04-13 01:55:06 +08:00
{
color_picker_options = color_picker_options_new ();
tools_register (COLOR_PICKER, (ToolOptions *) color_picker_options);
}
1997-11-25 06:05:25 +08:00
tool = tools_new_tool (COLOR_PICKER);
private = g_new (ColorPickerTool, 1);
private->core = draw_core_new (colorpicker_draw);
tool->preserve = FALSE; /* Don't preserve on drawable change */
1997-11-25 06:05:25 +08:00
tool->private = (void *) private;
tool->button_press_func = color_picker_button_press;
1997-11-25 06:05:25 +08:00
tool->button_release_func = color_picker_button_release;
tool->motion_func = color_picker_motion;
tool->cursor_update_func = color_picker_cursor_update;
tool->control_func = color_picker_control;
1997-11-25 06:05:25 +08:00
return tool;
}
void
tools_free_color_picker (Tool *tool)
{
ColorPickerTool * cp_tool;
cp_tool = (ColorPickerTool *) tool->private;
if (tool->state == ACTIVE)
draw_core_stop (cp_tool->core, tool);
draw_core_free (cp_tool->core);
1997-11-25 06:05:25 +08:00
if (color_picker_info)
{
info_dialog_free (color_picker_info);
color_picker_info = NULL;
1999-08-24 10:55:59 +08:00
color_panel_free (color_panel);
color_panel = NULL;
1997-11-25 06:05:25 +08:00
}
namespace cleanups. 1999-06-21 Michael Natterer <mitschel@cs.tu-berlin.de> * app/context_manager.c: namespace cleanups. * app/commands.[ch] * app/menus.c: moved the "Toggle Selection" menu entry to "View", sprinkled some separators and made the layers/channels/paths popup menus consistent with Tigert's last ops buttons change. * app/fileops.c * app/plug_in.c: check for gdisplay_active() returning NULL in some more places. * app/[all tool related files]: - Turned the ToolAction and ToolState #define's into typedef'ed enums, so the compiler can do some more sanity checking. - Removed one more unused global variable "active_tool_layer". - Removed some #include's from tools.c. - Standardized the individual tools' structure names. - Moved showing/hiding the tool options to separate functions. - Stuff... * app/commands.c * app/disp_callbacks.c * app/gdisplay.c * app/tools.c: fixed the segfaults which happened when the image of one of the tools which have dialogs (levels/posterize/...) was deleted. My approach was to do stricter sanity checking and to set some gdisplay pointers correctly where appropriate, so I can't tell exactly where the bug was. The curves tool now(??) updates on every _second_ display change only, which is really obscure. Finding/changing the display to operate on should definitely be done by connecting to the user context's "display_changed" signal. * app/gimpset.c: emit the "remove" signal _after_ removing the pointer from the set. If this was not a bug but a feature, please let me know, we'll need two signals then.
1999-06-22 06:12:07 +08:00
g_free (cp_tool);
1997-11-25 06:05:25 +08:00
}