Commit 677b1f2d authored by Daniel Sabo's avatar Daniel Sabo

app: mypaint: Add a toggle to change between erase & paint mode

parent 9493b51f
......@@ -138,6 +138,10 @@ gimp_mybrush_load (GimpContext *context,
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_HARDNESS);
brush->priv->eraser =
mypaint_brush_get_base_value (mypaint_brush,
MYPAINT_BRUSH_SETTING_ERASER) > 0.5f;
mypaint_brush_unref (mypaint_brush);
return g_list_prepend (NULL, brush);
......
......@@ -27,6 +27,7 @@ struct _GimpMybrushPrivate
gdouble radius;
gdouble opaque;
gdouble hardness;
gboolean eraser;
};
......
......@@ -103,6 +103,7 @@ gimp_mybrush_init (GimpMybrush *brush)
brush->priv->radius = 1.0;
brush->priv->opaque = 1.0;
brush->priv->hardness = 1.0;
brush->priv->eraser = FALSE;
}
static void
......@@ -259,3 +260,11 @@ gimp_mybrush_get_hardness (GimpMybrush *brush)
return brush->priv->hardness;
}
gboolean
gimp_mybrush_get_is_eraser (GimpMybrush *brush)
{
g_return_val_if_fail (GIMP_IS_MYBRUSH (brush), FALSE);
return brush->priv->eraser;
}
......@@ -59,6 +59,7 @@ const gchar * gimp_mybrush_get_brush_json (GimpMybrush *brush);
gdouble gimp_mybrush_get_radius (GimpMybrush *brush);
gdouble gimp_mybrush_get_opaque (GimpMybrush *brush);
gdouble gimp_mybrush_get_hardness (GimpMybrush *brush);
gboolean gimp_mybrush_get_is_eraser (GimpMybrush *brush);
#endif /* __GIMP_MYBRUSH_H__ */
......@@ -219,6 +219,9 @@ gimp_mybrush_core_paint (GimpPaintCore *paint_core,
mypaint_brush_set_base_value (mybrush->private->brush,
MYPAINT_BRUSH_SETTING_HARDNESS,
options->hardness);
mypaint_brush_set_base_value (mybrush->private->brush,
MYPAINT_BRUSH_SETTING_ERASER,
options->eraser ? 1.0f : 0.0f);
mypaint_brush_new_stroke (mybrush->private->brush);
mybrush->private->last_time = -1;
......
......@@ -39,7 +39,8 @@ enum
PROP_0,
PROP_RADIUS,
PROP_OPAQUE,
PROP_HARDNESS
PROP_HARDNESS,
PROP_ERASER
};
......@@ -83,6 +84,10 @@ gimp_mybrush_options_class_init (GimpMybrushOptionsClass *klass)
"hardness", NULL,
0.0, 1.0, 1.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ERASER,
"eraser", NULL,
FALSE,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -109,6 +114,9 @@ gimp_mybrush_options_set_property (GObject *object,
case PROP_OPAQUE:
options->opaque = g_value_get_double (value);
break;
case PROP_ERASER:
options->eraser = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -135,6 +143,9 @@ gimp_mybrush_options_get_property (GObject *object,
case PROP_HARDNESS:
g_value_set_double (value, options->hardness);
break;
case PROP_ERASER:
g_value_set_boolean (value, options->eraser);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -151,5 +162,6 @@ gimp_mybrush_options_mybrush_changed (GimpContext *context,
"radius", gimp_mybrush_get_radius (brush),
"opaque", gimp_mybrush_get_opaque (brush),
"hardness", gimp_mybrush_get_hardness (brush),
"eraser", gimp_mybrush_get_is_eraser (brush),
NULL);
}
......@@ -39,6 +39,7 @@ struct _GimpMybrushOptions
gdouble radius;
gdouble opaque;
gdouble hardness;
gboolean eraser;
};
struct _GimpMybrushOptionsClass
......
......@@ -56,6 +56,12 @@ gimp_mybrush_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
/* erase mode */
scale = gimp_prop_check_button_new (config, "eraser",
_("Erase with this brush"));
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
gtk_widget_show (scale);
/* radius */
scale = gimp_prop_spin_scale_new (config, "radius",
_("Radius"),
......
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