Commit 96baac78 authored by zhenfeng zhao's avatar zhenfeng zhao

Fade dynamics. Add fade as one more dynamics driving factor on GUI. Implement...

Fade dynamics. Add fade as one more dynamics driving factor on GUI. Implement fading dynamics calculation. Let fade work with all driven factors. Add pixel_dist parameter to get_dynamic_x. Adjusted function calls for get_dynamic_x.

        * app/paint/gimppaintoptions.c: Add initialization for fading dynamics. Add fading related variables similar to Random. Adjust get_dynamics_mix function. Add fading calculation in get_dynamics_x functions. Adjust get_dynamic_x functions for fade dynamics.

	* app/paint/gimppaintoptions.h: Add fading_options in GimpDynamicOptions.

	* app/tools/gimppaintoptions-gui.c: Add the function fading_options_gui.

	* app/paint/gimpclone.c
	* app/paint/gimpdodgeburn.c
	* app/paint/gimperaser.c
	* app/paint/gimpheal.c
	* app/paint/gimppaintbrush.c
	* app/paint/gimpsmudge.c
	* app/paint/gimpairbrush.c
	* app/paint/gimpbrushcore.c
	* app/paint/gimpconvolve.c: Adjust function calls. get_dynamic_opacity function calls were adjusted to have one more parameter, paint_core->pixel_dist.

some key words:
get_dynamic_
pixel_dist
paint_core->pixel_dist
parent fe09f320
/.anjuta/
/.anjuta_sym_db.db
/TODO.tasks
*.anjuta
*.c~
*.h~
*.patch
/app/
/Makefile
/Makefile.in
/aclocal.m4
......
......@@ -146,7 +146,8 @@ gimp_airbrush_paint (GimpPaintCore *paint_core,
airbrush->paint_options = paint_options;
dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options,
coords);
coords,
paint_core->pixel_dist);
timeout = 10000 / (options->rate * dynamic_rate);
......
......@@ -374,12 +374,15 @@ gimp_brush_core_start (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_transforming_brush)
{
core->scale = gimp_paint_options_get_dynamic_size (paint_options, coords,
TRUE);
TRUE,
paint_core->pixel_dist);
core->angle = gimp_paint_options_get_dynamic_angle (paint_options, coords);
core->angle = gimp_paint_options_get_dynamic_angle (paint_options, coords,
paint_core->pixel_dist);
core->aspect_ratio =
gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords);
gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
paint_core->pixel_dist);
}
core->spacing = (gdouble) gimp_brush_get_spacing (core->main_brush) / 100.0;
......@@ -722,12 +725,15 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core,
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_transforming_brush)
{
core->scale = gimp_paint_options_get_dynamic_size (paint_options, coords,
TRUE);
TRUE,
paint_core->pixel_dist);
core->angle = gimp_paint_options_get_dynamic_angle (paint_options, coords);
core->angle = gimp_paint_options_get_dynamic_angle (paint_options, coords,
paint_core->pixel_dist);
core->aspect_ratio =
gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords);
gimp_paint_options_get_dynamic_aspect_ratio (paint_options, coords,
paint_core->pixel_dist);
}
core->scale = gimp_brush_core_clamp_brush_scale (core, core->scale);
......
......@@ -238,9 +238,11 @@ gimp_clone_motion (GimpSourceCore *source_core,
}
}
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords,
......
......@@ -154,7 +154,8 @@ gimp_convolve_motion (GimpPaintCore *paint_core,
rate = options->rate;
rate *= gimp_paint_options_get_dynamic_rate (paint_options, coords);
rate *= gimp_paint_options_get_dynamic_rate (paint_options, coords,
paint_core->pixel_dist);
gimp_convolve_calculate_matrix (convolve, options->type,
brush_core->brush->mask->width / 2,
......
......@@ -246,9 +246,11 @@ gimp_dodge_burn_motion (GimpPaintCore *paint_core,
g_free (temp_data);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
/* Replace the newly dodgedburned area (canvas_buf) to the image */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
......
......@@ -135,9 +135,11 @@ gimp_eraser_motion (GimpPaintCore *paint_core,
color_pixels (temp_buf_get_data (area), col,
area->width * area->height, area->bytes);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
gimp_brush_core_paste_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords,
......
......@@ -439,7 +439,8 @@ gimp_heal_motion (GimpSourceCore *source_core,
TempBuf *mask_buf;
gdouble hardness;
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
mask_buf = gimp_brush_core_get_brush_mask (GIMP_BRUSH_CORE (source_core),
coords,
......@@ -547,7 +548,8 @@ gimp_heal_motion (GimpSourceCore *source_core,
temp_buf_free (temp);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
/* replace the canvas with our healed data */
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
......
......@@ -131,7 +131,8 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
paint_appl_mode = paint_options->application_mode;
grad_point = gimp_paint_options_get_dynamic_color (paint_options, coords);
grad_point = gimp_paint_options_get_dynamic_color (paint_options, coords,
paint_core->pixel_dist);
/* optionally take the color from the current gradient */
if (gimp_paint_options_get_gradient_color (paint_options, image,
......@@ -176,9 +177,11 @@ _gimp_paintbrush_motion (GimpPaintCore *paint_core,
area->bytes);
}
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
/* finally, let the brush core paste the colored area on the canvas */
gimp_brush_core_paste_canvas (brush_core, drawable,
......
This diff is collapsed.
......@@ -103,6 +103,7 @@ struct _GimpPaintOptions
GimpDynamicOptions *direction_options;
GimpDynamicOptions *tilt_options;
GimpDynamicOptions *random_options;
GimpDynamicOptions *fading_options;
GimpFadeOptions *fade_options;
GimpJitterOptions *jitter_options;
......@@ -144,27 +145,34 @@ GimpBrushApplicationMode
gdouble gimp_paint_options_get_dynamic_opacity (GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_size (GimpPaintOptions *paint_options,
const GimpCoords *coords,
gboolean use_dynamics);
gboolean use_dynamics,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_aspect_ratio
(GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_rate (GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_color (GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_angle (GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
gdouble gimp_paint_options_get_dynamic_hardness(GimpPaintOptions *paint_options,
const GimpCoords *coords);
const GimpCoords *coords,
gdouble pixel_dist);
#endif /* __GIMP_PAINT_OPTIONS_H__ */
......@@ -271,7 +271,8 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
area->x, area->y, area->width, area->height, FALSE);
/* Enable dynamic rate */
dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options, coords);
dynamic_rate = gimp_paint_options_get_dynamic_rate (paint_options, coords,
paint_core->pixel_dist);
rate = (options->rate / 100.0) * dynamic_rate;
/* The tempPR will be the built up buffer (for smudge) */
......@@ -311,9 +312,11 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
else
copy_region (&tempPR, &destPR);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords);
opacity *= gimp_paint_options_get_dynamic_opacity (paint_options, coords,
paint_core->pixel_dist);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords);
hardness = gimp_paint_options_get_dynamic_hardness (paint_options, coords,
paint_core->pixel_dist);
gimp_brush_core_replace_canvas (GIMP_BRUSH_CORE (paint_core), drawable,
coords,
......
......@@ -76,6 +76,12 @@ static void random_options_gui (GimpPaintOptions *paint_options,
GType tool_type,
GtkTable *table,
gint row);
/**/
static void fading_options_gui (GimpPaintOptions *paint_options,
GType tool_type,
GtkTable *table,
gint row);
/**/
static GtkWidget * fade_options_gui (GimpPaintOptions *paint_options,
GType tool_type);
static GtkWidget * gradient_options_gui (GimpPaintOptions *paint_options,
......@@ -234,7 +240,7 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
gtk_container_add (GTK_CONTAINER (frame), inner_frame);
gtk_widget_show (inner_frame);
table = gtk_table_new (5, n_dynamics + 2, FALSE);
table = gtk_table_new (7, n_dynamics + 2, FALSE);
gtk_container_add (GTK_CONTAINER (inner_frame), table);
gtk_widget_show (table);
......@@ -268,6 +274,14 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
//@@Nicolas
label = gtk_label_new (_("Fading - new:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 6, 7,
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
gtk_widget_show (label);
pressure_options_gui (options, tool_type,
GTK_TABLE (table), 1,
dynamics_labels);
......@@ -284,6 +298,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
random_options_gui (options, tool_type,
GTK_TABLE (table), 5);
fading_options_gui (options, tool_type,
GTK_TABLE (table), 6);
/* EEK: pack the fixed *after* the buttons so the table calls
* size-allocates on it *before* it places the toggles. Fixes
* label positions in RTL mode.
......@@ -790,6 +807,64 @@ random_options_gui (GimpPaintOptions *paint_options,
gtk_widget_show (scalebutton);
}
static void
fading_options_gui (GimpPaintOptions *paint_options,
GType tool_type,
GtkTable *table,
gint row)
{
GObject *config = G_OBJECT (paint_options);
gint column = 1;
GtkWidget *scalebutton;
if (tool_has_opacity_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-opacity",
table, column++, row);
}
if (tool_has_hardness_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-hardness",
table, column++, row);
}
if (tool_has_rate_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-rate",
table, column++, row);
}
if (tool_has_size_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-size",
table, column++, row);
}
if (tool_has_aspect_ratio_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-aspect-ratio",
table, column++, row);
}
if (tool_has_angle_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-angle",
table, column++, row);
}
if (tool_has_color_dynamics (tool_type))
{
dynamics_check_button_new (config, "fading-color",
table, column++, row);
}
scalebutton = gimp_prop_scale_button_new (config, "fading-prescale");
gtk_table_attach (table, scalebutton, column, column + 1, row, row + 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (scalebutton);
}
static GtkWidget *
fade_options_gui (GimpPaintOptions *paint_options,
GType tool_type)
......
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