[Bf-blender-cvs] [4ccaf56814a] master: Fix T62349: Grease Pencil top material list not working

Dalai Felinto noreply at git.blender.org
Fri Mar 8 19:36:39 CET 2019


Commit: 4ccaf56814a1389516dba7b2eb8fde0944dfccd8
Author: Dalai Felinto
Date:   Fri Mar 8 15:30:22 2019 -0300
Branches: master
https://developer.blender.org/rB4ccaf56814a1389516dba7b2eb8fde0944dfccd8

Fix T62349: Grease Pencil top material list not working

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.

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

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

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

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 d65d494630a..6b3660d85c6 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -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")
 
 
diff --git a/release/scripts/startup/bl_ui/properties_material.py b/release/scripts/startup/bl_ui/properties_material.py
index 07c94c90738..b05955e3598 100644
--- a/release/scripts/startup/bl_ui/properties_material.py
+++ b/release/scripts/startup/bl_ui/properties_material.py
@@ -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
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index c8691d15cc4..a27d2ff9b84 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -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'
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 8b6634acbcd..9fcc8b9e251 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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,



More information about the Bf-blender-cvs mailing list