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:

committed by
Sven Neumann

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>
|
2003-06-05 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/core/gimpchannel.c (gimp_channel_bounds): always return
|
* app/core/gimpchannel.c (gimp_channel_bounds): always return
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimpimage-pick-color.h"
|
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
|
|
||||||
#include "paint/gimppaintcore.h"
|
#include "paint/gimppaintcore.h"
|
||||||
@ -43,7 +42,7 @@
|
|||||||
#include "display/gimpdisplayshell.h"
|
#include "display/gimpdisplayshell.h"
|
||||||
#include "display/gimpstatusbar.h"
|
#include "display/gimpstatusbar.h"
|
||||||
|
|
||||||
#include "gimpcolorpickeroptions.h"
|
#include "gimpcoloroptions.h"
|
||||||
#include "gimpcolorpickertool.h"
|
#include "gimpcolorpickertool.h"
|
||||||
#include "gimppainttool.h"
|
#include "gimppainttool.h"
|
||||||
#include "gimptoolcontrol.h"
|
#include "gimptoolcontrol.h"
|
||||||
@ -79,20 +78,26 @@ static void gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
guint32 time,
|
guint32 time,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp);
|
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,
|
GimpCoords *coords,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp);
|
GimpDisplay *gdisp);
|
||||||
|
|
||||||
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
||||||
|
|
||||||
static void gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
static void gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||||
gint x,
|
GimpImageType sample_type,
|
||||||
gint y,
|
GimpRGB *color,
|
||||||
gint state);
|
gint color_index);
|
||||||
|
|
||||||
|
|
||||||
static GimpDrawToolClass *parent_class = NULL;
|
static GimpColorToolClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
GType
|
GType
|
||||||
@ -115,7 +120,7 @@ gimp_paint_tool_get_type (void)
|
|||||||
(GInstanceInitFunc) gimp_paint_tool_init,
|
(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",
|
"GimpPaintTool",
|
||||||
&tool_info, 0);
|
&tool_info, 0);
|
||||||
}
|
}
|
||||||
@ -129,10 +134,12 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
|||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GimpToolClass *tool_class;
|
GimpToolClass *tool_class;
|
||||||
GimpDrawToolClass *draw_tool_class;
|
GimpDrawToolClass *draw_tool_class;
|
||||||
|
GimpColorToolClass *color_tool_class;
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
tool_class = GIMP_TOOL_CLASS (klass);
|
tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
draw_tool_class = GIMP_DRAW_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);
|
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_press = gimp_paint_tool_button_press;
|
||||||
tool_class->button_release = gimp_paint_tool_button_release;
|
tool_class->button_release = gimp_paint_tool_button_release;
|
||||||
tool_class->motion = gimp_paint_tool_motion;
|
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;
|
draw_tool_class->draw = gimp_paint_tool_draw;
|
||||||
|
|
||||||
|
color_tool_class->picked = gimp_paint_tool_color_picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
||||||
{
|
{
|
||||||
GimpTool *tool;
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
||||||
|
|
||||||
tool = GIMP_TOOL (paint_tool);
|
|
||||||
|
|
||||||
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
||||||
|
|
||||||
paint_tool->pick_colors = FALSE;
|
paint_tool->pick_colors = FALSE;
|
||||||
paint_tool->pick_state = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_finalize (GObject *object)
|
gimp_paint_tool_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GimpPaintTool *paint_tool;
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
||||||
|
|
||||||
paint_tool = GIMP_PAINT_TOOL (object);
|
|
||||||
|
|
||||||
if (paint_tool->core)
|
if (paint_tool->core)
|
||||||
{
|
{
|
||||||
@ -189,12 +194,6 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case PAUSE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RESUME:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HALT:
|
case HALT:
|
||||||
gimp_paint_core_paint (paint_tool->core,
|
gimp_paint_core_paint (paint_tool->core,
|
||||||
drawable,
|
drawable,
|
||||||
@ -341,8 +340,12 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||||||
gimp_paint_tool_round_line (core, state);
|
gimp_paint_tool_round_line (core, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_tool_control_activate (tool->control);
|
/* let the parent class activate the tool */
|
||||||
tool->gdisp = gdisp;
|
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 */
|
/* pause the current selection */
|
||||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
|
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 */
|
/* Let the specific painting function initialize itself */
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
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 */
|
/* store the current brush pointer */
|
||||||
current_brush = core->brush;
|
current_brush = core->brush;
|
||||||
|
|
||||||
@ -416,21 +399,15 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||||||
|
|
||||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
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 */
|
/* Let the specific painting function finish up */
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
||||||
|
|
||||||
/* resume the current selection */
|
/* resume the current selection */
|
||||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
||||||
|
|
||||||
/* Set tool state to inactive -- no longer painting */
|
/* chain up to halt the tool */
|
||||||
gimp_tool_control_halt (tool->control);
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
|
||||||
|
coords, time, state, gdisp);
|
||||||
|
|
||||||
gimp_paint_core_finish (core, drawable);
|
gimp_paint_core_finish (core, drawable);
|
||||||
|
|
||||||
@ -457,11 +434,6 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
|
|
||||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
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;
|
core->cur_coords = *coords;
|
||||||
|
|
||||||
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
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.x -= off_x;
|
||||||
core->cur_coords.y -= off_y;
|
core->cur_coords.y -= off_y;
|
||||||
|
|
||||||
if (paint_tool->pick_state)
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
|
||||||
{
|
|
||||||
gimp_paint_tool_sample_color (drawable,
|
|
||||||
coords->x,
|
|
||||||
coords->y,
|
|
||||||
state);
|
|
||||||
|
|
||||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
|
||||||
|
|
||||||
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (core->flags & CORE_TRACES_ON_WINDOW)
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
||||||
@ -495,7 +460,37 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_cursor_update (GimpTool *tool,
|
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,
|
GimpCoords *coords,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp)
|
GimpDisplay *gdisp)
|
||||||
@ -587,58 +582,22 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
|
|||||||
|
|
||||||
gimp_draw_tool_start (draw_tool, gdisp);
|
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
|
static void
|
||||||
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
||||||
|
{
|
||||||
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
||||||
{
|
{
|
||||||
GimpPaintTool *paint_tool;
|
GimpPaintTool *paint_tool;
|
||||||
GimpPaintCore *core;
|
GimpPaintCore *core;
|
||||||
|
|
||||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||||
|
|
||||||
core = paint_tool->core;
|
core = paint_tool->core;
|
||||||
|
|
||||||
if (paint_tool->pick_state)
|
|
||||||
{
|
|
||||||
GimpToolInfo *info;
|
|
||||||
GimpColorOptions *options;
|
|
||||||
|
|
||||||
info = tool_manager_get_info_by_type (GIMP_TOOL (draw_tool)->tool_info->gimp,
|
|
||||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
|
||||||
|
|
||||||
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 */
|
/* Draw start target */
|
||||||
gimp_draw_tool_draw_handle (draw_tool,
|
gimp_draw_tool_draw_handle (draw_tool,
|
||||||
GIMP_HANDLE_CROSS,
|
GIMP_HANDLE_CROSS,
|
||||||
@ -667,41 +626,23 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||||||
core->cur_coords.y,
|
core->cur_coords.y,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||||
gint x,
|
GimpImageType sample_type,
|
||||||
gint y,
|
GimpRGB *color,
|
||||||
gint state)
|
gint color_index)
|
||||||
{
|
{
|
||||||
GimpToolInfo *picker_info;
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||||
GimpColorOptions *options;
|
|
||||||
GimpImage *gimage;
|
|
||||||
GimpRGB color;
|
|
||||||
|
|
||||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
if (tool->gdisp)
|
||||||
|
|
||||||
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 ((state & GDK_CONTROL_MASK))
|
GimpContext *context;
|
||||||
gimp_context_set_foreground (gimp_get_user_context (gimage->gimp),
|
|
||||||
&color);
|
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
||||||
else
|
gimp_context_set_foreground (context, color);
|
||||||
gimp_context_set_background (gimp_get_user_context (gimage->gimp),
|
|
||||||
&color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define __GIMP_PAINT_TOOL_H__
|
#define __GIMP_PAINT_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
#include "gimpdrawtool.h"
|
#include "gimpcolortool.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
||||||
@ -35,17 +35,16 @@ typedef struct _GimpPaintToolClass GimpPaintToolClass;
|
|||||||
|
|
||||||
struct _GimpPaintTool
|
struct _GimpPaintTool
|
||||||
{
|
{
|
||||||
GimpDrawTool parent_instance;
|
GimpColorTool parent_instance;
|
||||||
|
|
||||||
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
|
gboolean pick_colors; /* pick color if ctrl is pressed */
|
||||||
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
|
|
||||||
|
|
||||||
GimpPaintCore *core;
|
GimpPaintCore *core;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpPaintToolClass
|
struct _GimpPaintToolClass
|
||||||
{
|
{
|
||||||
GimpDrawToolClass parent_class;
|
GimpColorToolClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ gimp_color_options_class_init (GimpColorOptionsClass *klass)
|
|||||||
0);
|
0);
|
||||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_AVERAGE_RADIUS,
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_AVERAGE_RADIUS,
|
||||||
"average-radius", NULL,
|
"average-radius", NULL,
|
||||||
1.0, 15.0, 1.0,
|
1.0, 30.0, 3.0,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,10 @@
|
|||||||
|
|
||||||
static void gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass);
|
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_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,
|
static void gimp_color_picker_tool_control (GimpTool *tool,
|
||||||
GimpToolAction action,
|
GimpToolAction action,
|
||||||
GimpDisplay *gdisp);
|
GimpDisplay *gdisp);
|
||||||
@ -149,6 +150,7 @@ gimp_color_picker_tool_class_init (GimpColorPickerToolClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = gimp_color_picker_tool_finalize;
|
object_class->finalize = gimp_color_picker_tool_finalize;
|
||||||
|
|
||||||
|
tool_class->initialize = gimp_color_picker_tool_initialize;
|
||||||
tool_class->control = gimp_color_picker_tool_control;
|
tool_class->control = gimp_color_picker_tool_control;
|
||||||
|
|
||||||
color_tool_class->picked = gimp_color_picker_tool_picked;
|
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);
|
gimp_tool_control_set_preserve (GIMP_TOOL (tool)->control, FALSE);
|
||||||
|
|
||||||
/* always pick colors */
|
gimp_tool_control_set_tool_cursor (GIMP_TOOL (tool)->control,
|
||||||
gimp_color_tool_enable (GIMP_COLOR_TOOL (tool), TRUE);
|
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -177,6 +179,17 @@ gimp_color_picker_tool_finalize (GObject *object)
|
|||||||
G_OBJECT_CLASS (parent_class)->finalize (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
|
static void
|
||||||
gimp_color_picker_tool_control (GimpTool *tool,
|
gimp_color_picker_tool_control (GimpTool *tool,
|
||||||
GimpToolAction action,
|
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);
|
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)
|
if (options->update_active)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +52,7 @@ enum
|
|||||||
|
|
||||||
static void gimp_color_tool_class_init (GimpColorToolClass *klass);
|
static void gimp_color_tool_class_init (GimpColorToolClass *klass);
|
||||||
static void gimp_color_tool_init (GimpColorTool *color_tool);
|
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,
|
static void gimp_color_tool_button_press (GimpTool *tool,
|
||||||
GimpCoords *coords,
|
GimpCoords *coords,
|
||||||
@ -122,9 +123,11 @@ gimp_color_tool_get_type (void)
|
|||||||
static void
|
static void
|
||||||
gimp_color_tool_class_init (GimpColorToolClass *klass)
|
gimp_color_tool_class_init (GimpColorToolClass *klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *object_class;
|
||||||
GimpToolClass *tool_class;
|
GimpToolClass *tool_class;
|
||||||
GimpDrawToolClass *draw_class;
|
GimpDrawToolClass *draw_class;
|
||||||
|
|
||||||
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
tool_class = GIMP_TOOL_CLASS (klass);
|
tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||||
|
|
||||||
@ -142,6 +145,8 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
|
|||||||
GIMP_TYPE_COLOR | G_SIGNAL_TYPE_STATIC_SCOPE,
|
GIMP_TYPE_COLOR | G_SIGNAL_TYPE_STATIC_SCOPE,
|
||||||
G_TYPE_INT);
|
G_TYPE_INT);
|
||||||
|
|
||||||
|
object_class->finalize = gimp_color_tool_finalize;
|
||||||
|
|
||||||
tool_class->button_press = gimp_color_tool_button_press;
|
tool_class->button_press = gimp_color_tool_button_press;
|
||||||
tool_class->button_release = gimp_color_tool_button_release;
|
tool_class->button_release = gimp_color_tool_button_release;
|
||||||
tool_class->motion = gimp_color_tool_motion;
|
tool_class->motion = gimp_color_tool_motion;
|
||||||
@ -153,17 +158,27 @@ gimp_color_tool_class_init (GimpColorToolClass *klass)
|
|||||||
klass->picked = NULL;
|
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
|
static void
|
||||||
gimp_color_tool_init (GimpColorTool *color_tool)
|
gimp_color_tool_init (GimpColorTool *color_tool)
|
||||||
{
|
{
|
||||||
GimpTool *tool = GIMP_TOOL (color_tool);
|
|
||||||
|
|
||||||
color_tool->enabled = FALSE;
|
color_tool->enabled = FALSE;
|
||||||
color_tool->center_x = 0;
|
color_tool->center_x = 0;
|
||||||
color_tool->center_y = 0;
|
color_tool->center_y = 0;
|
||||||
|
color_tool->options = NULL;
|
||||||
gimp_tool_control_set_tool_cursor (tool->control,
|
|
||||||
GIMP_COLOR_PICKER_TOOL_CURSOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -252,13 +267,20 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||||||
coords->y > 0 &&
|
coords->y > 0 &&
|
||||||
coords->y < gdisp->gimage->height)
|
coords->y < gdisp->gimage->height)
|
||||||
{
|
{
|
||||||
gimp_tool_control_set_cursor (tool->control,
|
gimp_tool_set_cursor (tool, gdisp,
|
||||||
GIMP_COLOR_PICKER_CURSOR);
|
GIMP_COLOR_PICKER_CURSOR,
|
||||||
|
GIMP_COLOR_PICKER_TOOL_CURSOR,
|
||||||
|
GIMP_CURSOR_MODIFIER_NONE);
|
||||||
}
|
}
|
||||||
else
|
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);
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||||
@ -267,27 +289,23 @@ gimp_color_tool_cursor_update (GimpTool *tool,
|
|||||||
static void
|
static void
|
||||||
gimp_color_tool_draw (GimpDrawTool *draw_tool)
|
gimp_color_tool_draw (GimpDrawTool *draw_tool)
|
||||||
{
|
{
|
||||||
GimpTool *tool;
|
GimpColorTool *color_tool;
|
||||||
GimpColorOptions *options;
|
|
||||||
|
|
||||||
if (! GIMP_COLOR_TOOL (draw_tool)->enabled)
|
if (! GIMP_COLOR_TOOL (draw_tool)->enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tool = GIMP_TOOL (draw_tool);
|
color_tool = GIMP_COLOR_TOOL (draw_tool);
|
||||||
options = GIMP_COLOR_OPTIONS (tool->tool_info->tool_options);
|
|
||||||
|
|
||||||
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,
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
||||||
FALSE,
|
FALSE,
|
||||||
(color_tool->center_x -
|
color_tool->center_x - radius,
|
||||||
options->average_radius),
|
color_tool->center_y - radius,
|
||||||
(color_tool->center_y -
|
2 * radius + 1,
|
||||||
options->average_radius),
|
2 * radius + 1,
|
||||||
2 * options->average_radius + 1,
|
|
||||||
2 * options->average_radius + 1,
|
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,21 +318,17 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool,
|
|||||||
GimpRGB *color,
|
GimpRGB *color,
|
||||||
gint *color_index)
|
gint *color_index)
|
||||||
{
|
{
|
||||||
GimpTool *tool;
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||||
GimpColorOptions *options;
|
|
||||||
|
|
||||||
tool = GIMP_TOOL (color_tool);
|
|
||||||
options = GIMP_COLOR_OPTIONS (tool->tool_info->tool_options);
|
|
||||||
|
|
||||||
g_return_val_if_fail (tool->gdisp != NULL, FALSE);
|
g_return_val_if_fail (tool->gdisp != NULL, FALSE);
|
||||||
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
g_return_val_if_fail (tool->drawable != NULL, FALSE);
|
||||||
|
|
||||||
return gimp_image_pick_color (tool->gdisp->gimage,
|
return gimp_image_pick_color (tool->gdisp->gimage,
|
||||||
tool->drawable,
|
tool->drawable,
|
||||||
options->sample_merged,
|
color_tool->options->sample_merged,
|
||||||
x, y,
|
x, y,
|
||||||
options->sample_average,
|
color_tool->options->sample_average,
|
||||||
options->average_radius,
|
color_tool->options->average_radius,
|
||||||
sample_type,
|
sample_type,
|
||||||
color,
|
color,
|
||||||
color_index);
|
color_index);
|
||||||
@ -346,7 +360,32 @@ gimp_color_tool_pick (GimpColorTool *tool,
|
|||||||
|
|
||||||
void
|
void
|
||||||
gimp_color_tool_enable (GimpColorTool *color_tool,
|
gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||||
gboolean enable)
|
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;
|
GimpTool *tool;
|
||||||
|
|
||||||
@ -355,9 +394,21 @@ gimp_color_tool_enable (GimpColorTool *color_tool,
|
|||||||
tool = GIMP_TOOL (color_tool);
|
tool = GIMP_TOOL (color_tool);
|
||||||
if (gimp_tool_control_is_active (tool->control))
|
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;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ struct _GimpColorTool
|
|||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
gint center_x;
|
gint center_x;
|
||||||
gint center_y;
|
gint center_y;
|
||||||
|
|
||||||
|
GimpColorOptions *options;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpColorToolClass
|
struct _GimpColorToolClass
|
||||||
@ -65,6 +67,9 @@ 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,
|
void gimp_color_tool_enable (GimpColorTool *color_tool,
|
||||||
gboolean enable);
|
GimpColorOptions *options);
|
||||||
|
void gimp_color_tool_disable (GimpColorTool *color_tool);
|
||||||
|
gboolean gimp_color_tool_is_enabled (GimpColorTool *color_tool);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_COLOR_TOOL_H__ */
|
#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
|
static void
|
||||||
|
@ -141,18 +141,21 @@ gimp_eraser_tool_modifier_key (GimpTool *tool,
|
|||||||
gboolean press,
|
gboolean press,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp)
|
GimpDisplay *gdisp)
|
||||||
|
{
|
||||||
|
if ((key == GDK_CONTROL_MASK) &&
|
||||||
|
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
|
||||||
{
|
{
|
||||||
GimpEraserOptions *options;
|
GimpEraserOptions *options;
|
||||||
|
|
||||||
options = GIMP_ERASER_OPTIONS (tool->tool_info->tool_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 */
|
|
||||||
{
|
|
||||||
g_object_set (options,
|
g_object_set (options,
|
||||||
"anti-erase", ! options->anti_erase,
|
"anti-erase", ! options->anti_erase,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIMP_TOOL_CLASS (parent_class)->modifier_key (tool,
|
||||||
|
key, press, state, gdisp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -110,7 +110,8 @@ gimp_paintbrush_tool_init (GimpPaintbrushTool *paintbrush)
|
|||||||
tool = GIMP_TOOL (paintbrush);
|
tool = GIMP_TOOL (paintbrush);
|
||||||
paint_tool = GIMP_PAINT_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->pick_colors = TRUE;
|
||||||
paint_tool->core = g_object_new (GIMP_TYPE_PAINTBRUSH, NULL);
|
paint_tool->core = g_object_new (GIMP_TYPE_PAINTBRUSH, NULL);
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpdrawable.h"
|
#include "core/gimpdrawable.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimpimage-pick-color.h"
|
|
||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
|
|
||||||
#include "paint/gimppaintcore.h"
|
#include "paint/gimppaintcore.h"
|
||||||
@ -43,7 +42,7 @@
|
|||||||
#include "display/gimpdisplayshell.h"
|
#include "display/gimpdisplayshell.h"
|
||||||
#include "display/gimpstatusbar.h"
|
#include "display/gimpstatusbar.h"
|
||||||
|
|
||||||
#include "gimpcolorpickeroptions.h"
|
#include "gimpcoloroptions.h"
|
||||||
#include "gimpcolorpickertool.h"
|
#include "gimpcolorpickertool.h"
|
||||||
#include "gimppainttool.h"
|
#include "gimppainttool.h"
|
||||||
#include "gimptoolcontrol.h"
|
#include "gimptoolcontrol.h"
|
||||||
@ -79,20 +78,26 @@ static void gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
guint32 time,
|
guint32 time,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp);
|
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,
|
GimpCoords *coords,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp);
|
GimpDisplay *gdisp);
|
||||||
|
|
||||||
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
static void gimp_paint_tool_draw (GimpDrawTool *draw_tool);
|
||||||
|
|
||||||
static void gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
static void gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||||
gint x,
|
GimpImageType sample_type,
|
||||||
gint y,
|
GimpRGB *color,
|
||||||
gint state);
|
gint color_index);
|
||||||
|
|
||||||
|
|
||||||
static GimpDrawToolClass *parent_class = NULL;
|
static GimpColorToolClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
GType
|
GType
|
||||||
@ -115,7 +120,7 @@ gimp_paint_tool_get_type (void)
|
|||||||
(GInstanceInitFunc) gimp_paint_tool_init,
|
(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",
|
"GimpPaintTool",
|
||||||
&tool_info, 0);
|
&tool_info, 0);
|
||||||
}
|
}
|
||||||
@ -129,10 +134,12 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
|
|||||||
GObjectClass *object_class;
|
GObjectClass *object_class;
|
||||||
GimpToolClass *tool_class;
|
GimpToolClass *tool_class;
|
||||||
GimpDrawToolClass *draw_tool_class;
|
GimpDrawToolClass *draw_tool_class;
|
||||||
|
GimpColorToolClass *color_tool_class;
|
||||||
|
|
||||||
object_class = G_OBJECT_CLASS (klass);
|
object_class = G_OBJECT_CLASS (klass);
|
||||||
tool_class = GIMP_TOOL_CLASS (klass);
|
tool_class = GIMP_TOOL_CLASS (klass);
|
||||||
draw_tool_class = GIMP_DRAW_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);
|
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_press = gimp_paint_tool_button_press;
|
||||||
tool_class->button_release = gimp_paint_tool_button_release;
|
tool_class->button_release = gimp_paint_tool_button_release;
|
||||||
tool_class->motion = gimp_paint_tool_motion;
|
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;
|
draw_tool_class->draw = gimp_paint_tool_draw;
|
||||||
|
|
||||||
|
color_tool_class->picked = gimp_paint_tool_color_picked;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
gimp_paint_tool_init (GimpPaintTool *paint_tool)
|
||||||
{
|
{
|
||||||
GimpTool *tool;
|
GimpTool *tool = GIMP_TOOL (paint_tool);
|
||||||
|
|
||||||
tool = GIMP_TOOL (paint_tool);
|
|
||||||
|
|
||||||
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_EXACT);
|
||||||
|
|
||||||
paint_tool->pick_colors = FALSE;
|
paint_tool->pick_colors = FALSE;
|
||||||
paint_tool->pick_state = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_finalize (GObject *object)
|
gimp_paint_tool_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
GimpPaintTool *paint_tool;
|
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (object);
|
||||||
|
|
||||||
paint_tool = GIMP_PAINT_TOOL (object);
|
|
||||||
|
|
||||||
if (paint_tool->core)
|
if (paint_tool->core)
|
||||||
{
|
{
|
||||||
@ -189,12 +194,6 @@ gimp_paint_tool_control (GimpTool *tool,
|
|||||||
|
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case PAUSE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RESUME:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HALT:
|
case HALT:
|
||||||
gimp_paint_core_paint (paint_tool->core,
|
gimp_paint_core_paint (paint_tool->core,
|
||||||
drawable,
|
drawable,
|
||||||
@ -341,8 +340,12 @@ gimp_paint_tool_button_press (GimpTool *tool,
|
|||||||
gimp_paint_tool_round_line (core, state);
|
gimp_paint_tool_round_line (core, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_tool_control_activate (tool->control);
|
/* let the parent class activate the tool */
|
||||||
tool->gdisp = gdisp;
|
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 */
|
/* pause the current selection */
|
||||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_PAUSE);
|
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 */
|
/* Let the specific painting function initialize itself */
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, INIT_PAINT);
|
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 */
|
/* store the current brush pointer */
|
||||||
current_brush = core->brush;
|
current_brush = core->brush;
|
||||||
|
|
||||||
@ -416,21 +399,15 @@ gimp_paint_tool_button_release (GimpTool *tool,
|
|||||||
|
|
||||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
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 */
|
/* Let the specific painting function finish up */
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
gimp_paint_core_paint (core, drawable, paint_options, FINISH_PAINT);
|
||||||
|
|
||||||
/* resume the current selection */
|
/* resume the current selection */
|
||||||
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
gimp_image_selection_control (gdisp->gimage, GIMP_SELECTION_RESUME);
|
||||||
|
|
||||||
/* Set tool state to inactive -- no longer painting */
|
/* chain up to halt the tool */
|
||||||
gimp_tool_control_halt (tool->control);
|
GIMP_TOOL_CLASS (parent_class)->button_release (tool,
|
||||||
|
coords, time, state, gdisp);
|
||||||
|
|
||||||
gimp_paint_core_finish (core, drawable);
|
gimp_paint_core_finish (core, drawable);
|
||||||
|
|
||||||
@ -457,11 +434,6 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
|
|
||||||
drawable = gimp_image_active_drawable (gdisp->gimage);
|
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;
|
core->cur_coords = *coords;
|
||||||
|
|
||||||
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
|
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.x -= off_x;
|
||||||
core->cur_coords.y -= off_y;
|
core->cur_coords.y -= off_y;
|
||||||
|
|
||||||
if (paint_tool->pick_state)
|
GIMP_TOOL_CLASS (parent_class)->motion (tool, coords, time, state, gdisp);
|
||||||
{
|
|
||||||
gimp_paint_tool_sample_color (drawable,
|
|
||||||
coords->x,
|
|
||||||
coords->y,
|
|
||||||
state);
|
|
||||||
|
|
||||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (paint_tool));
|
|
||||||
|
|
||||||
|
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (core->flags & CORE_TRACES_ON_WINDOW)
|
if (core->flags & CORE_TRACES_ON_WINDOW)
|
||||||
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
gimp_paint_core_paint (core, drawable, paint_options, PRETRACE_PAINT);
|
||||||
@ -495,7 +460,37 @@ gimp_paint_tool_motion (GimpTool *tool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_cursor_update (GimpTool *tool,
|
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,
|
GimpCoords *coords,
|
||||||
GdkModifierType state,
|
GdkModifierType state,
|
||||||
GimpDisplay *gdisp)
|
GimpDisplay *gdisp)
|
||||||
@ -587,58 +582,22 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
|
|||||||
|
|
||||||
gimp_draw_tool_start (draw_tool, gdisp);
|
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
|
static void
|
||||||
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
||||||
|
{
|
||||||
|
if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
|
||||||
{
|
{
|
||||||
GimpPaintTool *paint_tool;
|
GimpPaintTool *paint_tool;
|
||||||
GimpPaintCore *core;
|
GimpPaintCore *core;
|
||||||
|
|
||||||
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
paint_tool = GIMP_PAINT_TOOL (draw_tool);
|
||||||
|
|
||||||
core = paint_tool->core;
|
core = paint_tool->core;
|
||||||
|
|
||||||
if (paint_tool->pick_state)
|
|
||||||
{
|
|
||||||
GimpToolInfo *info;
|
|
||||||
GimpColorOptions *options;
|
|
||||||
|
|
||||||
info = tool_manager_get_info_by_type (GIMP_TOOL (draw_tool)->tool_info->gimp,
|
|
||||||
GIMP_TYPE_COLOR_PICKER_TOOL);
|
|
||||||
|
|
||||||
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 */
|
/* Draw start target */
|
||||||
gimp_draw_tool_draw_handle (draw_tool,
|
gimp_draw_tool_draw_handle (draw_tool,
|
||||||
GIMP_HANDLE_CROSS,
|
GIMP_HANDLE_CROSS,
|
||||||
@ -667,41 +626,23 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
|
|||||||
core->cur_coords.y,
|
core->cur_coords.y,
|
||||||
TRUE);
|
TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_paint_tool_sample_color (GimpDrawable *drawable,
|
gimp_paint_tool_color_picked (GimpColorTool *color_tool,
|
||||||
gint x,
|
GimpImageType sample_type,
|
||||||
gint y,
|
GimpRGB *color,
|
||||||
gint state)
|
gint color_index)
|
||||||
{
|
{
|
||||||
GimpToolInfo *picker_info;
|
GimpTool *tool = GIMP_TOOL (color_tool);
|
||||||
GimpColorOptions *options;
|
|
||||||
GimpImage *gimage;
|
|
||||||
GimpRGB color;
|
|
||||||
|
|
||||||
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
if (tool->gdisp)
|
||||||
|
|
||||||
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 ((state & GDK_CONTROL_MASK))
|
GimpContext *context;
|
||||||
gimp_context_set_foreground (gimp_get_user_context (gimage->gimp),
|
|
||||||
&color);
|
context = gimp_get_user_context (tool->gdisp->gimage->gimp);
|
||||||
else
|
gimp_context_set_foreground (context, color);
|
||||||
gimp_context_set_background (gimp_get_user_context (gimage->gimp),
|
|
||||||
&color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define __GIMP_PAINT_TOOL_H__
|
#define __GIMP_PAINT_TOOL_H__
|
||||||
|
|
||||||
|
|
||||||
#include "gimpdrawtool.h"
|
#include "gimpcolortool.h"
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
#define GIMP_TYPE_PAINT_TOOL (gimp_paint_tool_get_type ())
|
||||||
@ -35,17 +35,16 @@ typedef struct _GimpPaintToolClass GimpPaintToolClass;
|
|||||||
|
|
||||||
struct _GimpPaintTool
|
struct _GimpPaintTool
|
||||||
{
|
{
|
||||||
GimpDrawTool parent_instance;
|
GimpColorTool parent_instance;
|
||||||
|
|
||||||
gboolean pick_colors; /* pick color if ctrl or alt is pressed */
|
gboolean pick_colors; /* pick color if ctrl is pressed */
|
||||||
gboolean pick_state; /* was ctrl or alt pressed when clicked? */
|
|
||||||
|
|
||||||
GimpPaintCore *core;
|
GimpPaintCore *core;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpPaintToolClass
|
struct _GimpPaintToolClass
|
||||||
{
|
{
|
||||||
GimpDrawToolClass parent_class;
|
GimpColorToolClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user