mirror of https://github.com/GNOME/gimp.git
use OPAQUE_OPACITY instead of 255.
2003-06-05 Sven Neumann <sven@gimp.org> * app/core/gimpdrawable.c (gimp_drawable_get_color_at): * app/core/gimpimage-projection.c (gimp_image_projection_get_color_at): use OPAQUE_OPACITY instead of 255. * app/core/gimpimage-pick-color.[ch]: factored out code that averages over colors so it can be used from GimpImageTool. * app/tools/gimpimagemaptool.[ch]: derived from GimpColorTool and added a GimpColorTool::pick implementation. * app/tools/gimpcoloroptions.c * app/tools/gimpcolorpickeroptions.c: add the toggle for "sample_merged" in gimp_color_picker_options_gui(). * app/tools/gimpcolortool.c (gimp_color_tool_cursor_update): check if the cursor is over the active drawable or if "sample_merged" is active. * app/tools/gimplevelstool.c: simplified since all color-picking is now handled by the parent classes. Fixes bug #112668.
This commit is contained in:
parent
21b4aba939
commit
b1c437b4f8
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2003-06-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpdrawable.c (gimp_drawable_get_color_at):
|
||||
* app/core/gimpimage-projection.c (gimp_image_projection_get_color_at):
|
||||
use OPAQUE_OPACITY instead of 255.
|
||||
|
||||
* app/core/gimpimage-pick-color.[ch]: factored out code that
|
||||
averages over colors so it can be used from GimpImageTool.
|
||||
|
||||
* app/tools/gimpimagemaptool.[ch]: derived from GimpColorTool and
|
||||
added a GimpColorTool::pick implementation.
|
||||
|
||||
* app/tools/gimpcoloroptions.c
|
||||
* app/tools/gimpcolorpickeroptions.c: add the toggle for
|
||||
"sample_merged" in gimp_color_picker_options_gui().
|
||||
|
||||
* app/tools/gimpcolortool.c (gimp_color_tool_cursor_update): check
|
||||
if the cursor is over the active drawable or if "sample_merged" is
|
||||
active.
|
||||
|
||||
* app/tools/gimplevelstool.c: simplified since all color-picking is
|
||||
now handled by the parent classes. Fixes bug #112668.
|
||||
|
||||
2003-06-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimpcoloroptions.c: changed the default radius.
|
||||
|
|
|
@ -1005,7 +1005,7 @@ gimp_drawable_get_color_at (GimpDrawable *drawable,
|
|||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_drawable_type (drawable)))
|
||||
dest[3] = src[gimp_drawable_bytes (drawable) - 1];
|
||||
else
|
||||
dest[3] = 255;
|
||||
dest[3] = OPAQUE_OPACITY;
|
||||
|
||||
if (gimp_drawable_is_indexed (drawable))
|
||||
dest[4] = src[0];
|
||||
|
|
|
@ -26,34 +26,26 @@
|
|||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimpimage-projection.h"
|
||||
|
||||
|
||||
typedef guchar * (* GetColorFunc) (GimpObject *object,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_image_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gboolean sample_merged,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpImageType *sample_type,
|
||||
GimpRGB *color,
|
||||
gint *color_index)
|
||||
{
|
||||
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;
|
||||
GimpImageType my_sample_type;
|
||||
gboolean is_indexed;
|
||||
GimpImagePickColorFunc color_func;
|
||||
GimpObject *color_obj;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (sample_merged || GIMP_IS_DRAWABLE (drawable), FALSE);
|
||||
|
@ -61,7 +53,15 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||
gimp_item_get_image (GIMP_ITEM (drawable)) == gimage,
|
||||
FALSE);
|
||||
|
||||
if (! sample_merged)
|
||||
if (sample_merged)
|
||||
{
|
||||
my_sample_type = gimp_image_projection_type (gimage);
|
||||
is_indexed = FALSE;
|
||||
|
||||
color_func = (GimpImagePickColorFunc) gimp_image_projection_get_color_at;
|
||||
color_obj = GIMP_OBJECT (gimage);
|
||||
}
|
||||
else
|
||||
{
|
||||
gint off_x, off_y;
|
||||
|
||||
|
@ -72,21 +72,31 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
color_func = (GimpImagePickColorFunc) gimp_drawable_get_color_at;
|
||||
color_obj = GIMP_OBJECT (drawable);
|
||||
}
|
||||
|
||||
has_alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (my_sample_type);
|
||||
if (sample_type)
|
||||
*sample_type = my_sample_type;
|
||||
|
||||
if (! (col = (* get_color_func) (get_color_obj, x, y)))
|
||||
return gimp_image_pick_color_by_func (color_obj, x, y, color_func,
|
||||
sample_average, average_radius,
|
||||
color, color_index);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_image_pick_color_by_func (GimpObject *object,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpImagePickColorFunc pick_color_func,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpRGB *color,
|
||||
gint *color_index)
|
||||
{
|
||||
guchar *col;
|
||||
|
||||
if (! (col = pick_color_func (object, x, y)))
|
||||
return FALSE;
|
||||
|
||||
if (sample_average)
|
||||
|
@ -99,16 +109,14 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||
|
||||
for (i = x - radius; i <= x + radius; i++)
|
||||
for (j = y - radius; j <= y + radius; j++)
|
||||
if ((tmp_col = (* get_color_func) (get_color_obj, i, j)))
|
||||
if ((tmp_col = pick_color_func (object, i, j)))
|
||||
{
|
||||
count++;
|
||||
|
||||
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_col[ALPHA_PIX];
|
||||
color_avg[ALPHA_PIX] += tmp_col[ALPHA_PIX];
|
||||
|
||||
g_free (tmp_col);
|
||||
}
|
||||
|
@ -116,41 +124,20 @@ gimp_image_pick_color (GimpImage *gimage,
|
|||
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)
|
||||
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
|
||||
is_indexed = FALSE;
|
||||
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
}
|
||||
|
||||
if (is_indexed)
|
||||
my_color_index = col[4];
|
||||
else
|
||||
my_color_index = -1;
|
||||
|
||||
if (has_alpha)
|
||||
gimp_rgba_set_uchar (&rgb_color,
|
||||
if (color)
|
||||
gimp_rgba_set_uchar (color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX],
|
||||
col[ALPHA_PIX]);
|
||||
else
|
||||
gimp_rgba_set_uchar (&rgb_color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX],
|
||||
OPAQUE_OPACITY);
|
||||
|
||||
if (color_index)
|
||||
*color_index = sample_average ? -1 : col[4];
|
||||
|
||||
g_free (col);
|
||||
|
||||
if (sample_type)
|
||||
*sample_type = my_sample_type;
|
||||
|
||||
if (color)
|
||||
*color = rgb_color;
|
||||
|
||||
if (color_index)
|
||||
*color_index = my_color_index;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -20,16 +20,30 @@
|
|||
#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,
|
||||
GimpImageType *sample_type,
|
||||
GimpRGB *color,
|
||||
gint *color_index);
|
||||
typedef guchar * (* GimpImagePickColorFunc) (GimpObject *object,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
|
||||
gboolean gimp_image_pick_color (GimpImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gboolean sample_merged,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpImageType *sample_type,
|
||||
GimpRGB *color,
|
||||
gint *color_index);
|
||||
|
||||
gboolean gimp_image_pick_color_by_func (GimpObject *object,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpImagePickColorFunc pick_color_func,
|
||||
gboolean sample_average,
|
||||
gdouble average_radius,
|
||||
GimpRGB *color,
|
||||
gint *color_index);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_PICK_COLOR_H__ */
|
||||
|
|
|
@ -198,7 +198,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||
else
|
||||
dest[3] = 255;
|
||||
dest[3] = OPAQUE_OPACITY;
|
||||
|
||||
dest[4] = 0;
|
||||
tile_release (tile, FALSE);
|
||||
|
|
|
@ -198,7 +198,7 @@ gimp_image_projection_get_color_at (GimpImage *gimage,
|
|||
if (GIMP_IMAGE_TYPE_HAS_ALPHA (gimp_image_projection_type (gimage)))
|
||||
dest[3] = src[gimp_image_projection_bytes (gimage) - 1];
|
||||
else
|
||||
dest[3] = 255;
|
||||
dest[3] = OPAQUE_OPACITY;
|
||||
|
||||
dest[4] = 0;
|
||||
tile_release (tile, FALSE);
|
||||
|
|
|
@ -184,12 +184,6 @@ gimp_color_options_gui (GimpToolOptions *tool_options)
|
|||
|
||||
vbox = gimp_tool_options_gui (tool_options);
|
||||
|
||||
/* the sample merged toggle button */
|
||||
button = gimp_prop_check_button_new (config, "sample-merged",
|
||||
_("Sample Merged"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* the sample average options */
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
|
||||
|
|
|
@ -163,6 +163,12 @@ gimp_color_picker_options_gui (GimpToolOptions *tool_options)
|
|||
|
||||
vbox = gimp_color_options_gui (tool_options);
|
||||
|
||||
/* the sample merged toggle button */
|
||||
button = gimp_prop_check_button_new (config, "sample-merged",
|
||||
_("Sample Merged"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
/* the update active color toggle button */
|
||||
button = gimp_prop_check_button_new (config, "update-active",
|
||||
_("Update Active Color"));
|
||||
|
|
|
@ -259,27 +259,30 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
if (GIMP_COLOR_TOOL (tool)->enabled)
|
||||
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
||||
|
||||
if (color_tool->enabled)
|
||||
{
|
||||
GdkCursorType cursor = GIMP_BAD_CURSOR;
|
||||
|
||||
if (gdisp->gimage &&
|
||||
|
||||
coords->x > 0 &&
|
||||
coords->x < gdisp->gimage->width &&
|
||||
coords->y > 0 &&
|
||||
coords->y < gdisp->gimage->height)
|
||||
coords->y < gdisp->gimage->height &&
|
||||
|
||||
(color_tool->options->sample_merged ||
|
||||
gimp_display_coords_in_active_drawable (gdisp, coords)))
|
||||
{
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_COLOR_PICKER_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_BAD_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
cursor = GIMP_COLOR_PICKER_CURSOR;
|
||||
}
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
cursor,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
|
||||
return; /* don't chain up */
|
||||
}
|
||||
|
||||
|
@ -323,10 +326,8 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|||
g_return_val_if_fail (tool->gdisp != NULL, FALSE);
|
||||
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
||||
|
||||
return gimp_image_pick_color (tool->gdisp->gimage,
|
||||
tool->drawable,
|
||||
return gimp_image_pick_color (tool->gdisp->gimage, tool->drawable, x, y,
|
||||
color_tool->options->sample_merged,
|
||||
x, y,
|
||||
color_tool->options->sample_average,
|
||||
color_tool->options->average_radius,
|
||||
sample_type,
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimpimagemap.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
|
@ -36,6 +37,7 @@
|
|||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimpimagemaptool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
||||
|
@ -55,6 +57,12 @@ static void gimp_image_map_tool_control (GimpTool *tool,
|
|||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static gboolean gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpImageType *sample_type,
|
||||
GimpRGB *color,
|
||||
gint *color_index);
|
||||
static void gimp_image_map_tool_map (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_image_map_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_image_map_tool_reset (GimpImageMapTool *image_map_tool);
|
||||
|
@ -95,7 +103,7 @@ gimp_image_map_tool_get_type (void)
|
|||
(GInstanceInitFunc) gimp_image_map_tool_init,
|
||||
};
|
||||
|
||||
tool_type = g_type_register_static (GIMP_TYPE_TOOL,
|
||||
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
||||
"GimpImageMapTool",
|
||||
&tool_info, 0);
|
||||
}
|
||||
|
@ -106,11 +114,13 @@ gimp_image_map_tool_get_type (void)
|
|||
static void
|
||||
gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpColorToolClass *color_tool_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -119,6 +129,8 @@ gimp_image_map_tool_class_init (GimpImageMapToolClass *klass)
|
|||
tool_class->initialize = gimp_image_map_tool_initialize;
|
||||
tool_class->control = gimp_image_map_tool_control;
|
||||
|
||||
color_tool_class->pick = gimp_image_map_tool_pick_color;
|
||||
|
||||
klass->map = NULL;
|
||||
klass->dialog = NULL;
|
||||
klass->reset = NULL;
|
||||
|
@ -288,18 +300,10 @@ gimp_image_map_tool_control (GimpTool *tool,
|
|||
GimpToolAction action,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpImageMapTool *image_map_tool;
|
||||
|
||||
image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
||||
GimpImageMapTool *image_map_tool = GIMP_IMAGE_MAP_TOOL (tool);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE:
|
||||
break;
|
||||
|
||||
case RESUME:
|
||||
break;
|
||||
|
||||
case HALT:
|
||||
if (image_map_tool->shell)
|
||||
gimp_image_map_tool_cancel_clicked (NULL, image_map_tool);
|
||||
|
@ -312,6 +316,25 @@ gimp_image_map_tool_control (GimpTool *tool,
|
|||
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_image_map_tool_pick_color (GimpColorTool *color_tool,
|
||||
gint x,
|
||||
gint y,
|
||||
GimpImageType *sample_type,
|
||||
GimpRGB *color,
|
||||
gint *color_index)
|
||||
{
|
||||
GimpImageMapTool *tool = GIMP_IMAGE_MAP_TOOL (color_tool);
|
||||
|
||||
*sample_type = gimp_drawable_type (tool->drawable);
|
||||
|
||||
return gimp_image_pick_color_by_func (GIMP_OBJECT (tool->image_map), x, y,
|
||||
(GimpImagePickColorFunc) gimp_image_map_get_color_at,
|
||||
color_tool->options->sample_average,
|
||||
color_tool->options->average_radius,
|
||||
color, color_index);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_map_tool_map (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __GIMP_IMAGE_MAP_TOOL_H__
|
||||
|
||||
|
||||
#include "gimptool.h"
|
||||
#include "gimpcolortool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_IMAGE_MAP_TOOL (gimp_image_map_tool_get_type ())
|
||||
|
@ -35,24 +35,24 @@ typedef struct _GimpImageMapToolClass GimpImageMapToolClass;
|
|||
|
||||
struct _GimpImageMapTool
|
||||
{
|
||||
GimpTool parent_instance;
|
||||
GimpColorTool parent_instance;
|
||||
|
||||
GimpDrawable *drawable;
|
||||
GimpImageMap *image_map;
|
||||
GimpDrawable *drawable;
|
||||
GimpImageMap *image_map;
|
||||
|
||||
gboolean preview;
|
||||
gboolean preview;
|
||||
|
||||
/* the dialog */
|
||||
const gchar *shell_identifier;
|
||||
const gchar *shell_desc;
|
||||
const gchar *shell_identifier;
|
||||
const gchar *shell_desc;
|
||||
|
||||
GtkWidget *shell;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *shell;
|
||||
GtkWidget *main_vbox;
|
||||
};
|
||||
|
||||
struct _GimpImageMapToolClass
|
||||
{
|
||||
GimpToolClass parent_class;
|
||||
GimpColorToolClass parent_class;
|
||||
|
||||
/* virtual functions */
|
||||
void (* map) (GimpImageMapTool *image_map_tool);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -53,6 +54,7 @@
|
|||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimplevelstool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
||||
|
@ -93,21 +95,11 @@ static void gimp_levels_tool_finalize (GObject *object);
|
|||
|
||||
static void gimp_levels_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_levels_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_levels_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_levels_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_levels_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index);
|
||||
static void gimp_levels_tool_map (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||
static void gimp_levels_tool_reset (GimpImageMapTool *image_map_tool);
|
||||
|
@ -143,9 +135,6 @@ static gint levels_input_da_events (GtkWidget *widget,
|
|||
static gint levels_output_da_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
GimpLevelsTool *l_tool);
|
||||
static void levels_input_color_pick (GimpTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
GimpCoords *coords);
|
||||
|
||||
static void file_dialog_create (GimpLevelsTool *l_tool);
|
||||
static void file_dialog_ok_callback (GimpLevelsTool *l_tool);
|
||||
|
@ -166,7 +155,8 @@ gimp_levels_tool_register (GimpToolRegisterCallback callback,
|
|||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_LEVELS_TOOL,
|
||||
G_TYPE_NONE, NULL,
|
||||
GIMP_TYPE_COLOR_OPTIONS,
|
||||
gimp_color_options_gui,
|
||||
FALSE,
|
||||
"gimp-levels-tool",
|
||||
_("Levels"),
|
||||
|
@ -213,20 +203,21 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
|
|||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpColorToolClass *color_tool_class;
|
||||
GimpImageMapToolClass *image_map_tool_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_levels_tool_finalize;
|
||||
object_class->finalize = gimp_levels_tool_finalize;
|
||||
|
||||
tool_class->initialize = gimp_levels_tool_initialize;
|
||||
tool_class->button_press = gimp_levels_tool_button_press;
|
||||
tool_class->motion = gimp_levels_tool_motion;
|
||||
tool_class->cursor_update = gimp_levels_tool_cursor_update;
|
||||
tool_class->initialize = gimp_levels_tool_initialize;
|
||||
|
||||
color_tool_class->picked = gimp_levels_tool_color_picked;
|
||||
|
||||
image_map_tool_class->map = gimp_levels_tool_map;
|
||||
image_map_tool_class->dialog = gimp_levels_tool_dialog;
|
||||
|
@ -333,50 +324,6 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||
l_tool->hist);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_levels_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
levels_input_color_pick (tool, tool->drawable, coords);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_levels_tool_motion (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
levels_input_color_pick (tool, tool->drawable, coords);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_levels_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
if (GIMP_LEVELS_TOOL (tool)->active_picker)
|
||||
{
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
||||
gimp_tool_control_set_cursor (tool->control,
|
||||
gimp_display_coords_in_active_drawable (gdisp,
|
||||
coords) ?
|
||||
GIMP_MOUSE_CURSOR : GIMP_BAD_CURSOR);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_NONE);
|
||||
gimp_tool_control_set_cursor (tool->control, GIMP_MOUSE_CURSOR);
|
||||
}
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_levels_tool_map (GimpImageMapTool *image_map_tool)
|
||||
{
|
||||
|
@ -1173,11 +1120,15 @@ levels_input_picker_toggled (GtkWidget *widget,
|
|||
FALSE);
|
||||
|
||||
tool->active_picker = widget;
|
||||
|
||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
||||
GIMP_COLOR_OPTIONS (GIMP_TOOL (tool)->tool_info->tool_options));
|
||||
}
|
||||
else if (tool->active_picker == widget)
|
||||
{
|
||||
tool->active_picker = NULL;
|
||||
}
|
||||
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1394,34 +1345,27 @@ levels_input_adjust_by_color (Levels *levels,
|
|||
}
|
||||
|
||||
static void
|
||||
levels_input_color_pick (GimpTool *tool,
|
||||
GimpDrawable *drawable,
|
||||
GimpCoords *coords)
|
||||
gimp_levels_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index)
|
||||
{
|
||||
GimpLevelsTool *l_tool;
|
||||
guchar *color;
|
||||
guchar col[5];
|
||||
guint value;
|
||||
gint x, y;
|
||||
|
||||
l_tool = GIMP_LEVELS_TOOL (tool);
|
||||
l_tool = GIMP_LEVELS_TOOL (color_tool);
|
||||
|
||||
if (! l_tool->active_picker || !drawable)
|
||||
return;
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (drawable), &x, &y);
|
||||
|
||||
x = RINT (coords->x) - x;
|
||||
y = RINT (coords->y) - y;
|
||||
|
||||
color = gimp_image_map_get_color_at (GIMP_IMAGE_MAP_TOOL (tool)->image_map,
|
||||
x, y);
|
||||
if (!color)
|
||||
return;
|
||||
gimp_rgba_get_uchar (color,
|
||||
col + RED_PIX,
|
||||
col + GREEN_PIX,
|
||||
col + BLUE_PIX,
|
||||
col + ALPHA_PIX);
|
||||
|
||||
value = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l_tool->active_picker),
|
||||
"pick_value"));
|
||||
|
||||
if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (drawable->type))
|
||||
if (value & ALL_CHANNELS && GIMP_IMAGE_TYPE_IS_RGB (sample_type))
|
||||
{
|
||||
GimpHistogramChannel channel;
|
||||
|
||||
|
@ -1446,20 +1390,19 @@ levels_input_color_pick (GimpTool *tool,
|
|||
channel <= GIMP_HISTOGRAM_BLUE;
|
||||
channel++)
|
||||
{
|
||||
levels_input_adjust_by_color (l_tool->levels, value, channel, color);
|
||||
levels_input_adjust_by_color (l_tool->levels,
|
||||
value, channel, col);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
levels_input_adjust_by_color (l_tool->levels,
|
||||
value, l_tool->channel, color);
|
||||
value, l_tool->channel, col);
|
||||
}
|
||||
|
||||
levels_update (l_tool, ALL);
|
||||
|
||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (l_tool));
|
||||
|
||||
g_free (color);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in New Issue