From 4320adbf860a47d2557ec9486e4fb3b0684fe27a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Dec 2018 13:09:15 +1100 Subject: Cleanup: remove redundant gpencil material checks Poll checks for an object, no need to check for non-object materials in the draw function. --- .../startup/bl_ui/properties_material_gpencil.py | 57 ++++++++++------------ 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'release/scripts/startup/bl_ui/properties_material_gpencil.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 -- cgit v1.2.3