[Bf-blender-cvs] [4320adbf860] blender2.8: Cleanup: remove redundant gpencil material checks

Campbell Barton noreply at git.blender.org
Sun Dec 2 03:12:17 CET 2018


Commit: 4320adbf860a47d2557ec9486e4fb3b0684fe27a
Author: Campbell Barton
Date:   Sun Dec 2 13:09:15 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB4320adbf860a47d2557ec9486e4fb3b0684fe27a

Cleanup: remove redundant gpencil material checks

Poll checks for an object, no need to check for non-object
materials in the draw function.

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

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_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 3aba3489a57..fc25b70b36a 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -100,54 +100,47 @@ class MATERIAL_PT_gpencil_slots(Panel):
         layout = self.layout
         gpd = context.gpencil_data
 
-        mat = context.object.active_material
         ob = context.object
         slot = context.material_slot
-        space = context.space_data
 
-        if ob:
-            is_sortable = len(ob.material_slots) > 1
-            rows = 7
+        is_sortable = len(ob.material_slots) > 1
+        rows = 7
 
-            row = layout.row()
+        row = layout.row()
 
-            row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
+        row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
 
-            col = row.column(align=True)
-            col.operator("object.material_slot_add", icon='ADD', text="")
-            col.operator("object.material_slot_remove", icon='REMOVE', text="")
+        col = row.column(align=True)
+        col.operator("object.material_slot_add", icon='ADD', text="")
+        col.operator("object.material_slot_remove", icon='REMOVE', text="")
 
-            col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
+        col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
 
-            if is_sortable:
-                col.separator()
+        if is_sortable:
+            col.separator()
 
-                col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
-                col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+            col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
+            col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
 
-                col.separator()
+            col.separator()
 
-                sub = col.column(align=True)
-                sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
-                sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True
+            sub = col.column(align=True)
+            sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
+            sub.operator("gpencil.color_isolate", icon='RESTRICT_VIEW_ON', text="").affect_visibility = True
 
         row = layout.row()
 
-        if ob:
-            row.template_ID(ob, "active_material", new="material.new", live_icon=True)
-
-            if slot:
-                icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
-                row.prop(slot, "link", icon=icon_link, icon_only=True)
+        row.template_ID(ob, "active_material", new="material.new", live_icon=True)
 
-            if gpd.use_stroke_edit_mode:
-                row = layout.row(align=True)
-                row.operator("gpencil.stroke_change_color", text="Assign")
-                row.operator("gpencil.color_select", text="Select").deselect = False
-                row.operator("gpencil.color_select", text="Deselect").deselect = True
+        if slot:
+            icon_link = 'MESH_DATA' if slot.link == 'DATA' else 'OBJECT_DATA'
+            row.prop(slot, "link", icon=icon_link, icon_only=True)
 
-        elif mat:
-            row.template_ID(space, "pin_id")
+        if gpd.use_stroke_edit_mode:
+            row = layout.row(align=True)
+            row.operator("gpencil.stroke_change_color", text="Assign")
+            row.operator("gpencil.color_select", text="Select").deselect = False
+            row.operator("gpencil.color_select", text="Deselect").deselect = True
 
 
 # Used as parent for "Stroke" and "Fill" panels
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 383f1938cd2..affd6fedb0f 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -189,7 +189,7 @@ class VIEW3D_HT_header(Header):
                 sub = row.row(align=True)
                 sub.active = tool_settings.use_proportional_edit_objects
                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
-                
+
             elif gpd is not None and obj.type == 'GPENCIL':
                 if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode:
                     row = layout.row(align=True)
@@ -5397,30 +5397,29 @@ class TOPBAR_PT_gpencil_materials(Panel):
         layout = self.layout
         ob = context.object
 
-        if ob:
-            is_sortable = len(ob.material_slots) > 1
-            rows = 1
-            if (is_sortable):
-                rows = 10
+        is_sortable = len(ob.material_slots) > 1
+        rows = 1
+        if (is_sortable):
+            rows = 10
 
-            row = layout.row()
+        row = layout.row()
 
-            row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
+        row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
 
-            col = row.column(align=True)
-            col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
+        col = row.column(align=True)
+        col.menu("GPENCIL_MT_color_specials", icon='DOWNARROW_HLT', text="")
 
-            if is_sortable:
-                col.separator()
+        if is_sortable:
+            col.separator()
 
-                col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
-                col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+            col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
+            col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
 
-                col.separator()
+            col.separator()
 
-                sub = col.column(align=True)
-                sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
-                sub.operator("gpencil.color_isolate", icon='HIDE_OFF', text="").affect_visibility = True
+            sub = col.column(align=True)
+            sub.operator("gpencil.color_isolate", icon='LOCKED', text="").affect_visibility = False
+            sub.operator("gpencil.color_isolate", icon='HIDE_OFF', text="").affect_visibility = True
 
 
 classes = (



More information about the Bf-blender-cvs mailing list