[gimp] app: Fix pdb size and dynamics brush stuff
- From: Mikael Magnusson <mikachu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: Fix pdb size and dynamics brush stuff
- Date: Sat, 19 Mar 2011 20:10:12 +0000 (UTC)
commit 5d5430e110e1deb376e6bef09eeee7975dcc4fc6
Author: Alexia Death <alexiadeath gmail com>
Date: Sat Mar 19 17:12:14 2011 +0200
app: Fix pdb size and dynamics brush stuff
[ Mikael: deduplicated brush size setting and fixed some whitespace ]
app/pdb/paint-tools-cmds.c | 43 ++++++++++++++++++++++++++++++++++---
tools/pdbgen/pdb/paint_tools.pdb | 43 ++++++++++++++++++++++++++++++++++---
2 files changed, 78 insertions(+), 8 deletions(-)
---
diff --git a/app/pdb/paint-tools-cmds.c b/app/pdb/paint-tools-cmds.c
index ba594a4..271e292 100644
--- a/app/pdb/paint-tools-cmds.c
+++ b/app/pdb/paint-tools-cmds.c
@@ -25,7 +25,9 @@
#include "pdb-types.h"
+#include "core/gimpbrush.h"
#include "core/gimpdrawable.h"
+#include "core/gimpdynamics.h"
#include "core/gimppaintinfo.h"
#include "core/gimpparamspecs.h"
#include "paint/gimppaintcore-stroke.h"
@@ -53,12 +55,23 @@ paint_tools_stroke (Gimp *gimp,
{
GimpPaintCore *core;
GimpCoords *coords;
+ GimpBrush *brush;
gboolean retval;
+ gdouble brush_size;
+ gint height, width;
gint i;
va_list args;
n_strokes /= 2; /* #doubles -> #points */
+ brush = gimp_context_get_brush (context);
+ gimp_brush_transform_size (brush, 1.0, 1.0, 0.0, &height, &width);
+ brush_size = MAX (height, width);
+
+ g_object_set (options,
+ "brush-size", brush_size,
+ NULL);
+
/* undefine the paint-relevant context properties and get them
* from the current context
*/
@@ -665,19 +678,41 @@ paintbrush_invoker (GimpProcedure *procedure,
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
+ GimpDynamics *pdb_dynamics = GIMP_DYNAMICS (gimp_dynamics_new (context, "pdb"));
+ GimpDynamics *user_dynamics = gimp_context_get_dynamics (context);
g_object_set (options,
"application-mode", method,
- "use-fade", fade_out > 0.0,
- "fade-length", fade_out,
- "use-gradient", gradient_length > 0.0,
- "gradient-length", gradient_length,
+ "fade-length", MAX (fade_out, gradient_length),
NULL);
+ if (fade_out > 0)
+ {
+ GimpDynamicsOutput *opacity_output = gimp_dynamics_get_output (pdb_dynamics,
+ GIMP_DYNAMICS_OUTPUT_OPACITY);
+ g_object_set (opacity_output,
+ "use-fade", TRUE,
+ NULL);
+ }
+
+ if (gradient_length > 0)
+ {
+ GimpDynamicsOutput *color_output = gimp_dynamics_get_output (pdb_dynamics,
+ GIMP_DYNAMICS_OUTPUT_COLOR);
+
+ g_object_set (color_output,
+ "use-fade", TRUE,
+ NULL);
+ }
+
+ gimp_context_set_dynamics (context, pdb_dynamics);
+
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, error,
"undo-desc", info->blurb,
NULL);
+
+ gimp_context_set_dynamics (context, user_dynamics);
}
else
success = FALSE;
diff --git a/tools/pdbgen/pdb/paint_tools.pdb b/tools/pdbgen/pdb/paint_tools.pdb
index 486ad17..e4e665c 100644
--- a/tools/pdbgen/pdb/paint_tools.pdb
+++ b/tools/pdbgen/pdb/paint_tools.pdb
@@ -603,19 +603,41 @@ HELP
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpPaintOptions *options = gimp_paint_options_new (info);
+ GimpDynamics *pdb_dynamics = GIMP_DYNAMICS (gimp_dynamics_new (context, "pdb"));
+ GimpDynamics *user_dynamics = gimp_context_get_dynamics (context);
g_object_set (options,
"application-mode", method,
- "use-fade", fade_out > 0.0,
- "fade-length", fade_out,
- "use-gradient", gradient_length > 0.0,
- "gradient-length", gradient_length,
+ "fade-length", MAX (fade_out, gradient_length),
NULL);
+ if (fade_out > 0)
+ {
+ GimpDynamicsOutput *opacity_output = gimp_dynamics_get_output (pdb_dynamics,
+ GIMP_DYNAMICS_OUTPUT_OPACITY);
+ g_object_set (opacity_output,
+ "use-fade", TRUE,
+ NULL);
+ }
+
+ if (gradient_length > 0)
+ {
+ GimpDynamicsOutput *color_output = gimp_dynamics_get_output (pdb_dynamics,
+ GIMP_DYNAMICS_OUTPUT_COLOR);
+
+ g_object_set (color_output,
+ "use-fade", TRUE,
+ NULL);
+ }
+
+ gimp_context_set_dynamics (context, pdb_dynamics);
+
success = paint_tools_stroke (gimp, context, options, drawable,
num_strokes, strokes, error,
"undo-desc", info->blurb,
NULL);
+
+ gimp_context_set_dynamics (context, user_dynamics);
}
else
success = FALSE;
@@ -934,12 +956,23 @@ paint_tools_stroke (Gimp *gimp,
{
GimpPaintCore *core;
GimpCoords *coords;
+ GimpBrush *brush;
gboolean retval;
+ gdouble brush_size;
+ gint height, width;
gint i;
va_list args;
n_strokes /= 2; /* #doubles -> #points */
+ brush = gimp_context_get_brush (context);
+ gimp_brush_transform_size (brush, 1.0, 1.0, 0.0, &height, &width);
+ brush_size = MAX (height, width);
+
+ g_object_set (options,
+ "brush-size", brush_size,
+ NULL);
+
/* undefine the paint-relevant context properties and get them
* from the current context
*/
@@ -977,6 +1010,8 @@ CODE
@headers = qw("libgimpmath/gimpmath.h"
+ "core/gimpbrush.h"
+ "core/gimpdynamics.h"
"core/gimppaintinfo.h"
"paint/gimppaintcore.h"
"paint/gimppaintcore-stroke.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]