Commit 32280a17 authored by shark0r's avatar shark0r Committed by Michael Natterer

app: Add "No erasing effect" parameter to MyPaint brush

Last and unrelated patch of bug #785001.
parent 9b9daba7
......@@ -218,7 +218,8 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
gimp_drawable_get_active_mask (drawable),
paint_core->mask_buffer,
paint_core->mask_x_offset,
paint_core->mask_y_offset);
paint_core->mask_y_offset,
GIMP_MYBRUSH_OPTIONS (paint_options));
gimp_mybrush_core_create_brushes (mybrush, drawable, paint_options, sym);
......
......@@ -40,7 +40,8 @@ enum
PROP_RADIUS,
PROP_OPAQUE,
PROP_HARDNESS,
PROP_ERASER
PROP_ERASER,
PROP_NO_ERASING
};
......@@ -107,6 +108,13 @@ gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_NO_ERASING,
"no-erasing",
_("No erasing effect"),
_("Never decrease alpha of existing pixels"),
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -144,6 +152,9 @@ gimp_mybrush_options_set_property (GObject *object,
case PROP_ERASER:
options->eraser = g_value_get_boolean (value);
break;
case PROP_NO_ERASING:
options->no_erasing = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -173,6 +184,9 @@ gimp_mybrush_options_get_property (GObject *object,
case PROP_ERASER:
g_value_set_boolean (value, options->eraser);
break;
case PROP_NO_ERASING:
g_value_set_boolean (value, options->no_erasing);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -40,6 +40,7 @@ struct _GimpMybrushOptions
gdouble opaque;
gdouble hardness;
gboolean eraser;
gboolean no_erasing;
};
struct _GimpMybrushOptionsClass
......
......@@ -29,6 +29,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "gimpmybrushoptions.h"
#include "gimpmybrushsurface.h"
......@@ -41,6 +42,7 @@ struct _GimpMybrushSurface
gint paint_mask_y;
GeglRectangle dirty;
GimpComponentMask component_mask;
GimpMybrushOptions *options;
};
/* --- Taken from mypaint-tiled-surface.c --- */
......@@ -468,6 +470,9 @@ gimp_mypaint_surface_draw_dab (MyPaintSurface *base_surface,
}
}
if (surface->options->no_erasing)
a = MAX (a, pixel[ALPHA]);
if (component_mask != GIMP_COMPONENT_MASK_ALL)
{
if (component_mask & GIMP_COMPONENT_MASK_RED)
......@@ -526,11 +531,12 @@ gimp_mypaint_surface_destroy (MyPaintSurface *base_surface)
}
GimpMybrushSurface *
gimp_mypaint_surface_new (GeglBuffer *buffer,
GimpComponentMask component_mask,
GeglBuffer *paint_mask,
gint paint_mask_x,
gint paint_mask_y)
gimp_mypaint_surface_new (GeglBuffer *buffer,
GimpComponentMask component_mask,
GeglBuffer *paint_mask,
gint paint_mask_x,
gint paint_mask_y,
GimpMybrushOptions *options)
{
GimpMybrushSurface *surface = g_malloc0 (sizeof (GimpMybrushSurface));
......@@ -542,6 +548,7 @@ gimp_mypaint_surface_new (GeglBuffer *buffer,
surface->surface.end_atomic = gimp_mypaint_surface_end_atomic;
surface->surface.destroy = gimp_mypaint_surface_destroy;
surface->component_mask = component_mask;
surface->options = options;
surface->buffer = g_object_ref (buffer);
if (paint_mask)
surface->paint_mask = g_object_ref (paint_mask);
......
......@@ -22,11 +22,12 @@
typedef struct _GimpMybrushSurface GimpMybrushSurface;
GimpMybrushSurface *
gimp_mypaint_surface_new (GeglBuffer *buffer,
GimpComponentMask component_mask,
GeglBuffer *paint_mask,
gint paint_mask_x,
gint paint_mask_y);
gimp_mypaint_surface_new (GeglBuffer *buffer,
GimpComponentMask component_mask,
GeglBuffer *paint_mask,
gint paint_mask_x,
gint paint_mask_y,
GimpMybrushOptions *options);
#endif /* __GIMP_MYBRUSH_SURFACE_H__ */
......@@ -61,6 +61,11 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* no erasing */
scale = gimp_prop_check_button_new (config, "no-erasing", NULL);
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* radius */
scale = gimp_prop_spin_scale_new (config, "radius", NULL,
0.1, 1.0, 2);
......
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