1
/* The GIMP -- an image manipulation program
1
/* GIMP - The GNU Image Manipulation Program
2
2
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
4
4
* This program is free software; you can redistribute it and/or modify
25
25
#include "tools-types.h"
27
#include "core/gimptoolinfo.h"
29
27
#include "paint/gimpconvolveoptions.h"
31
29
#include "widgets/gimphelp-ids.h"
32
#include "widgets/gimppropwidgets.h"
33
30
#include "widgets/gimpwidgets-utils.h"
35
32
#include "gimpconvolvetool.h"
39
36
#include "gimp-intl.h"
42
static void gimp_convolve_tool_class_init (GimpConvolveToolClass *klass);
43
static void gimp_convolve_tool_init (GimpConvolveTool *tool);
45
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
48
GdkModifierType state,
50
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
52
GdkModifierType state,
55
static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options);
58
static GimpPaintToolClass *parent_class;
39
static void gimp_convolve_tool_modifier_key (GimpTool *tool,
42
GdkModifierType state,
43
GimpDisplay *display);
44
static void gimp_convolve_tool_cursor_update (GimpTool *tool,
46
GdkModifierType state,
47
GimpDisplay *display);
48
static void gimp_convolve_tool_oper_update (GimpTool *tool,
50
GdkModifierType state,
52
GimpDisplay *display);
53
static void gimp_convolve_tool_status_update (GimpTool *tool,
54
GimpConvolveType type);
56
static GtkWidget * gimp_convolve_options_gui (GimpToolOptions *options);
59
G_DEFINE_TYPE (GimpConvolveTool, gimp_convolve_tool, GIMP_TYPE_BRUSH_TOOL)
61
#define parent_class gimp_convolve_tool_parent_class
67
70
gimp_convolve_options_gui,
68
71
GIMP_PAINT_OPTIONS_CONTEXT_MASK,
69
72
"gimp-convolve-tool",
74
_("Blur / Sharpen Tool: Selective blurring or unblurring using a brush"),
75
N_("Bl_ur / Sharpen"), "<shift>U",
73
76
NULL, GIMP_HELP_TOOL_CONVOLVE,
74
77
GIMP_STOCK_TOOL_BLUR,
79
gimp_convolve_tool_get_type (void)
81
static GType tool_type = 0;
85
static const GTypeInfo tool_info =
87
sizeof (GimpConvolveToolClass),
89
(GBaseFinalizeFunc) NULL,
90
(GClassInitFunc) gimp_convolve_tool_class_init,
91
NULL, /* class_finalize */
92
NULL, /* class_data */
93
sizeof (GimpConvolveTool),
95
(GInstanceInitFunc) gimp_convolve_tool_init,
98
tool_type = g_type_register_static (GIMP_TYPE_PAINT_TOOL,
107
82
gimp_convolve_tool_class_init (GimpConvolveToolClass *klass)
109
84
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
111
parent_class = g_type_class_peek_parent (klass);
113
86
tool_class->modifier_key = gimp_convolve_tool_modifier_key;
114
87
tool_class->cursor_update = gimp_convolve_tool_cursor_update;
88
tool_class->oper_update = gimp_convolve_tool_oper_update;
122
96
gimp_tool_control_set_tool_cursor (tool->control,
123
97
GIMP_TOOL_CURSOR_BLUR);
124
gimp_tool_control_set_toggle_tool_cursor (tool->control,
125
GIMP_TOOL_CURSOR_BLUR);
126
98
gimp_tool_control_set_toggle_cursor_modifier (tool->control,
127
99
GIMP_CURSOR_MODIFIER_MINUS);
101
gimp_convolve_tool_status_update (tool, GIMP_BLUR_CONVOLVE);
131
105
gimp_convolve_tool_modifier_key (GimpTool *tool,
132
106
GdkModifierType key,
134
GdkModifierType state,
108
GdkModifierType state,
109
GimpDisplay *display)
137
GimpConvolveOptions *options;
139
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
111
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
141
113
if ((key == GDK_CONTROL_MASK) &&
142
114
! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
161
133
gimp_convolve_tool_cursor_update (GimpTool *tool,
162
134
GimpCoords *coords,
163
GdkModifierType state,
166
GimpConvolveOptions *options;
168
options = GIMP_CONVOLVE_OPTIONS (tool->tool_info->tool_options);
170
gimp_tool_control_set_toggle (tool->control,
171
(options->type == GIMP_SHARPEN_CONVOLVE));
173
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
135
GdkModifierType state,
136
GimpDisplay *display)
138
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
140
gimp_tool_control_set_toggled (tool->control,
141
(options->type == GIMP_SHARPEN_CONVOLVE));
143
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
147
gimp_convolve_tool_oper_update (GimpTool *tool,
149
GdkModifierType state,
151
GimpDisplay *display)
153
GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
155
gimp_convolve_tool_status_update (tool, options->type);
157
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
162
gimp_convolve_tool_status_update (GimpTool *tool,
163
GimpConvolveType type)
165
GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool);
169
case GIMP_BLUR_CONVOLVE:
170
paint_tool->status = _("Click to blur");
171
paint_tool->status_line = _("Click to blur the line");
172
paint_tool->status_ctrl = _("%s to sharpen");
175
case GIMP_SHARPEN_CONVOLVE:
176
paint_tool->status = _("Click to sharpen");
177
paint_tool->status_line = _("Click to sharpen the line");
178
paint_tool->status_ctrl = _("%s to blur");
179
189
static GtkWidget *
180
190
gimp_convolve_options_gui (GimpToolOptions *tool_options)
192
GObject *config = G_OBJECT (tool_options);
193
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
184
194
GtkWidget *table;
185
195
GtkWidget *frame;
188
config = G_OBJECT (tool_options);
190
vbox = gimp_paint_options_gui (tool_options);
192
198
/* the type radio box */
193
str = g_strdup_printf (_("Convolve Type %s"),
199
str = g_strdup_printf (_("Convolve Type (%s)"),
194
200
gimp_get_mod_string (GDK_CONTROL_MASK));
196
202
frame = gimp_prop_enum_radio_frame_new (config, "type",