From ace4234a986b4e5c33d3e4ace73c22b7a92664b4 Mon Sep 17 00:00:00 2001 From: Alexia Death Date: Mon, 19 Jan 2015 10:46:31 +0200 Subject: [PATCH] app: make all tools capable of dynamic force respect the options slider --- app/paint/gimpclone.c | 34 +++++++++++++++--------- app/paint/gimpdodgeburn.c | 24 ++++++++++++----- app/paint/gimperaser.c | 20 ++++++++++---- app/paint/gimpheal.c | 46 +++++++++++++++++++------------- app/paint/gimppaintbrush.c | 7 ++--- app/paint/gimpsmudge.c | 54 ++++++++++++++++++++++---------------- 6 files changed, 116 insertions(+), 69 deletions(-) diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index a232adb4c9..554b8934c5 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -151,13 +151,15 @@ gimp_clone_motion (GimpSourceCore *source_core, gint paint_area_width, gint paint_area_height) { - GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); - GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options); - GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options); - GimpContext *context = GIMP_CONTEXT (paint_options); - GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - gdouble fade_point; - gdouble force; + GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); + GimpCloneOptions *options = GIMP_CLONE_OPTIONS (paint_options); + GimpSourceOptions *source_options = GIMP_SOURCE_OPTIONS (paint_options); + GimpContext *context = GIMP_CONTEXT (paint_options); + GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); + gdouble fade_point; + gdouble force; + gdouble dyn_force; + GimpDynamicsOutput *dyn_output = NULL; 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, paint_core->pixel_dist); - force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics, - GIMP_DYNAMICS_OUTPUT_FORCE, - coords, - paint_options, - fade_point); + dyn_output = gimp_dynamics_get_output (GIMP_BRUSH_CORE (paint_core)->dynamics, + GIMP_DYNAMICS_OUTPUT_FORCE); + + dyn_force = gimp_dynamics_get_linear_value (GIMP_BRUSH_CORE (paint_core)->dynamics, + 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, coords, diff --git a/app/paint/gimpdodgeburn.c b/app/paint/gimpdodgeburn.c index dd4ac8c9a6..92b3298ddd 100644 --- a/app/paint/gimpdodgeburn.c +++ b/app/paint/gimpdodgeburn.c @@ -120,7 +120,9 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core, gint paint_buffer_y; gdouble fade_point; gdouble opacity; - gdouble hardness; + gdouble force; + gdouble dyn_force; + GimpDynamicsOutput *dyn_output = NULL; fade_point = gimp_paint_options_get_fade (paint_options, image, paint_core->pixel_dist); @@ -152,11 +154,19 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core, options->type, options->mode); - hardness = gimp_dynamics_get_linear_value (dynamics, - GIMP_DYNAMICS_OUTPUT_HARDNESS, - coords, - paint_options, - fade_point); + dyn_output = gimp_dynamics_get_output (dynamics, + GIMP_DYNAMICS_OUTPUT_FORCE); + + dyn_force = gimp_dynamics_get_linear_value (dynamics, + 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 */ 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), gimp_context_get_opacity (context), gimp_paint_options_get_brush_mode (paint_options), - hardness, + force, GIMP_PAINT_CONSTANT); } diff --git a/app/paint/gimperaser.c b/app/paint/gimperaser.c index 0e22e6b7f8..91a38bcf92 100644 --- a/app/paint/gimperaser.c +++ b/app/paint/gimperaser.c @@ -116,6 +116,8 @@ gimp_eraser_motion (GimpPaintCore *paint_core, GimpRGB background; GeglColor *color; gdouble force; + gdouble dyn_force; + GimpDynamicsOutput *dyn_output = NULL; fade_point = gimp_paint_options_get_fade (paint_options, image, paint_core->pixel_dist); @@ -148,11 +150,19 @@ gimp_eraser_motion (GimpPaintCore *paint_core, else paint_mode = GIMP_NORMAL_MODE; - force = gimp_dynamics_get_linear_value (dynamics, - GIMP_DYNAMICS_OUTPUT_FORCE, - coords, - paint_options, - fade_point); + dyn_output = gimp_dynamics_get_output (dynamics, + GIMP_DYNAMICS_OUTPUT_FORCE); + + dyn_force = gimp_dynamics_get_linear_value (dynamics, + 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, coords, diff --git a/app/paint/gimpheal.c b/app/paint/gimpheal.c index 71306039be..b0e7f7eb23 100644 --- a/app/paint/gimpheal.c +++ b/app/paint/gimpheal.c @@ -475,31 +475,41 @@ gimp_heal_motion (GimpSourceCore *source_core, gint paint_area_width, gint paint_area_height) { - GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); - GimpContext *context = GIMP_CONTEXT (paint_options); - GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; - GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - GeglBuffer *src_copy; - GeglBuffer *mask_buffer; - const GimpTempBuf *mask_buf; - gdouble fade_point; - gdouble hardness; - gint mask_off_x; - gint mask_off_y; + GimpPaintCore *paint_core = GIMP_PAINT_CORE (source_core); + GimpContext *context = GIMP_CONTEXT (paint_options); + GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; + GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); + GeglBuffer *src_copy; + GeglBuffer *mask_buffer; + const GimpTempBuf *mask_buf; + gdouble fade_point; + gdouble force; + gint mask_off_x; + gint mask_off_y; + gdouble dyn_force; + GimpDynamicsOutput *dyn_output = NULL; fade_point = gimp_paint_options_get_fade (paint_options, image, paint_core->pixel_dist); - hardness = gimp_dynamics_get_linear_value (dynamics, - GIMP_DYNAMICS_OUTPUT_HARDNESS, - coords, - paint_options, - fade_point); + dyn_output = gimp_dynamics_get_output (dynamics, + GIMP_DYNAMICS_OUTPUT_FORCE); + + dyn_force = gimp_dynamics_get_linear_value (dynamics, + 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), coords, GIMP_BRUSH_HARD, - hardness); + force); /* check that all buffers are of the same size */ 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), gimp_context_get_opacity (context), gimp_paint_options_get_brush_mode (paint_options), - hardness, + force, GIMP_PAINT_INCREMENTAL); } diff --git a/app/paint/gimppaintbrush.c b/app/paint/gimppaintbrush.c index 4073e28973..3c605e177a 100644 --- a/app/paint/gimppaintbrush.c +++ b/app/paint/gimppaintbrush.c @@ -124,7 +124,6 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core, gdouble force; gdouble dyn_force; GimpDynamicsOutput *dyn_output = NULL; - gdouble option_force; image = gimp_item_get_image (GIMP_ITEM (drawable)); @@ -209,13 +208,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core, coords, paint_options, fade_point); - force = 0.5; - option_force = paint_options->brush_force; if (gimp_dynamics_output_is_enabled (dyn_output)) force = dyn_force; - else if (option_force != 0.5) - force = option_force; + else + force = paint_options->brush_force; /* finally, let the brush core paste the colored area on the canvas */ gimp_brush_core_paste_canvas (brush_core, drawable, diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 418b8924c0..24f777ce63 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -233,22 +233,24 @@ gimp_smudge_motion (GimpPaintCore *paint_core, GimpPaintOptions *paint_options, const GimpCoords *coords) { - GimpSmudge *smudge = GIMP_SMUDGE (paint_core); - GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options); - GimpContext *context = GIMP_CONTEXT (paint_options); - GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; - GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); - GeglBuffer *paint_buffer; - gint paint_buffer_x; - gint paint_buffer_y; - gint paint_buffer_width; - gint paint_buffer_height; - gdouble fade_point; - gdouble opacity; - gdouble rate; - gdouble dynamic_rate; - gint x, y; - gdouble hardness; + GimpSmudge *smudge = GIMP_SMUDGE (paint_core); + GimpSmudgeOptions *options = GIMP_SMUDGE_OPTIONS (paint_options); + GimpContext *context = GIMP_CONTEXT (paint_options); + GimpDynamics *dynamics = GIMP_BRUSH_CORE (paint_core)->dynamics; + GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable)); + GeglBuffer *paint_buffer; + gint paint_buffer_x; + gint paint_buffer_y; + gint paint_buffer_width; + gint paint_buffer_height; + gdouble fade_point; + gdouble opacity; + gdouble rate; + gdouble dynamic_rate; + gint x, y; + gdouble force; + gdouble dyn_force; + GimpDynamicsOutput *dyn_output = NULL; fade_point = gimp_paint_options_get_fade (paint_options, image, paint_core->pixel_dist); @@ -316,18 +318,26 @@ gimp_smudge_motion (GimpPaintCore *paint_core, paint_buffer, GEGL_RECTANGLE (0, 0, 0, 0)); - hardness = gimp_dynamics_get_linear_value (dynamics, - GIMP_DYNAMICS_OUTPUT_HARDNESS, - coords, - paint_options, - fade_point); + dyn_output = gimp_dynamics_get_output (dynamics, + GIMP_DYNAMICS_OUTPUT_FORCE); + + dyn_force = gimp_dynamics_get_linear_value (dynamics, + 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, coords, MIN (opacity, GIMP_OPACITY_OPAQUE), gimp_context_get_opacity (context), gimp_paint_options_get_brush_mode (paint_options), - hardness, + force, GIMP_PAINT_INCREMENTAL); }