~ubuntu-branches/ubuntu/gutsy/gimp/gutsy

« back to all changes in this revision

Viewing changes to app/tools/gimpbrushtool.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-06-22 17:33:56 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070622173356-ncevaebpjiwyxkif
Tags: 2.3.18-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/control: Maintainer change.
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch,
    debian/patches/10_dont_show_wizard.patch: Distro patches.
  - debian/rules:
    - use dh_iconcache,
    - i18n magic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
                             guint                  n_params,
125
125
                             GObjectConstructParam *params)
126
126
{
127
 
  GObject       *object;
128
 
  GimpTool      *tool;
129
 
  GimpPaintTool *paint_tool;
130
 
  GimpBrushTool *brush_tool;
 
127
  GObject           *object;
 
128
  GimpTool          *tool;
 
129
  GimpPaintTool     *paint_tool;
 
130
  GimpBrushTool     *brush_tool;
 
131
  GimpDisplayConfig *display_config;
131
132
 
132
133
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
133
134
 
137
138
 
138
139
  g_assert (GIMP_IS_BRUSH_CORE (paint_tool->core));
139
140
 
140
 
  brush_tool->show_cursor =
141
 
    GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config)->show_paint_tool_cursor;
142
 
  brush_tool->draw_brush =
143
 
    GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config)->show_brush_outline;
144
 
 
145
 
  g_signal_connect_object (tool->tool_info->gimp->config,
146
 
                           "notify::show-paint-tool-cursor",
 
141
  display_config = GIMP_DISPLAY_CONFIG (tool->tool_info->gimp->config);
 
142
 
 
143
  brush_tool->show_cursor = display_config->show_paint_tool_cursor;
 
144
  brush_tool->draw_brush  = display_config->show_brush_outline;
 
145
 
 
146
  g_signal_connect_object (display_config, "notify::show-paint-tool-cursor",
147
147
                           G_CALLBACK (gimp_brush_tool_notify_brush),
148
148
                           brush_tool, 0);
149
 
  g_signal_connect_object (tool->tool_info->gimp->config,
150
 
                           "notify::show-brush-outline",
 
149
  g_signal_connect_object (display_config, "notify::show-brush-outline",
151
150
                           G_CALLBACK (gimp_brush_tool_notify_brush),
152
151
                           brush_tool, 0);
153
152
 
259
258
  if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (draw_tool)))
260
259
    return;
261
260
 
262
 
  if (brush_tool->draw_brush)
263
 
    {
264
 
      GimpPaintTool    *paint_tool    = GIMP_PAINT_TOOL (draw_tool);
265
 
      GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (draw_tool);
266
 
      GimpBrushCore    *brush_core    = GIMP_BRUSH_CORE (paint_tool->core);
267
 
 
268
 
      /*  don't create the segments for the purpose of undrawing (if we
269
 
       *  don't have the segments, we can hardly have drawn them before)
270
 
       */
271
 
      if (! brush_core->brush_bound_segs && brush_core->main_brush &&
272
 
          ! gimp_draw_tool_is_drawn (draw_tool))
273
 
        {
274
 
          gimp_brush_core_create_bound_segs (brush_core, paint_options);
275
 
        }
276
 
 
277
 
      if (brush_core->brush_bound_segs)
278
 
        {
279
 
          gdouble brush_x, brush_y;
280
 
 
281
 
          brush_x = (brush_tool->brush_x -
282
 
                     ((gdouble) brush_core->brush_bound_width  / 2.0));
283
 
          brush_y = (brush_tool->brush_y -
284
 
                     ((gdouble) brush_core->brush_bound_height / 2.0));
285
 
 
286
 
          if (gimp_paint_options_get_brush_mode (paint_options) ==
287
 
              GIMP_BRUSH_HARD)
288
 
            {
 
261
  gimp_brush_tool_draw_brush (brush_tool,
 
262
                              brush_tool->brush_x, brush_tool->brush_y);
 
263
}
 
264
 
 
265
void
 
266
gimp_brush_tool_draw_brush (GimpBrushTool *brush_tool,
 
267
                            gdouble        x,
 
268
                            gdouble        y)
 
269
{
 
270
  GimpDrawTool     *draw_tool;
 
271
  GimpBrushCore    *brush_core;
 
272
  GimpPaintOptions *paint_options;
 
273
 
 
274
  g_return_if_fail (GIMP_IS_BRUSH_TOOL (brush_tool));
 
275
 
 
276
  if (! brush_tool->draw_brush)
 
277
    return;
 
278
 
 
279
  draw_tool     = GIMP_DRAW_TOOL (brush_tool);
 
280
  brush_core    = GIMP_BRUSH_CORE (GIMP_PAINT_TOOL (brush_tool)->core);
 
281
  paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (brush_tool);
 
282
 
 
283
  /*  don't create the segments for the purpose of undrawing (if we
 
284
   *  don't have the segments, we can hardly have drawn them before)
 
285
   */
 
286
  if (! brush_core->brush_bound_segs && brush_core->main_brush &&
 
287
      ! gimp_draw_tool_is_drawn (draw_tool))
 
288
    {
 
289
      gimp_brush_core_create_bound_segs (brush_core, paint_options);
 
290
    }
 
291
 
 
292
  if (brush_core->brush_bound_segs)
 
293
    {
 
294
      x -= ((gdouble) brush_core->brush_bound_width  / 2.0);
 
295
      y -= ((gdouble) brush_core->brush_bound_height / 2.0);
 
296
 
 
297
      if (gimp_paint_options_get_brush_mode (paint_options) == GIMP_BRUSH_HARD)
 
298
        {
289
299
#define EPSILON 0.000001
290
300
 
291
 
              /*  Add EPSILON before rounding since e.g.
292
 
               *  (5.0 - 0.5) may end up at (4.499999999....)
293
 
               *  due to floating point fnords
294
 
               */
295
 
              brush_x = RINT (brush_x + EPSILON);
296
 
              brush_y = RINT (brush_y + EPSILON);
 
301
          /*  Add EPSILON before rounding since e.g.
 
302
           *  (5.0 - 0.5) may end up at (4.499999999....)
 
303
           *  due to floating point fnords
 
304
           */
 
305
          x = RINT (x + EPSILON);
 
306
          y = RINT (y + EPSILON);
297
307
 
298
308
#undef EPSILON
299
 
            }
300
 
 
301
 
          gimp_draw_tool_draw_boundary (draw_tool,
302
 
                                        brush_core->brush_bound_segs,
303
 
                                        brush_core->n_brush_bound_segs,
304
 
                                        brush_x,
305
 
                                        brush_y,
306
 
                                        FALSE);
307
309
        }
 
310
 
 
311
      gimp_draw_tool_draw_boundary (draw_tool,
 
312
                                    brush_core->brush_bound_segs,
 
313
                                    brush_core->n_brush_bound_segs,
 
314
                                    x, y,
 
315
                                    FALSE);
308
316
    }
309
317
}
310
318