Commit c31d675a authored by Michael Natterer's avatar Michael Natterer 😴

app: move all GimpDynamicsOutput members to private

parent 67228651
......@@ -66,6 +66,35 @@ enum
};
typedef struct _GimpDynamicsOutputPrivate GimpDynamicsOutputPrivate;
struct _GimpDynamicsOutputPrivate
{
GimpDynamicsOutputType type;
gboolean use_pressure;
gboolean use_velocity;
gboolean use_direction;
gboolean use_tilt;
gboolean use_wheel;
gboolean use_random;
gboolean use_fade;
GimpCurve *pressure_curve;
GimpCurve *velocity_curve;
GimpCurve *direction_curve;
GimpCurve *tilt_curve;
GimpCurve *wheel_curve;
GimpCurve *random_curve;
GimpCurve *fade_curve;
};
#define GET_PRIVATE(output) \
G_TYPE_INSTANCE_GET_PRIVATE (output, \
GIMP_TYPE_DYNAMICS_OUTPUT, \
GimpDynamicsOutputPrivate)
static void gimp_dynamics_output_finalize (GObject *object);
static void gimp_dynamics_output_set_property (GObject *object,
guint property_id,
......@@ -180,39 +209,42 @@ gimp_dynamics_output_class_init (GimpDynamicsOutputClass *klass)
GIMP_TYPE_CURVE,
GIMP_CONFIG_PARAM_AGGREGATE);
g_type_class_add_private (klass, sizeof (GimpDynamicsOutputPrivate));
}
static void
gimp_dynamics_output_init (GimpDynamicsOutput *output)
{
output->pressure_curve = gimp_dynamics_output_create_curve (output,
"pressure-curve");
output->velocity_curve = gimp_dynamics_output_create_curve (output,
"velocity-curve");
output->direction_curve = gimp_dynamics_output_create_curve (output,
"direction-curve");
output->tilt_curve = gimp_dynamics_output_create_curve (output,
"tilt-curve");
output->wheel_curve = gimp_dynamics_output_create_curve (output,
"wheel-curve");
output->random_curve = gimp_dynamics_output_create_curve (output,
"random-curve");
output->fade_curve = gimp_dynamics_output_create_curve (output,
"fade-curve");
GimpDynamicsOutputPrivate *private = GET_PRIVATE (output);
private->pressure_curve = gimp_dynamics_output_create_curve (output,
"pressure-curve");
private->velocity_curve = gimp_dynamics_output_create_curve (output,
"velocity-curve");
private->direction_curve = gimp_dynamics_output_create_curve (output,
"direction-curve");
private->tilt_curve = gimp_dynamics_output_create_curve (output,
"tilt-curve");
private->wheel_curve = gimp_dynamics_output_create_curve (output,
"wheel-curve");
private->random_curve = gimp_dynamics_output_create_curve (output,
"random-curve");
private->fade_curve = gimp_dynamics_output_create_curve (output,
"fade-curve");
}
static void
gimp_dynamics_output_finalize (GObject *object)
{
GimpDynamicsOutput *output = GIMP_DYNAMICS_OUTPUT (object);
GimpDynamicsOutputPrivate *private = GET_PRIVATE (object);
g_object_unref (output->pressure_curve);
g_object_unref (output->velocity_curve);
g_object_unref (output->direction_curve);
g_object_unref (output->tilt_curve);
g_object_unref (output->wheel_curve);
g_object_unref (output->random_curve);
g_object_unref (output->fade_curve);
g_object_unref (private->pressure_curve);
g_object_unref (private->velocity_curve);
g_object_unref (private->direction_curve);
g_object_unref (private->tilt_curve);
g_object_unref (private->wheel_curve);
g_object_unref (private->random_curve);
g_object_unref (private->fade_curve);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
......@@ -223,75 +255,75 @@ gimp_dynamics_output_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GimpDynamicsOutput *output = GIMP_DYNAMICS_OUTPUT (object);
GimpDynamicsOutputPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
output->type = g_value_get_enum (value);
private->type = g_value_get_enum (value);
break;
case PROP_USE_PRESSURE:
output->use_pressure = g_value_get_boolean (value);
private->use_pressure = g_value_get_boolean (value);
break;
case PROP_USE_VELOCITY:
output->use_velocity = g_value_get_boolean (value);
private->use_velocity = g_value_get_boolean (value);
break;
case PROP_USE_DIRECTION:
output->use_direction = g_value_get_boolean (value);
private->use_direction = g_value_get_boolean (value);
break;
case PROP_USE_TILT:
output->use_tilt = g_value_get_boolean (value);
private->use_tilt = g_value_get_boolean (value);
break;
case PROP_USE_WHEEL:
output->use_wheel = g_value_get_boolean (value);
private->use_wheel = g_value_get_boolean (value);
break;
case PROP_USE_RANDOM:
output->use_random = g_value_get_boolean (value);
private->use_random = g_value_get_boolean (value);
break;
case PROP_USE_FADE:
output->use_fade = g_value_get_boolean (value);
private->use_fade = g_value_get_boolean (value);
break;
case PROP_PRESSURE_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->pressure_curve);
private->pressure_curve);
break;
case PROP_VELOCITY_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->velocity_curve);
private->velocity_curve);
break;
case PROP_DIRECTION_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->direction_curve);
private->direction_curve);
break;
case PROP_TILT_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->tilt_curve);
private->tilt_curve);
break;
case PROP_WHEEL_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->wheel_curve);
private->wheel_curve);
break;
case PROP_RANDOM_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->random_curve);
private->random_curve);
break;
case PROP_FADE_CURVE:
gimp_dynamics_output_copy_curve (g_value_get_object (value),
output->fade_curve);
private->fade_curve);
break;
default:
......@@ -306,68 +338,68 @@ gimp_dynamics_output_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GimpDynamicsOutput *output = GIMP_DYNAMICS_OUTPUT (object);
GimpDynamicsOutputPrivate *private = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
g_value_set_enum (value, output->type);
g_value_set_enum (value, private->type);
break;
case PROP_USE_PRESSURE:
g_value_set_boolean (value, output->use_pressure);
g_value_set_boolean (value, private->use_pressure);
break;
case PROP_USE_VELOCITY:
g_value_set_boolean (value, output->use_velocity);
g_value_set_boolean (value, private->use_velocity);
break;
case PROP_USE_DIRECTION:
g_value_set_boolean (value, output->use_direction);
g_value_set_boolean (value, private->use_direction);
break;
case PROP_USE_TILT:
g_value_set_boolean (value, output->use_tilt);
g_value_set_boolean (value, private->use_tilt);
break;
case PROP_USE_WHEEL:
g_value_set_boolean (value, output->use_wheel);
g_value_set_boolean (value, private->use_wheel);
break;
case PROP_USE_RANDOM:
g_value_set_boolean (value, output->use_random);
g_value_set_boolean (value, private->use_random);
break;
case PROP_USE_FADE:
g_value_set_boolean (value, output->use_fade);
g_value_set_boolean (value, private->use_fade);
break;
case PROP_PRESSURE_CURVE:
g_value_set_object (value, output->pressure_curve);
g_value_set_object (value, private->pressure_curve);
break;
case PROP_VELOCITY_CURVE:
g_value_set_object (value, output->velocity_curve);
g_value_set_object (value, private->velocity_curve);
break;
case PROP_DIRECTION_CURVE:
g_value_set_object (value, output->direction_curve);
g_value_set_object (value, private->direction_curve);
break;
case PROP_TILT_CURVE:
g_value_set_object (value, output->tilt_curve);
g_value_set_object (value, private->tilt_curve);
break;
case PROP_WHEEL_CURVE:
g_value_set_object (value, output->wheel_curve);
g_value_set_object (value, private->wheel_curve);
break;
case PROP_RANDOM_CURVE:
g_value_set_object (value, output->random_curve);
g_value_set_object (value, private->random_curve);
break;
case PROP_FADE_CURVE:
g_value_set_object (value, output->fade_curve);
g_value_set_object (value, private->fade_curve);
break;
default:
......@@ -394,13 +426,15 @@ gimp_dynamics_output_new (const gchar *name,
gboolean
gimp_dynamics_output_is_enabled (GimpDynamicsOutput *output)
{
return (output->use_pressure ||
output->use_velocity ||
output->use_direction ||
output->use_tilt ||
output->use_wheel ||
output->use_random ||
output->use_fade);
GimpDynamicsOutputPrivate *private = GET_PRIVATE (output);
return (private->use_pressure ||
private->use_velocity ||
private->use_direction ||
private->use_tilt ||
private->use_wheel ||
private->use_random ||
private->use_fade);
}
gdouble
......@@ -409,39 +443,41 @@ gimp_dynamics_output_get_linear_value (GimpDynamicsOutput *output,
GimpPaintOptions *options,
gdouble fade_point)
{
gdouble total = 0.0;
gdouble result = 1.0;
gint factors = 0;
GimpDynamicsOutputPrivate *private = GET_PRIVATE (output);
gdouble total = 0.0;
gdouble result = 1.0;
gint factors = 0;
if (output->use_pressure)
if (private->use_pressure)
{
total += gimp_curve_map_value (output->pressure_curve, coords->pressure);
total += gimp_curve_map_value (private->pressure_curve,
coords->pressure);
factors++;
}
if (output->use_velocity)
if (private->use_velocity)
{
total += gimp_curve_map_value (output->velocity_curve,
total += gimp_curve_map_value (private->velocity_curve,
(1.0 - coords->velocity));
factors++;
}
if (output->use_direction)
if (private->use_direction)
{
total += gimp_curve_map_value (output->direction_curve,
total += gimp_curve_map_value (private->direction_curve,
fmod (coords->direction + 0.5, 1));
factors++;
}
if (output->use_tilt)
if (private->use_tilt)
{
total += gimp_curve_map_value (output->tilt_curve,
total += gimp_curve_map_value (private->tilt_curve,
(1.0 - sqrt (SQR (coords->xtilt) +
SQR (coords->ytilt))));
factors++;
}
if (output->use_wheel)
if (private->use_wheel)
{
gdouble wheel;
if (coords->wheel >= 0.5)
......@@ -449,20 +485,20 @@ gimp_dynamics_output_get_linear_value (GimpDynamicsOutput *output,
else
wheel = 1 - coords->wheel * 2;
total += gimp_curve_map_value (output->wheel_curve, wheel);
total += gimp_curve_map_value (private->wheel_curve, wheel);
factors++;
}
if (output->use_random)
if (private->use_random)
{
total += gimp_curve_map_value (output->random_curve,
total += gimp_curve_map_value (private->random_curve,
g_random_double_range (0.0, 1.0));
factors++;
}
if (output->use_fade)
if (private->use_fade)
{
total += gimp_curve_map_value (output->fade_curve, fade_point);
total += gimp_curve_map_value (private->fade_curve, fade_point);
factors++;
}
......@@ -484,33 +520,36 @@ gimp_dynamics_output_get_angular_value (GimpDynamicsOutput *output,
GimpPaintOptions *options,
gdouble fade_point)
{
gdouble total = 0.0;
gdouble result = 0.0; /* angles are additive, so we retun zero for no change. */
gint factors = 0;
GimpDynamicsOutputPrivate *private = GET_PRIVATE (output);
gdouble total = 0.0;
gdouble result = 0.0; /* angles are additive, so we retun zero for no change. */
gint factors = 0;
if (output->use_pressure)
if (private->use_pressure)
{
total += gimp_curve_map_value (output->pressure_curve, coords->pressure);
total += gimp_curve_map_value (private->pressure_curve,
coords->pressure);
factors++;
}
if (output->use_velocity)
if (private->use_velocity)
{
total += gimp_curve_map_value (output->velocity_curve,
total += gimp_curve_map_value (private->velocity_curve,
(1.0 - coords->velocity));
factors++;
}
if (output->use_direction)
if (private->use_direction)
{
total += gimp_curve_map_value (output->direction_curve, coords->direction);
total += gimp_curve_map_value (private->direction_curve,
coords->direction);
factors++;
}
/* For tilt to make sense, it needs to be converted to an angle, not
* just a vector
*/
if (output->use_tilt)
if (private->use_tilt)
{
gdouble tilt_x = coords->xtilt;
gdouble tilt_y = coords->ytilt;
......@@ -542,28 +581,28 @@ gimp_dynamics_output_get_angular_value (GimpDynamicsOutput *output,
while (tilt < 0.0)
tilt += 1.0;
total += gimp_curve_map_value (output->tilt_curve, tilt);
total += gimp_curve_map_value (private->tilt_curve, tilt);
factors++;
}
if (output->use_wheel)
if (private->use_wheel)
{
gdouble angle = 1.0 - fmod(0.5 + coords->wheel, 1);
total += gimp_curve_map_value (output->wheel_curve, angle);
total += gimp_curve_map_value (private->wheel_curve, angle);
factors++;
}
if (output->use_random)
if (private->use_random)
{
total += gimp_curve_map_value (output->random_curve,
total += gimp_curve_map_value (private->random_curve,
g_random_double_range (0.0, 1.0));
factors++;
}
if (output->use_fade)
if (private->use_fade)
{
total += gimp_curve_map_value (output->fade_curve, fade_point);
total += gimp_curve_map_value (private->fade_curve, fade_point);
factors++;
}
......@@ -585,26 +624,30 @@ gimp_dynamics_output_get_aspect_value (GimpDynamicsOutput *output,
GimpPaintOptions *options,
gdouble fade_point)
{
gdouble total = 0.0;
gint factors = 0;
gdouble sign = 1.0;
gdouble result = 1.0;
GimpDynamicsOutputPrivate *private = GET_PRIVATE (output);
gdouble total = 0.0;
gint factors = 0;
gdouble sign = 1.0;
gdouble result = 1.0;
if (output->use_pressure)
if (private->use_pressure)
{
total += gimp_curve_map_value (output->pressure_curve, coords->pressure);
total += gimp_curve_map_value (private->pressure_curve,
coords->pressure);
factors++;
}
if (output->use_velocity)
if (private->use_velocity)
{
total += gimp_curve_map_value (output->velocity_curve, coords->velocity);
total += gimp_curve_map_value (private->velocity_curve,
coords->velocity);
factors++;
}
if (output->use_direction)
if (private->use_direction)
{
gdouble direction = gimp_curve_map_value (output->direction_curve, coords->direction);
gdouble direction = gimp_curve_map_value (private->direction_curve,
coords->direction);
if (((direction > 0.875) && (direction <= 1.0)) ||
((direction > 0.0) && (direction < 0.125)) ||
......@@ -615,11 +658,11 @@ gimp_dynamics_output_get_aspect_value (GimpDynamicsOutput *output,
factors++;
}
if (output->use_tilt)
if (private->use_tilt)
{
gdouble tilt_value = MAX (fabs (coords->xtilt), fabs (coords->ytilt));
tilt_value = gimp_curve_map_value (output->tilt_curve,
tilt_value = gimp_curve_map_value (private->tilt_curve,
tilt_value);
total += tilt_value;
......@@ -627,9 +670,10 @@ gimp_dynamics_output_get_aspect_value (GimpDynamicsOutput *output,
factors++;
}
if (output->use_wheel)
if (private->use_wheel)
{
gdouble wheel = gimp_curve_map_value (output->wheel_curve, coords->wheel);
gdouble wheel = gimp_curve_map_value (private->wheel_curve,
coords->wheel);
if (((wheel > 0.875) && (wheel <= 1.0)) ||
((wheel > 0.0) && (wheel < 0.125)) ||
......@@ -641,18 +685,18 @@ gimp_dynamics_output_get_aspect_value (GimpDynamicsOutput *output,
}
if (output->use_random)
if (private->use_random)
{
gdouble random = gimp_curve_map_value (output->random_curve,
gdouble random = gimp_curve_map_value (private->random_curve,
g_random_double_range (0.0, 1.0));
total += random;
factors++;
}
if (output->use_fade)
if (private->use_fade)
{
total += gimp_curve_map_value (output->fade_curve, fade_point);
total += gimp_curve_map_value (private->fade_curve, fade_point);
factors++;
}
......
......@@ -34,25 +34,7 @@ typedef struct _GimpDynamicsOutputClass GimpDynamicsOutputClass;
struct _GimpDynamicsOutput
{
GimpObject parent_instance;
GimpDynamicsOutputType type;
gboolean use_pressure;
gboolean use_velocity;
gboolean use_direction;
gboolean use_tilt;
gboolean use_wheel;
gboolean use_random;
gboolean use_fade;
GimpCurve *pressure_curve;
GimpCurve *velocity_curve;
GimpCurve *direction_curve;
GimpCurve *tilt_curve;
GimpCurve *wheel_curve;
GimpCurve *random_curve;
GimpCurve *fade_curve;
GimpObject parent_instance;
};
struct _GimpDynamicsOutputClass
......
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