mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
changed the default radius.
2003-06-05 Sven Neumann <sven@gimp.org> * app/tools/gimpcoloroptions.c: changed the default radius. * app/tools/gimpcolortool.[ch]: pass GimpColorOptions to gimp_color_tool_enable(). Added gimp_color_tool_disable() and gimp_color_tool_is_enabled(). * app/tools/gimpcolorpickertool.c: changed accordingly. * app/tools/gimppainttool.[ch]: derived GimpPaintTool from GimpColorTool and removed most color picking code. * app/tools/gimpdodgeburntool.c (gimp_dodgeburn_tool_modifier_key) * app/tools/gimperasertool.c (gimp_eraser_tool_modifier_key): chain up to the parent class. * app/tools/gimppaintbrushtool.c: purely cosmetic change.
This commit is contained in:
parent
f8081a8629
commit
21b4aba939
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2003-06-05 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/tools/gimpcoloroptions.c: changed the default radius.
|
||||
|
||||
* app/tools/gimpcolortool.[ch]: pass GimpColorOptions to
|
||||
gimp_color_tool_enable(). Added gimp_color_tool_disable() and
|
||||
gimp_color_tool_is_enabled().
|
||||
|
||||
* app/tools/gimpcolorpickertool.c: changed accordingly.
|
||||
|
||||
* app/tools/gimppainttool.[ch]: derived GimpPaintTool from
|
||||
GimpColorTool and removed most color picking code.
|
||||
|
||||
* app/tools/gimpdodgeburntool.c (gimp_dodgeburn_tool_modifier_key)
|
||||
* app/tools/gimperasertool.c (gimp_eraser_tool_modifier_key):
|
||||
chain up to the parent class.
|
||||
|
||||
* app/tools/gimppaintbrushtool.c: purely cosmetic change.
|
||||
|
||||
2003-06-05 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpchannel.c (gimp_channel_bounds): always return
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "paint/gimppaintcore.h"
|
||||
|
@ -43,7 +42,7 @@
|
|||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpstatusbar.h"
|
||||
|
||||
#include "gimpcolorpickeroptions.h"
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimpcolorpickertool.h"
|
||||
#include "gimppainttool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
@ -79,20 +78,26 @@ static void gimp_paint_tool_motion (GimpTool *tool,
|
|||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_paint_tool_cursor_update (GimpTool *tool,
|
||||
static void gimp_paint_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_paint_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint state);
|
||||
static void gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index);
|
||||
|
||||
|
||||
static GimpDrawToolClass *parent_class = NULL;
|
||||
static GimpColorToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
|
@ -115,7 +120,7 @@ gimp_paint_tool_get_type (void)
|
|||
(GInstanceInitFunc) gimp_paint_tool_init,
|
||||
};
|
||||
|
||||
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
||||
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
||||
"GimpPaintTool",
|
||||
&tool_info, 0);
|
||||
}
|
||||
|
@ -126,13 +131,15 @@ gimp_paint_tool_get_type (void)
|
|||
static void
|
||||
gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GimpColorToolClass *color_tool_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -142,30 +149,28 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
|||
tool_class->button_press = gimp_paint_tool_button_press;
|
||||
tool_class->button_release = gimp_paint_tool_button_release;
|
||||
tool_class->motion = gimp_paint_tool_motion;
|
||||
tool_class->cursor_update = gimp_paint_tool_cursor_update;
|
||||
tool_class->modifier_key = gimp_paint_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_paint_tool_oper_update;
|
||||
|
||||
draw_tool_class->draw = gimp_paint_tool_draw;
|
||||
|
||||
color_tool_class->picked = gimp_paint_tool_color_picked;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
tool = GIMP_TOOL (paint_tool);
|
||||
GimpTool *tool = GIMP_TOOL (paint_tool);
|
||||
|
||||
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
||||
|
||||
paint_tool->pick_colors = FALSE;
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_finalize (GObject *object)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
|
||||
paint_tool = GIMP_PAINT_TOOL (object);
|
||||
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
||||
|
||||
if (paint_tool->core)
|
||||
{
|
||||
|
@ -189,12 +194,6 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE:
|
||||
break;
|
||||
|
||||
case RESUME:
|
||||
break;
|
||||
|
||||
case HALT:
|
||||
gimp_paint_core_paint (paint_tool->core,
|
||||
drawable,
|
||||
|
@ -341,8 +340,12 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
gimp_paint_tool_round_line (core, state);
|
||||
}
|
||||
|
||||
gimp_tool_control_activate (tool->control);
|
||||
tool->gdisp = gdisp;
|
||||
/* let the parent class activate the tool */
|
||||
GIMP_TOOL_CLASS (parent_class)->button_press (tool,
|
||||
coords, time, state, gdisp);
|
||||
|
||||
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||
return;
|
||||
|
||||
/* pause the current selection */
|
||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
|
||||
|
@ -350,26 +353,6 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
/* Let the specific painting function initialize itself */
|
||||
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
||||
|
||||
if (paint_tool->pick_colors &&
|
||||
! (state & GDK_SHIFT_MASK) &&
|
||||
(state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
gimp_paint_tool_sample_color (drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
state);
|
||||
|
||||
paint_tool->pick_state = TRUE;
|
||||
|
||||
gimp_draw_tool_start (draw_tool, gdisp);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
/* store the current brush pointer */
|
||||
current_brush = core->brush;
|
||||
|
||||
|
@ -416,21 +399,15 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||
|
||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
/* Let the specific painting function finish up */
|
||||
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
||||
|
||||
/* resume the current selection */
|
||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
||||
|
||||
/* Set tool state to inactive -- no longer painting */
|
||||
gimp_tool_control_halt (tool->control);
|
||||
/* chain up to halt the tool */
|
||||
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
|
||||
coords, time, state, gdisp);
|
||||
|
||||
gimp_paint_core_finish (core, drawable);
|
||||
|
||||
|
@ -457,11 +434,6 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
|
||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (paint_tool));
|
||||
}
|
||||
|
||||
core->cur_coords = *coords;
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
||||
|
@ -469,17 +441,10 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
core->cur_coords.x -= off_x;
|
||||
core->cur_coords.y -= off_y;
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_paint_tool_sample_color (drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
state);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
||||
|
||||
return;
|
||||
}
|
||||
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
|
||||
|
||||
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||
return;
|
||||
|
||||
if (core->flags & CORE_TRACES_ON_WINDOW)
|
||||
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
||||
|
@ -495,10 +460,40 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_paint_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
if (key != GDK_CONTROL_MASK)
|
||||
return;
|
||||
|
||||
if (GIMP_PAINT_TOOL (tool)->pick_colors && ! (state & GDK_SHIFT_MASK))
|
||||
{
|
||||
if (press)
|
||||
{
|
||||
GimpToolInfo *info;
|
||||
|
||||
info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
|
||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
||||
GIMP_COLOR_OPTIONS (info->tool_options));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_paint_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
|
@ -587,58 +582,22 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
|
|||
|
||||
gimp_draw_tool_start (draw_tool, gdisp);
|
||||
}
|
||||
else if (paint_tool->pick_colors &&
|
||||
! (state & GDK_SHIFT_MASK) &&
|
||||
(state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
/* If Ctrl or Mod1 is pressed, pick colors */
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_COLOR_PICKER_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpPaintCore *core;
|
||||
|
||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||
|
||||
core = paint_tool->core;
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
||||
{
|
||||
GimpToolInfo *info;
|
||||
GimpColorOptions *options;
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpPaintCore *core;
|
||||
|
||||
info = tool_manager_get_info_by_type (GIMP_TOOL (draw_tool)->tool_info->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||
core = paint_tool->core;
|
||||
|
||||
options = GIMP_COLOR_OPTIONS (info->tool_options);
|
||||
|
||||
if (options->sample_average)
|
||||
{
|
||||
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||
FALSE,
|
||||
(core->cur_coords.x -
|
||||
options->average_radius),
|
||||
(core->cur_coords.y -
|
||||
options->average_radius),
|
||||
2 * options->average_radius + 1,
|
||||
2 * options->average_radius + 1,
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw start target */
|
||||
gimp_draw_tool_draw_handle (draw_tool,
|
||||
GIMP_HANDLE_CROSS,
|
||||
|
@ -667,41 +626,23 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||
core->cur_coords.y,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint state)
|
||||
gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index)
|
||||
{
|
||||
GimpToolInfo *picker_info;
|
||||
GimpColorOptions *options;
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
picker_info = tool_manager_get_info_by_type (gimage->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
|
||||
options = GIMP_COLOR_OPTIONS (picker_info->tool_options);
|
||||
|
||||
if (gimp_image_pick_color (gimage,
|
||||
drawable,
|
||||
options->sample_merged,
|
||||
x, y,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
NULL,
|
||||
&color,
|
||||
NULL))
|
||||
if (tool->gdisp)
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK))
|
||||
gimp_context_set_foreground (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
else
|
||||
gimp_context_set_background (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
GimpContext *context;
|
||||
|
||||
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
||||
gimp_context_set_foreground (context, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __GIMP_PAINT_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpdrawtool.h"
|
||||
#include "gimpcolortool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
||||
|
@ -35,17 +35,16 @@ typedef struct _GimpPaintToolClass GimpPaintToolClass;
|
|||
|
||||
struct _GimpPaintTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpColorTool parent_instance;
|
||||
|
||||
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
|
||||
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
|
||||
gboolean pick_colors; /* pick color if ctrl is pressed */
|
||||
|
||||
GimpPaintCore *core;
|
||||
};
|
||||
|
||||
struct _GimpPaintToolClass
|
||||
{
|
||||
GimpDrawToolClass parent_class;
|
||||
GimpColorToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ gimp_color_options_class_init (GimpColorOptionsClass *klass)
|
|||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_AVERAGE_RADIUS,
|
||||
"average-radius", NULL,
|
||||
1.0, 15.0, 1.0,
|
||||
1.0, 30.0, 3.0,
|
||||
0);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,10 @@
|
|||
|
||||
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
|
||||
static void gimp_color_picker_tool_init (GimpColorPickerTool *tool);
|
||||
static void gimp_color_picker_tool_finalize (GObject *object);
|
||||
|
||||
static void gimp_color_picker_tool_finalize (GObject *object);
|
||||
|
||||
static void gimp_color_picker_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_color_picker_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
GimpDisplay *gdisp);
|
||||
|
@ -149,6 +150,7 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
|
|||
|
||||
object_class->finalize = gimp_color_picker_tool_finalize;
|
||||
|
||||
tool_class->initialize = gimp_color_picker_tool_initialize;
|
||||
tool_class->control = gimp_color_picker_tool_control;
|
||||
|
||||
color_tool_class->picked = gimp_color_picker_tool_picked;
|
||||
|
@ -159,8 +161,8 @@ gimp_color_picker_tool_init (GimpColorPickerTool *tool)
|
|||
{
|
||||
gimp_tool_control_set_preserve (GIMP_TOOL (tool)->control, FALSE);
|
||||
|
||||
/* always pick colors */
|
||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool), TRUE);
|
||||
gimp_tool_control_set_tool_cursor (GIMP_TOOL (tool)->control,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -177,6 +179,17 @@ gimp_color_picker_tool_finalize (GObject *object)
|
|||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
|
||||
|
||||
/* always pick colors */
|
||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
||||
GIMP_COLOR_OPTIONS (tool->tool_info->tool_options));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_picker_tool_control (GimpTool *tool,
|
||||
GimpToolAction action,
|
||||
|
@ -215,7 +228,7 @@ gimp_color_picker_tool_picked (GimpColorTool *color_tool,
|
|||
|
||||
gimp_color_picker_tool_info_update (sample_type, color, color_index);
|
||||
|
||||
options = GIMP_COLOR_PICKER_OPTIONS (tool->tool_info->tool_options);
|
||||
options = GIMP_COLOR_PICKER_OPTIONS (color_tool->options);
|
||||
|
||||
if (options->update_active)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,7 @@ enum
|
|||
|
||||
static void gimp_color_tool_class_init (GimpColorToolClass *klass);
|
||||
static void gimp_color_tool_init (GimpColorTool *color_tool);
|
||||
static void gimp_color_tool_finalize (GObject *object);
|
||||
|
||||
static void gimp_color_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
|
@ -122,11 +123,13 @@ gimp_color_tool_get_type (void)
|
|||
static void
|
||||
gimp_color_tool_class_init (GimpColorToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_class;
|
||||
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
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);
|
||||
|
||||
|
@ -142,6 +145,8 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
|
|||
GIMP_TYPE_COLOR | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||
G_TYPE_INT);
|
||||
|
||||
object_class->finalize = gimp_color_tool_finalize;
|
||||
|
||||
tool_class->button_press = gimp_color_tool_button_press;
|
||||
tool_class->button_release = gimp_color_tool_button_release;
|
||||
tool_class->motion = gimp_color_tool_motion;
|
||||
|
@ -153,17 +158,27 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
|
|||
klass->picked = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_tool_finalize (GObject *object)
|
||||
{
|
||||
GimpColorTool *color_tool = GIMP_COLOR_TOOL (object);
|
||||
|
||||
if (color_tool->options)
|
||||
{
|
||||
g_object_unref (color_tool->options);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_tool_init (GimpColorTool *color_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||
|
||||
color_tool->enabled = FALSE;
|
||||
color_tool->center_x = 0;
|
||||
color_tool->center_y = 0;
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -252,13 +267,20 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||
coords->y > 0 &&
|
||||
coords->y < gdisp->gimage->height)
|
||||
{
|
||||
gimp_tool_control_set_cursor (tool->control,
|
||||
GIMP_COLOR_PICKER_CURSOR);
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_COLOR_PICKER_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_tool_control_set_cursor (tool->control, GIMP_BAD_CURSOR);
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_BAD_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
}
|
||||
|
||||
return; /* don't chain up */
|
||||
}
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
|
@ -267,27 +289,23 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||
static void
|
||||
gimp_color_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpColorOptions *options;
|
||||
GimpColorTool *color_tool;
|
||||
|
||||
if (! GIMP_COLOR_TOOL (draw_tool)->enabled)
|
||||
return;
|
||||
|
||||
tool = GIMP_TOOL (draw_tool);
|
||||
options = GIMP_COLOR_OPTIONS (tool->tool_info->tool_options);
|
||||
color_tool = GIMP_COLOR_TOOL (draw_tool);
|
||||
|
||||
if (options->sample_average)
|
||||
if (color_tool->options->sample_average)
|
||||
{
|
||||
GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool);
|
||||
gdouble radius = color_tool->options->average_radius;
|
||||
|
||||
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||
FALSE,
|
||||
(color_tool->center_x -
|
||||
options->average_radius),
|
||||
(color_tool->center_y -
|
||||
options->average_radius),
|
||||
2 * options->average_radius + 1,
|
||||
2 * options->average_radius + 1,
|
||||
color_tool->center_x - radius,
|
||||
color_tool->center_y - radius,
|
||||
2 * radius + 1,
|
||||
2 * radius + 1,
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -300,21 +318,17 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|||
GimpRGB *color,
|
||||
gint *color_index)
|
||||
{
|
||||
GimpTool *tool;
|
||||
GimpColorOptions *options;
|
||||
|
||||
tool = GIMP_TOOL (color_tool);
|
||||
options = GIMP_COLOR_OPTIONS (tool->tool_info->tool_options);
|
||||
GimpTool *tool = GIMP_TOOL (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,
|
||||
options->sample_merged,
|
||||
color_tool->options->sample_merged,
|
||||
x, y,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
color_tool->options->sample_average,
|
||||
color_tool->options->average_radius,
|
||||
sample_type,
|
||||
color,
|
||||
color_index);
|
||||
|
@ -345,8 +359,33 @@ gimp_color_tool_pick (GimpColorTool *tool,
|
|||
|
||||
|
||||
void
|
||||
gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||
gboolean enable)
|
||||
gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||
GimpColorOptions *options)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_TOOL (color_tool));
|
||||
g_return_if_fail (GIMP_IS_COLOR_OPTIONS (options));
|
||||
|
||||
tool = GIMP_TOOL (color_tool);
|
||||
if (gimp_tool_control_is_active (tool->control))
|
||||
{
|
||||
g_warning ("Trying to enable GimpColorTool while it is active.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (color_tool->options)
|
||||
{
|
||||
g_object_unref (color_tool->options);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
color_tool->options = g_object_ref (options);
|
||||
|
||||
color_tool->enabled = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_tool_disable (GimpColorTool *color_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
|
@ -355,9 +394,21 @@ gimp_color_tool_enable (GimpColorTool *color_tool,
|
|||
tool = GIMP_TOOL (color_tool);
|
||||
if (gimp_tool_control_is_active (tool->control))
|
||||
{
|
||||
g_warning ("Trying to enable/disable GimpColorTool while it is active.");
|
||||
g_warning ("Trying to disable GimpColorTool while it is active.");
|
||||
return;
|
||||
}
|
||||
|
||||
color_tool->enabled = enable ? TRUE : FALSE;
|
||||
if (color_tool->options)
|
||||
{
|
||||
g_object_unref (color_tool->options);
|
||||
color_tool->options = NULL;
|
||||
}
|
||||
|
||||
color_tool->enabled = FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_color_tool_is_enabled (GimpColorTool *color_tool)
|
||||
{
|
||||
return color_tool->enabled;
|
||||
}
|
||||
|
|
|
@ -35,11 +35,13 @@ typedef struct _GimpColorToolClass GimpColorToolClass;
|
|||
|
||||
struct _GimpColorTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpDrawTool parent_instance;
|
||||
|
||||
gboolean enabled;
|
||||
gint center_x;
|
||||
gint center_y;
|
||||
gboolean enabled;
|
||||
gint center_x;
|
||||
gint center_y;
|
||||
|
||||
GimpColorOptions *options;
|
||||
};
|
||||
|
||||
struct _GimpColorToolClass
|
||||
|
@ -62,9 +64,12 @@ struct _GimpColorToolClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_color_tool_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_color_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||
GimpColorOptions *options);
|
||||
void gimp_color_tool_disable (GimpColorTool *color_tool);
|
||||
gboolean gimp_color_tool_is_enabled (GimpColorTool *color_tool);
|
||||
|
||||
void gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||
gboolean enable);
|
||||
|
||||
#endif /* __GIMP_COLOR_TOOL_H__ */
|
||||
|
|
|
@ -162,7 +162,8 @@ gimp_dodgeburn_tool_modifier_key (GimpTool *tool,
|
|||
}
|
||||
}
|
||||
|
||||
gimp_tool_control_set_toggle (tool->control, (options->type == GIMP_BURN));
|
||||
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool,
|
||||
key, press, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -142,17 +142,20 @@ gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpEraserOptions *options;
|
||||
|
||||
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
if ((key == GDK_CONTROL_MASK) &&
|
||||
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
|
||||
{
|
||||
GimpEraserOptions *options;
|
||||
|
||||
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
g_object_set (options,
|
||||
"anti-erase", ! options->anti_erase,
|
||||
NULL);
|
||||
}
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool,
|
||||
key, press, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -110,7 +110,8 @@ gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush)
|
|||
tool = GIMP_TOOL (paintbrush);
|
||||
paint_tool = GIMP_PAINT_TOOL (paintbrush);
|
||||
|
||||
gimp_tool_control_set_tool_cursor (tool->control, GIMP_PAINTBRUSH_TOOL_CURSOR);
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_PAINTBRUSH_TOOL_CURSOR);
|
||||
|
||||
paint_tool->pick_colors = TRUE;
|
||||
paint_tool->core = g_object_new (GIMP_TYPE_PAINTBRUSH, NULL);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-pick-color.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "paint/gimppaintcore.h"
|
||||
|
@ -43,7 +42,7 @@
|
|||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpstatusbar.h"
|
||||
|
||||
#include "gimpcolorpickeroptions.h"
|
||||
#include "gimpcoloroptions.h"
|
||||
#include "gimpcolorpickertool.h"
|
||||
#include "gimppainttool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
@ -79,20 +78,26 @@ static void gimp_paint_tool_motion (GimpTool *tool,
|
|||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_paint_tool_cursor_update (GimpTool *tool,
|
||||
static void gimp_paint_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_paint_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static void gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint state);
|
||||
static void gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index);
|
||||
|
||||
|
||||
static GimpDrawToolClass *parent_class = NULL;
|
||||
static GimpColorToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
|
@ -115,7 +120,7 @@ gimp_paint_tool_get_type (void)
|
|||
(GInstanceInitFunc) gimp_paint_tool_init,
|
||||
};
|
||||
|
||||
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
||||
tool_type = g_type_register_static (GIMP_TYPE_COLOR_TOOL,
|
||||
"GimpPaintTool",
|
||||
&tool_info, 0);
|
||||
}
|
||||
|
@ -126,13 +131,15 @@ gimp_paint_tool_get_type (void)
|
|||
static void
|
||||
gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GObjectClass *object_class;
|
||||
GimpToolClass *tool_class;
|
||||
GimpDrawToolClass *draw_tool_class;
|
||||
GimpColorToolClass *color_tool_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
color_tool_class = GIMP_COLOR_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -142,30 +149,28 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
|||
tool_class->button_press = gimp_paint_tool_button_press;
|
||||
tool_class->button_release = gimp_paint_tool_button_release;
|
||||
tool_class->motion = gimp_paint_tool_motion;
|
||||
tool_class->cursor_update = gimp_paint_tool_cursor_update;
|
||||
tool_class->modifier_key = gimp_paint_tool_modifier_key;
|
||||
tool_class->oper_update = gimp_paint_tool_oper_update;
|
||||
|
||||
draw_tool_class->draw = gimp_paint_tool_draw;
|
||||
|
||||
color_tool_class->picked = gimp_paint_tool_color_picked;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
||||
{
|
||||
GimpTool *tool;
|
||||
|
||||
tool = GIMP_TOOL (paint_tool);
|
||||
GimpTool *tool = GIMP_TOOL (paint_tool);
|
||||
|
||||
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
||||
|
||||
paint_tool->pick_colors = FALSE;
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_finalize (GObject *object)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
|
||||
paint_tool = GIMP_PAINT_TOOL (object);
|
||||
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
||||
|
||||
if (paint_tool->core)
|
||||
{
|
||||
|
@ -189,12 +194,6 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||
|
||||
switch (action)
|
||||
{
|
||||
case PAUSE:
|
||||
break;
|
||||
|
||||
case RESUME:
|
||||
break;
|
||||
|
||||
case HALT:
|
||||
gimp_paint_core_paint (paint_tool->core,
|
||||
drawable,
|
||||
|
@ -341,8 +340,12 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
gimp_paint_tool_round_line (core, state);
|
||||
}
|
||||
|
||||
gimp_tool_control_activate (tool->control);
|
||||
tool->gdisp = gdisp;
|
||||
/* let the parent class activate the tool */
|
||||
GIMP_TOOL_CLASS (parent_class)->button_press (tool,
|
||||
coords, time, state, gdisp);
|
||||
|
||||
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||
return;
|
||||
|
||||
/* pause the current selection */
|
||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
|
||||
|
@ -350,26 +353,6 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||
/* Let the specific painting function initialize itself */
|
||||
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
||||
|
||||
if (paint_tool->pick_colors &&
|
||||
! (state & GDK_SHIFT_MASK) &&
|
||||
(state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
gimp_paint_tool_sample_color (drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
state);
|
||||
|
||||
paint_tool->pick_state = TRUE;
|
||||
|
||||
gimp_draw_tool_start (draw_tool, gdisp);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
/* store the current brush pointer */
|
||||
current_brush = core->brush;
|
||||
|
||||
|
@ -416,21 +399,15 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||
|
||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
paint_tool->pick_state = FALSE;
|
||||
}
|
||||
|
||||
/* Let the specific painting function finish up */
|
||||
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
||||
|
||||
/* resume the current selection */
|
||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
||||
|
||||
/* Set tool state to inactive -- no longer painting */
|
||||
gimp_tool_control_halt (tool->control);
|
||||
/* chain up to halt the tool */
|
||||
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
|
||||
coords, time, state, gdisp);
|
||||
|
||||
gimp_paint_core_finish (core, drawable);
|
||||
|
||||
|
@ -457,11 +434,6 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
|
||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (paint_tool));
|
||||
}
|
||||
|
||||
core->cur_coords = *coords;
|
||||
|
||||
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
||||
|
@ -469,17 +441,10 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
core->cur_coords.x -= off_x;
|
||||
core->cur_coords.y -= off_y;
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
{
|
||||
gimp_paint_tool_sample_color (drawable,
|
||||
coords->x,
|
||||
coords->y,
|
||||
state);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
||||
|
||||
return;
|
||||
}
|
||||
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
|
||||
|
||||
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||
return;
|
||||
|
||||
if (core->flags & CORE_TRACES_ON_WINDOW)
|
||||
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
||||
|
@ -495,10 +460,40 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
gimp_paint_tool_modifier_key (GimpTool *tool,
|
||||
GdkModifierType key,
|
||||
gboolean press,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
if (key != GDK_CONTROL_MASK)
|
||||
return;
|
||||
|
||||
if (GIMP_PAINT_TOOL (tool)->pick_colors && ! (state & GDK_SHIFT_MASK))
|
||||
{
|
||||
if (press)
|
||||
{
|
||||
GimpToolInfo *info;
|
||||
|
||||
info = tool_manager_get_info_by_type (gdisp->gimage->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
|
||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool),
|
||||
GIMP_COLOR_OPTIONS (info->tool_options));
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_color_tool_disable (GIMP_COLOR_TOOL (tool));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_paint_tool_oper_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpDrawTool *draw_tool;
|
||||
|
@ -587,58 +582,22 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
|
|||
|
||||
gimp_draw_tool_start (draw_tool, gdisp);
|
||||
}
|
||||
else if (paint_tool->pick_colors &&
|
||||
! (state & GDK_SHIFT_MASK) &&
|
||||
(state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)))
|
||||
{
|
||||
/* If Ctrl or Mod1 is pressed, pick colors */
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp,
|
||||
GIMP_COLOR_PICKER_CURSOR,
|
||||
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||
GIMP_CURSOR_MODIFIER_NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpPaintCore *core;
|
||||
|
||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||
|
||||
core = paint_tool->core;
|
||||
|
||||
if (paint_tool->pick_state)
|
||||
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
||||
{
|
||||
GimpToolInfo *info;
|
||||
GimpColorOptions *options;
|
||||
GimpPaintTool *paint_tool;
|
||||
GimpPaintCore *core;
|
||||
|
||||
info = tool_manager_get_info_by_type (GIMP_TOOL (draw_tool)->tool_info->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||
core = paint_tool->core;
|
||||
|
||||
options = GIMP_COLOR_OPTIONS (info->tool_options);
|
||||
|
||||
if (options->sample_average)
|
||||
{
|
||||
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||
FALSE,
|
||||
(core->cur_coords.x -
|
||||
options->average_radius),
|
||||
(core->cur_coords.y -
|
||||
options->average_radius),
|
||||
2 * options->average_radius + 1,
|
||||
2 * options->average_radius + 1,
|
||||
TRUE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Draw start target */
|
||||
gimp_draw_tool_draw_handle (draw_tool,
|
||||
GIMP_HANDLE_CROSS,
|
||||
|
@ -667,41 +626,23 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||
core->cur_coords.y,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
gint state)
|
||||
gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||
GimpImageType sample_type,
|
||||
GimpRGB *color,
|
||||
gint color_index)
|
||||
{
|
||||
GimpToolInfo *picker_info;
|
||||
GimpColorOptions *options;
|
||||
GimpImage *gimage;
|
||||
GimpRGB color;
|
||||
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||
|
||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
|
||||
picker_info = tool_manager_get_info_by_type (gimage->gimp,
|
||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
||||
|
||||
options = GIMP_COLOR_OPTIONS (picker_info->tool_options);
|
||||
|
||||
if (gimp_image_pick_color (gimage,
|
||||
drawable,
|
||||
options->sample_merged,
|
||||
x, y,
|
||||
options->sample_average,
|
||||
options->average_radius,
|
||||
NULL,
|
||||
&color,
|
||||
NULL))
|
||||
if (tool->gdisp)
|
||||
{
|
||||
if ((state & GDK_CONTROL_MASK))
|
||||
gimp_context_set_foreground (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
else
|
||||
gimp_context_set_background (gimp_get_user_context (gimage->gimp),
|
||||
&color);
|
||||
GimpContext *context;
|
||||
|
||||
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
||||
gimp_context_set_foreground (context, color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#define __GIMP_PAINT_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpdrawtool.h"
|
||||
#include "gimpcolortool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
||||
|
@ -35,17 +35,16 @@ typedef struct _GimpPaintToolClass GimpPaintToolClass;
|
|||
|
||||
struct _GimpPaintTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
GimpColorTool parent_instance;
|
||||
|
||||
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
|
||||
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
|
||||
gboolean pick_colors; /* pick color if ctrl is pressed */
|
||||
|
||||
GimpPaintCore *core;
|
||||
};
|
||||
|
||||
struct _GimpPaintToolClass
|
||||
{
|
||||
GimpDrawToolClass parent_class;
|
||||
GimpColorToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue