Commit: c6ef2f587e8af59980f0680ff911d8b704fff7e0
Author: Antonio Vazquez
Date:   Wed Feb 28 17:21:43 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBc6ef2f587e8af59980f0680ff911d8b704fff7e0

Replace brush type by enum

This is the first step to add eraser brush

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

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/blenkernel/intern/gpencil.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/editors/gpencil/gpencil_ops.c
M       source/blender/editors/gpencil/gpencil_utils.c
M       source/blender/makesdna/DNA_gpencil_types.h
M       source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index b6cffc90914..92eb3dab30b 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -2091,8 +2091,9 @@ class VIEW3D_PT_tools_grease_pencil_brush(Panel):
             layout.prop(brush, "name", text="")
             # layout.separator()
 
-            layout.prop(brush, "fill_only", text="Fill Brush")
-            if not brush.fill_only:
+            layout.prop(brush, "type", expand=True)
+
+            if brush.type == 'DRAW':
                 row = layout.row(align=True)
                 row.prop(brush, "use_random_pressure", text="", 
icon='RNDCURVE')
                 row.prop(brush, "line_width", text="Radius")
@@ -2101,7 +2102,8 @@ class VIEW3D_PT_tools_grease_pencil_brush(Panel):
                 row.prop(brush, "use_random_strength", text="", 
icon='RNDCURVE')
                 row.prop(brush, "strength", slider=True)
                 row.prop(brush, "use_strength_pressure", text="", 
icon='STYLUS_PRESSURE')
-            else:
+
+            if brush.type == 'FILL':
                 col = layout.column(align=True)
                 col.prop(brush, "fill_leak", text="Leak Size")
                 col.prop(brush, "line_width", text="Thickness")
@@ -2172,7 +2174,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_option(Panel):
             row.prop(brush, "angle", slider=True)
             row.prop(brush, "angle_factor", text="Factor", slider=True)
 
-            if brush.fill_only is False:
+            if brush.type == 'DRAW':
                 row.separator()
                 col = layout.column(align=True)
                 col.prop(brush, "use_stabilizer", text="Stabilizer")
diff --git a/source/blender/blenkernel/intern/gpencil.c 
b/source/blender/blenkernel/intern/gpencil.c
index dfaff1d3b1c..8b09c6a0a5d 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -590,6 +590,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0.0f;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_PENCIL;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -620,6 +621,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0.0f;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_PEN;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -648,6 +650,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0.0f;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_INK;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -682,6 +685,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0.0f;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_INKNOISE;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -717,6 +721,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_BLOCK;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -745,6 +750,7 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        brush->draw_random_sub = 0.0f;
        copy_v3_v3(brush->curcolor, curcolor);
        brush->icon = GPBRUSH_MARKER;
+       brush->type = GP_BRUSH_TYPE_DRAW;
 
        brush->lazy_radius = LAZY_RADIUS;
        brush->lazy_factor = LAZY_FACTOR;
@@ -752,12 +758,13 @@ void BKE_gpencil_brush_init_presets(ToolSettings *ts)
        /* Fill brush */
        brush = BKE_gpencil_brush_addnew(ts, "Fill", false);
        brush->thickness = 1.0f;
-       brush->flag |= (GP_BRUSH_FILL_ONLY | GP_BRUSH_ENABLE_CURSOR);
+       brush->flag |= GP_BRUSH_ENABLE_CURSOR;
        brush->draw_sensitivity = 1.0f;
        brush->fill_leak = 3;
        brush->fill_threshold = 0.1f;
        brush->fill_simplylvl = 1;
        brush->icon = GPBRUSH_FILL;
+       brush->type = GP_BRUSH_TYPE_FILL;
 
        brush->draw_smoothfac = 0.5f;
        brush->draw_smoothlvl = 1;
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 41b63a20f4f..037d86556aa 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1148,7 +1148,24 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *main)
                }
        }
 
+       /* Hero open movie special code. This could removed later */
        {
+               /* set brush modes */
+               for (Scene *scene = main->scene.first; scene; scene = 
scene->id.next) {
+                       /* drawing brushes */
+                       ToolSettings *ts = scene->toolsettings;
+                       for (bGPDbrush *brush = ts->gp_brushes.first; brush; 
brush = brush->next) {
+                               if (brush->flag & GP_BRUSH_FILL_ONLY) {
+                                       brush->type = GP_BRUSH_TYPE_FILL;
+                                       brush->flag &= ~GP_BRUSH_FILL_ONLY;
+                               }
+                               else {
+                                       brush->type = GP_BRUSH_TYPE_DRAW;
+                               }
+                       }
+               }
+
+
                /* rescale old grease pencil pixel factor (needed for Hero open 
movie files) */
                for (bGPdata *gpd = main->gpencil.first; gpd; gpd = 
gpd->id.next) {
                        /* old data was always bigger than 30 */
diff --git a/source/blender/editors/gpencil/gpencil_ops.c 
b/source/blender/editors/gpencil/gpencil_ops.c
index 07a6770408f..b281d9bc20a 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -119,7 +119,7 @@ static int gp_stroke_paintmode_draw_poll(bContext *C)
        bGPdata *gpd = CTX_data_gpencil_data(C);
        ToolSettings *ts = CTX_data_tool_settings(C);
        bGPDbrush *brush = BKE_gpencil_brush_getactive(ts);
-       return (gpd && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush) && 
((brush->flag & GP_BRUSH_FILL_ONLY) == 0));
+       return (gpd && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush) && 
(brush->type == GP_BRUSH_TYPE_DRAW));
 }
 
 /* Poll callback for stroke painting (fill) */
@@ -129,7 +129,7 @@ static int gp_stroke_paintmode_fill_poll(bContext *C)
        bGPdata *gpd = CTX_data_gpencil_data(C);
        ToolSettings *ts = CTX_data_tool_settings(C);
        bGPDbrush *brush = BKE_gpencil_brush_getactive(ts);
-       return (gpd && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush) && 
(brush->flag & GP_BRUSH_FILL_ONLY));
+       return (gpd && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush) && 
(brush->type == GP_BRUSH_TYPE_FILL));
 }
 
 /* Poll callback for stroke sculpting mode */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c 
b/source/blender/editors/gpencil/gpencil_utils.c
index c482dcc2d95..05812f1f311 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1353,7 +1353,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int 
y, void *customdata)
                        if ((palcolor) && (GPENCIL_PAINT_MODE(gpd)) && 
                                ((paintbrush->flag & GP_BRUSH_STABILIZE_MOUSE) 
== 0) &&
                                ((paintbrush->flag & 
GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
-                               ((paintbrush->flag & GP_BRUSH_FILL_ONLY) == 0))
+                               (paintbrush->type == GP_BRUSH_TYPE_DRAW))
                        {
                                radius = 2.0f;
                                copy_v3_v3(color, palcolor->rgb);
@@ -1395,7 +1395,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int 
y, void *customdata)
        if ((palcolor) && (GPENCIL_PAINT_MODE(gpd)) && 
                ((paintbrush->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
                ((paintbrush->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0) &&
-               ((paintbrush->flag & GP_BRUSH_FILL_ONLY) == 0))
+               (paintbrush->type == GP_BRUSH_TYPE_DRAW))
        {
                imm_draw_circle_fill_2d(pos, x, y, radius, 40);
        }
diff --git a/source/blender/makesdna/DNA_gpencil_types.h 
b/source/blender/makesdna/DNA_gpencil_types.h
index a6ddab79749..e73198ee4f2 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -139,7 +139,7 @@ typedef struct bGPDbrush {
        
        float uv_random;          /* random factor for UV rotation */
        int   input_samples;      /* maximum distance before generate new point 
for very fast mouse movements */
-       char  pad[4];
+       int   type;               /* type of brush (draw, fill, erase, etc..) */
 } bGPDbrush;
 
 /* bGPDbrush->flag */
@@ -159,7 +159,7 @@ typedef enum eGPDbrush_Flag {
        /* enable screen cursor */
        GP_BRUSH_ENABLE_CURSOR = (1 << 6),
        /* brush is only for filling */
-       GP_BRUSH_FILL_ONLY = (1 << 7),
+       GP_BRUSH_FILL_ONLY = (1 << 7), /* Deprecated */
        /* fill hide transparent */
        GP_BRUSH_FILL_HIDE = (1 << 8),
        /* show fill help lines */
@@ -539,6 +539,13 @@ typedef enum eGP_FillDrawModes {
        GP_FILL_DMODE_CONTROL = 2,
 } eGP_FillDrawModes;
 
+/* bGPDbrush->brush type */
+typedef enum eGP_BrushType {
+       GP_BRUSH_TYPE_DRAW = 0,
+       GP_BRUSH_TYPE_FILL = 1,
+       GP_BRUSH_TYPE_ERASE = 2,
+} eGP_BrushType;
+
 /* xray modes (Depth Ordering) */
 typedef enum eGP_DepthOrdering {
        GP_XRAY_FRONT = 0,
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index cc5ad69ce03..19576eafa8b 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -446,10 +446,16 @@ EnumPropertyItem rna_enum_gpencil_drawing_brushes_items[] 
= {
 };
 
 static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
-{ GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as fill 
boundary limits" },
-{ GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Control", "Use internal control lines 
as fill boundary limits" },
-{ GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and control 
lines as fill boundary limits" },
-{ 0, NULL, 0, NULL, NULL }
+       { GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as 
fill boundary limits" },
+       { GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Control", "Use internal control 
lines as fill boundary limits" },
+       { GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and 
control lines as fill boundary limits" },
+       { 0, NULL, 0, NULL, NULL }
+};
+static EnumPropertyItem rna_enum_gpencil_brush_types_items[] = {
+       { GP_BRUSH_TYPE_DRAW, "DRAW", 0, "Draw", "The brush is of type used f

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to