Commit 7515d9b6 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

made "spacing" a property.

2006-12-06  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpbrush.c: made "spacing" a property.

	* app/core/gimpbrushgenerated-save.c
	* app/core/gimpbrushgenerated.c
	* app/core/gimpbrushpipe.c: use it. Don't access brush->spacing
	manually, always use accessors.
parent 09d0edba
2006-12-06 Michael Natterer <mitch@gimp.org>
* app/core/gimpbrush.c: made "spacing" a property.
* app/core/gimpbrushgenerated-save.c
* app/core/gimpbrushgenerated.c
* app/core/gimpbrushpipe.c: use it. Don't access brush->spacing
manually, always use accessors.
2006-12-05 Sven Neumann <sven@gimp.org>
* tools/Makefile.am
......
......@@ -41,7 +41,21 @@ enum
LAST_SIGNAL
};
enum
{
PROP_0,
PROP_SPACING
};
static void gimp_brush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_brush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_brush_finalize (GObject *object);
static gint64 gimp_brush_get_memsize (GimpObject *object,
......@@ -110,6 +124,12 @@ gimp_brush_class_init (GimpBrushClass *klass)
klass->scale_mask = gimp_brush_real_scale_mask;
klass->scale_pixmap = gimp_brush_real_scale_pixmap;
klass->spacing_changed = NULL;
g_object_class_install_property (object_class, PROP_SPACING,
g_param_spec_double ("spacing", NULL, NULL,
1.0, 5000.0, 20.0,
GIMP_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
}
static void
......@@ -125,6 +145,44 @@ gimp_brush_init (GimpBrush *brush)
brush->y_axis.y = 15.0;
}
static void
gimp_brush_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpBrush *brush = GIMP_BRUSH (object);
switch (property_id)
{
case PROP_SPACING:
gimp_brush_set_spacing (brush, g_value_get_double (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_brush_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpBrush *brush = GIMP_BRUSH (object);
switch (property_id)
{
case PROP_SPACING:
g_value_set_double (value, brush->spacing);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_brush_finalize (GObject *object)
{
......@@ -447,6 +505,7 @@ gimp_brush_set_spacing (GimpBrush *brush,
brush->spacing = spacing;
gimp_brush_spacing_changed (brush);
g_object_notify (G_OBJECT (brush), "spacing");
}
}
......
......@@ -98,7 +98,7 @@ gimp_brush_generated_save (GimpData *data,
/* write brush spacing */
fprintf (file, "%s\n",
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f",
GIMP_BRUSH (brush)->spacing));
gimp_brush_get_spacing (GIMP_BRUSH (brush))));
/* write brush radius */
fprintf (file, "%s\n",
......
......@@ -471,6 +471,7 @@ gimp_brush_generated_new (const gchar *name,
brush = g_object_new (GIMP_TYPE_BRUSH_GENERATED,
"name", name,
"mime-type", "application/x-gimp-brush-generated",
"spacing", 20,
"shape", shape,
"radius", radius,
"spikes", spikes,
......@@ -479,8 +480,6 @@ gimp_brush_generated_new (const gchar *name,
"angle", angle,
NULL);
GIMP_BRUSH (brush)->spacing = 20;
return GIMP_DATA (brush);
}
......
......@@ -175,7 +175,7 @@ gimp_brush_pipe_select_brush (GimpBrush *brush,
/* calculates brush native spacing in pixels, based on it's width)*/
spacing = ((gdouble) pipe->current->spacing / 100) *
spacing = ((gdouble) gimp_brush_get_spacing (pipe->current) / 100) *
MAX (brush->mask->width, brush->mask->height);
brushix = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment