Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_ui/space_node.py
| Context not available. | |||||
| layout.separator_spacer() | layout.separator_spacer() | ||||
| row = layout.row() | |||||
| types_that_support_material = {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'GPENCIL'} | types_that_support_material = {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'GPENCIL'} | ||||
| # disable material slot buttons when pinned, cannot find correct slot within id_from (#36589) | # disable material slot buttons when pinned, cannot find correct slot within id_from (#36589) | ||||
| # disable also when the selected object does not support materials | # disable also when the selected object does not support materials | ||||
| row.enabled = not snode.pin and ob.type in types_that_support_material | enable_slots_and_material = not snode.pin and ob.type in types_that_support_material | ||||
| if ob.type != 'LIGHT': | |||||
| row = layout.row() | |||||
| row.enabled = enable_slots_and_material | |||||
| row.ui_units_x = 4 | |||||
| row.popover(panel="NODE_MT_slots") | |||||
| row = layout.row() | |||||
| row.enabled = enable_slots_and_material | |||||
| # Show material.new when no active ID/slot exists | # Show material.new when no active ID/slot exists | ||||
| if not id_from and ob.type in types_that_support_material: | if not id_from and ob.type in types_that_support_material: | ||||
| row.template_ID(ob, "active_material", new="material.new") | row.template_ID(ob, "active_material", new="material.new") | ||||
| Context not available. | |||||
| layout.operator("node.read_viewlayers") | layout.operator("node.read_viewlayers") | ||||
| class NODE_MT_slots(Panel): | |||||
| bl_space_type = "NODE_EDITOR" | |||||
| bl_region_type = 'HEADER' | |||||
| bl_label = "Slot" | |||||
| bl_ui_units_x = 8 | |||||
| def draw_header(self, context): | |||||
| ob = context.object | |||||
| if len(ob.material_slots) > 0: | |||||
| self.bl_label = "Slot " + str(ob.active_material_index + 1) | |||||
| else: | |||||
| self.bl_label = "Slot" | |||||
| # Mirrors part of EEVEE_MATERIAL_PT_context_material | |||||
| def draw(self, context): | |||||
| layout = self.layout | |||||
| row = layout.row() | |||||
| col = row.column() | |||||
| ob = context.object | |||||
| col.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index") | |||||
| col = row.column(align=True) | |||||
| col.operator("object.material_slot_add", icon='ADD', text="") | |||||
| col.operator("object.material_slot_remove", icon='REMOVE', text="") | |||||
| col.separator() | |||||
| col.menu("MATERIAL_MT_context_menu", icon='DOWNARROW_HLT', text="") | |||||
| if len(ob.material_slots) > 1: | |||||
| 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' | |||||
| class NODE_PT_node_color_presets(PresetPanel, Panel): | class NODE_PT_node_color_presets(PresetPanel, Panel): | ||||
| """Predefined node color""" | """Predefined node color""" | ||||
| bl_label = "Color Presets" | bl_label = "Color Presets" | ||||
| Context not available. | |||||
| NODE_MT_view, | NODE_MT_view, | ||||
| NODE_MT_select, | NODE_MT_select, | ||||
| NODE_MT_node, | NODE_MT_node, | ||||
| NODE_MT_slots, | |||||
| NODE_PT_node_color_presets, | NODE_PT_node_color_presets, | ||||
| NODE_MT_node_color_context_menu, | NODE_MT_node_color_context_menu, | ||||
| NODE_MT_context_menu, | NODE_MT_context_menu, | ||||
| Context not available. | |||||