[gimp/wip/pippin: 23/23] Add "No erasing effect" parameter to MyPaint brush
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/pippin: 23/23] Add "No erasing effect" parameter to MyPaint brush
- Date: Thu, 27 Apr 2017 21:56:59 +0000 (UTC)
commit caf01fb5ac789c473aba74d4a7b0a06eaacd99b7
Author: shark0r <b91502038 ntu edu tw>
Date: Fri Apr 14 19:55:58 2017 +0800
Add "No erasing effect" parameter to MyPaint brush
app/paint/gimpmybrushcore.c | 3 ++-
app/paint/gimpmybrushoptions.c | 16 +++++++++++++++-
app/paint/gimpmybrushoptions.h | 1 +
app/paint/gimpmybrushsurface.c | 17 ++++++++++++-----
app/paint/gimpmybrushsurface.h | 11 ++++++-----
app/tools/gimpmybrushoptions-gui.c | 5 +++++
6 files changed, 41 insertions(+), 12 deletions(-)
---
diff --git a/app/paint/gimpmybrushcore.c b/app/paint/gimpmybrushcore.c
index d0931a5..a0531f9 100644
--- a/app/paint/gimpmybrushcore.c
+++ b/app/paint/gimpmybrushcore.c
@@ -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);
diff --git a/app/paint/gimpmybrushoptions.c b/app/paint/gimpmybrushoptions.c
index fbbd191..f755e53 100644
--- a/app/paint/gimpmybrushoptions.c
+++ b/app/paint/gimpmybrushoptions.c
@@ -40,7 +40,8 @@ enum
PROP_RADIUS,
PROP_OPAQUE,
PROP_HARDNESS,
- PROP_ERASER
+ PROP_ERASER,
+ PROP_NO_ERASING_EFFECT
};
@@ -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_EFFECT,
+ "no-erasing-effect",
+ _("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_EFFECT:
+ options->no_erasing_effect = 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_EFFECT:
+ g_value_set_boolean (value, options->no_erasing_effect);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
diff --git a/app/paint/gimpmybrushoptions.h b/app/paint/gimpmybrushoptions.h
index fcf9931..dbda696 100644
--- a/app/paint/gimpmybrushoptions.h
+++ b/app/paint/gimpmybrushoptions.h
@@ -40,6 +40,7 @@ struct _GimpMybrushOptions
gdouble opaque;
gdouble hardness;
gboolean eraser;
+ gboolean no_erasing_effect;
};
struct _GimpMybrushOptionsClass
diff --git a/app/paint/gimpmybrushsurface.c b/app/paint/gimpmybrushsurface.c
index 6ba0c95..00b3ee7 100644
--- a/app/paint/gimpmybrushsurface.c
+++ b/app/paint/gimpmybrushsurface.c
@@ -30,6 +30,7 @@
#include "libgimpcolor/gimpcolor.h"
#include "gimpmybrushsurface.h"
+#include "gimpmybrushoptions.h"
struct _GimpMybrushSurface
@@ -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_effect)
+ a = MAX(a, pixel[ALPHA]);
+
if (component_mask != GIMP_COMPONENT_MASK_ALL)
{
if (component_mask & GIMP_COMPONENT_MASK_RED)
@@ -527,11 +532,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));
mypaint_surface_init ((MyPaintSurface *)surface);
@@ -541,6 +547,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);
diff --git a/app/paint/gimpmybrushsurface.h b/app/paint/gimpmybrushsurface.h
index bf9c49c..c3fc737 100644
--- a/app/paint/gimpmybrushsurface.h
+++ b/app/paint/gimpmybrushsurface.h
@@ -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__ */
diff --git a/app/tools/gimpmybrushoptions-gui.c b/app/tools/gimpmybrushoptions-gui.c
index 8a8999d..b4846e6 100644
--- a/app/tools/gimpmybrushoptions-gui.c
+++ b/app/tools/gimpmybrushoptions-gui.c
@@ -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 effect */
+ scale = gimp_prop_check_button_new (config, "no-erasing-effect", 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]