app: make all tools capable of dynamic force respect the options slider

This commit is contained in:
Alexia Death 2015-01-19 10:46:31 +02:00
parent 7c27d9588a
commit ace4234a98
6 changed files with 116 additions and 69 deletions

View File

@ -151,13 +151,15 @@ gimp_clone_motion (GimpSourceCore *source_core,
gint paint_area_width, gint paint_area_width,
gint paint_area_height) gint paint_area_height)
{ {
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options); GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options);
GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options); GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
gdouble fade_point; gdouble fade_point;
gdouble force; gdouble force;
gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL;
if (gimp_source_core_use_source (source_core, source_options)) if (gimp_source_core_use_source (source_core, source_options))
{ {
@ -195,11 +197,19 @@ gimp_clone_motion (GimpSourceCore *source_core,
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics, dyn_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE, GIMP_DYNAMICS_OUTPUT_FORCE);
coords,
paint_options, dyn_force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics,
fade_point); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
paint_options,
fade_point);
if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force;
else
force = paint_options->brush_force;
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,

View File

@ -120,7 +120,9 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
gint paint_buffer_y; gint paint_buffer_y;
gdouble fade_point; gdouble fade_point;
gdouble opacity; gdouble opacity;
gdouble hardness; gdouble force;
gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL;
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
@ -152,11 +154,19 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
options->type, options->type,
options->mode); options->mode);
hardness = gimp_dynamics_get_linear_value (dynamics, dyn_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS, GIMP_DYNAMICS_OUTPUT_FORCE);
coords,
paint_options, dyn_force = gimp_dynamics_get_linear_value (dynamics,
fade_point); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
paint_options,
fade_point);
if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force;
else
force = paint_options->brush_force;
/* Replace the newly dodgedburned area (paint_area) to the image */ /* Replace the newly dodgedburned area (paint_area) to the image */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
@ -164,6 +174,6 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
MIN (opacity, GIMP_OPACITY_OPAQUE), MIN (opacity, GIMP_OPACITY_OPAQUE),
gimp_context_get_opacity (context), gimp_context_get_opacity (context),
gimp_paint_options_get_brush_mode (paint_options), gimp_paint_options_get_brush_mode (paint_options),
hardness, force,
GIMP_PAINT_CONSTANT); GIMP_PAINT_CONSTANT);
} }

View File

@ -116,6 +116,8 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
GimpRGB background; GimpRGB background;
GeglColor *color; GeglColor *color;
gdouble force; gdouble force;
gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL;
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
@ -148,11 +150,19 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
else else
paint_mode = GIMP_NORMAL_MODE; paint_mode = GIMP_NORMAL_MODE;
force = gimp_dynamics_get_linear_value (dynamics, dyn_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_FORCE, GIMP_DYNAMICS_OUTPUT_FORCE);
coords,
paint_options, dyn_force = gimp_dynamics_get_linear_value (dynamics,
fade_point); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
paint_options,
fade_point);
if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force;
else
force = paint_options->brush_force;
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,

View File

@ -475,31 +475,41 @@ gimp_heal_motion (GimpSourceCore *source_core,
gint paint_area_width, gint paint_area_width,
gint paint_area_height) gint paint_area_height)
{ {
GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *src_copy; GeglBuffer *src_copy;
GeglBuffer *mask_buffer; GeglBuffer *mask_buffer;
const GimpTempBuf *mask_buf; const GimpTempBuf *mask_buf;
gdouble fade_point; gdouble fade_point;
gdouble hardness; gdouble force;
gint mask_off_x; gint mask_off_x;
gint mask_off_y; gint mask_off_y;
gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL;
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
hardness = gimp_dynamics_get_linear_value (dynamics, dyn_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS, GIMP_DYNAMICS_OUTPUT_FORCE);
coords,
paint_options, dyn_force = gimp_dynamics_get_linear_value (dynamics,
fade_point); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
paint_options,
fade_point);
if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force;
else
force = paint_options->brush_force;
mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core), mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core),
coords, coords,
GIMP_BRUSH_HARD, GIMP_BRUSH_HARD,
hardness); force);
/* check that all buffers are of the same size */ /* check that all buffers are of the same size */
if (src_rect->width != gegl_buffer_get_width (paint_buffer) || if (src_rect->width != gegl_buffer_get_width (paint_buffer) ||
@ -569,6 +579,6 @@ gimp_heal_motion (GimpSourceCore *source_core,
MIN (opacity, GIMP_OPACITY_OPAQUE), MIN (opacity, GIMP_OPACITY_OPAQUE),
gimp_context_get_opacity (context), gimp_context_get_opacity (context),
gimp_paint_options_get_brush_mode (paint_options), gimp_paint_options_get_brush_mode (paint_options),
hardness, force,
GIMP_PAINT_INCREMENTAL); GIMP_PAINT_INCREMENTAL);
} }

View File

@ -124,7 +124,6 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
gdouble force; gdouble force;
gdouble dyn_force; gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL; GimpDynamicsOutput *dyn_output = NULL;
gdouble option_force;
image = gimp_item_get_image (GIMP_ITEM (drawable)); image = gimp_item_get_image (GIMP_ITEM (drawable));
@ -209,13 +208,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
coords, coords,
paint_options, paint_options,
fade_point); fade_point);
force = 0.5;
option_force = paint_options->brush_force;
if (gimp_dynamics_output_is_enabled (dyn_output)) if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force; force = dyn_force;
else if (option_force != 0.5) else
force = option_force; force = paint_options->brush_force;
/* finally, let the brush core paste the colored area on the canvas */ /* finally, let the brush core paste the colored area on the canvas */
gimp_brush_core_paste_canvas (brush_core, drawable, gimp_brush_core_paste_canvas (brush_core, drawable,

View File

@ -233,22 +233,24 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
GimpPaintOptions *paint_options, GimpPaintOptions *paint_options,
const GimpCoords *coords) const GimpCoords *coords)
{ {
GimpSmudge *smudge = GIMP_SMUDGE (paint_core); GimpSmudge *smudge = GIMP_SMUDGE (paint_core);
GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options); GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options);
GimpContext *context = GIMP_CONTEXT (paint_options); GimpContext *context = GIMP_CONTEXT (paint_options);
GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics;
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GeglBuffer *paint_buffer; GeglBuffer *paint_buffer;
gint paint_buffer_x; gint paint_buffer_x;
gint paint_buffer_y; gint paint_buffer_y;
gint paint_buffer_width; gint paint_buffer_width;
gint paint_buffer_height; gint paint_buffer_height;
gdouble fade_point; gdouble fade_point;
gdouble opacity; gdouble opacity;
gdouble rate; gdouble rate;
gdouble dynamic_rate; gdouble dynamic_rate;
gint x, y; gint x, y;
gdouble hardness; gdouble force;
gdouble dyn_force;
GimpDynamicsOutput *dyn_output = NULL;
fade_point = gimp_paint_options_get_fade (paint_options, image, fade_point = gimp_paint_options_get_fade (paint_options, image,
paint_core->pixel_dist); paint_core->pixel_dist);
@ -316,18 +318,26 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
paint_buffer, paint_buffer,
GEGL_RECTANGLE (0, 0, 0, 0)); GEGL_RECTANGLE (0, 0, 0, 0));
hardness = gimp_dynamics_get_linear_value (dynamics, dyn_output = gimp_dynamics_get_output (dynamics,
GIMP_DYNAMICS_OUTPUT_HARDNESS, GIMP_DYNAMICS_OUTPUT_FORCE);
coords,
paint_options, dyn_force = gimp_dynamics_get_linear_value (dynamics,
fade_point); GIMP_DYNAMICS_OUTPUT_FORCE,
coords,
paint_options,
fade_point);
if (gimp_dynamics_output_is_enabled (dyn_output))
force = dyn_force;
else
force = paint_options->brush_force;
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable, gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords, coords,
MIN (opacity, GIMP_OPACITY_OPAQUE), MIN (opacity, GIMP_OPACITY_OPAQUE),
gimp_context_get_opacity (context), gimp_context_get_opacity (context),
gimp_paint_options_get_brush_mode (paint_options), gimp_paint_options_get_brush_mode (paint_options),
hardness, force,
GIMP_PAINT_INCREMENTAL); GIMP_PAINT_INCREMENTAL);
} }