mirror of https://github.com/GNOME/gimp.git
app/core/Makefile.am new files.
2001-12-12 Michael Natterer <mitch@gimp.org> * app/core/Makefile.am * app/core/gimpimage-pick-color.[ch]: new files. gimp_image_pick_color() doesn't set the FG or BG color and doesn't touch the current palettte. * app/tools/gimpcolorpickertool.[ch]: removed the actual picking code, set the user_context's FG or BG color here. * app/gui/palette-editor.[ch]: s/palette_set_active_color/palette_editor_update_color/, don't set the FG and BG color here. The function is still #if 0'ed. * app/gui/toolbox.c: fixed WM resize hints in toolbox_style_set(), code cleanup. * app/tools/gimppainttool.[ch]: some cleanup before chopping. * app/tools/gimpsmudgetool.c: changed accordingly. * tools/pdbgen/pdb/misc_tools.pdb: removed the possibility to set the FG or BG color or add the picked color to the active palette bacause it doesn't belong here. Palette PDB wrappers are on the TODO anyway. * app/pdb/misc_tools_cmds.c * libgimp/gimpmisctools_pdb.[ch]: regenerated. * plug-ins/perl/examples/image_tile * plug-ins/perl/examples/logulator * plug-ins/script-fu/scripts/hsv-graph.scm * plug-ins/script-fu/scripts/title-header.scm: changed accordingly.
This commit is contained in:
parent
30804a2df6
commit
1bc1419e8f
35
ChangeLog
35
ChangeLog
|
@ -1,3 +1,38 @@
|
|||
2001-12-12 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/gimpimage-pick-color.[ch]: new files.
|
||||
|
||||
gimp_image_pick_color() doesn't set the FG or BG color and doesn't
|
||||
touch the current palettte.
|
||||
|
||||
* app/tools/gimpcolorpickertool.[ch]: removed the actual picking
|
||||
code, set the user_context's FG or BG color here.
|
||||
|
||||
* app/gui/palette-editor.[ch]:
|
||||
s/palette_set_active_color/palette_editor_update_color/, don't set
|
||||
the FG and BG color here. The function is still #if 0'ed.
|
||||
|
||||
* app/gui/toolbox.c: fixed WM resize hints in toolbox_style_set(),
|
||||
code cleanup.
|
||||
|
||||
* app/tools/gimppainttool.[ch]: some cleanup before chopping.
|
||||
|
||||
* app/tools/gimpsmudgetool.c: changed accordingly.
|
||||
|
||||
* tools/pdbgen/pdb/misc_tools.pdb: removed the possibility to set
|
||||
the FG or BG color or add the picked color to the active palette
|
||||
bacause it doesn't belong here. Palette PDB wrappers are on the
|
||||
TODO anyway.
|
||||
|
||||
* app/pdb/misc_tools_cmds.c
|
||||
* libgimp/gimpmisctools_pdb.[ch]: regenerated.
|
||||
|
||||
* plug-ins/perl/examples/image_tile
|
||||
* plug-ins/perl/examples/logulator
|
||||
* plug-ins/script-fu/scripts/hsv-graph.scm
|
||||
* plug-ins/script-fu/scripts/title-header.scm: changed accordingly.
|
||||
|
||||
2001-12-12 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* docs/Wilber_Construction_Kit.xcf.gz: new version with additional
|
||||
|
|
|
@ -96,6 +96,8 @@ libappcore_a_sources = @STRIP_BEGIN@ \
|
|||
gimpimage-merge.h \
|
||||
gimpimage-new.c \
|
||||
gimpimage-new.h \
|
||||
gimpimage-pick-color.c \
|
||||
gimpimage-pick-color.h \
|
||||
gimpimage-projection.c \
|
||||
gimpimage-projection.h \
|
||||
gimpimage-qmask.c \
|
||||
|
|
|
@ -18,560 +18,74 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
#include "gui/gui-types.h"
|
||||
#include "core-types.h"
|
||||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-projection.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "gui/info-dialog.h"
|
||||
#include "gui/palette-editor.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "gimpdrawtool.h"
|
||||
#include "gimpcolorpickertool.h"
|
||||
#include "tool_manager.h"
|
||||
#include "tool_options.h"
|
||||
|
||||
#include "gimprc.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
/* maximum information buffer size */
|
||||
#define MAX_INFO_BUF 8
|
||||
typedef guchar * (* GetColorFunc) (GimpObject *object,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
/* the color picker structures */
|
||||
|
||||
typedef struct _GimpColorPickerToolOptions GimpColorPickerToolOptions;
|
||||
|
||||
struct _GimpColorPickerToolOptions
|
||||
gboolean
|
||||
gimp_image_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gboolean sample_merged,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpRGB *color,
|
||||
GimpImageType *sample_type,
|
||||
gint *color_index)
|
||||
{
|
||||
GimpToolOptions tool_options;
|
||||
|
||||
gboolean sample_merged;
|
||||
gboolean sample_merged_d;
|
||||
GtkWidget *sample_merged_w;
|
||||
|
||||
gboolean sample_average;
|
||||
gboolean sample_average_d;
|
||||
GtkWidget *sample_average_w;
|
||||
|
||||
gdouble average_radius;
|
||||
gdouble average_radius_d;
|
||||
GtkObject *average_radius_w;
|
||||
|
||||
gboolean update_active;
|
||||
gboolean update_active_d;
|
||||
GtkWidget *update_active_w;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
|
||||
static void gimp_color_picker_tool_init (GimpColorPickerTool *color_picker_tool);
|
||||
|
||||
static void gimp_color_picker_tool_finalize (GObject *object);
|
||||
|
||||
static void gimp_color_picker_tool_control (GimpTool *tool,
|
||||
ToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_color_picker_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_color_picker_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_color_picker_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_color_picker_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_color_picker_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static GimpToolOptions * gimp_color_picker_tool_options_new (GimpToolInfo *tool_info);
|
||||
static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options);
|
||||
|
||||
static void gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void gimp_color_picker_tool_info_update (GimpTool *tool,
|
||||
gboolean valid);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/* 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 *gimp_color_picker_tool_info = NULL;
|
||||
static GtkWidget *color_area = 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];
|
||||
|
||||
static GimpDrawToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
void
|
||||
gimp_color_picker_tool_register (Gimp *gimp,
|
||||
GimpToolRegisterCallback callback)
|
||||
{
|
||||
(* callback) (gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL,
|
||||
gimp_color_picker_tool_options_new,
|
||||
FALSE,
|
||||
"gimp:color_picker_tool",
|
||||
_("Color Picker"),
|
||||
_("Pick colors from the image"),
|
||||
N_("/Tools/Color Picker"), "<shift>O",
|
||||
NULL, "tools/color_picker.html",
|
||||
GIMP_STOCK_TOOL_COLOR_PICKER);
|
||||
}
|
||||
|
||||
GtkType
|
||||
gimp_color_picker_tool_get_type (void)
|
||||
{
|
||||
static GtkType tool_type = 0;
|
||||
|
||||
if (! tool_type)
|
||||
{
|
||||
static const GTypeInfo tool_info =
|
||||
{
|
||||
sizeof (GimpColorPickerToolClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_color_picker_tool_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpColorPickerTool),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_color_picker_tool_init,
|
||||
};
|
||||
|
||||
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
||||
"GimpColorPickerTool",
|
||||
&tool_info, 0);
|
||||
}
|
||||
|
||||
return tool_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_color_picker_tool_finalize;
|
||||
|
||||
tool_class->control = gimp_color_picker_tool_control;
|
||||
tool_class->button_press = gimp_color_picker_tool_button_press;
|
||||
tool_class->button_release = gimp_color_picker_tool_button_release;
|
||||
tool_class->motion = gimp_color_picker_tool_motion;
|
||||
tool_class->cursor_update = gimp_color_picker_tool_cursor_update;
|
||||
|
||||
draw_class->draw = gimp_color_picker_tool_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_init (GimpColorPickerTool *color_picker_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
tool = GIMP_TOOL (color_picker_tool);
|
||||
|
||||
tool->tool_cursor = GIMP_COLOR_PICKER_TOOL_CURSOR;
|
||||
|
||||
tool->preserve = FALSE; /* Don't preserve on drawable change */
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_finalize (GObject *object)
|
||||
{
|
||||
if (gimp_color_picker_tool_info)
|
||||
{
|
||||
info_dialog_free (gimp_color_picker_tool_info);
|
||||
gimp_color_picker_tool_info = NULL;
|
||||
|
||||
color_area = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_control (GimpTool *tool,
|
||||
ToolAction action,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE :
|
||||
break;
|
||||
|
||||
case RESUME :
|
||||
break;
|
||||
|
||||
case HALT :
|
||||
info_dialog_popdown (gimp_color_picker_tool_info);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (GIMP_TOOL_CLASS (parent_class)->control)
|
||||
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpColorPickerTool *cp_tool;
|
||||
GimpColorPickerToolOptions *options;
|
||||
GimpDisplayShell *shell;
|
||||
gint off_x, off_y;
|
||||
|
||||
cp_tool = GIMP_COLOR_PICKER_TOOL (tool);
|
||||
|
||||
options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
/* Make the tool active and set it's gdisplay & drawable */
|
||||
tool->gdisp = gdisp;
|
||||
tool->drawable = gimp_image_active_drawable (gdisp->gimage);
|
||||
tool->state = ACTIVE;
|
||||
|
||||
/* create the info dialog if it doesn't exist */
|
||||
if (! gimp_color_picker_tool_info)
|
||||
{
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *frame;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_color_picker_tool_info = info_dialog_new (_("Color Picker"),
|
||||
tool_manager_help_func,
|
||||
NULL);
|
||||
|
||||
/* if the gdisplay is for a color image, the dialog must have RGB */
|
||||
switch (gimp_drawable_type (tool->drawable))
|
||||
{
|
||||
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Red:"), red_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Green:"), green_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Blue:"), blue_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Alpha:"), alpha_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Hex Triplet:"), hex_buf);
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Index:"), index_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Red:"), red_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Green:"), green_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Blue:"), blue_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Alpha:"), alpha_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Hex Triplet"), hex_buf);
|
||||
break;
|
||||
|
||||
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Intensity:"), gray_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Alpha:"), alpha_buf);
|
||||
info_dialog_add_label (gimp_color_picker_tool_info, _("Hex Triplet:"), hex_buf);
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
}
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (gimp_color_picker_tool_info->vbox), hbox,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
gtk_widget_reparent (gimp_color_picker_tool_info->info_table, hbox);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
||||
|
||||
gimp_rgba_set (&color, 0.0, 0.0, 0.0, 0.0);
|
||||
color_area =
|
||||
gimp_color_area_new (&color,
|
||||
gimp_drawable_has_alpha (tool->drawable) ?
|
||||
GIMP_COLOR_AREA_LARGE_CHECKS :
|
||||
GIMP_COLOR_AREA_FLAT,
|
||||
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
|
||||
gtk_widget_set_usize (color_area, 48, 64);
|
||||
gtk_drag_dest_unset (color_area);
|
||||
gtk_container_add (GTK_CONTAINER (frame), color_area);
|
||||
gtk_widget_show (color_area);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
/* create the action area */
|
||||
gimp_dialog_create_action_area
|
||||
(GIMP_DIALOG (gimp_color_picker_tool_info->shell),
|
||||
|
||||
GTK_STOCK_CLOSE, gimp_color_picker_tool_info_window_close_callback,
|
||||
gimp_color_picker_tool_info, NULL, NULL, TRUE, FALSE,
|
||||
|
||||
NULL);
|
||||
}
|
||||
|
||||
/* Keep the coordinates of the target */
|
||||
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
||||
&off_x, &off_y);
|
||||
|
||||
cp_tool->centerx = coords->x - off_x;
|
||||
cp_tool->centery = coords->y - off_y;
|
||||
|
||||
gdk_pointer_grab (shell->canvas->window, FALSE,
|
||||
GDK_POINTER_MOTION_HINT_MASK |
|
||||
GDK_BUTTON1_MOTION_MASK |
|
||||
GDK_BUTTON_RELEASE_MASK,
|
||||
NULL, NULL, time);
|
||||
|
||||
/* if the shift key is down, create a new color.
|
||||
* otherwise, modify the current color.
|
||||
*/
|
||||
if (state & GDK_SHIFT_MASK)
|
||||
{
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
COLOR_NEW));
|
||||
update_type = COLOR_UPDATE_NEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
COLOR_UPDATE));
|
||||
update_type = COLOR_UPDATE;
|
||||
}
|
||||
|
||||
/* Start drawing the colorpicker tool */
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), shell->canvas->window);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_button_release (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpColorPickerTool *cp_tool;
|
||||
GimpColorPickerToolOptions *options;
|
||||
|
||||
cp_tool = GIMP_COLOR_PICKER_TOOL(tool);
|
||||
|
||||
options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options;
|
||||
|
||||
gdk_pointer_ungrab (time);
|
||||
gdk_flush ();
|
||||
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (cp_tool));
|
||||
|
||||
tool->state = INACTIVE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpColorPickerTool *cp_tool;
|
||||
GimpColorPickerToolOptions *options;
|
||||
gint off_x, off_y;
|
||||
|
||||
cp_tool = GIMP_COLOR_PICKER_TOOL (tool);
|
||||
|
||||
options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
gimp_drawable_offsets (gimp_image_active_drawable (gdisp->gimage),
|
||||
&off_x, &off_y);
|
||||
|
||||
cp_tool->centerx = coords->x - off_x;
|
||||
cp_tool->centery = coords->y - off_y;
|
||||
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpDisplayShell *shell;
|
||||
|
||||
shell = GIMP_DISPLAY_SHELL (gdisp->shell);
|
||||
|
||||
/* We used to use the following code here:
|
||||
*
|
||||
* if (gimp_image_pick_correlate_layer (gdisp->gimage, x, y)) { ... }
|
||||
*/
|
||||
|
||||
if (gdisp->gimage &&
|
||||
coords->x > 0 &&
|
||||
coords->x < gdisp->gimage->width &&
|
||||
coords->y > 0 &&
|
||||
coords->y < gdisp->gimage->height)
|
||||
{
|
||||
gimp_display_shell_install_tool_cursor (shell,
|
||||
GIMP_COLOR_PICKER_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_display_shell_install_tool_cursor (shell,
|
||||
GIMP_BAD_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef guchar * (*GetColorFunc) (GimpObject *object,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
guchar *color;
|
||||
gint offx, offy;
|
||||
gint has_alpha;
|
||||
gint is_indexed;
|
||||
GetColorFunc get_color_func;
|
||||
GimpObject *get_color_obj;
|
||||
|
||||
|
||||
if (!drawable && !sample_merged)
|
||||
return FALSE;
|
||||
GimpRGB rgb_color;
|
||||
guchar *col;
|
||||
GimpImageType my_sample_type;
|
||||
gint my_color_index;
|
||||
gboolean has_alpha;
|
||||
gboolean is_indexed;
|
||||
GetColorFunc get_color_func;
|
||||
GimpObject *get_color_obj;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (sample_merged || GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||
g_return_val_if_fail (! drawable || gimp_drawable_gimage (drawable) == gimage,
|
||||
FALSE);
|
||||
|
||||
if (! sample_merged)
|
||||
{
|
||||
gimp_drawable_offsets (drawable, &offx, &offy);
|
||||
x -= offx;
|
||||
y -= offy;
|
||||
gint off_x, off_y;
|
||||
|
||||
sample_type = gimp_drawable_type (drawable);
|
||||
is_indexed = gimp_drawable_is_indexed (drawable);
|
||||
gimp_drawable_offsets (drawable, &off_x, &off_y);
|
||||
x -= off_x;
|
||||
y -= off_y;
|
||||
|
||||
my_sample_type = gimp_drawable_type (drawable);
|
||||
is_indexed = gimp_drawable_is_indexed (drawable);
|
||||
|
||||
get_color_func = (GetColorFunc) gimp_drawable_get_color_at;
|
||||
get_color_obj = GIMP_OBJECT (drawable);
|
||||
get_color_obj = GIMP_OBJECT (drawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
sample_type = gimp_image_projection_type (gimage);
|
||||
is_indexed = FALSE;
|
||||
my_sample_type = gimp_image_projection_type (gimage);
|
||||
is_indexed = FALSE;
|
||||
|
||||
get_color_func = (GetColorFunc) gimp_image_projection_get_color_at;
|
||||
get_color_obj = GIMP_OBJECT (gimage);
|
||||
get_color_obj = GIMP_OBJECT (gimage);
|
||||
}
|
||||
|
||||
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (sample_type);
|
||||
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (my_sample_type);
|
||||
|
||||
if (!(color = (* get_color_func) (get_color_obj, x, y)))
|
||||
if (! (col = (* get_color_func) (get_color_obj, x, y)))
|
||||
return FALSE;
|
||||
|
||||
if (sample_average)
|
||||
|
@ -579,315 +93,61 @@ pick_color_do (GimpImage *gimage,
|
|||
gint i, j;
|
||||
gint count = 0;
|
||||
gint color_avg[4] = { 0, 0, 0, 0 };
|
||||
guchar *tmp_color;
|
||||
guchar *tmp_col;
|
||||
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)))
|
||||
if ((tmp_col = (* get_color_func) (get_color_obj, i, j)))
|
||||
{
|
||||
count++;
|
||||
|
||||
color_avg[RED_PIX] += tmp_color[RED_PIX];
|
||||
color_avg[GREEN_PIX] += tmp_color[GREEN_PIX];
|
||||
color_avg[BLUE_PIX] += tmp_color[BLUE_PIX];
|
||||
color_avg[RED_PIX] += tmp_col[RED_PIX];
|
||||
color_avg[GREEN_PIX] += tmp_col[GREEN_PIX];
|
||||
color_avg[BLUE_PIX] += tmp_col[BLUE_PIX];
|
||||
if (has_alpha)
|
||||
color_avg[ALPHA_PIX] += tmp_color[ALPHA_PIX];
|
||||
color_avg[ALPHA_PIX] += tmp_col[ALPHA_PIX];
|
||||
|
||||
g_free (tmp_color);
|
||||
g_free (tmp_col);
|
||||
}
|
||||
|
||||
color[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
||||
color[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
|
||||
color[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
||||
col[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
||||
col[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
|
||||
col[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
||||
|
||||
if (has_alpha)
|
||||
color[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
|
||||
is_indexed = FALSE;
|
||||
}
|
||||
|
||||
col_value[RED_PIX] = color[RED_PIX];
|
||||
col_value[GREEN_PIX] = color[GREEN_PIX];
|
||||
col_value[BLUE_PIX] = color[BLUE_PIX];
|
||||
if (has_alpha)
|
||||
col_value[ALPHA_PIX] = color[ALPHA_PIX];
|
||||
if (is_indexed)
|
||||
col_value[4] = color[4];
|
||||
my_color_index = col[4];
|
||||
else
|
||||
my_color_index = -1;
|
||||
|
||||
if (update_active)
|
||||
palette_set_active_color (col_value [RED_PIX],
|
||||
col_value [GREEN_PIX],
|
||||
col_value [BLUE_PIX],
|
||||
final);
|
||||
if (has_alpha)
|
||||
gimp_rgba_set_uchar (&rgb_color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX],
|
||||
col[ALPHA_PIX]);
|
||||
else
|
||||
gimp_rgb_set_uchar (&rgb_color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX]);
|
||||
|
||||
g_free (color);
|
||||
g_free (col);
|
||||
|
||||
if (color)
|
||||
*color = rgb_color;
|
||||
|
||||
if (sample_type)
|
||||
*sample_type = my_sample_type;
|
||||
|
||||
if (color_index)
|
||||
*color_index = my_color_index;
|
||||
|
||||
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
|
||||
gimp_color_picker_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpColorPickerTool *cp_tool;
|
||||
GimpColorPickerToolOptions *options;
|
||||
GimpTool *tool;
|
||||
|
||||
cp_tool = GIMP_COLOR_PICKER_TOOL (draw_tool);
|
||||
tool = GIMP_TOOL (draw_tool);
|
||||
|
||||
options = (GimpColorPickerToolOptions *) tool->tool_info->tool_options;
|
||||
|
||||
if (options->sample_average)
|
||||
{
|
||||
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||
FALSE,
|
||||
cp_tool->centerx - options->average_radius,
|
||||
cp_tool->centery - options->average_radius,
|
||||
2 * options->average_radius + 1,
|
||||
2 * options->average_radius + 1,
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_info_update (GimpTool *tool,
|
||||
gboolean valid)
|
||||
{
|
||||
if (!valid)
|
||||
{
|
||||
if (GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, 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"));
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpRGB color;
|
||||
guchar r = 0;
|
||||
guchar g = 0;
|
||||
guchar b = 0;
|
||||
guchar a = 0;
|
||||
|
||||
if (! GTK_WIDGET_IS_SENSITIVE (color_area))
|
||||
gtk_widget_set_sensitive (color_area, TRUE);
|
||||
|
||||
switch (sample_type)
|
||||
{
|
||||
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
|
||||
g_snprintf (index_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]);
|
||||
if (sample_type == GIMP_RGBA_IMAGE)
|
||||
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
|
||||
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]);
|
||||
|
||||
r = col_value [RED_PIX];
|
||||
g = col_value [GREEN_PIX];
|
||||
b = col_value [BLUE_PIX];
|
||||
if (sample_type == GIMP_RGBA_IMAGE)
|
||||
a = col_value [ALPHA_PIX];
|
||||
break;
|
||||
|
||||
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
|
||||
g_snprintf (index_buf, MAX_INFO_BUF, "%d", col_value [4]);
|
||||
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]);
|
||||
if (sample_type == GIMP_INDEXEDA_IMAGE)
|
||||
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
|
||||
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]);
|
||||
|
||||
r = col_value [RED_PIX];
|
||||
g = col_value [GREEN_PIX];
|
||||
b = col_value [BLUE_PIX];
|
||||
if (sample_type == GIMP_INDEXEDA_IMAGE)
|
||||
a = col_value [ALPHA_PIX];
|
||||
break;
|
||||
|
||||
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
|
||||
g_snprintf (gray_buf, MAX_INFO_BUF, "%d", col_value [GRAY_PIX]);
|
||||
if (sample_type == GIMP_GRAYA_IMAGE)
|
||||
g_snprintf (alpha_buf, MAX_INFO_BUF, "%d", col_value [ALPHA_PIX]);
|
||||
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]);
|
||||
|
||||
r = col_value [GRAY_PIX];
|
||||
g = col_value [GRAY_PIX];
|
||||
b = col_value [GRAY_PIX];
|
||||
if (sample_type == GIMP_GRAYA_IMAGE)
|
||||
a = col_value [ALPHA_PIX];
|
||||
break;
|
||||
}
|
||||
|
||||
gimp_rgba_set_uchar (&color, r, g, b, a);
|
||||
|
||||
gimp_color_area_set_color (GIMP_COLOR_AREA (color_area), &color);
|
||||
}
|
||||
|
||||
info_dialog_update (gimp_color_picker_tool_info);
|
||||
info_dialog_popup (gimp_color_picker_tool_info);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_info_window_close_callback (GtkWidget *widget,
|
||||
gpointer client_data)
|
||||
{
|
||||
info_dialog_popdown ((InfoDialog *) client_data);
|
||||
}
|
||||
|
||||
|
||||
/* tool options stuff */
|
||||
|
||||
static GimpToolOptions *
|
||||
gimp_color_picker_tool_options_new (GimpToolInfo *tool_info)
|
||||
{
|
||||
GimpColorPickerToolOptions *options;
|
||||
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *abox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *scale;
|
||||
|
||||
options = g_new0 (GimpColorPickerToolOptions, 1);
|
||||
|
||||
tool_options_init ((GimpToolOptions *) options, tool_info);
|
||||
|
||||
((GimpToolOptions *) options)->reset_func = gimp_color_picker_tool_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;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = options->tool_options.main_vbox;
|
||||
|
||||
/* 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);
|
||||
g_signal_connect (G_OBJECT (options->sample_merged_w), "toggled",
|
||||
G_CALLBACK (gimp_toggle_button_update),
|
||||
&options->sample_merged);
|
||||
gtk_widget_show (options->sample_merged_w);
|
||||
|
||||
/* the sample average options */
|
||||
table = gtk_table_new (2, 2, FALSE);
|
||||
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);
|
||||
g_signal_connect (G_OBJECT (options->sample_average_w), "toggled",
|
||||
G_CALLBACK (gimp_toggle_button_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);
|
||||
g_object_set_data (G_OBJECT (options->sample_average_w), "set_sensitive",
|
||||
scale);
|
||||
gtk_widget_set_sensitive (label, options->sample_average_d);
|
||||
g_object_set_data (G_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);
|
||||
g_signal_connect (G_OBJECT (options->average_radius_w), "value_changed",
|
||||
G_CALLBACK (gimp_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);
|
||||
g_signal_connect (G_OBJECT (options->update_active_w), "toggled",
|
||||
G_CALLBACK (gimp_toggle_button_update),
|
||||
&options->update_active);
|
||||
gtk_widget_show (options->update_active_w);
|
||||
|
||||
return (GimpToolOptions *) options;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options)
|
||||
{
|
||||
GimpColorPickerToolOptions *options;
|
||||
|
||||
options = (GimpColorPickerToolOptions *) tool_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);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_IMAGE_PICK_COLOR_H__
|
||||
#define __GIMP_IMAGE_PICK_COLOR_H__
|
||||
|
||||
|
||||
gboolean gimp_image_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gboolean sample_merged,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpRGB *color,
|
||||
GimpImageType *sample_type,
|
||||
gint *color_index);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */
|
|
@ -162,40 +162,32 @@ static GtkTargetEntry color_palette_target_table[] =
|
|||
/* called from color_picker.h *********************************************/
|
||||
|
||||
void
|
||||
palette_set_active_color (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint state)
|
||||
palette_editor_update_color (GimpContext *context,
|
||||
const GimpRGB *color,
|
||||
GimpUpdateColorState state)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: palette_set_active_color()
|
||||
#endif
|
||||
#if 0
|
||||
GimpPalette *palette;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
(guchar) r,
|
||||
(guchar) g,
|
||||
(guchar) b,
|
||||
255);
|
||||
|
||||
if (top_level_edit_palette)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
|
||||
palette = gimp_context_get_palette (top_level_edit_palette->context);
|
||||
|
||||
if (palette)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_NEW:
|
||||
case GIMP_UPDATE_COLOR_STATE_NEW:
|
||||
top_level_edit_palette->color = gimp_palette_add_entry (palette,
|
||||
NULL,
|
||||
&color);
|
||||
color);
|
||||
break;
|
||||
|
||||
case COLOR_UPDATE_NEW:
|
||||
top_level_edit_palette->color->color = color;
|
||||
case GIMP_UPDATE_COLOR_STATE_UPDATE_NEW:
|
||||
top_level_edit_palette->color->color = *color;
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (palette));
|
||||
break;
|
||||
|
@ -205,11 +197,6 @@ palette_set_active_color (gint r,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gimp_context_set_foreground (gimp_get_user_context (the_gimp), &color);
|
||||
else if (active_color == BACKGROUND)
|
||||
gimp_context_set_background (gimp_get_user_context (the_gimp), &color);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -20,25 +20,26 @@
|
|||
#define __PALETTE_EDITOR_H__
|
||||
|
||||
|
||||
/* The states for updating a color in the palette via palette_set_* calls */
|
||||
#define COLOR_NEW 0
|
||||
#define COLOR_UPDATE_NEW 1
|
||||
#define COLOR_UPDATE 2
|
||||
typedef enum
|
||||
{
|
||||
GIMP_UPDATE_COLOR_STATE_NEW,
|
||||
GIMP_UPDATE_COLOR_STATE_UPDATE_NEW,
|
||||
GIMP_UPDATE_COLOR_STATE_UPDATE
|
||||
} GimpUpdateColorState;
|
||||
|
||||
|
||||
typedef struct _PaletteEditor PaletteEditor;
|
||||
|
||||
|
||||
PaletteEditor * palette_editor_new (Gimp *gimp);
|
||||
PaletteEditor * palette_editor_new (Gimp *gimp);
|
||||
|
||||
void palette_editor_set_palette (PaletteEditor *palette_editor,
|
||||
GimpPalette *palette);
|
||||
void palette_editor_free (PaletteEditor *palette_editor);
|
||||
void palette_editor_set_palette (PaletteEditor *palette_editor,
|
||||
GimpPalette *palette);
|
||||
void palette_editor_free (PaletteEditor *palette_editor);
|
||||
|
||||
void palette_set_active_color (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint state);
|
||||
void palette_editor_update_color (GimpContext *context,
|
||||
const GimpRGB *color,
|
||||
GimpUpdateColorState state);
|
||||
|
||||
|
||||
#endif /* __PALETTE_EDITOR_H__ */
|
||||
|
|
|
@ -61,40 +61,48 @@
|
|||
#include "pixmaps/swap.xpm"
|
||||
|
||||
|
||||
/* local functions */
|
||||
static void toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gint toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
gpointer data);
|
||||
/* local function prototypes */
|
||||
|
||||
static gint toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gint toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void toolbox_create_tools (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
static void toolbox_create_color_area (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
static void toolbox_create_indicator_area (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
|
||||
static void toolbox_style_set_callback (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
gpointer data);
|
||||
static void toolbox_drop_drawable (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_tool (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_buffer (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data);
|
||||
|
||||
static void toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gboolean toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
gpointer data);
|
||||
|
||||
static gboolean toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gboolean toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void toolbox_style_set (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
Gimp *gimp);
|
||||
|
||||
static void toolbox_drop_drawable (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_tool (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_buffer (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
|
||||
#define COLUMNS 3
|
||||
#define ROWS 8
|
||||
#define MARGIN 2
|
||||
|
||||
/* local variables */
|
||||
static GtkWidget * toolbox_shell = NULL;
|
||||
static GtkWidget *toolbox_shell = NULL;
|
||||
|
||||
static GtkTargetEntry toolbox_target_table[] =
|
||||
{
|
||||
|
@ -109,204 +117,7 @@ static GtkTargetEntry toolbox_target_table[] =
|
|||
};
|
||||
|
||||
|
||||
static void
|
||||
toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
tool_info = GIMP_TOOL_INFO (data);
|
||||
|
||||
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
||||
"gimp:tool-options-dialog", -1);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
app_exit (FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_devices_check_change (GIMP (data), event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
create_indicator_area (GtkWidget *parent,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
|
||||
|
||||
ind_area = indicator_area_create (context);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
create_color_area (GtkWidget *parent,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *col_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkBitmap *default_mask;
|
||||
GdkPixmap *swap_pixmap;
|
||||
GdkBitmap *swap_mask;
|
||||
|
||||
if (! GTK_WIDGET_REALIZED (parent))
|
||||
gtk_widget_realize (parent);
|
||||
|
||||
default_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
|
||||
&default_mask,
|
||||
&parent->style->bg[GTK_STATE_NORMAL],
|
||||
default_xpm);
|
||||
swap_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
|
||||
&swap_mask,
|
||||
&parent->style->bg[GTK_STATE_NORMAL],
|
||||
swap_xpm);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (parent), frame,
|
||||
TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#color_area");
|
||||
|
||||
col_area = color_area_create (context,
|
||||
54, 42,
|
||||
default_pixmap, default_mask,
|
||||
swap_pixmap, swap_mask);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), col_area);
|
||||
gimp_help_set_help_data
|
||||
(col_area,
|
||||
_("Foreground & background colors. The black "
|
||||
"and white squares reset colors. The arrows swap colors. Double "
|
||||
"click to select a color from a colorrequester."), NULL);
|
||||
|
||||
gtk_widget_show (col_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data)
|
||||
{
|
||||
if (tool_info)
|
||||
{
|
||||
GtkWidget *toolbox_button;
|
||||
|
||||
toolbox_button =
|
||||
g_object_get_data (G_OBJECT (tool_info), "toolbox_button");
|
||||
|
||||
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
|
||||
{
|
||||
g_signal_handlers_block_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
|
||||
gtk_widget_activate (toolbox_button);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_tools (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GList *list;
|
||||
GSList *group = NULL;
|
||||
|
||||
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
|
||||
tool_info = (GimpToolInfo *) list->data;
|
||||
|
||||
button = gtk_radio_button_new (group);
|
||||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), "toolbox_button", button);
|
||||
|
||||
image = gtk_image_new_from_stock (tool_info->stock_id,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (toolbox_tool_button_toggled),
|
||||
tool_info);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "button_press_event",
|
||||
G_CALLBACK (toolbox_tool_button_press),
|
||||
tool_info);
|
||||
|
||||
gimp_help_set_help_data (button,
|
||||
tool_info->help,
|
||||
tool_info->help_data);
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_show (wbox);
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
toolbox_create (Gimp *gimp)
|
||||
|
@ -332,8 +143,8 @@ toolbox_create (Gimp *gimp)
|
|||
NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (window), "style_set",
|
||||
G_CALLBACK (toolbox_style_set_callback),
|
||||
NULL);
|
||||
G_CALLBACK (toolbox_style_set),
|
||||
gimp);
|
||||
|
||||
/* We need to know when the current device changes, so we can update
|
||||
* the correct tool - to do this we connect to motion events.
|
||||
|
@ -358,15 +169,14 @@ toolbox_create (Gimp *gimp)
|
|||
gtk_widget_set_extension_events (window, GDK_EXTENSION_EVENTS_CURSOR);
|
||||
}
|
||||
|
||||
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), toolbox_factory->widget,
|
||||
FALSE, TRUE, 0);
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (toolbox_factory->widget);
|
||||
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), toolbox_factory->accel_group);
|
||||
|
@ -384,17 +194,17 @@ toolbox_create (Gimp *gimp)
|
|||
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (wbox);
|
||||
|
||||
create_tools (wbox, context);
|
||||
toolbox_create_tools (wbox, context);
|
||||
|
||||
g_signal_connect_object (G_OBJECT (context), "tool_changed",
|
||||
G_CALLBACK (toolbox_tool_changed),
|
||||
G_OBJECT (wbox),
|
||||
0);
|
||||
|
||||
create_color_area (wbox, context);
|
||||
toolbox_create_color_area (wbox, context);
|
||||
|
||||
if (gimprc.show_indicators)
|
||||
create_indicator_area (wbox, context);
|
||||
toolbox_create_indicator_area (wbox, context);
|
||||
|
||||
gtk_drag_dest_set (window,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
|
@ -420,6 +230,8 @@ toolbox_create (Gimp *gimp)
|
|||
toolbox_drop_buffer,
|
||||
context);
|
||||
|
||||
toolbox_style_set (window, NULL, gimp);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
toolbox_shell = window;
|
||||
|
@ -435,25 +247,270 @@ toolbox_free (Gimp *gimp)
|
|||
gtk_widget_destroy (toolbox_shell);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
toolbox_style_set_callback (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
gpointer data)
|
||||
toolbox_create_tools (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GdkGeometry geometry;
|
||||
GtkStyle *style;
|
||||
GList *list;
|
||||
GSList *group = NULL;
|
||||
|
||||
style = gtk_widget_get_style (window);
|
||||
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
|
||||
geometry.min_width = 2 + 26 + 2 * style->xthickness;
|
||||
geometry.min_height = 80 + 26 + 2 * style->ythickness;
|
||||
geometry.width_inc = 26 + 2 * style->xthickness;
|
||||
geometry.height_inc = 26 + 2 * style->ythickness;
|
||||
tool_info = (GimpToolInfo *) list->data;
|
||||
|
||||
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
||||
NULL,
|
||||
&geometry,
|
||||
GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
|
||||
button = gtk_radio_button_new (group);
|
||||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), "toolbox-button", button);
|
||||
|
||||
image = gtk_image_new_from_stock (tool_info->stock_id,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (toolbox_tool_button_toggled),
|
||||
tool_info);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "button_press_event",
|
||||
G_CALLBACK (toolbox_tool_button_press),
|
||||
tool_info);
|
||||
|
||||
gimp_help_set_help_data (button,
|
||||
tool_info->help,
|
||||
tool_info->help_data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_create_color_area (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *col_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkBitmap *default_mask;
|
||||
GdkPixmap *swap_pixmap;
|
||||
GdkBitmap *swap_mask;
|
||||
|
||||
if (! GTK_WIDGET_REALIZED (wbox))
|
||||
gtk_widget_realize (wbox);
|
||||
|
||||
default_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
|
||||
&default_mask,
|
||||
&wbox->style->bg[GTK_STATE_NORMAL],
|
||||
default_xpm);
|
||||
swap_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
|
||||
&swap_mask,
|
||||
&wbox->style->bg[GTK_STATE_NORMAL],
|
||||
swap_xpm);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (wbox), frame,
|
||||
TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#color_area");
|
||||
|
||||
col_area = color_area_create (context,
|
||||
54, 42,
|
||||
default_pixmap, default_mask,
|
||||
swap_pixmap, swap_mask);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), col_area);
|
||||
gimp_help_set_help_data
|
||||
(col_area,
|
||||
_("Foreground & background colors. The black "
|
||||
"and white squares reset colors. The arrows swap colors. Double "
|
||||
"click to select a color from a colorrequester."), NULL);
|
||||
|
||||
gtk_widget_show (col_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
g_object_set_data (G_OBJECT (wbox), "color-area", frame);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_create_indicator_area (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), frame, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
|
||||
|
||||
ind_area = indicator_area_create (context);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
g_object_set_data (G_OBJECT (wbox), "indicator-area", frame);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data)
|
||||
{
|
||||
if (tool_info)
|
||||
{
|
||||
GtkWidget *toolbox_button;
|
||||
|
||||
toolbox_button =
|
||||
g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
||||
|
||||
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
|
||||
{
|
||||
g_signal_handlers_block_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
|
||||
gtk_widget_activate (toolbox_button);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
tool_info = GIMP_TOOL_INFO (data);
|
||||
|
||||
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
||||
"gimp:tool-options-dialog", -1);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
app_exit (FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_devices_check_change (GIMP (data), event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_style_set (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
Gimp *gimp)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *tool_button;
|
||||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimp->tool_info_list,
|
||||
"gimp:rect_select_tool");
|
||||
tool_button = g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
||||
|
||||
if (tool_button)
|
||||
{
|
||||
GtkWidget *wbox;
|
||||
GtkWidget *widget;
|
||||
GtkRequisition menubar_requisition;
|
||||
GtkRequisition button_requisition;
|
||||
GtkRequisition color_requisition;
|
||||
GtkRequisition indicator_requisition;
|
||||
GdkGeometry geometry;
|
||||
gint border_width;
|
||||
GList *children;
|
||||
|
||||
children =
|
||||
gtk_container_get_children (GTK_CONTAINER (GTK_BIN (window)->child));
|
||||
|
||||
gtk_widget_size_request (g_list_nth_data (children, 0),
|
||||
&menubar_requisition);
|
||||
|
||||
wbox = g_list_nth_data (children, 1);
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
gtk_widget_size_request (tool_button, &button_requisition);
|
||||
|
||||
widget = g_object_get_data (G_OBJECT (wbox), "color-area");
|
||||
gtk_widget_size_request (widget, &color_requisition);
|
||||
|
||||
widget = g_object_get_data (G_OBJECT (wbox), "indicator-area");
|
||||
gtk_widget_size_request (widget, &indicator_requisition);
|
||||
|
||||
border_width =
|
||||
gtk_container_get_border_width (GTK_CONTAINER (GTK_BIN (window)->child));
|
||||
|
||||
geometry.min_width = (2 * border_width +
|
||||
2 * button_requisition.width);
|
||||
geometry.min_height = (2 * border_width +
|
||||
button_requisition.height +
|
||||
menubar_requisition.height +
|
||||
MAX (color_requisition.height,
|
||||
indicator_requisition.height));
|
||||
geometry.width_inc = button_requisition.width;
|
||||
geometry.height_inc = button_requisition.height;
|
||||
|
||||
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
||||
NULL,
|
||||
&geometry,
|
||||
GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -166,7 +166,7 @@ static void gimp_paint_tool_invalidate_cache (GimpBrush *brush,
|
|||
|
||||
|
||||
/* paint buffers utility functions */
|
||||
static void free_paint_buffers (void);
|
||||
static void gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool);
|
||||
|
||||
/* brush pipe utility functions */
|
||||
static void paint_line_pixmap_mask (GimpImage *dest,
|
||||
|
@ -288,7 +288,7 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||
|
||||
case HALT:
|
||||
gimp_paint_tool_paint (paint_tool, drawable, FINISH_PAINT);
|
||||
gimp_paint_tool_cleanup ();
|
||||
gimp_paint_tool_cleanup (paint_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1063,7 +1063,7 @@ gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_paint_tool_cleanup (void)
|
||||
gimp_paint_tool_cleanup (GimpPaintTool *paint_tool)
|
||||
{
|
||||
/* CLEANUP */
|
||||
/* If the undo tiles exist, nuke them */
|
||||
|
@ -1081,7 +1081,7 @@ gimp_paint_tool_cleanup (void)
|
|||
}
|
||||
|
||||
/* Free the temporary buffers if they exist */
|
||||
free_paint_buffers ();
|
||||
gimp_paint_tool_free_buffers (paint_tool);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2084,7 +2084,7 @@ set_canvas_tiles (gint x,
|
|||
|
||||
|
||||
static void
|
||||
free_paint_buffers (void)
|
||||
gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool)
|
||||
{
|
||||
if (orig_buf)
|
||||
temp_buf_free (orig_buf);
|
||||
|
|
|
@ -113,59 +113,57 @@ struct _PaintUndo
|
|||
|
||||
GType gimp_paint_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_paint_tool_paint (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_paint (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
PaintState state);
|
||||
PaintState state);
|
||||
|
||||
void gimp_paint_tool_no_draw (GimpPaintTool *tool);
|
||||
|
||||
int gimp_paint_tool_start (GimpPaintTool *tool,
|
||||
int gimp_paint_tool_start (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_finish (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_cleanup (void);
|
||||
void gimp_paint_tool_cleanup (GimpPaintTool *paint_tool);
|
||||
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
|
||||
GimpGradient *gradient,
|
||||
gdouble gradient_length,
|
||||
GimpRGB *color,
|
||||
GradientPaintMode mode);
|
||||
|
||||
/* paint tool painting functions */
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *paint_tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_PAINT_TOOL_H__ */
|
||||
|
|
|
@ -507,7 +507,7 @@ gimp_smudge_tool_non_gui (GimpDrawable *drawable,
|
|||
|
||||
gimp_paint_tool_finish (paint_tool, drawable);
|
||||
|
||||
gimp_paint_tool_cleanup ();
|
||||
gimp_paint_tool_cleanup (paint_tool);
|
||||
|
||||
gimp_smudge_tool_finish (paint_tool, drawable);
|
||||
|
||||
|
|
|
@ -21,23 +21,21 @@
|
|||
#include "config.h"
|
||||
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbasetypes.h"
|
||||
|
||||
#include "pdb-types.h"
|
||||
#include "tools/tools-types.h"
|
||||
#include "procedural_db.h"
|
||||
|
||||
#include "base/base-enums.h"
|
||||
#include "base/tile-manager.h"
|
||||
#include "core/core-enums.h"
|
||||
#include "core/core-types.h"
|
||||
#include "core/gimpdrawable-blend.h"
|
||||
#include "core/gimpdrawable-bucket-fill.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "tools/gimpcolorpickertool.h"
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
|
@ -364,7 +362,6 @@ color_picker_invoker (Gimp *gimp,
|
|||
gboolean sample_merged;
|
||||
gboolean sample_average;
|
||||
gdouble average_radius;
|
||||
gboolean save_color;
|
||||
GimpRGB color;
|
||||
|
||||
gimage = gimp_image_get_by_ID (gimp, args[0].value.pdb_int);
|
||||
|
@ -385,8 +382,6 @@ color_picker_invoker (Gimp *gimp,
|
|||
if (sample_average && (average_radius <= 0.0))
|
||||
success = FALSE;
|
||||
|
||||
save_color = args[7].value.pdb_int ? TRUE : FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (!sample_merged)
|
||||
|
@ -394,17 +389,15 @@ color_picker_invoker (Gimp *gimp,
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = pick_color (gimage, drawable, (int) x, (int) y,
|
||||
sample_merged, sample_average, average_radius,
|
||||
save_color);
|
||||
if (success)
|
||||
{
|
||||
gimp_rgba_set_uchar (&color,
|
||||
col_value[RED_PIX],
|
||||
col_value[GREEN_PIX],
|
||||
col_value[BLUE_PIX],
|
||||
col_value[ALPHA_PIX]);
|
||||
}
|
||||
success = gimp_image_pick_color (gimage,
|
||||
drawable,
|
||||
sample_merged,
|
||||
(gint) x, (gint) y,
|
||||
sample_average,
|
||||
average_radius,
|
||||
&color,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return_args = procedural_db_return_args (&color_picker_proc, success);
|
||||
|
@ -451,11 +444,6 @@ static ProcArg color_picker_inargs[] =
|
|||
GIMP_PDB_FLOAT,
|
||||
"average_radius",
|
||||
"The radius of pixels to average"
|
||||
},
|
||||
{
|
||||
GIMP_PDB_INT32,
|
||||
"save_color",
|
||||
"Save the color to the active palette"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -477,7 +465,7 @@ static ProcRecord color_picker_proc =
|
|||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996",
|
||||
GIMP_INTERNAL,
|
||||
8,
|
||||
7,
|
||||
color_picker_inargs,
|
||||
1,
|
||||
color_picker_outargs,
|
||||
|
|
|
@ -166,7 +166,7 @@ static void gimp_paint_tool_invalidate_cache (GimpBrush *brush,
|
|||
|
||||
|
||||
/* paint buffers utility functions */
|
||||
static void free_paint_buffers (void);
|
||||
static void gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool);
|
||||
|
||||
/* brush pipe utility functions */
|
||||
static void paint_line_pixmap_mask (GimpImage *dest,
|
||||
|
@ -288,7 +288,7 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||
|
||||
case HALT:
|
||||
gimp_paint_tool_paint (paint_tool, drawable, FINISH_PAINT);
|
||||
gimp_paint_tool_cleanup ();
|
||||
gimp_paint_tool_cleanup (paint_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1063,7 +1063,7 @@ gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_paint_tool_cleanup (void)
|
||||
gimp_paint_tool_cleanup (GimpPaintTool *paint_tool)
|
||||
{
|
||||
/* CLEANUP */
|
||||
/* If the undo tiles exist, nuke them */
|
||||
|
@ -1081,7 +1081,7 @@ gimp_paint_tool_cleanup (void)
|
|||
}
|
||||
|
||||
/* Free the temporary buffers if they exist */
|
||||
free_paint_buffers ();
|
||||
gimp_paint_tool_free_buffers (paint_tool);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2084,7 +2084,7 @@ set_canvas_tiles (gint x,
|
|||
|
||||
|
||||
static void
|
||||
free_paint_buffers (void)
|
||||
gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool)
|
||||
{
|
||||
if (orig_buf)
|
||||
temp_buf_free (orig_buf);
|
||||
|
|
|
@ -113,59 +113,57 @@ struct _PaintUndo
|
|||
|
||||
GType gimp_paint_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_paint_tool_paint (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_paint (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
PaintState state);
|
||||
PaintState state);
|
||||
|
||||
void gimp_paint_tool_no_draw (GimpPaintTool *tool);
|
||||
|
||||
int gimp_paint_tool_start (GimpPaintTool *tool,
|
||||
int gimp_paint_tool_start (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_finish (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_cleanup (void);
|
||||
void gimp_paint_tool_cleanup (GimpPaintTool *paint_tool);
|
||||
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
|
||||
GimpGradient *gradient,
|
||||
gdouble gradient_length,
|
||||
GimpRGB *color,
|
||||
GradientPaintMode mode);
|
||||
|
||||
/* paint tool painting functions */
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *paint_tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_PAINT_TOOL_H__ */
|
||||
|
|
|
@ -26,11 +26,14 @@
|
|||
#include "tools-types.h"
|
||||
#include "gui/gui-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-projection.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "gui/color-area.h"
|
||||
#include "gui/info-dialog.h"
|
||||
#include "gui/palette-editor.h"
|
||||
|
||||
|
@ -109,6 +112,17 @@ static void gimp_color_picker_tool_cursor_update (GimpTool *tool,
|
|||
|
||||
static void gimp_color_picker_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static gboolean gimp_color_picker_tool_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
gboolean update_active,
|
||||
GimpUpdateColorState update_state);
|
||||
|
||||
|
||||
static GimpToolOptions * gimp_color_picker_tool_options_new (GimpToolInfo *tool_info);
|
||||
static void gimp_color_picker_tool_options_reset (GimpToolOptions *tool_options);
|
||||
|
||||
|
@ -117,34 +131,19 @@ static void gimp_color_picker_tool_info_window_close_callback (GtkWidget *widg
|
|||
static void gimp_color_picker_tool_info_update (GimpTool *tool,
|
||||
gboolean valid);
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
/* 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 *gimp_color_picker_tool_info = NULL;
|
||||
static GtkWidget *color_area = 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];
|
||||
static gint col_value[5] = { 0, 0, 0, 0, 0 };
|
||||
static GimpUpdateColorState update_type;
|
||||
static GimpImageType sample_type;
|
||||
static InfoDialog *gimp_color_picker_tool_info = NULL;
|
||||
static GtkWidget *color_area = 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];
|
||||
|
||||
static GimpDrawToolClass *parent_class = NULL;
|
||||
|
||||
|
@ -384,31 +383,35 @@ gimp_color_picker_tool_button_press (GimpTool *tool,
|
|||
*/
|
||||
if (state & GDK_SHIFT_MASK)
|
||||
{
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
COLOR_NEW));
|
||||
update_type = COLOR_UPDATE_NEW;
|
||||
gimp_color_picker_tool_info_update
|
||||
(tool,
|
||||
gimp_color_picker_tool_pick_color (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
GIMP_UPDATE_COLOR_STATE_NEW));
|
||||
|
||||
update_type = GIMP_UPDATE_COLOR_STATE_UPDATE_NEW;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
COLOR_UPDATE));
|
||||
update_type = COLOR_UPDATE;
|
||||
gimp_color_picker_tool_info_update
|
||||
(tool,
|
||||
gimp_color_picker_tool_pick_color (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
GIMP_UPDATE_COLOR_STATE_UPDATE));
|
||||
|
||||
update_type = GIMP_UPDATE_COLOR_STATE_UPDATE;
|
||||
}
|
||||
|
||||
/* Start drawing the colorpicker tool */
|
||||
|
@ -432,16 +435,17 @@ gimp_color_picker_tool_button_release (GimpTool *tool,
|
|||
gdk_pointer_ungrab (time);
|
||||
gdk_flush ();
|
||||
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
gimp_color_picker_tool_info_update
|
||||
(tool,
|
||||
gimp_color_picker_tool_pick_color (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (cp_tool));
|
||||
|
||||
|
@ -471,16 +475,17 @@ gimp_color_picker_tool_motion (GimpTool *tool,
|
|||
cp_tool->centerx = coords->x - off_x;
|
||||
cp_tool->centery = coords->y - off_y;
|
||||
|
||||
gimp_color_picker_tool_info_update (tool,
|
||||
pick_color_do (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
gimp_color_picker_tool_info_update
|
||||
(tool,
|
||||
gimp_color_picker_tool_pick_color (gdisp->gimage,
|
||||
tool->drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
options->sample_merged,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
options->update_active,
|
||||
update_type));
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
|
@ -520,130 +525,6 @@ gimp_color_picker_tool_cursor_update (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
typedef guchar * (*GetColorFunc) (GimpObject *object,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
guchar *color;
|
||||
gint offx, offy;
|
||||
gint has_alpha;
|
||||
gint is_indexed;
|
||||
GetColorFunc get_color_func;
|
||||
GimpObject *get_color_obj;
|
||||
|
||||
|
||||
if (!drawable && !sample_merged)
|
||||
return FALSE;
|
||||
|
||||
if (! sample_merged)
|
||||
{
|
||||
gimp_drawable_offsets (drawable, &offx, &offy);
|
||||
x -= offx;
|
||||
y -= offy;
|
||||
|
||||
sample_type = gimp_drawable_type (drawable);
|
||||
is_indexed = gimp_drawable_is_indexed (drawable);
|
||||
|
||||
get_color_func = (GetColorFunc) gimp_drawable_get_color_at;
|
||||
get_color_obj = GIMP_OBJECT (drawable);
|
||||
}
|
||||
else
|
||||
{
|
||||
sample_type = gimp_image_projection_type (gimage);
|
||||
is_indexed = FALSE;
|
||||
|
||||
get_color_func = (GetColorFunc) gimp_image_projection_get_color_at;
|
||||
get_color_obj = GIMP_OBJECT (gimage);
|
||||
}
|
||||
|
||||
has_alpha = GIMP_IMAGE_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++;
|
||||
|
||||
color_avg[RED_PIX] += tmp_color[RED_PIX];
|
||||
color_avg[GREEN_PIX] += tmp_color[GREEN_PIX];
|
||||
color_avg[BLUE_PIX] += tmp_color[BLUE_PIX];
|
||||
if (has_alpha)
|
||||
color_avg[ALPHA_PIX] += tmp_color[ALPHA_PIX];
|
||||
|
||||
g_free (tmp_color);
|
||||
}
|
||||
|
||||
color[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
||||
color[GREEN_PIX] = (guchar) (color_avg[GREEN_PIX] / count);
|
||||
color[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
||||
if (has_alpha)
|
||||
color[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
|
||||
is_indexed = FALSE;
|
||||
}
|
||||
|
||||
col_value[RED_PIX] = color[RED_PIX];
|
||||
col_value[GREEN_PIX] = color[GREEN_PIX];
|
||||
col_value[BLUE_PIX] = color[BLUE_PIX];
|
||||
if (has_alpha)
|
||||
col_value[ALPHA_PIX] = color[ALPHA_PIX];
|
||||
if (is_indexed)
|
||||
col_value[4] = color[4];
|
||||
|
||||
if (update_active)
|
||||
palette_set_active_color (col_value [RED_PIX],
|
||||
col_value [GREEN_PIX],
|
||||
col_value [BLUE_PIX],
|
||||
final);
|
||||
|
||||
g_free (color);
|
||||
|
||||
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
|
||||
gimp_color_picker_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
|
@ -668,6 +549,57 @@ gimp_color_picker_tool_draw (GimpDrawTool *draw_tool)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_color_picker_tool_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
gboolean update_active,
|
||||
GimpUpdateColorState update_state)
|
||||
{
|
||||
GimpRGB color;
|
||||
gint color_index;
|
||||
gboolean retval;
|
||||
guchar r, g, b, a;
|
||||
|
||||
retval = gimp_image_pick_color (gimage,
|
||||
drawable,
|
||||
sample_merged,
|
||||
x, y,
|
||||
sample_average,
|
||||
average_radius,
|
||||
&color,
|
||||
&sample_type,
|
||||
&color_index);
|
||||
|
||||
gimp_rgba_get_uchar (&color, &r, &g, &b, &a);
|
||||
|
||||
col_value[RED_PIX] = r;
|
||||
col_value[GREEN_PIX] = g;
|
||||
col_value[BLUE_PIX] = b;
|
||||
col_value[ALPHA_PIX] = a;
|
||||
col_value[4] = color_index;
|
||||
|
||||
if (update_active)
|
||||
{
|
||||
palette_editor_update_color (gimp_get_user_context (gimage->gimp),
|
||||
&color,
|
||||
update_state);
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gimp_context_set_foreground (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
else if (active_color == BACKGROUND)
|
||||
gimp_context_set_background (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_info_update (GimpTool *tool,
|
||||
gboolean valid)
|
||||
|
|
|
@ -47,8 +47,6 @@ struct _GimpColorPickerToolClass
|
|||
GimpDrawToolClass parent_class;
|
||||
};
|
||||
|
||||
/* FIXME: Whats this doing here? */
|
||||
extern gint col_value[5];
|
||||
|
||||
void gimp_color_picker_tool_register (Gimp *gimp,
|
||||
GimpToolRegisterCallback callback);
|
||||
|
@ -56,14 +54,4 @@ void gimp_color_picker_tool_register (Gimp *gimp,
|
|||
GType gimp_color_picker_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
gboolean pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
double average_radius,
|
||||
gint final);
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_PICKER_TOOL_H__ */
|
||||
|
|
|
@ -166,7 +166,7 @@ static void gimp_paint_tool_invalidate_cache (GimpBrush *brush,
|
|||
|
||||
|
||||
/* paint buffers utility functions */
|
||||
static void free_paint_buffers (void);
|
||||
static void gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool);
|
||||
|
||||
/* brush pipe utility functions */
|
||||
static void paint_line_pixmap_mask (GimpImage *dest,
|
||||
|
@ -288,7 +288,7 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||
|
||||
case HALT:
|
||||
gimp_paint_tool_paint (paint_tool, drawable, FINISH_PAINT);
|
||||
gimp_paint_tool_cleanup ();
|
||||
gimp_paint_tool_cleanup (paint_tool);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1063,7 +1063,7 @@ gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_paint_tool_cleanup (void)
|
||||
gimp_paint_tool_cleanup (GimpPaintTool *paint_tool)
|
||||
{
|
||||
/* CLEANUP */
|
||||
/* If the undo tiles exist, nuke them */
|
||||
|
@ -1081,7 +1081,7 @@ gimp_paint_tool_cleanup (void)
|
|||
}
|
||||
|
||||
/* Free the temporary buffers if they exist */
|
||||
free_paint_buffers ();
|
||||
gimp_paint_tool_free_buffers (paint_tool);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2084,7 +2084,7 @@ set_canvas_tiles (gint x,
|
|||
|
||||
|
||||
static void
|
||||
free_paint_buffers (void)
|
||||
gimp_paint_tool_free_buffers (GimpPaintTool *paint_tool)
|
||||
{
|
||||
if (orig_buf)
|
||||
temp_buf_free (orig_buf);
|
||||
|
|
|
@ -113,59 +113,57 @@ struct _PaintUndo
|
|||
|
||||
GType gimp_paint_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_paint_tool_paint (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_paint (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
PaintState state);
|
||||
PaintState state);
|
||||
|
||||
void gimp_paint_tool_no_draw (GimpPaintTool *tool);
|
||||
|
||||
int gimp_paint_tool_start (GimpPaintTool *tool,
|
||||
int gimp_paint_tool_start (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_interpolate (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_finish (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_finish (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_paint_tool_cleanup (void);
|
||||
void gimp_paint_tool_cleanup (GimpPaintTool *paint_tool);
|
||||
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *tool,
|
||||
void gimp_paint_tool_get_color_from_gradient (GimpPaintTool *paint_tool,
|
||||
GimpGradient *gradient,
|
||||
gdouble gradient_length,
|
||||
GimpRGB *color,
|
||||
GradientPaintMode mode);
|
||||
|
||||
/* paint tool painting functions */
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
TempBuf * gimp_paint_tool_get_paint_area (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gdouble scale);
|
||||
TempBuf * gimp_paint_tool_get_orig_image (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2);
|
||||
void gimp_paint_tool_paste_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
GimpLayerModeEffects paint_mode,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_replace_canvas (GimpPaintTool *paint_tool,
|
||||
GimpDrawable *drawable,
|
||||
gint brush_opacity,
|
||||
gint image_opacity,
|
||||
BrushApplicationMode brush_hardness,
|
||||
gdouble brush_scale,
|
||||
PaintApplicationMode mode);
|
||||
void gimp_paint_tool_color_area_with_pixmap (GimpPaintTool *paint_tool,
|
||||
GimpImage *dest,
|
||||
GimpDrawable *drawable,
|
||||
TempBuf *area,
|
||||
gdouble scale,
|
||||
BrushApplicationMode mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_PAINT_TOOL_H__ */
|
||||
|
|
|
@ -507,7 +507,7 @@ gimp_smudge_tool_non_gui (GimpDrawable *drawable,
|
|||
|
||||
gimp_paint_tool_finish (paint_tool, drawable);
|
||||
|
||||
gimp_paint_tool_cleanup ();
|
||||
gimp_paint_tool_cleanup (paint_tool);
|
||||
|
||||
gimp_smudge_tool_finish (paint_tool, drawable);
|
||||
|
||||
|
|
|
@ -162,40 +162,32 @@ static GtkTargetEntry color_palette_target_table[] =
|
|||
/* called from color_picker.h *********************************************/
|
||||
|
||||
void
|
||||
palette_set_active_color (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint state)
|
||||
palette_editor_update_color (GimpContext *context,
|
||||
const GimpRGB *color,
|
||||
GimpUpdateColorState state)
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: palette_set_active_color()
|
||||
#endif
|
||||
#if 0
|
||||
GimpPalette *palette;
|
||||
GimpRGB color;
|
||||
|
||||
gimp_rgba_set_uchar (&color,
|
||||
(guchar) r,
|
||||
(guchar) g,
|
||||
(guchar) b,
|
||||
255);
|
||||
|
||||
if (top_level_edit_palette)
|
||||
{
|
||||
GimpPalette *palette;
|
||||
|
||||
palette = gimp_context_get_palette (top_level_edit_palette->context);
|
||||
|
||||
if (palette)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case COLOR_NEW:
|
||||
case GIMP_UPDATE_COLOR_STATE_NEW:
|
||||
top_level_edit_palette->color = gimp_palette_add_entry (palette,
|
||||
NULL,
|
||||
&color);
|
||||
color);
|
||||
break;
|
||||
|
||||
case COLOR_UPDATE_NEW:
|
||||
top_level_edit_palette->color->color = color;
|
||||
case GIMP_UPDATE_COLOR_STATE_UPDATE_NEW:
|
||||
top_level_edit_palette->color->color = *color;
|
||||
|
||||
gimp_data_dirty (GIMP_DATA (palette));
|
||||
break;
|
||||
|
@ -205,11 +197,6 @@ palette_set_active_color (gint r,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (active_color == FOREGROUND)
|
||||
gimp_context_set_foreground (gimp_get_user_context (the_gimp), &color);
|
||||
else if (active_color == BACKGROUND)
|
||||
gimp_context_set_background (gimp_get_user_context (the_gimp), &color);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -20,25 +20,26 @@
|
|||
#define __PALETTE_EDITOR_H__
|
||||
|
||||
|
||||
/* The states for updating a color in the palette via palette_set_* calls */
|
||||
#define COLOR_NEW 0
|
||||
#define COLOR_UPDATE_NEW 1
|
||||
#define COLOR_UPDATE 2
|
||||
typedef enum
|
||||
{
|
||||
GIMP_UPDATE_COLOR_STATE_NEW,
|
||||
GIMP_UPDATE_COLOR_STATE_UPDATE_NEW,
|
||||
GIMP_UPDATE_COLOR_STATE_UPDATE
|
||||
} GimpUpdateColorState;
|
||||
|
||||
|
||||
typedef struct _PaletteEditor PaletteEditor;
|
||||
|
||||
|
||||
PaletteEditor * palette_editor_new (Gimp *gimp);
|
||||
PaletteEditor * palette_editor_new (Gimp *gimp);
|
||||
|
||||
void palette_editor_set_palette (PaletteEditor *palette_editor,
|
||||
GimpPalette *palette);
|
||||
void palette_editor_free (PaletteEditor *palette_editor);
|
||||
void palette_editor_set_palette (PaletteEditor *palette_editor,
|
||||
GimpPalette *palette);
|
||||
void palette_editor_free (PaletteEditor *palette_editor);
|
||||
|
||||
void palette_set_active_color (gint r,
|
||||
gint g,
|
||||
gint b,
|
||||
gint state);
|
||||
void palette_editor_update_color (GimpContext *context,
|
||||
const GimpRGB *color,
|
||||
GimpUpdateColorState state);
|
||||
|
||||
|
||||
#endif /* __PALETTE_EDITOR_H__ */
|
||||
|
|
|
@ -61,40 +61,48 @@
|
|||
#include "pixmaps/swap.xpm"
|
||||
|
||||
|
||||
/* local functions */
|
||||
static void toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gint toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
gpointer data);
|
||||
/* local function prototypes */
|
||||
|
||||
static gint toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gint toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void toolbox_create_tools (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
static void toolbox_create_color_area (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
static void toolbox_create_indicator_area (GtkWidget *wbox,
|
||||
GimpContext *context);
|
||||
|
||||
static void toolbox_style_set_callback (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
gpointer data);
|
||||
static void toolbox_drop_drawable (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_tool (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_buffer (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data);
|
||||
|
||||
static void toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gboolean toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *bevent,
|
||||
gpointer data);
|
||||
|
||||
static gboolean toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static gboolean toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void toolbox_style_set (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
Gimp *gimp);
|
||||
|
||||
static void toolbox_drop_drawable (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_tool (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
static void toolbox_drop_buffer (GtkWidget *widget,
|
||||
GimpViewable *viewable,
|
||||
gpointer data);
|
||||
|
||||
#define COLUMNS 3
|
||||
#define ROWS 8
|
||||
#define MARGIN 2
|
||||
|
||||
/* local variables */
|
||||
static GtkWidget * toolbox_shell = NULL;
|
||||
static GtkWidget *toolbox_shell = NULL;
|
||||
|
||||
static GtkTargetEntry toolbox_target_table[] =
|
||||
{
|
||||
|
@ -109,204 +117,7 @@ static GtkTargetEntry toolbox_target_table[] =
|
|||
};
|
||||
|
||||
|
||||
static void
|
||||
toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
tool_info = GIMP_TOOL_INFO (data);
|
||||
|
||||
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
||||
"gimp:tool-options-dialog", -1);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
app_exit (FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint
|
||||
toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_devices_check_change (GIMP (data), event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
create_indicator_area (GtkWidget *parent,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (parent), frame, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
|
||||
|
||||
ind_area = indicator_area_create (context);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
static void
|
||||
create_color_area (GtkWidget *parent,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *col_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkBitmap *default_mask;
|
||||
GdkPixmap *swap_pixmap;
|
||||
GdkBitmap *swap_mask;
|
||||
|
||||
if (! GTK_WIDGET_REALIZED (parent))
|
||||
gtk_widget_realize (parent);
|
||||
|
||||
default_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
|
||||
&default_mask,
|
||||
&parent->style->bg[GTK_STATE_NORMAL],
|
||||
default_xpm);
|
||||
swap_pixmap = gdk_pixmap_create_from_xpm_d (parent->window,
|
||||
&swap_mask,
|
||||
&parent->style->bg[GTK_STATE_NORMAL],
|
||||
swap_xpm);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (parent), frame,
|
||||
TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#color_area");
|
||||
|
||||
col_area = color_area_create (context,
|
||||
54, 42,
|
||||
default_pixmap, default_mask,
|
||||
swap_pixmap, swap_mask);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), col_area);
|
||||
gimp_help_set_help_data
|
||||
(col_area,
|
||||
_("Foreground & background colors. The black "
|
||||
"and white squares reset colors. The arrows swap colors. Double "
|
||||
"click to select a color from a colorrequester."), NULL);
|
||||
|
||||
gtk_widget_show (col_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data)
|
||||
{
|
||||
if (tool_info)
|
||||
{
|
||||
GtkWidget *toolbox_button;
|
||||
|
||||
toolbox_button =
|
||||
g_object_get_data (G_OBJECT (tool_info), "toolbox_button");
|
||||
|
||||
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
|
||||
{
|
||||
g_signal_handlers_block_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
|
||||
gtk_widget_activate (toolbox_button);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_tools (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GList *list;
|
||||
GSList *group = NULL;
|
||||
|
||||
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
|
||||
tool_info = (GimpToolInfo *) list->data;
|
||||
|
||||
button = gtk_radio_button_new (group);
|
||||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), "toolbox_button", button);
|
||||
|
||||
image = gtk_image_new_from_stock (tool_info->stock_id,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (toolbox_tool_button_toggled),
|
||||
tool_info);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "button_press_event",
|
||||
G_CALLBACK (toolbox_tool_button_press),
|
||||
tool_info);
|
||||
|
||||
gimp_help_set_help_data (button,
|
||||
tool_info->help,
|
||||
tool_info->help_data);
|
||||
|
||||
}
|
||||
|
||||
gtk_widget_show (wbox);
|
||||
}
|
||||
/* public functions */
|
||||
|
||||
GtkWidget *
|
||||
toolbox_create (Gimp *gimp)
|
||||
|
@ -332,8 +143,8 @@ toolbox_create (Gimp *gimp)
|
|||
NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (window), "style_set",
|
||||
G_CALLBACK (toolbox_style_set_callback),
|
||||
NULL);
|
||||
G_CALLBACK (toolbox_style_set),
|
||||
gimp);
|
||||
|
||||
/* We need to know when the current device changes, so we can update
|
||||
* the correct tool - to do this we connect to motion events.
|
||||
|
@ -358,15 +169,14 @@ toolbox_create (Gimp *gimp)
|
|||
gtk_widget_set_extension_events (window, GDK_EXTENSION_EVENTS_CURSOR);
|
||||
}
|
||||
|
||||
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 1);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_vbox);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
toolbox_factory = gtk_item_factory_from_path ("<Toolbox>");
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), toolbox_factory->widget,
|
||||
FALSE, TRUE, 0);
|
||||
FALSE, FALSE, 0);
|
||||
gtk_widget_show (toolbox_factory->widget);
|
||||
|
||||
gtk_window_add_accel_group (GTK_WINDOW (window), toolbox_factory->accel_group);
|
||||
|
@ -384,17 +194,17 @@ toolbox_create (Gimp *gimp)
|
|||
gtk_box_pack_start (GTK_BOX (main_vbox), wbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (wbox);
|
||||
|
||||
create_tools (wbox, context);
|
||||
toolbox_create_tools (wbox, context);
|
||||
|
||||
g_signal_connect_object (G_OBJECT (context), "tool_changed",
|
||||
G_CALLBACK (toolbox_tool_changed),
|
||||
G_OBJECT (wbox),
|
||||
0);
|
||||
|
||||
create_color_area (wbox, context);
|
||||
toolbox_create_color_area (wbox, context);
|
||||
|
||||
if (gimprc.show_indicators)
|
||||
create_indicator_area (wbox, context);
|
||||
toolbox_create_indicator_area (wbox, context);
|
||||
|
||||
gtk_drag_dest_set (window,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
|
@ -420,6 +230,8 @@ toolbox_create (Gimp *gimp)
|
|||
toolbox_drop_buffer,
|
||||
context);
|
||||
|
||||
toolbox_style_set (window, NULL, gimp);
|
||||
|
||||
gtk_widget_show (window);
|
||||
|
||||
toolbox_shell = window;
|
||||
|
@ -435,25 +247,270 @@ toolbox_free (Gimp *gimp)
|
|||
gtk_widget_destroy (toolbox_shell);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
toolbox_style_set_callback (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
gpointer data)
|
||||
toolbox_create_tools (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GdkGeometry geometry;
|
||||
GtkStyle *style;
|
||||
GList *list;
|
||||
GSList *group = NULL;
|
||||
|
||||
style = gtk_widget_get_style (window);
|
||||
for (list = GIMP_LIST (context->gimp->tool_info_list)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *button;
|
||||
GtkWidget *image;
|
||||
|
||||
geometry.min_width = 2 + 26 + 2 * style->xthickness;
|
||||
geometry.min_height = 80 + 26 + 2 * style->ythickness;
|
||||
geometry.width_inc = 26 + 2 * style->xthickness;
|
||||
geometry.height_inc = 26 + 2 * style->ythickness;
|
||||
tool_info = (GimpToolInfo *) list->data;
|
||||
|
||||
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
||||
NULL,
|
||||
&geometry,
|
||||
GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
|
||||
button = gtk_radio_button_new (group);
|
||||
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
||||
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), button,
|
||||
FALSE, FALSE, FALSE, FALSE);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_object_set_data (G_OBJECT (tool_info), "toolbox-button", button);
|
||||
|
||||
image = gtk_image_new_from_stock (tool_info->stock_id,
|
||||
GTK_ICON_SIZE_BUTTON);
|
||||
gtk_container_add (GTK_CONTAINER (button), image);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "toggled",
|
||||
G_CALLBACK (toolbox_tool_button_toggled),
|
||||
tool_info);
|
||||
|
||||
g_signal_connect (G_OBJECT (button), "button_press_event",
|
||||
G_CALLBACK (toolbox_tool_button_press),
|
||||
tool_info);
|
||||
|
||||
gimp_help_set_help_data (button,
|
||||
tool_info->help,
|
||||
tool_info->help_data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_create_color_area (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *col_area;
|
||||
GdkPixmap *default_pixmap;
|
||||
GdkBitmap *default_mask;
|
||||
GdkPixmap *swap_pixmap;
|
||||
GdkBitmap *swap_mask;
|
||||
|
||||
if (! GTK_WIDGET_REALIZED (wbox))
|
||||
gtk_widget_realize (wbox);
|
||||
|
||||
default_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
|
||||
&default_mask,
|
||||
&wbox->style->bg[GTK_STATE_NORMAL],
|
||||
default_xpm);
|
||||
swap_pixmap = gdk_pixmap_create_from_xpm_d (wbox->window,
|
||||
&swap_mask,
|
||||
&wbox->style->bg[GTK_STATE_NORMAL],
|
||||
swap_xpm);
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (wbox), frame,
|
||||
TRUE, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#color_area");
|
||||
|
||||
col_area = color_area_create (context,
|
||||
54, 42,
|
||||
default_pixmap, default_mask,
|
||||
swap_pixmap, swap_mask);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), col_area);
|
||||
gimp_help_set_help_data
|
||||
(col_area,
|
||||
_("Foreground & background colors. The black "
|
||||
"and white squares reset colors. The arrows swap colors. Double "
|
||||
"click to select a color from a colorrequester."), NULL);
|
||||
|
||||
gtk_widget_show (col_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
g_object_set_data (G_OBJECT (wbox), "color-area", frame);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_create_indicator_area (GtkWidget *wbox,
|
||||
GimpContext *context)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
GtkWidget *alignment;
|
||||
GtkWidget *ind_area;
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
|
||||
gtk_wrap_box_pack (GTK_WRAP_BOX (wbox), frame, TRUE, TRUE, TRUE, TRUE);
|
||||
|
||||
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (alignment), 3);
|
||||
gtk_container_add (GTK_CONTAINER (frame), alignment);
|
||||
|
||||
gimp_help_set_help_data (alignment, NULL, "#indicator_area");
|
||||
|
||||
ind_area = indicator_area_create (context);
|
||||
gtk_container_add (GTK_CONTAINER (alignment), ind_area);
|
||||
|
||||
gtk_widget_show (ind_area);
|
||||
gtk_widget_show (alignment);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
g_object_set_data (G_OBJECT (wbox), "indicator-area", frame);
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_changed (GimpContext *context,
|
||||
GimpToolInfo *tool_info,
|
||||
gpointer data)
|
||||
{
|
||||
if (tool_info)
|
||||
{
|
||||
GtkWidget *toolbox_button;
|
||||
|
||||
toolbox_button =
|
||||
g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
||||
|
||||
if (toolbox_button && ! GTK_TOGGLE_BUTTON (toolbox_button)->active)
|
||||
{
|
||||
g_signal_handlers_block_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
|
||||
gtk_widget_activate (toolbox_button);
|
||||
|
||||
g_signal_handlers_unblock_by_func (G_OBJECT (toolbox_button),
|
||||
toolbox_tool_button_toggled,
|
||||
tool_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_tool_button_toggled (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
|
||||
tool_info = GIMP_TOOL_INFO (data);
|
||||
|
||||
if ((tool_info) && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
gimp_context_set_tool (gimp_get_user_context (tool_info->gimp), tool_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_tool_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
gpointer data)
|
||||
{
|
||||
if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
|
||||
{
|
||||
gimp_dialog_factory_dialog_new (global_dialog_factory,
|
||||
"gimp:tool-options-dialog", -1);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
app_exit (FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
toolbox_check_device (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
gimp_devices_check_change (GIMP (data), event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
toolbox_style_set (GtkWidget *window,
|
||||
GtkStyle *previous_style,
|
||||
Gimp *gimp)
|
||||
{
|
||||
GimpToolInfo *tool_info;
|
||||
GtkWidget *tool_button;
|
||||
|
||||
tool_info = (GimpToolInfo *)
|
||||
gimp_container_get_child_by_name (gimp->tool_info_list,
|
||||
"gimp:rect_select_tool");
|
||||
tool_button = g_object_get_data (G_OBJECT (tool_info), "toolbox-button");
|
||||
|
||||
if (tool_button)
|
||||
{
|
||||
GtkWidget *wbox;
|
||||
GtkWidget *widget;
|
||||
GtkRequisition menubar_requisition;
|
||||
GtkRequisition button_requisition;
|
||||
GtkRequisition color_requisition;
|
||||
GtkRequisition indicator_requisition;
|
||||
GdkGeometry geometry;
|
||||
gint border_width;
|
||||
GList *children;
|
||||
|
||||
children =
|
||||
gtk_container_get_children (GTK_CONTAINER (GTK_BIN (window)->child));
|
||||
|
||||
gtk_widget_size_request (g_list_nth_data (children, 0),
|
||||
&menubar_requisition);
|
||||
|
||||
wbox = g_list_nth_data (children, 1);
|
||||
|
||||
g_list_free (children);
|
||||
|
||||
gtk_widget_size_request (tool_button, &button_requisition);
|
||||
|
||||
widget = g_object_get_data (G_OBJECT (wbox), "color-area");
|
||||
gtk_widget_size_request (widget, &color_requisition);
|
||||
|
||||
widget = g_object_get_data (G_OBJECT (wbox), "indicator-area");
|
||||
gtk_widget_size_request (widget, &indicator_requisition);
|
||||
|
||||
border_width =
|
||||
gtk_container_get_border_width (GTK_CONTAINER (GTK_BIN (window)->child));
|
||||
|
||||
geometry.min_width = (2 * border_width +
|
||||
2 * button_requisition.width);
|
||||
geometry.min_height = (2 * border_width +
|
||||
button_requisition.height +
|
||||
menubar_requisition.height +
|
||||
MAX (color_requisition.height,
|
||||
indicator_requisition.height));
|
||||
geometry.width_inc = button_requisition.width;
|
||||
geometry.height_inc = button_requisition.height;
|
||||
|
||||
gtk_window_set_geometry_hints (GTK_WINDOW (window),
|
||||
NULL,
|
||||
&geometry,
|
||||
GDK_HINT_MIN_SIZE | GDK_HINT_RESIZE_INC);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -166,7 +166,6 @@ gimp_bucket_fill (gint32 drawable_ID,
|
|||
* @sample_merged: Use the composite image, not the drawable.
|
||||
* @sample_average: Average the color of all the pixels in a specified radius.
|
||||
* @average_radius: The radius of pixels to average.
|
||||
* @save_color: Save the color to the active palette.
|
||||
* @color: The return color.
|
||||
*
|
||||
* Determine the color at the given drawable coordinates
|
||||
|
@ -193,7 +192,6 @@ gimp_color_picker (gint32 image_ID,
|
|||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
gboolean save_color,
|
||||
GimpRGB *color)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
|
@ -209,7 +207,6 @@ gimp_color_picker (gint32 image_ID,
|
|||
GIMP_PDB_INT32, sample_merged,
|
||||
GIMP_PDB_INT32, sample_average,
|
||||
GIMP_PDB_FLOAT, average_radius,
|
||||
GIMP_PDB_INT32, save_color,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
|
|
@ -58,7 +58,6 @@ gboolean gimp_color_picker (gint32 image_ID,
|
|||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
gboolean save_color,
|
||||
GimpRGB *color);
|
||||
|
||||
|
||||
|
|
|
@ -324,9 +324,7 @@ sub get_image_cells {
|
|||
($end_complete-$start_complete)*$x/$xcells)/100);
|
||||
}
|
||||
for(my $y=0;$y<$ycells;$y++) {
|
||||
# Why is this setting FG? PDB docs seem to indicate that I can shut
|
||||
# that off...
|
||||
my $color = gimp_color_picker($draw,$x,$y,0,1,1.0,0); # Gimp 1.1 -deleted $img
|
||||
my $color = gimp_color_picker($draw,$x,$y,0,1,1.0); # Gimp 1.1 -deleted $img
|
||||
my @c;
|
||||
if ($DO_HSV) {
|
||||
@c = rgb2hsv(@$color);
|
||||
|
|
|
@ -977,7 +977,7 @@ sub script_fu_title_header {
|
|||
gimp_palette_set_background ([0, 0, 0]);
|
||||
gimp_edit_fill ($bg_layer, BG_IMAGE_FILL);
|
||||
gimp_ellipse_select ($img, 0, 0, $text_height, $text_height, REPLACE, 1, 0, 0);
|
||||
gimp_palette_set_background (gimp_color_picker ($text_layer, $text_layers_offset, 0, 1, 0, 6, 0));
|
||||
gimp_palette_set_background (gimp_color_picker ($text_layer, $text_layers_offset, 0, 1, 0, 6));
|
||||
gimp_edit_fill ($bg_layer, BG_IMAGE_FILL);
|
||||
gimp_rect_select ($img, ($img_width - $fade_width), 0, $fade_width, $text_height, REPLACE, 0, 0);
|
||||
gimp_palette_set_foreground (gimp_palette_get_background ());
|
||||
|
|
|
@ -283,7 +283,7 @@
|
|||
(set! rgb (car (gimp-color-picker img drawable
|
||||
(+ beg-x (* x-len (/ index limit)))
|
||||
(+ beg-y (* y-len (/ index limit)))
|
||||
TRUE FALSE 0 0)))
|
||||
TRUE FALSE 0)))
|
||||
(fill-color-band gimg clayer index scale x-base 40 rgb)
|
||||
(rgb-to-hsv rgb hsv)
|
||||
(plot-hsv gimg hsv-layer index scale x-base y-base hsv)
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
(gimp-edit-fill bg-layer BG-IMAGE-FILL)
|
||||
|
||||
(gimp-ellipse-select img 0 0 text-height text-height REPLACE TRUE FALSE 0)
|
||||
(gimp-palette-set-background (car (gimp-color-picker img text-layer text-layers-offset 0 TRUE FALSE 0 0)))
|
||||
(gimp-palette-set-background (car (gimp-color-picker img text-layer text-layers-offset 0 TRUE FALSE 0)))
|
||||
(gimp-edit-fill bg-layer BG-IMAGE-FILL)
|
||||
|
||||
; Fade-out gradient at the right
|
||||
|
|
|
@ -222,9 +222,7 @@ HELP
|
|||
radius' },
|
||||
{ name => 'average_radius', type => '0 < float',
|
||||
desc => 'The radius of pixels to average',
|
||||
cond => [ 'sample_average' ] },
|
||||
{ name => 'save_color', type => 'boolean',
|
||||
desc => 'Save the color to the active palette' }
|
||||
cond => [ 'sample_average' ] }
|
||||
);
|
||||
$inargs[1]->{no_success} = 1;
|
||||
|
||||
|
@ -234,7 +232,7 @@ HELP
|
|||
);
|
||||
|
||||
%invoke = (
|
||||
headers => [ qw("tools/gimpcolorpickertool.h") ],
|
||||
headers => [ qw("core/gimpimage-pick-color.h") ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
if (!sample_merged)
|
||||
|
@ -242,25 +240,22 @@ HELP
|
|||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
success = pick_color (gimage, drawable, (int) x, (int) y,
|
||||
sample_merged, sample_average, average_radius,
|
||||
save_color);
|
||||
if (success)
|
||||
{
|
||||
gimp_rgba_set_uchar (&color,
|
||||
col_value[RED_PIX],
|
||||
col_value[GREEN_PIX],
|
||||
col_value[BLUE_PIX],
|
||||
col_value[ALPHA_PIX]);
|
||||
}
|
||||
success = gimp_image_pick_color (gimage,
|
||||
drawable,
|
||||
sample_merged,
|
||||
(gint) x, (gint) y,
|
||||
sample_average,
|
||||
average_radius,
|
||||
&color,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@headers = qw("libgimpmath/gimpmath.h" "base/tile-manager.h"
|
||||
"core/gimpdrawable.h" "tools/tools-types.h");
|
||||
@headers = qw("libgimpmath/gimpmath.h" "core/gimpdrawable.h");
|
||||
|
||||
@procs = qw(blend bucket_fill color_picker);
|
||||
|
||||
|
|
Loading…
Reference in New Issue