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
40
40
#include "gimp-intl.h"
43
static void gimp_airbrush_class_init (GimpAirbrushClass *klass);
44
static void gimp_airbrush_init (GimpAirbrush *airbrush);
46
static void gimp_airbrush_finalize (GObject *object);
48
static void gimp_airbrush_paint (GimpPaintCore *paint_core,
49
GimpDrawable *drawable,
50
GimpPaintOptions *paint_options,
51
GimpPaintState paint_state,
53
static void gimp_airbrush_motion (GimpPaintCore *paint_core,
54
GimpDrawable *drawable,
55
GimpPaintOptions *paint_options);
56
static gboolean gimp_airbrush_timeout (gpointer data);
59
static GimpPaintbrushClass *parent_class = NULL;
43
static void gimp_airbrush_finalize (GObject *object);
45
static void gimp_airbrush_paint (GimpPaintCore *paint_core,
46
GimpDrawable *drawable,
47
GimpPaintOptions *paint_options,
48
GimpPaintState paint_state,
50
static void gimp_airbrush_motion (GimpPaintCore *paint_core,
51
GimpDrawable *drawable,
52
GimpPaintOptions *paint_options);
53
static gboolean gimp_airbrush_timeout (gpointer data);
56
G_DEFINE_TYPE (GimpAirbrush, gimp_airbrush, GIMP_TYPE_PAINTBRUSH)
58
#define parent_class gimp_airbrush_parent_class
66
65
(* callback) (gimp,
67
66
GIMP_TYPE_AIRBRUSH,
68
67
GIMP_TYPE_AIRBRUSH_OPTIONS,
73
gimp_airbrush_get_type (void)
75
static GType type = 0;
79
static const GTypeInfo info =
81
sizeof (GimpAirbrushClass),
83
(GBaseFinalizeFunc) NULL,
84
(GClassInitFunc) gimp_airbrush_class_init,
85
NULL, /* class_finalize */
86
NULL, /* class_data */
87
sizeof (GimpAirbrush),
89
(GInstanceInitFunc) gimp_airbrush_init,
92
type = g_type_register_static (GIMP_TYPE_PAINTBRUSH,
70
"gimp-tool-airbrush");
103
76
GObjectClass *object_class = G_OBJECT_CLASS (klass);
104
77
GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass);
106
parent_class = g_type_class_peek_parent (klass);
108
79
object_class->finalize = gimp_airbrush_finalize;
110
81
paint_core_class->paint = gimp_airbrush_paint;
145
116
case GIMP_PAINT_STATE_INIT:
146
117
if (airbrush->timeout_id)
148
g_source_remove (airbrush->timeout_id);
149
airbrush->timeout_id = 0;
119
g_source_remove (airbrush->timeout_id);
120
airbrush->timeout_id = 0;
152
123
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,
157
128
case GIMP_PAINT_STATE_MOTION:
158
129
if (airbrush->timeout_id)
160
g_source_remove (airbrush->timeout_id);
161
airbrush->timeout_id = 0;
131
g_source_remove (airbrush->timeout_id);
132
airbrush->timeout_id = 0;
164
135
gimp_airbrush_motion (paint_core, drawable, paint_options);
166
137
if (options->rate != 0.0)
170
airbrush->drawable = drawable;
141
airbrush->drawable = drawable;
171
142
airbrush->paint_options = paint_options;
173
timeout = (paint_options->pressure_options->rate ?
174
(10000 / (options->rate * PRESSURE_SCALE * paint_core->cur_coords.pressure)) :
175
(10000 / options->rate));
144
timeout = (paint_options->pressure_options->rate ?
145
(10000 / (options->rate * PRESSURE_SCALE * paint_core->cur_coords.pressure)) :
146
(10000 / options->rate));
177
airbrush->timeout_id = g_timeout_add (timeout,
148
airbrush->timeout_id = g_timeout_add (timeout,
178
149
gimp_airbrush_timeout,
183
154
case GIMP_PAINT_STATE_FINISH:
184
155
if (airbrush->timeout_id)
186
g_source_remove (airbrush->timeout_id);
187
airbrush->timeout_id = 0;
157
g_source_remove (airbrush->timeout_id);
158
airbrush->timeout_id = 0;
190
161
GIMP_PAINT_CORE_CLASS (parent_class)->paint (paint_core, drawable,