Commit: 628908a710a2f7a4b4900bc93b0b3c445a4ed0ad
Author: Antonioya
Date:   Sat Nov 3 08:46:21 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB628908a710a2f7a4b4900bc93b0b3c445a4ed0ad

GP: New main switches to hide stroke and fill material

New parameters to switch visibility of stroke and fill

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

M       release/scripts/startup/bl_ui/properties_material_gpencil.py
M       source/blender/blenkernel/intern/material.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M       source/blender/makesdna/DNA_material_types.h
M       source/blender/makesrna/intern/rna_material.c

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

diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py 
b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 5fb9d9795e3..a3fdd37e029 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -179,6 +179,12 @@ class 
MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
     bl_label = "Stroke"
     bl_parent_id = 'MATERIAL_PT_gpencil_surface'
 
+    def draw_header(self, context):
+        ma = context.object.active_material
+        if ma is not None and ma.grease_pencil is not None:
+            gpcolor = ma.grease_pencil
+            self.layout.prop(gpcolor, "show_stroke", text="")
+
     @staticmethod
     def draw(self, context):
         layout = self.layout
@@ -211,6 +217,12 @@ class 
MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
     bl_label = "Fill"
     bl_parent_id = 'MATERIAL_PT_gpencil_surface'
 
+    def draw_header(self, context):
+        ma = context.object.active_material
+        if ma is not None and ma.grease_pencil is not None:
+            gpcolor = ma.grease_pencil
+            self.layout.prop(gpcolor, "show_fill", text="")
+
     @staticmethod
     def draw(self, context):
         layout = self.layout
diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index 5eb056ae69a..b6ea88597fd 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -127,6 +127,9 @@ void BKE_material_init_gpencil_settings(Material *ma)
                ARRAY_SET_ITEMS(gp_style->texture_scale, 1.0f, 1.0f);
                gp_style->texture_opacity = 1.0f;
                gp_style->texture_pixsize = 100.0f;
+
+               gp_style->flag |= GP_STYLE_STROKE_SHOW;
+               gp_style->flag |= GP_STYLE_FILL_SHOW;
        }
 }
 
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 1384a4f28e2..56e91729d0e 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -2234,6 +2234,22 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
                                OB_EMPTY_IMAGE_VISIBLE_PERSPECTIVE |
                                OB_EMPTY_IMAGE_VISIBLE_ORTHOGRAPHIC);
                }
+
+
+       }
+
+       /* TODO: add to next version bump */
+       {
+               /* grease pencil main material show switches */
+               for (Material *mat = bmain->mat.first; mat; mat = mat->id.next) 
{
+                       if (mat->gp_style) {
+                               if (((mat->gp_style->flag & 
GP_STYLE_STROKE_SHOW) == 0) &&
+                                       ((mat->gp_style->flag & 
GP_STYLE_FILL_SHOW) == 0)) {
+                                       mat->gp_style->flag |= 
GP_STYLE_STROKE_SHOW;
+                                       mat->gp_style->flag |= 
GP_STYLE_FILL_SHOW;
+                               }
+                       }
+               }
        }
 
        {
@@ -2243,4 +2259,5 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
                        }
                }
        }
+
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 54a2cf4b960..6d60bd41562 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -836,7 +836,8 @@ static void gpencil_draw_strokes(
                        if (gps->totpoints > 0) {
                                if ((gps->totpoints > 2) && 
(!stl->storage->simplify_fill) &&
                                    ((gp_style->fill_rgba[3] > 
GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)) &&
-                                   ((gps->flag & GP_STROKE_NOFILL) == 0))
+                                   ((gps->flag & GP_STROKE_NOFILL) == 0) &&
+                                       (gp_style->flag & GP_STYLE_FILL_SHOW))
                                {
                                        stl->shgroups[id].shgrps_fill = 
DRW_gpencil_shgroup_fill_create(
                                                e_data, vedata, 
psl->stroke_pass, e_data->gpencil_fill_sh, gpd, gp_style, id);
@@ -881,9 +882,10 @@ static void gpencil_draw_strokes(
                        }
                        /* stroke */
                        if (strokegrp) {
+                               const float nop = ((gp_style->flag & 
GP_STYLE_STROKE_SHOW) == 0) || (gp_style->stroke_rgba[3] < 
GPENCIL_ALPHA_OPACITY_THRESH) ? 0.0f : opacity;
                                gpencil_add_stroke_shgroup(
                                        cache, strokegrp, ob, gpl, derived_gpf, 
gps,
-                                       opacity, tintcolor, false, custonion);
+                                       nop, tintcolor, false, custonion);
                        }
                }
 
diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index 9d4da91aaed..85dfe300429 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -98,7 +98,11 @@ typedef enum eMaterialGPencilStyle_Flag {
        /* Flip fill colors */
        GP_STYLE_COLOR_FLIP_FILL = (1 << 6),
        /* Stroke Texture is a pattern */
-       GP_STYLE_STROKE_PATTERN = (1 << 7)
+       GP_STYLE_STROKE_PATTERN = (1 << 7),
+       /* Stroke show main switch */
+       GP_STYLE_STROKE_SHOW = (1 << 8),
+       /* Fill  show main switch */
+       GP_STYLE_FILL_SHOW = (1 << 9)
 } eMaterialGPencilStyle_Flag;
 
 typedef enum eMaterialGPencilStyle_Mode {
diff --git a/source/blender/makesrna/intern/rna_material.c 
b/source/blender/makesrna/intern/rna_material.c
index 2d38a99af63..7a3d45c7a62 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -581,6 +581,16 @@ static void rna_def_material_greasepencil(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Pattern", "Use Fill Texture as a 
pattern to apply color");
        RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, 
"rna_MaterialGpencil_update");
 
+       prop = RNA_def_property(srna, "show_stroke", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_STROKE_SHOW);
+       RNA_def_property_ui_text(prop, "Show Stroke", "Show stroke lines of 
this material");
+       RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, 
"rna_MaterialGpencil_update");
+
+       prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_STYLE_FILL_SHOW);
+       RNA_def_property_ui_text(prop, "Show Fill", "Show stroke fills of this 
material");
+       RNA_def_property_update(prop, NC_GPENCIL | ND_SHADING, 
"rna_MaterialGpencil_update");
+
        /* pass index for future compositing and editing tools */
        prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_UNSIGNED);
        RNA_def_property_int_sdna(prop, NULL, "index");

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

Reply via email to