Commit 873cf2b5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

Enable brush scaling for smudge (but only before, not while painting).

2007-11-13  Michael Natterer  <mitch@gimp.org>

	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.


svn path=/trunk/; revision=24140
parent af237c22
2007-11-13 Michael Natterer <mitch@gimp.org>
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 <sven@gimp.org>
* app/core/gimp-utils.c (gimp_get_default_unit): return
......
......@@ -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 (scale < 1 / 256.0)
scale = 1 / 16.0;
else
scale = sqrt (scale);
}
if (paint_options->pressure_options->inverse_size)
scale = 1.0 - 0.9 * pressure;
else if (paint_options->pressure_options->size)
scale = pressure;
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;
}
......
......@@ -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);
......
......@@ -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;
}
......@@ -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 */
......
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