Cleaning up the dynamics init a little bit more

This commit is contained in:
Alexia Death 2009-08-20 18:24:50 +03:00
parent 4af5324d58
commit e04a7617d5
4 changed files with 46 additions and 38 deletions

View File

@ -2487,7 +2487,7 @@ gimp_context_real_set_brush (GimpContext *context,
/* dynamics *****************************************************************/
GimpDynamicsOptions *
GimpDynamics *
gimp_context_get_dynamics (GimpContext *context)
{
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@ -2497,7 +2497,7 @@ gimp_context_get_dynamics (GimpContext *context)
void
gimp_context_set_dynamics (GimpContext *context,
GimpDynamicsOptions *dynamics)
GimpDynamics *dynamics)
{
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (! dynamics || GIMP_IS_DYNAMICS (dynamics));
@ -2547,10 +2547,10 @@ static void gimp_context_dynamics_list_thaw (GimpContainer *container,
GimpContext *context)
{
GimpDynamicsOptions *dynamics;
/*
/*
if (! context->dynamics_name)
context->dynamics_name = g_strdup (context->gimp->config->default_dynamics);
*/
*/
dynamics = gimp_context_find_object (context, container,
context->dynamics_name,
gimp_dynamics_get_standard ());

View File

@ -114,7 +114,7 @@ struct _GimpContextClass
void (* brush_changed) (GimpContext *context,
GimpBrush *brush);
void (* dynamics_changed) (GimpContext *context,
GimpDynamicsOptions *dynamics);
GimpDynamics *dynamics);
void (* pattern_changed) (GimpContext *context,
GimpPattern *pattern);
void (* gradient_changed) (GimpContext *context,
@ -263,9 +263,9 @@ void gimp_context_set_brush (GimpContext *context,
void gimp_context_brush_changed (GimpContext *context);
/* dynamics */
GimpDynamicsOptions * gimp_context_get_dynamics (GimpContext *context);
GimpDynamics * gimp_context_get_dynamics (GimpContext *context);
void gimp_context_set_dynamics (GimpContext *context,
GimpDynamicsOptions *dynamics);
GimpDynamics *dynamics);
void gimp_context_dynamics_changed (GimpContext *context);

View File

@ -158,7 +158,7 @@ static void gimp_dynamics_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
static void gimp_dynamics_output_init (GimpDynamicsOutput *dynamics);
static GimpDynamicsOutput* gimp_dynamics_output_init ();
static void gimp_dynamics_output_finalize (GimpDynamicsOutput *dynamics);
@ -185,15 +185,6 @@ gimp_dynamics_class_init (GimpDynamicsClass *klass)
object_class->get_property = gimp_dynamics_get_property;
object_class->notify = gimp_dynamics_notify;
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RANDOM_ASPECT_RATIO,
"random-aspect-ratio", NULL,
DEFAULT_RANDOM_ASPECT_RATIO,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FADING_ASPECT_RATIO,
"fading-aspect-ratio", NULL,
DEFAULT_FADING_ASPECT_RATIO,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_PRESSURE_OPACITY,
"pressure-opacity", NULL,
DEFAULT_PRESSURE_OPACITY,
@ -334,6 +325,10 @@ gimp_dynamics_class_init (GimpDynamicsClass *klass)
"random-angle", NULL,
DEFAULT_RANDOM_ANGLE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_RANDOM_ASPECT_RATIO,
"random-aspect-ratio", NULL,
DEFAULT_RANDOM_ASPECT_RATIO,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FADING_OPACITY,
"fading-opacity", NULL,
@ -359,25 +354,29 @@ gimp_dynamics_class_init (GimpDynamicsClass *klass)
"fading-angle", NULL,
DEFAULT_FADING_ANGLE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_FADING_ASPECT_RATIO,
"fading-aspect-ratio", NULL,
DEFAULT_FADING_ASPECT_RATIO,
GIMP_PARAM_STATIC_STRINGS);
}
static void
gimp_dynamics_init (GimpDynamics *options)
{
gimp_dynamics_output_init(options->opacity_dynamics);
options->opacity_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->hardness_dynamics);
options->hardness_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->rate_dynamics);
options->rate_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->size_dynamics);
options->size_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->aspect_ratio_dynamics);
options->aspect_ratio_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->color_dynamics);
options->color_dynamics = gimp_dynamics_output_init();
gimp_dynamics_output_init(options->angle_dynamics);
options->angle_dynamics = gimp_dynamics_output_init();
}
@ -401,14 +400,13 @@ gimp_dynamics_finalize (GObject *object)
gimp_dynamics_output_finalize (options->angle_dynamics);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
gimp_dynamics_output_init (GimpDynamicsOutput *dynamics)
static GimpDynamicsOutput*
gimp_dynamics_output_init()
{
dynamics = g_slice_new0 (GimpDynamicsOutput);
GimpDynamicsOutput * dynamics = g_slice_new0 (GimpDynamicsOutput);
dynamics->pressure_curve = g_object_new (GIMP_TYPE_CURVE,
"name", "Pressure curve",
@ -428,6 +426,7 @@ gimp_dynamics_output_init (GimpDynamicsOutput *dynamics)
dynamics->fade_curve = g_object_new (GIMP_TYPE_CURVE,
"name", "Fade curve",
NULL);
return dynamics;
}
static void
@ -469,7 +468,6 @@ gimp_dynamics_set_property (GObject *object,
switch (property_id)
{
case PROP_PRESSURE_OPACITY:
opacity_dynamics->pressure = g_value_get_boolean (value);
break;
@ -907,7 +905,7 @@ gimp_dynamics_get_standard (void)
gdouble
gimp_dynamics_get_output_val (GimpDynamicsOutput *output, GimpCoords *coords)
{
printf("Dynamics queried...");
printf("Dynamics queried...\n");
return 1;
}

View File

@ -377,6 +377,9 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
GimpBrushCore *core = GIMP_BRUSH_CORE (paint_core);
GimpBrush *brush;
core->dynamics = gimp_context_get_dynamics (GIMP_CONTEXT (paint_options));
brush = gimp_context_get_brush (GIMP_CONTEXT (paint_options));
if (core->main_brush != brush)
@ -394,6 +397,12 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
core->scale = paint_options->brush_scale;/* gimp_paint_options_get_dynamic_size (paint_options, coords,
TRUE,
paint_core->pixel_dist);*/
if (core->dynamics)
{
core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, coords);
printf("PAss GO 2\n");
}
else printf("Go to jail\n");
core->angle = paint_options->brush_angle;/* gimp_paint_options_get_dynamic_angle (paint_options, coords,
paint_core->pixel_dist);*/
@ -746,6 +755,7 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
if (core->dynamics)
{
core->scale *= gimp_dynamics_get_output_val(core->dynamics->size_dynamics, coords);
printf("PAssing go1\n");
}
core->angle = paint_options->brush_angle; /* gimp_paint_options_get_dynamic_angle (paint_options, coords,