mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 01:43:24 +00:00
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
This commit is contained in:
parent
af237c2246
commit
873cf2b53e
5 changed files with 69 additions and 43 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
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>
|
2007-11-12 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/gimp-utils.c (gimp_get_default_unit): return
|
* 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;
|
paint_core_class->get_paint_area = gimp_brush_core_get_paint_area;
|
||||||
|
|
||||||
klass->handles_changing_brush = FALSE;
|
klass->handles_changing_brush = FALSE;
|
||||||
klass->use_scale = TRUE;
|
klass->handles_scaling_brush = TRUE;
|
||||||
klass->set_brush = gimp_brush_core_real_set_brush;
|
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 drawable_width, drawable_height;
|
||||||
gint brush_width, brush_height;
|
gint brush_width, brush_height;
|
||||||
|
|
||||||
|
if (GIMP_BRUSH_CORE_GET_CLASS (core)->handles_scaling_brush)
|
||||||
core->scale = gimp_brush_core_calc_brush_scale (core, paint_options,
|
core->scale = gimp_brush_core_calc_brush_scale (core, paint_options,
|
||||||
paint_core->cur_coords.pressure);
|
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,
|
gimp_brush_scale_size (core->brush, core->scale,
|
||||||
&brush_width, &brush_height);
|
&brush_width, &brush_height);
|
||||||
|
@ -766,7 +768,6 @@ gimp_brush_core_create_bound_segs (GimpBrushCore *core,
|
||||||
g_return_if_fail (core->main_brush != NULL);
|
g_return_if_fail (core->main_brush != NULL);
|
||||||
g_return_if_fail (core->brush_bound_segs == 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)
|
if (scale > 0.0)
|
||||||
|
@ -909,9 +910,8 @@ gimp_brush_core_calc_brush_scale (GimpBrushCore *core,
|
||||||
{
|
{
|
||||||
gdouble scale = 1.0;
|
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)
|
if (paint_options->pressure_options->inverse_size)
|
||||||
scale = 1.0 - 0.9 * pressure;
|
scale = 1.0 - 0.9 * pressure;
|
||||||
|
@ -925,7 +925,6 @@ gimp_brush_core_calc_brush_scale (GimpBrushCore *core,
|
||||||
}
|
}
|
||||||
|
|
||||||
scale *= paint_options->brush_scale;
|
scale *= paint_options->brush_scale;
|
||||||
}
|
|
||||||
|
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ struct _GimpBrushCoreClass
|
||||||
/* Set for tools that don't mind if the brush changes while painting */
|
/* Set for tools that don't mind if the brush changes while painting */
|
||||||
gboolean handles_changing_brush;
|
gboolean handles_changing_brush;
|
||||||
|
|
||||||
/* Scale the brush mask depending on pressure */
|
/* Set for tools that don't mind if the brush scales while painting */
|
||||||
gboolean use_scale;
|
gboolean handles_scaling_brush;
|
||||||
|
|
||||||
void (* set_brush) (GimpBrushCore *core,
|
void (* set_brush) (GimpBrushCore *core,
|
||||||
GimpBrush *brush);
|
GimpBrush *brush);
|
||||||
|
|
|
@ -90,7 +90,7 @@ gimp_smudge_class_init (GimpSmudgeClass *klass)
|
||||||
|
|
||||||
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
|
static void
|
||||||
|
@ -249,14 +249,14 @@ gimp_smudge_motion (GimpPaintCore *paint_core,
|
||||||
if (opacity == 0.0)
|
if (opacity == 0.0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Get the unclipped brush coordinates */
|
|
||||||
gimp_smudge_brush_coords (paint_core, &x, &y, &w, &h);
|
|
||||||
|
|
||||||
/* Get the paint area (Smudge won't scale!) */
|
/* Get the paint area (Smudge won't scale!) */
|
||||||
area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options);
|
area = gimp_paint_core_get_paint_area (paint_core, drawable, paint_options);
|
||||||
if (! area)
|
if (! area)
|
||||||
return;
|
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 */
|
/* srcPR will be the pixels under the current painthit from the drawable */
|
||||||
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
||||||
area->x, area->y, area->width, area->height, FALSE);
|
area->x, area->y, area->width, area->height, FALSE);
|
||||||
|
@ -323,10 +323,15 @@ gimp_smudge_brush_coords (GimpPaintCore *paint_core,
|
||||||
gint *h)
|
gint *h)
|
||||||
{
|
{
|
||||||
GimpBrushCore *brush_core = GIMP_BRUSH_CORE (paint_core);
|
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 */
|
/* 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;
|
*x = (gint) paint_core->cur_coords.x - width / 2 - 1;
|
||||||
*y = (gint) paint_core->cur_coords.y - brush_core->brush->mask->height / 2 - 1;
|
*y = (gint) paint_core->cur_coords.y - height / 2 - 1;
|
||||||
*w = brush_core->brush->mask->width + 2;
|
*w = width + 2;
|
||||||
*h = brush_core->brush->mask->height + 2;
|
*h = height + 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,25 +116,21 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
|
||||||
/* the brush */
|
/* the brush */
|
||||||
if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL))
|
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,
|
button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
|
||||||
"brush-view-type", "brush-view-size");
|
"brush-view-type", "brush-view-size");
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, table_row++,
|
||||||
_("Brush:"), 0.0, 0.5,
|
_("Brush:"), 0.0, 0.5,
|
||||||
button, 2, FALSE);
|
button, 2, FALSE);
|
||||||
|
|
||||||
if (tool_type != GIMP_TYPE_SMUDGE_TOOL)
|
|
||||||
{
|
|
||||||
GtkObject *adj;
|
|
||||||
|
|
||||||
adj = gimp_prop_scale_entry_new (config, "brush-scale",
|
adj = gimp_prop_scale_entry_new (config, "brush-scale",
|
||||||
GTK_TABLE (table), 0, table_row++,
|
GTK_TABLE (table), 0, table_row++,
|
||||||
_("Scale:"),
|
_("Scale:"),
|
||||||
0.01, 0.1, 2,
|
0.01, 0.1, 2,
|
||||||
FALSE, 0.0, 0.0);
|
FALSE, 0.0, 0.0);
|
||||||
|
|
||||||
gimp_scale_entry_set_logarithmic (adj, TRUE);
|
gimp_scale_entry_set_logarithmic (adj, TRUE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* the gradient */
|
/* the gradient */
|
||||||
if (tool_type == GIMP_TYPE_BLEND_TOOL)
|
if (tool_type == GIMP_TYPE_BLEND_TOOL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue