[Bf-blender-cvs] [95655f008c0] greasepencil-object: Change Eraser icon depending of eraser mode

Antonio Vazquez noreply at git.blender.org
Mon Mar 12 10:00:04 CET 2018


Commit: 95655f008c0149aae3d4fd6a52d60ebfc2be607b
Author: Antonio Vazquez
Date:   Mon Mar 12 09:49:25 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB95655f008c0149aae3d4fd6a52d60ebfc2be607b

Change Eraser icon depending of eraser mode

===================================================================

M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

===================================================================

diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index 46a474ad98a..989c6bfdac0 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -144,7 +144,7 @@ typedef struct Brush {
 
 	/* grease pencil drawing brush data */
 	short thickness;          /* thickness to apply to strokes */
-	short gp_flag;            /* internal grease pecncil drawing flags */
+	short gp_flag;            /* internal grease pencil drawing flags */
 	float draw_smoothfac;     /* amount of smoothing to apply to newly created strokes */
 	short draw_smoothlvl;     /* number of times to apply smooth factor to new strokes */
 	short draw_subdivide;     /* number of times to subdivide new strokes */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 09054cedb83..a994dcd8d09 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -665,6 +665,33 @@ static void rna_brush_gpencil_default_eraser(Main *bmain, Scene *scene, PointerR
 		}
 	}
 }
+
+static void rna_brush_gpencil_eraser_mode(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
+{
+	ToolSettings *ts = scene->toolsettings;
+	Paint *paint = &ts->gp_paint->paint;
+	Brush *brush = paint->brush;
+
+	/* set eraser icon */
+	if ((brush) && (brush->gp_brush_type == GP_BRUSH_TYPE_ERASE)) {
+		switch (brush->gp_eraser_mode) {
+			case GP_BRUSH_ERASER_SOFT:
+				brush->gp_icon_id = GPBRUSH_ERASE_SOFT;
+				break;
+			case GP_BRUSH_ERASER_HARD:
+				brush->gp_icon_id = GPBRUSH_ERASE_HARD;
+				break;
+			case GP_BRUSH_ERASER_STROKE:
+				brush->gp_icon_id = GPBRUSH_ERASE_STROKE;
+				break;
+			default:
+				brush->gp_icon_id = GPBRUSH_ERASE_SOFT;
+				break;
+		}
+	}
+
+}
+
 #else
 
 static void rna_def_brush_texture_slot(BlenderRNA *brna)
@@ -1753,6 +1780,7 @@ static void rna_def_brush(BlenderRNA *brna)
 	RNA_def_property_enum_sdna(prop, NULL, "gp_eraser_mode");
 	RNA_def_property_enum_items(prop, rna_enum_gpencil_brush_eraser_modes_items);
 	RNA_def_property_ui_text(prop, "Mode", "Eraser Mode");
+	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_brush_gpencil_eraser_mode");
 
 	prop = RNA_def_property(srna, "gpencil_fill_draw_mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "gp_fill_draw_mode");



More information about the Bf-blender-cvs mailing list