diff --git a/ChangeLog b/ChangeLog index 510460a7ca..4d4ea47412 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +2007-11-13 Michael Natterer + + Enable brush scaling for smudge (but only before, not while + painting). Fixes bug #471348. + + * app/paint/gimpbrushcore.[ch] (struct GimpBrushCoreClass): rename + member "use_scale" to "handles_scaling_brush". + + (gimp_brush_core_calc_brush_scale): apply pressure scale only if + both "handles_scaling_brush" and "use_pressure" are TRUE, and + apply the scaling from the options unconditionally. + + (gimp_brush_core_get_paint_area): don't re-fetch core->scale if + "handles_scaling_brush" is FALSE to keep the brush from scaling + *while* painting. + + (gimp_brush_core_create_bound_segs): use the brush scale from the + options unconditionally since that's always used now. + + * app/paint/gimpsmudge.c (gimp_smudge_brush_coords): use + gimp_brush_scale_size() to figure the accum_buffer's size instead + of using the brush mask's size directly. + + * app/tools/gimppaintoptions-gui.c (gimp_paint_options_gui): show + the brush scale controls for all brush tools. + 2007-11-12 Sven Neumann * app/core/gimp-utils.c (gimp_get_default_unit): return diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c index 0772477d60..3df6e2276a 100644 --- a/app/paint/gimpbrushcore.c +++ b/app/paint/gimpbrushcore.c @@ -157,7 +157,7 @@ gimp_brush_core_class_init (GimpBrushCoreClass *klass) paint_core_class->get_paint_area = gimp_brush_core_get_paint_area; klass->handles_changing_brush = FALSE; - klass->use_scale = TRUE; + klass->handles_scaling_brush = TRUE; klass->set_brush = gimp_brush_core_real_set_brush; } @@ -677,8 +677,10 @@ gimp_brush_core_get_paint_area (GimpPaintCore *paint_core, gint drawable_width, drawable_height; gint brush_width, brush_height; - core->scale = gimp_brush_core_calc_brush_scale (core, paint_options, - paint_core->cur_coords.pressure); + if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_scaling_brush) + core->scale = gimp_brush_core_calc_brush_scale (core, paint_options, + paint_core->cur_coords.pressure); + /* else use scale from start(), we don't support on-the-fly scaling */ gimp_brush_scale_size (core->brush, core->scale, &brush_width, &brush_height); @@ -766,8 +768,7 @@ gimp_brush_core_create_bound_segs (GimpBrushCore *core, g_return_if_fail (core->main_brush != NULL); g_return_if_fail (core->brush_bound_segs == NULL); - if (GIMP_BRUSH_CORE_GET_CLASS (core)->use_scale) - scale = paint_options->brush_scale; + scale = paint_options->brush_scale; if (scale > 0.0) mask = gimp_brush_scale_mask (core->main_brush, scale); @@ -909,24 +910,22 @@ gimp_brush_core_calc_brush_scale (GimpBrushCore *core, { gdouble scale = 1.0; - if (GIMP_BRUSH_CORE_GET_CLASS (core)->use_scale) + if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_scaling_brush && + GIMP_PAINT_CORE (core)->use_pressure) { - if (GIMP_PAINT_CORE (core)->use_pressure) - { - if (paint_options->pressure_options->inverse_size) - scale = 1.0 - 0.9 * pressure; - else if (paint_options->pressure_options->size) - scale = pressure; + if (paint_options->pressure_options->inverse_size) + scale = 1.0 - 0.9 * pressure; + else if (paint_options->pressure_options->size) + scale = pressure; - if (scale < 1 / 256.0) - scale = 1 / 16.0; - else - scale = sqrt (scale); - } - - scale *= paint_options->brush_scale; + if (scale < 1 / 256.0) + scale = 1 / 16.0; + else + scale = sqrt (scale); } + scale *= paint_options->brush_scale; + return scale; } diff --git a/app/paint/gimpbrushcore.h b/app/paint/gimpbrushcore.h index 400a34f203..79aa336111 100644 --- a/app/paint/gimpbrushcore.h +++ b/app/paint/gimpbrushcore.h @@ -91,8 +91,8 @@ struct _GimpBrushCoreClass /* Set for tools that don't mind if the brush changes while painting */ gboolean handles_changing_brush; - /* Scale the brush mask depending on pressure */ - gboolean use_scale; + /* Set for tools that don't mind if the brush scales while painting */ + gboolean handles_scaling_brush; void (* set_brush) (GimpBrushCore *core, GimpBrush *brush); diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c index 4421d82ecd..ceba1d20a9 100644 --- a/app/paint/gimpsmudge.c +++ b/app/paint/gimpsmudge.c @@ -86,11 +86,11 @@ gimp_smudge_class_init (GimpSmudgeClass *klass) GimpPaintCoreClass *paint_core_class = GIMP_PAINT_CORE_CLASS (klass); GimpBrushCoreClass *brush_core_class = GIMP_BRUSH_CORE_CLASS (klass); - object_class->finalize = gimp_smudge_finalize; + object_class->finalize = gimp_smudge_finalize; - paint_core_class->paint = gimp_smudge_paint; + paint_core_class->paint = gimp_smudge_paint; - brush_core_class->use_scale = FALSE; + brush_core_class->handles_scaling_brush = FALSE; } static void @@ -249,14 +249,14 @@ gimp_smudge_motion (GimpPaintCore *paint_core, if (opacity == 0.0) return; - /* Get the unclipped brush coordinates */ - gimp_smudge_brush_coords (paint_core, &x, &y, &w, &h); - /* Get the paint area (Smudge won't scale!) */ area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options); if (! area) return; + /* Get the unclipped brush coordinates */ + gimp_smudge_brush_coords (paint_core, &x, &y, &w, &h); + /* srcPR will be the pixels under the current painthit from the drawable */ pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable), area->x, area->y, area->width, area->height, FALSE); @@ -323,10 +323,15 @@ gimp_smudge_brush_coords (GimpPaintCore *paint_core, gint *h) { GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core); + gint width; + gint height; + + gimp_brush_scale_size (brush_core->brush, brush_core->scale, + &width, &height); /* Note: these are the brush mask size plus a border of 1 pixel */ - *x = (gint) paint_core->cur_coords.x - brush_core->brush->mask->width / 2 - 1; - *y = (gint) paint_core->cur_coords.y - brush_core->brush->mask->height / 2 - 1; - *w = brush_core->brush->mask->width + 2; - *h = brush_core->brush->mask->height + 2; + *x = (gint) paint_core->cur_coords.x - width / 2 - 1; + *y = (gint) paint_core->cur_coords.y - height / 2 - 1; + *w = width + 2; + *h = height + 2; } diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c index e3ed981303..b420a198c5 100644 --- a/app/tools/gimppaintoptions-gui.c +++ b/app/tools/gimppaintoptions-gui.c @@ -116,24 +116,20 @@ gimp_paint_options_gui (GimpToolOptions *tool_options) /* the brush */ if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL)) { + GtkObject *adj; + button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2, "brush-view-type", "brush-view-size"); gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++, _("Brush:"), 0.0, 0.5, button, 2, FALSE); - if (tool_type != GIMP_TYPE_SMUDGE_TOOL) - { - GtkObject *adj; - - adj = gimp_prop_scale_entry_new (config, "brush-scale", - GTK_TABLE (table), 0, table_row++, - _("Scale:"), - 0.01, 0.1, 2, - FALSE, 0.0, 0.0); - - gimp_scale_entry_set_logarithmic (adj, TRUE); - } + adj = gimp_prop_scale_entry_new (config, "brush-scale", + GTK_TABLE (table), 0, table_row++, + _("Scale:"), + 0.01, 0.1, 2, + FALSE, 0.0, 0.0); + gimp_scale_entry_set_logarithmic (adj, TRUE); } /* the gradient */