Shader Editor: tweak when the UI for managing the material is enabled

- disable the UI if the currently selected object does not support materials.
- add Metaballs and GPencil as types supporting material.
This commit is contained in:
Ines Almeida
2018-09-12 19:26:28 +02:00
parent 2e07af36fd
commit 32a461adf2
4 changed files with 7 additions and 5 deletions

View File

@@ -63,10 +63,12 @@ class NODE_HT_header(Header):
layout.separator_spacer()
row = layout.row()
types_that_support_material = {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'GPENCIL'}
# disable material slot buttons when pinned, cannot find correct slot within id_from (#36589)
row.enabled = not snode.pin
# disable also when the selected object does not support materials
row.enabled = not snode.pin and ob.type in types_that_support_material
# Show material.new when no active ID/slot exists
if not id_from and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'METABALL'}:
if not id_from and ob.type in types_that_support_material:
row.template_ID(ob, "active_material", new="material.new")
# Material ID, but not for Lights
if id_from and ob.type != 'LIGHT':