[Bf-blender-cvs] [5bdcbfc42b7] greasepencil-refactor: GPencil: Add new Hide and Invert icons to Masks

Antonio Vazquez noreply at git.blender.org
Tue Feb 11 15:09:31 CET 2020


Commit: 5bdcbfc42b71611bf8f1b4355a4c448b0851e061
Author: Antonio Vazquez
Date:   Tue Feb 11 11:24:56 2020 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rB5bdcbfc42b71611bf8f1b4355a4c448b0851e061

GPencil: Add new Hide and Invert icons to Masks

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index e854c4cdbfe..d540eab7dab 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -769,18 +769,22 @@ class GreasePencilLayerAdjustmentsPanel:
         col = layout.row(align=True)
         col.prop(gpl, "lock_material")
 
+
 class GPENCIL_UL_masks(UIList):
     def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
         mask = item
         if self.layout_type in {'DEFAULT', 'COMPACT'}:
-            layout.prop(mask, "name", text="", emboss=False, icon_value=icon)
+            row = layout.row(align=True)
+            row.prop(mask, "name", text="", emboss=False, icon_value=icon)
+            icon_mask = 'HOLDOUT_ON' if mask.invert else 'MOD_MASK'
+            row.prop(mask, "invert", text="", emboss=False, icon=icon_mask)
+            row.prop(mask, "hide", text="", emboss=False)
         elif self.layout_type == 'GRID':
             layout.alignment = 'CENTER'
             layout.prop(mask, "name", text="", emboss=False, icon_value=icon)
 
 
 class GreasePencilLayerMasksPanel:
-
     def draw_header(self, context):
         ob = context.active_object
         gpd = ob.data
@@ -805,13 +809,12 @@ class GreasePencilLayerMasksPanel:
             rows = 4
             row = layout.row()
             col = row.column()
-            col.template_list("GPENCIL_UL_masks", "", gpl, "mask_layers", gpl.mask_layers, "active_mask_index", rows=rows)
+            col.template_list("GPENCIL_UL_masks", "", gpl, "mask_layers", gpl.mask_layers,
+                            "active_mask_index", rows=rows, sort_lock=True)
 
             col2 = row.column(align=True)
             col2.operator("gpencil.layer_mask_remove", icon='REMOVE', text="")
 
-            row = layout.row()
-            row.prop(gpl, "invert_mask")
 
 class GreasePencilLayerRelationsPanel:
 
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f0fabd256fe..93612aa2309 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -329,8 +329,18 @@ typedef enum eGPDframe_Flag {
 typedef struct bGPDlayer_Mask {
   struct bGPDlayer_Mask *next, *prev;
   char name[128];
+  short flag;
+  char _pad[6];
 } bGPDlayer_Mask;
 
+/* bGPDlayer_Mask->flag */
+typedef enum ebGPDlayer_Mask_Flag {
+  /* Mask is hidden. */
+  GP_MASK_HIDE = (1 << 0),
+  /* Mask is inverted. */
+  GP_MASK_INVERT = (1 << 1),
+} ebGPDlayer_Mask_Flag;
+
 /* Runtime temp data for bGPDlayer */
 typedef struct bGPDlayer_Runtime {
   /** Id for dynamic icon used to show annotation color preview for layer. */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 20b3426f1b4..4af325079b1 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1681,6 +1681,18 @@ static void rna_def_gpencil_layer_mask(BlenderRNA *brna)
   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_mask_info_set");
   RNA_def_struct_name_property(srna, prop);
   RNA_def_property_update(prop, NC_GPENCIL | ND_DATA | NA_RENAME, NULL);
+
+  /* Flags */
+  prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MASK_HIDE);
+  RNA_def_property_ui_icon(prop, ICON_HIDE_OFF, -1);
+  RNA_def_property_ui_text(prop, "Hide", "Set mask Visibility");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
+  prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_MASK_INVERT);
+  RNA_def_property_ui_text(prop, "Invert", "Invert mask");
+  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 }
 
 static void rna_def_gpencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)



More information about the Bf-blender-cvs mailing list