~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/tools/gimppaintoptions-gui.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
24
23
 
25
24
#include "tools-types.h"
26
25
 
 
26
#include "base/temp-buf.h"
 
27
 
 
28
#include "core/gimpbrush.h"
27
29
#include "core/gimptoolinfo.h"
28
30
 
29
31
#include "paint/gimppaintoptions.h"
30
32
 
31
33
#include "widgets/gimppropwidgets.h"
 
34
#include "widgets/gimpspinscale.h"
32
35
#include "widgets/gimpviewablebox.h"
 
36
#include "widgets/gimpwidgets-constructors.h"
33
37
#include "widgets/gimpwidgets-utils.h"
34
38
 
35
39
#include "gimpairbrushtool.h"
48
52
#include "gimp-intl.h"
49
53
 
50
54
 
51
 
static gboolean    tool_has_opacity_dynamics  (GType       tool_type);
52
 
static gboolean    tool_has_hardness_dynamics (GType       tool_type);
53
 
static gboolean    tool_has_rate_dynamics     (GType       tool_type);
54
 
static gboolean    tool_has_size_dynamics     (GType       tool_type);
55
 
static gboolean    tool_has_color_dynamics    (GType       tool_type);
 
55
static void gimp_paint_options_gui_reset_size  (GtkWidget        *button,
 
56
                                                GimpPaintOptions *paint_options);
 
57
static void gimp_paint_options_gui_reset_aspect_ratio
 
58
                                               (GtkWidget        *button,
 
59
                                                GimpPaintOptions *paint_options);
 
60
static void gimp_paint_options_gui_reset_angle (GtkWidget        *button,
 
61
                                                GimpPaintOptions *paint_options);
56
62
 
57
 
static void        pressure_options_gui (GimpPaintOptions *paint_options,
58
 
                                         GType             tool_type,
59
 
                                         GtkTable         *table,
60
 
                                         gint              row,
61
 
                                         GtkWidget        *labels[]);
62
 
static void        velocity_options_gui (GimpPaintOptions *paint_options,
63
 
                                         GType             tool_type,
64
 
                                         GtkTable         *table,
65
 
                                         gint              row);
66
 
static void        random_options_gui   (GimpPaintOptions *paint_options,
67
 
                                         GType             tool_type,
68
 
                                         GtkTable         *table,
69
 
                                         gint              row);
70
 
static GtkWidget * fade_options_gui     (GimpPaintOptions *paint_options,
71
 
                                         GType             tool_type);
72
 
static GtkWidget * gradient_options_gui (GimpPaintOptions *paint_options,
73
 
                                         GType             tool_type,
74
 
                                         GtkWidget        *incremental_toggle);
75
 
static GtkWidget * jitter_options_gui   (GimpPaintOptions *paint_options,
76
 
                                         GType             tool_type);
 
63
static GtkWidget * dynamics_options_gui        (GimpPaintOptions *paint_options,
 
64
                                                GType             tool_type);
 
65
static GtkWidget * jitter_options_gui          (GimpPaintOptions *paint_options,
 
66
                                                GType             tool_type);
 
67
static GtkWidget * smoothing_options_gui       (GimpPaintOptions *paint_options,
 
68
                                                GType             tool_type);
77
69
 
78
70
 
79
71
/*  public functions  */
84
76
  GObject          *config  = G_OBJECT (tool_options);
85
77
  GimpPaintOptions *options = GIMP_PAINT_OPTIONS (tool_options);
86
78
  GtkWidget        *vbox    = gimp_tool_options_gui (tool_options);
87
 
  GtkWidget        *frame;
88
 
  GtkWidget        *table;
 
79
  GtkWidget        *hbox;
89
80
  GtkWidget        *menu;
90
81
  GtkWidget        *label;
91
 
  GtkWidget        *button;
92
 
  GtkWidget        *incremental_toggle = NULL;
93
 
  gint              table_row          = 0;
94
 
  gint              n_dynamics         = 0;
95
 
  GtkWidget        *dynamics_labels[5];
 
82
  GtkWidget        *scale;
96
83
  GType             tool_type;
97
84
 
98
85
  tool_type = tool_options->tool_info->tool_type;
99
86
 
100
 
  /*  the main table  */
101
 
  table = gtk_table_new (3, 3, FALSE);
102
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
103
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
104
 
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
105
 
  gtk_widget_show (table);
106
 
 
107
 
  g_object_set_data (G_OBJECT (vbox), GIMP_PAINT_OPTIONS_TABLE_KEY, table);
108
 
 
109
87
  /*  the paint mode menu  */
110
 
  menu  = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE);
111
 
  label = gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
112
 
                                     _("Mode:"), 0.0, 0.5,
113
 
                                     menu, 2, FALSE);
 
88
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
89
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
90
  gtk_widget_show (hbox);
 
91
 
 
92
  label = gtk_label_new (_("Mode:"));
 
93
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 
94
  gtk_widget_show (label);
 
95
 
 
96
  menu = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE);
 
97
  gtk_box_pack_start (GTK_BOX (hbox), menu, TRUE, TRUE, 0);
 
98
  gtk_widget_show (menu);
114
99
 
115
100
  if (tool_type == GIMP_TYPE_ERASER_TOOL     ||
116
101
      tool_type == GIMP_TYPE_CONVOLVE_TOOL   ||
122
107
    }
123
108
 
124
109
  /*  the opacity scale  */
125
 
  gimp_prop_opacity_entry_new (config, "opacity",
126
 
                               GTK_TABLE (table), 0, table_row++,
127
 
                               _("Opacity:"));
 
110
  scale = gimp_prop_opacity_spin_scale_new (config, "opacity",
 
111
                                            _("Opacity"));
 
112
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
113
  gtk_widget_show (scale);
128
114
 
129
115
  /*  the brush  */
130
116
  if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
131
117
    {
132
 
      GtkObject *adj;
133
 
 
134
 
      button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
135
 
                                        "brush-view-type", "brush-view-size");
136
 
      gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
137
 
                                 _("Brush:"), 0.0, 0.5,
138
 
                                 button, 2, FALSE);
139
 
 
140
 
      adj = gimp_prop_scale_entry_new (config, "brush-scale",
141
 
                                       GTK_TABLE (table), 0, table_row++,
142
 
                                       _("Scale:"),
143
 
                                       0.01, 0.1, 2,
144
 
                                       FALSE, 0.0, 0.0);
145
 
      gimp_scale_entry_set_logarithmic (adj, TRUE);
146
 
    }
147
 
 
148
 
  if (tool_has_opacity_dynamics (tool_type))
149
 
    {
150
 
      dynamics_labels[n_dynamics] = gtk_label_new (_("Opacity"));
151
 
      n_dynamics++;
152
 
    }
153
 
 
154
 
  if (tool_has_hardness_dynamics (tool_type))
155
 
    {
156
 
      dynamics_labels[n_dynamics] = gtk_label_new (_("Hardness"));
157
 
      n_dynamics++;
158
 
    }
159
 
 
160
 
  if (tool_has_rate_dynamics (tool_type))
161
 
    {
162
 
      dynamics_labels[n_dynamics] = gtk_label_new (_("Rate"));
163
 
      n_dynamics++;
164
 
    }
165
 
 
166
 
  if (tool_has_size_dynamics (tool_type))
167
 
    {
168
 
      dynamics_labels[n_dynamics] = gtk_label_new (_("Size"));
169
 
      n_dynamics++;
170
 
    }
171
 
 
172
 
  if (tool_has_color_dynamics (tool_type))
173
 
    {
174
 
      dynamics_labels[n_dynamics] = gtk_label_new (_("Color"));
175
 
      n_dynamics++;
176
 
    }
177
 
 
178
 
  if (n_dynamics > 0)
179
 
    {
180
 
      GtkWidget *inner_frame;
181
 
      GtkWidget *fixed;
182
 
      gint       i;
183
 
      gboolean   rtl = gtk_widget_get_direction (vbox) == GTK_TEXT_DIR_RTL;
184
 
 
185
 
      frame = gimp_prop_expander_new (config, "dynamics-expanded",
186
 
                                      _("Brush Dynamics"));
187
 
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
188
 
      gtk_widget_show (frame);
189
 
 
190
 
      inner_frame = gimp_frame_new ("<expander>");
191
 
      gtk_container_add (GTK_CONTAINER (frame), inner_frame);
192
 
      gtk_widget_show (inner_frame);
193
 
 
194
 
      table = gtk_table_new (4, n_dynamics + 2, FALSE);
195
 
      gtk_container_add (GTK_CONTAINER (inner_frame), table);
196
 
      gtk_widget_show (table);
197
 
 
198
 
      label = gtk_label_new (_("Pressure:"));
199
 
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
200
 
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
201
 
                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
202
 
      gtk_widget_show (label);
203
 
 
204
 
      label = gtk_label_new (_("Velocity:"));
205
 
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
206
 
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
207
 
                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
208
 
      gtk_widget_show (label);
209
 
 
210
 
      label = gtk_label_new (_("Random:"));
211
 
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
212
 
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
213
 
                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
214
 
      gtk_widget_show (label);
215
 
 
216
 
      pressure_options_gui (options, tool_type,
217
 
                            GTK_TABLE (table), 1,
218
 
                            dynamics_labels);
219
 
 
220
 
      velocity_options_gui (options, tool_type,
221
 
                            GTK_TABLE (table), 2);
222
 
 
223
 
      random_options_gui (options, tool_type,
224
 
                          GTK_TABLE (table), 3);
225
 
 
226
 
      /* EEK: pack the fixed *after* the buttons so the table calls
227
 
       * size-allocates on it *before* it places the toggles. Fixes
228
 
       * label positions in RTL mode.
229
 
       */
230
 
      fixed = gtk_fixed_new ();
231
 
      gtk_table_attach (GTK_TABLE (table), fixed, 0, n_dynamics + 2, 0, 1,
232
 
                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
233
 
      gtk_widget_show (fixed);
234
 
 
235
 
      for (i = 0; i < n_dynamics; i++)
236
 
        {
237
 
          gtk_label_set_angle (GTK_LABEL (dynamics_labels[i]),
238
 
                               rtl ? 315 : 45);
239
 
          gtk_misc_set_alignment (GTK_MISC (dynamics_labels[i]), 1.0, 1.0);
240
 
          gtk_fixed_put (GTK_FIXED (fixed), dynamics_labels[i], 0, 0);
241
 
          gtk_widget_show (dynamics_labels[i]);
242
 
        }
243
 
    }
244
 
 
245
 
  if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
246
 
    {
247
 
      frame = fade_options_gui (options, tool_type);
 
118
      GtkWidget *button;
 
119
      GtkWidget *hbox;
 
120
      GtkWidget *frame;
 
121
 
 
122
      button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options),
 
123
                                        _("Brush"), 2,
 
124
                                        "brush-view-type", "brush-view-size",
 
125
                                        "gimp-brush-editor");
 
126
      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
127
      gtk_widget_show (button);
 
128
 
 
129
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
130
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
131
      gtk_widget_show (hbox);
 
132
 
 
133
      scale = gimp_prop_spin_scale_new (config, "brush-size",
 
134
                                        _("Size"),
 
135
                                        0.01, 1.0, 2);
 
136
      gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
 
137
      gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
 
138
      gtk_widget_show (scale);
 
139
 
 
140
      button = gimp_stock_button_new (GIMP_STOCK_RESET, NULL);
 
141
      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
142
      gtk_image_set_from_stock (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))),
 
143
                                GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
 
144
      gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 
145
      gtk_widget_show (button);
 
146
 
 
147
      g_signal_connect (button, "clicked",
 
148
                        G_CALLBACK (gimp_paint_options_gui_reset_size),
 
149
                        options);
 
150
 
 
151
      gimp_help_set_help_data (button,
 
152
                               _("Reset size to brush's native size"), NULL);
 
153
 
 
154
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
155
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
156
      gtk_widget_show (hbox);
 
157
 
 
158
      scale = gimp_prop_spin_scale_new (config, "brush-aspect-ratio",
 
159
                                        _("Aspect Ratio"),
 
160
                                        0.01, 0.1, 2);
 
161
      gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
 
162
      gtk_widget_show (scale);
 
163
 
 
164
      button = gimp_stock_button_new (GIMP_STOCK_RESET, NULL);
 
165
      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
166
      gtk_image_set_from_stock (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))),
 
167
                                GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
 
168
      gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 
169
      gtk_widget_show (button);
 
170
 
 
171
      g_signal_connect (button, "clicked",
 
172
                        G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio),
 
173
                        options);
 
174
 
 
175
      gimp_help_set_help_data (button,
 
176
                               _("Reset aspect ratio to brush's native"), NULL);
 
177
 
 
178
      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
179
      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
180
      gtk_widget_show (hbox);
 
181
 
 
182
      scale = gimp_prop_spin_scale_new (config, "brush-angle",
 
183
                                        _("Angle"),
 
184
                                        1.0, 5.0, 2);
 
185
      gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
 
186
      gtk_widget_show (scale);
 
187
 
 
188
      button = gimp_stock_button_new (GIMP_STOCK_RESET, NULL);
 
189
      gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
 
190
      gtk_image_set_from_stock (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))),
 
191
                                GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU);
 
192
      gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
 
193
      gtk_widget_show (button);
 
194
 
 
195
      g_signal_connect (button, "clicked",
 
196
                        G_CALLBACK (gimp_paint_options_gui_reset_angle),
 
197
                        options);
 
198
 
 
199
      gimp_help_set_help_data (button,
 
200
                               _("Reset angle to zero"), NULL);
 
201
 
 
202
      button = gimp_prop_dynamics_box_new (NULL, GIMP_CONTEXT (tool_options),
 
203
                                           _("Dynamics"), 2,
 
204
                                           "dynamics-view-type",
 
205
                                           "dynamics-view-size",
 
206
                                           "gimp-dynamics-editor");
 
207
      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
208
      gtk_widget_show (button);
 
209
 
 
210
      frame = dynamics_options_gui (options, tool_type);
248
211
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
249
212
      gtk_widget_show (frame);
250
213
 
253
216
      gtk_widget_show (frame);
254
217
    }
255
218
 
 
219
  /*  the "smooth stroke" options  */
 
220
  if (g_type_is_a (tool_type, GIMP_TYPE_PAINT_TOOL))
 
221
    {
 
222
      GtkWidget *frame;
 
223
 
 
224
      frame = smoothing_options_gui (options, tool_type);
 
225
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
226
      gtk_widget_show (frame);
 
227
    }
 
228
 
256
229
  /*  the "incremental" toggle  */
257
230
  if (tool_type == GIMP_TYPE_PENCIL_TOOL     ||
258
231
      tool_type == GIMP_TYPE_PAINTBRUSH_TOOL ||
259
232
      tool_type == GIMP_TYPE_ERASER_TOOL)
260
233
    {
261
 
      incremental_toggle =
262
 
        gimp_prop_enum_check_button_new (config,
263
 
                                         "application-mode",
264
 
                                         _("Incremental"),
265
 
                                         GIMP_PAINT_CONSTANT,
266
 
                                         GIMP_PAINT_INCREMENTAL);
267
 
      gtk_box_pack_start (GTK_BOX (vbox), incremental_toggle, FALSE, FALSE, 0);
268
 
      gtk_widget_show (incremental_toggle);
 
234
      GtkWidget *button;
 
235
 
 
236
      button = gimp_prop_enum_check_button_new (config,
 
237
                                                "application-mode",
 
238
                                                _("Incremental"),
 
239
                                                GIMP_PAINT_CONSTANT,
 
240
                                                GIMP_PAINT_INCREMENTAL);
 
241
      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
 
242
      gtk_widget_show (button);
269
243
    }
270
244
 
271
245
  /* the "hard edge" toggle */
277
251
      tool_type == GIMP_TYPE_DODGE_BURN_TOOL        ||
278
252
      tool_type == GIMP_TYPE_SMUDGE_TOOL)
279
253
    {
 
254
      GtkWidget *button;
 
255
 
280
256
      button = gimp_prop_check_button_new (config, "hard", _("Hard edge"));
281
257
      gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
282
258
      gtk_widget_show (button);
283
259
    }
284
260
 
285
 
  if (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL))
286
 
    {
287
 
      frame = gradient_options_gui (options, tool_type, incremental_toggle);
288
 
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
289
 
      gtk_widget_show (frame);
290
 
    }
291
 
 
292
261
  return vbox;
293
262
}
294
263
 
295
264
 
296
265
/*  private functions  */
297
266
 
298
 
static gboolean
299
 
tool_has_opacity_dynamics (GType tool_type)
300
 
{
301
 
  return (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL) ||
302
 
          tool_type == GIMP_TYPE_CLONE_TOOL             ||
303
 
          tool_type == GIMP_TYPE_HEAL_TOOL              ||
304
 
          tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL ||
305
 
          tool_type == GIMP_TYPE_DODGE_BURN_TOOL        ||
306
 
          tool_type == GIMP_TYPE_ERASER_TOOL);
307
 
}
308
 
 
309
 
static gboolean
310
 
tool_has_hardness_dynamics (GType tool_type)
311
 
{
312
 
  return (tool_type == GIMP_TYPE_AIRBRUSH_TOOL          ||
313
 
          tool_type == GIMP_TYPE_CLONE_TOOL             ||
314
 
          tool_type == GIMP_TYPE_HEAL_TOOL              ||
315
 
          tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL ||
316
 
          tool_type == GIMP_TYPE_CONVOLVE_TOOL          ||
317
 
          tool_type == GIMP_TYPE_ERASER_TOOL            ||
318
 
          tool_type == GIMP_TYPE_DODGE_BURN_TOOL        ||
319
 
          tool_type == GIMP_TYPE_PAINTBRUSH_TOOL        ||
320
 
          tool_type == GIMP_TYPE_SMUDGE_TOOL);
321
 
}
322
 
 
323
 
static gboolean
324
 
tool_has_rate_dynamics (GType tool_type)
325
 
{
326
 
  return (tool_type == GIMP_TYPE_AIRBRUSH_TOOL          ||
327
 
          tool_type == GIMP_TYPE_CONVOLVE_TOOL          ||
328
 
          tool_type == GIMP_TYPE_SMUDGE_TOOL);
329
 
}
330
 
 
331
 
static gboolean
332
 
tool_has_size_dynamics (GType tool_type)
333
 
{
334
 
  return (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL) ||
335
 
          tool_type == GIMP_TYPE_CLONE_TOOL             ||
336
 
          tool_type == GIMP_TYPE_HEAL_TOOL              ||
337
 
          tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL ||
338
 
          tool_type == GIMP_TYPE_CONVOLVE_TOOL          ||
339
 
          tool_type == GIMP_TYPE_DODGE_BURN_TOOL        ||
340
 
          tool_type == GIMP_TYPE_ERASER_TOOL);
341
 
}
342
 
 
343
 
static gboolean
344
 
tool_has_color_dynamics (GType tool_type)
345
 
{
346
 
  return (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL));
347
 
}
348
 
 
349
 
static GtkWidget *
350
 
dynamics_check_button_new (GObject     *config,
351
 
                           const gchar *property_name,
352
 
                           GtkTable    *table,
353
 
                           gint         column,
354
 
                           gint         row)
355
 
{
356
 
  GtkWidget *button;
357
 
 
358
 
  button = gimp_prop_check_button_new (config, property_name, NULL);
359
 
  gtk_table_attach (table, button, column, column + 1, row, row + 1,
360
 
                    GTK_SHRINK, GTK_SHRINK, 0, 0);
361
 
  gtk_widget_show (button);
362
 
 
363
 
  return button;
364
 
}
365
 
 
366
 
static void
367
 
dynamics_check_button_size_allocate (GtkWidget     *toggle,
368
 
                                     GtkAllocation *allocation,
369
 
                                     GtkWidget     *label)
370
 
{
371
 
  GtkWidget *fixed = label->parent;
372
 
  gint       x, y;
373
 
 
374
 
  if (gtk_widget_get_direction (label) == GTK_TEXT_DIR_LTR)
375
 
    x = allocation->x;
376
 
  else
377
 
    x = allocation->x + allocation->width - label->allocation.width;
378
 
 
379
 
  x -= fixed->allocation.x;
380
 
 
381
 
  y = fixed->allocation.height - label->allocation.height;
382
 
 
383
 
  gtk_fixed_move (GTK_FIXED (fixed), label, x, y);
384
 
}
385
 
 
386
 
static void
387
 
pressure_options_gui (GimpPaintOptions *paint_options,
388
 
                      GType             tool_type,
389
 
                      GtkTable         *table,
390
 
                      gint              row,
391
 
                      GtkWidget        *labels[])
392
 
{
393
 
  GObject   *config = G_OBJECT (paint_options);
394
 
  GtkWidget *button;
395
 
  gint       column = 1;
396
 
  GtkWidget *scalebutton;
397
 
 
398
 
  if (tool_has_opacity_dynamics (tool_type))
399
 
    {
400
 
      button = dynamics_check_button_new (config, "pressure-opacity",
401
 
                                          table, column, row);
402
 
      g_signal_connect (button, "size-allocate",
403
 
                        G_CALLBACK (dynamics_check_button_size_allocate),
404
 
                        labels[column - 1]);
405
 
      column++;
406
 
    }
407
 
 
408
 
  if (tool_has_hardness_dynamics (tool_type))
409
 
    {
410
 
      button = dynamics_check_button_new (config, "pressure-hardness",
411
 
                                          table, column, row);
412
 
      g_signal_connect (button, "size-allocate",
413
 
                        G_CALLBACK (dynamics_check_button_size_allocate),
414
 
                        labels[column - 1]);
415
 
      column++;
416
 
    }
417
 
 
418
 
  if (tool_has_rate_dynamics (tool_type))
419
 
    {
420
 
      button = dynamics_check_button_new (config, "pressure-rate",
421
 
                                          table, column, row);
422
 
      g_signal_connect (button, "size-allocate",
423
 
                        G_CALLBACK (dynamics_check_button_size_allocate),
424
 
                        labels[column - 1]);
425
 
      column++;
426
 
    }
427
 
 
428
 
  if (tool_has_size_dynamics (tool_type))
429
 
    {
430
 
      if (tool_type != GIMP_TYPE_AIRBRUSH_TOOL)
431
 
        button = dynamics_check_button_new (config, "pressure-size",
432
 
                                            table, column, row);
433
 
      else
434
 
        button = dynamics_check_button_new (config, "pressure-inverse-size",
435
 
                                            table, column, row);
436
 
 
437
 
      g_signal_connect (button, "size-allocate",
438
 
                        G_CALLBACK (dynamics_check_button_size_allocate),
439
 
                        labels[column - 1]);
440
 
      column++;
441
 
    }
442
 
 
443
 
  if (tool_has_color_dynamics (tool_type))
444
 
    {
445
 
      button = dynamics_check_button_new (config, "pressure-color",
446
 
                                          table, column, row);
447
 
      g_signal_connect (button, "size-allocate",
448
 
                        G_CALLBACK (dynamics_check_button_size_allocate),
449
 
                        labels[column - 1]);
450
 
      column++;
451
 
    }
452
 
 
453
 
   scalebutton = gimp_prop_scale_button_new (config, "pressure-prescale");
454
 
   gtk_table_attach (table, scalebutton, column, column + 1, row, row + 1,
455
 
                    GTK_SHRINK, GTK_SHRINK, 0, 0);
456
 
   gtk_widget_show (scalebutton);
457
 
}
458
 
 
459
 
static void
460
 
velocity_options_gui (GimpPaintOptions *paint_options,
461
 
                      GType             tool_type,
462
 
                      GtkTable         *table,
463
 
                      gint              row)
464
 
{
465
 
  GObject   *config = G_OBJECT (paint_options);
466
 
  gint       column = 1;
467
 
  GtkWidget *scalebutton;
468
 
 
469
 
  if (tool_has_opacity_dynamics (tool_type))
470
 
    {
471
 
      dynamics_check_button_new (config, "velocity-opacity",
472
 
                                 table, column++, row);
473
 
    }
474
 
 
475
 
  if (tool_has_hardness_dynamics (tool_type))
476
 
    {
477
 
      dynamics_check_button_new (config, "velocity-hardness",
478
 
                                 table, column++, row);
479
 
    }
480
 
 
481
 
  if (tool_has_rate_dynamics (tool_type))
482
 
    {
483
 
      dynamics_check_button_new (config, "velocity-rate",
484
 
                                 table, column++, row);
485
 
    }
486
 
 
487
 
  if (tool_has_size_dynamics (tool_type))
488
 
    {
489
 
      dynamics_check_button_new (config, "velocity-size",
490
 
                                 table, column++, row);
491
 
    }
492
 
 
493
 
  if (tool_has_color_dynamics (tool_type))
494
 
    {
495
 
      dynamics_check_button_new (config, "velocity-color",
496
 
                                 table, column++, row);
497
 
    }
498
 
 
499
 
  scalebutton = gimp_prop_scale_button_new (config, "velocity-prescale");
500
 
  gtk_table_attach (table, scalebutton, column, column + 1, row, row + 1,
501
 
                    GTK_SHRINK, GTK_SHRINK, 0, 0);
502
 
  gtk_widget_show (scalebutton);
503
 
}
504
 
 
505
 
static void
506
 
random_options_gui (GimpPaintOptions *paint_options,
507
 
                    GType             tool_type,
508
 
                    GtkTable         *table,
509
 
                    gint              row)
510
 
{
511
 
  GObject   *config = G_OBJECT (paint_options);
512
 
  gint       column = 1;
513
 
  GtkWidget *scalebutton;
514
 
 
515
 
  if (tool_has_opacity_dynamics (tool_type))
516
 
    {
517
 
      dynamics_check_button_new (config, "random-opacity",
518
 
                                 table, column++, row);
519
 
    }
520
 
 
521
 
  if (tool_has_hardness_dynamics (tool_type))
522
 
    {
523
 
      dynamics_check_button_new (config, "random-hardness",
524
 
                                 table, column++, row);
525
 
    }
526
 
 
527
 
  if (tool_has_rate_dynamics (tool_type))
528
 
    {
529
 
      dynamics_check_button_new (config, "random-rate",
530
 
                                 table, column++, row);
531
 
    }
532
 
 
533
 
  if (tool_has_size_dynamics (tool_type))
534
 
    {
535
 
      dynamics_check_button_new (config, "random-size",
536
 
                                 table, column++, row);
537
 
    }
538
 
 
539
 
  if (tool_has_color_dynamics (tool_type))
540
 
    {
541
 
      dynamics_check_button_new (config, "random-color",
542
 
                                 table, column++, row);
543
 
    }
544
 
 
545
 
   scalebutton = gimp_prop_scale_button_new (config, "random-prescale");
546
 
   gtk_table_attach (table, scalebutton, column, column + 1, row, row + 1,
547
 
                    GTK_SHRINK, GTK_SHRINK, 0, 0);
548
 
   gtk_widget_show (scalebutton);
549
 
}
550
 
 
551
 
static GtkWidget *
552
 
fade_options_gui (GimpPaintOptions *paint_options,
553
 
                  GType             tool_type)
 
267
static GtkWidget *
 
268
dynamics_options_gui (GimpPaintOptions *paint_options,
 
269
                      GType             tool_type)
554
270
{
555
271
  GObject   *config = G_OBJECT (paint_options);
556
272
  GtkWidget *frame;
557
 
  GtkWidget *table;
558
 
  GtkWidget *spinbutton;
 
273
  GtkWidget *inner_frame;
 
274
  GtkWidget *label;
 
275
  GtkWidget *scale;
559
276
  GtkWidget *menu;
560
 
 
561
 
  table = gtk_table_new (1, 3, FALSE);
562
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
563
 
 
564
 
  frame = gimp_prop_expanding_frame_new (config, "use-fade",
565
 
                                         _("Fade out"),
566
 
                                         table, NULL);
567
 
 
568
 
  /*  the fade-out sizeentry  */
569
 
  spinbutton = gimp_prop_spin_button_new (config, "fade-length",
570
 
                                          1.0, 50.0, 0);
571
 
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 6);
572
 
 
573
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
574
 
                             _("Length:"), 0.0, 0.5,
575
 
                             spinbutton, 1, FALSE);
576
 
 
577
 
  /*  the fade-out unitmenu  */
578
 
  menu = gimp_prop_unit_menu_new (config, "fade-unit", "%a");
579
 
  gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 0, 1,
580
 
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
 
277
  GtkWidget *combo;
 
278
  GtkWidget *checkbox;
 
279
  GtkWidget *vbox;
 
280
  GtkWidget *inner_vbox;
 
281
  GtkWidget *hbox;
 
282
  GtkWidget *box;
 
283
 
 
284
  frame = gimp_prop_expander_new (config, "dynamics-expanded",
 
285
                                  _("Dynamics Options"));
 
286
 
 
287
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
 
288
  gtk_container_add (GTK_CONTAINER (frame), vbox);
 
289
  gtk_widget_show (vbox);
 
290
 
 
291
  inner_frame = gimp_frame_new (_("Fade Options"));
 
292
  gtk_box_pack_start (GTK_BOX (vbox), inner_frame, FALSE, FALSE, 0);
 
293
  gtk_widget_show (inner_frame);
 
294
 
 
295
  inner_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
 
296
  gtk_container_add (GTK_CONTAINER (inner_frame), inner_vbox);
 
297
  gtk_widget_show (inner_vbox);
 
298
 
 
299
  /*  the fade-out scale & unitmenu  */
 
300
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
301
  gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, FALSE, FALSE, 0);
 
302
  gtk_widget_show (hbox);
 
303
 
 
304
  scale = gimp_prop_spin_scale_new (config, "fade-length",
 
305
                                    _("Fade length"), 1.0, 50.0, 0);
 
306
  gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0);
 
307
  gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0);
 
308
  gtk_widget_show (scale);
 
309
 
 
310
  menu = gimp_prop_unit_combo_box_new (config, "fade-unit");
 
311
  gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
581
312
  gtk_widget_show (menu);
582
313
 
 
314
#if 0
 
315
  /* FIXME pixel digits */
583
316
  g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
584
317
  gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0);
 
318
#endif
 
319
 
 
320
  /*  the repeat type  */
 
321
  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
 
322
  gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, FALSE, FALSE, 0);
 
323
  gtk_widget_show (hbox);
 
324
 
 
325
  label = gtk_label_new (_("Repeat:"));
 
326
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
 
327
  gtk_widget_show (label);
 
328
 
 
329
  combo = gimp_prop_enum_combo_box_new (config, "fade-repeat", 0, 0);
 
330
  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
 
331
  gtk_widget_show (combo);
 
332
 
 
333
  checkbox = gimp_prop_check_button_new (config, "fade-reverse",
 
334
                                         _("Reverse"));
 
335
  gtk_box_pack_start (GTK_BOX (inner_vbox), checkbox, FALSE, FALSE, 0);
 
336
  gtk_widget_show (checkbox);
 
337
 
 
338
  /* Color UI */
 
339
  if (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL))
 
340
    {
 
341
      inner_frame = gimp_frame_new (_("Color Options"));
 
342
      gtk_box_pack_start (GTK_BOX (vbox), inner_frame, FALSE, FALSE, 0);
 
343
      gtk_widget_show (inner_frame);
 
344
 
 
345
      box = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (config),
 
346
                                        _("Gradient"), 2,
 
347
                                        "gradient-view-type",
 
348
                                        "gradient-view-size",
 
349
                                        "gradient-reverse",
 
350
                                        "gimp-gradient-editor");
 
351
      gtk_container_add (GTK_CONTAINER (inner_frame), box);
 
352
      gtk_widget_show (box);
 
353
    }
585
354
 
586
355
  return frame;
587
356
}
592
361
{
593
362
  GObject   *config = G_OBJECT (paint_options);
594
363
  GtkWidget *frame;
595
 
  GtkWidget *table;
 
364
  GtkWidget *scale;
596
365
 
597
 
  table = gtk_table_new (1, 3, FALSE);
598
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
 
366
  scale = gimp_prop_spin_scale_new (config, "jitter-amount",
 
367
                                    _("Amount"),
 
368
                                    0.01, 1.0, 2);
599
369
 
600
370
  frame = gimp_prop_expanding_frame_new (config, "use-jitter",
601
371
                                         _("Apply Jitter"),
602
 
                                         table, NULL);
603
 
 
604
 
  gimp_prop_scale_entry_new (config, "jitter-amount",
605
 
                             GTK_TABLE (table), 0, 0,
606
 
                             _("Amount:"),
607
 
                             0.01, 0.1, 2,
608
 
                             TRUE, 0.0, 5.0);
 
372
                                         scale, NULL);
609
373
 
610
374
  return frame;
611
375
}
612
376
 
613
377
static GtkWidget *
614
 
gradient_options_gui (GimpPaintOptions *paint_options,
615
 
                      GType             tool_type,
616
 
                      GtkWidget        *incremental_toggle)
 
378
smoothing_options_gui (GimpPaintOptions *paint_options,
 
379
                       GType             tool_type)
617
380
{
618
381
  GObject   *config = G_OBJECT (paint_options);
619
382
  GtkWidget *frame;
620
 
  GtkWidget *table;
621
 
  GtkWidget *spinbutton;
622
 
  GtkWidget *button;
623
 
  GtkWidget *menu;
624
 
  GtkWidget *combo;
625
 
 
626
 
  table = gtk_table_new (3, 3, FALSE);
627
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
628
 
  gtk_table_set_row_spacings (GTK_TABLE (table), 2);
629
 
 
630
 
  frame = gimp_prop_expanding_frame_new (config, "use-gradient",
631
 
                                         _("Use color from gradient"),
632
 
                                         table, &button);
633
 
 
634
 
  if (incremental_toggle)
635
 
    {
636
 
      gtk_widget_set_sensitive (incremental_toggle,
637
 
                                ! paint_options->gradient_options->use_gradient);
638
 
      g_object_set_data (G_OBJECT (button), "inverse_sensitive",
639
 
                         incremental_toggle);
640
 
    }
641
 
 
642
 
  /*  the gradient view  */
643
 
  button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (config), 2,
644
 
                                       "gradient-view-type",
645
 
                                       "gradient-view-size",
646
 
                                       "gradient-reverse");
647
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
648
 
                             _("Gradient:"), 0.0, 0.5,
649
 
                             button, 2, TRUE);
650
 
 
651
 
  /*  the gradient length scale  */
652
 
  spinbutton = gimp_prop_spin_button_new (config, "gradient-length",
653
 
                                          1.0, 50.0, 0);
654
 
  gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 6);
655
 
 
656
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
657
 
                             _("Length:"), 0.0, 0.5,
658
 
                             spinbutton, 1, FALSE);
659
 
 
660
 
  /*  the gradient unitmenu  */
661
 
  menu = gimp_prop_unit_menu_new (config, "gradient-unit", "%a");
662
 
  gtk_table_attach (GTK_TABLE (table), menu, 2, 3, 1, 2,
663
 
                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
664
 
  gtk_widget_show (menu);
665
 
 
666
 
  g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
667
 
  gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0);
668
 
 
669
 
  /*  the repeat type  */
670
 
  combo = gimp_prop_enum_combo_box_new (config, "gradient-repeat", 0, 0);
671
 
  gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
672
 
                             _("Repeat:"), 0.0, 0.5,
673
 
                             combo, 2, FALSE);
 
383
  GtkWidget *vbox;
 
384
  GtkWidget *scale;
 
385
 
 
386
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
 
387
 
 
388
  frame = gimp_prop_expanding_frame_new (config, "use-smoothing",
 
389
                                         _("Smooth stroke"),
 
390
                                         vbox, NULL);
 
391
 
 
392
  scale = gimp_prop_spin_scale_new (config, "smoothing-quality",
 
393
                                    _("Quality"),
 
394
                                    1, 10, 1);
 
395
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
396
  gtk_widget_show (scale);
 
397
 
 
398
  scale = gimp_prop_spin_scale_new (config, "smoothing-factor",
 
399
                                    _("Weight"),
 
400
                                    1, 10, 1);
 
401
  gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
 
402
  gtk_widget_show (scale);
674
403
 
675
404
  return frame;
676
405
}
 
406
 
 
407
static void
 
408
gimp_paint_options_gui_reset_size (GtkWidget        *button,
 
409
                                   GimpPaintOptions *paint_options)
 
410
{
 
411
 GimpBrush *brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
 
412
 
 
413
 if (brush)
 
414
   {
 
415
     g_object_set (paint_options,
 
416
                   "brush-size", (gdouble) MAX (brush->mask->width,
 
417
                                                brush->mask->height),
 
418
                   NULL);
 
419
   }
 
420
}
 
421
 
 
422
static void
 
423
gimp_paint_options_gui_reset_aspect_ratio (GtkWidget        *button,
 
424
                                           GimpPaintOptions *paint_options)
 
425
{
 
426
   g_object_set (paint_options,
 
427
                 "brush-aspect-ratio", 0.0,
 
428
                 NULL);
 
429
}
 
430
 
 
431
static void
 
432
gimp_paint_options_gui_reset_angle (GtkWidget        *button,
 
433
                                    GimpPaintOptions *paint_options)
 
434
{
 
435
   g_object_set (paint_options,
 
436
                 "brush-angle", 0.0,
 
437
                 NULL);
 
438
}