Fix T62349: Grease Pencil top material list not working
authorDalai Felinto <dfelinto@gmail.com>
Fri, 8 Mar 2019 18:30:22 +0000 (15:30 -0300)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 8 Mar 2019 18:36:31 +0000 (15:36 -0300)
This is a fixup for my own: 92d185faebe.
I'm also fixing the poll of the EEVEE_MATERIAL_PT_context_material
which would fail when we had no context.material available.

release/scripts/startup/bl_ui/properties_grease_pencil_common.py
release/scripts/startup/bl_ui/properties_material.py
release/scripts/startup/bl_ui/properties_material_gpencil.py
release/scripts/startup/bl_ui/space_view3d.py

index d65d494..6b3660d 100644 (file)
@@ -856,21 +856,16 @@ class GreasePencilToolsPanel:
 
 class GreasePencilMaterialsPanel:
     # Mix-in, use for properties editor and top-bar.
-
-    @classmethod
-    def poll(cls, context):
-        ob = context.object
-        ma = context.material
-        return (ob and ob.type == 'GPENCIL') or (ma and ma.grease_pencil)
-
     @staticmethod
     def draw(self, context):
         layout = self.layout
         show_full_ui = (self.bl_space_type == 'PROPERTIES')
 
         ob = context.object
-        gpd = context.gpencil
-        space = context.space_data
+        if hasattr(context, "gpencil"):
+            gpd = context.gpencil
+        else:
+            gpd = context.gpencil_data
 
         row = layout.row()
 
@@ -916,6 +911,7 @@ class GreasePencilMaterialsPanel:
                     row.operator("gpencil.color_select", text="Deselect").deselect = True
 
         else:
+            space = context.space_data
             row.template_ID(space, "pin_id")
 
 
index 07c94c9..b05955e 100644 (file)
@@ -87,8 +87,13 @@ class EEVEE_MATERIAL_PT_context_material(MaterialButtonsPanel, Panel):
 
     @classmethod
     def poll(cls, context):
+        ob = context.object
         mat = context.material
-        return (context.object or mat) and (context.engine in cls.COMPAT_ENGINES) and not mat.grease_pencil
+
+        if (ob and ob.type == 'GPENCIL') or (mat and mat.grease_pencil):
+            return False
+
+        return (ob or mat) and (context.engine in cls.COMPAT_ENGINES)
 
     def draw(self, context):
         layout = self.layout
index c8691d1..a27d2ff 100644 (file)
@@ -85,7 +85,7 @@ class GPMaterialButtonsPanel:
         return ma and ma.grease_pencil
 
 
-class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, Panel):
+class MATERIAL_PT_gpencil_slots(GreasePencilMaterialsPanel, GPMaterialButtonsPanel, Panel):
     bl_label = "Grease Pencil Material Slots"
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
index 8b6634a..9fcc8b9 100644 (file)
@@ -5766,6 +5766,11 @@ class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):
     bl_label = "Materials"
     bl_ui_units_x = 14
 
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        return ob and ob.type == 'GPENCIL'
+
 
 classes = (
     VIEW3D_HT_header,