copy icon in the material buttons list view so you can copy the current set of materi...
[blender-staging.git] / release / scripts / ui / buttons_material.py
index 2415d636dab50d1551f89508b4786564d26c1996..03e11e003e20267ff028bcf7314b1025ed8e1b10 100644 (file)
@@ -1,6 +1,19 @@
        
 import bpy
 
+def active_node_mat(mat):
+       # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
+       # which settings from node-materials are used
+       if mat:
+               mat_node = mat.active_node_material
+               if mat_node:
+                       return mat_node
+               else:
+                       return mat
+
+       return None
+
+
 class MaterialButtonsPanel(bpy.types.Panel):
        __space_type__ = 'PROPERTIES'
        __region_type__ = 'WINDOW'
@@ -46,6 +59,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
                        col = row.column(align=True)
                        col.itemO("object.material_slot_add", icon='ICON_ZOOMIN', text="")
                        col.itemO("object.material_slot_remove", icon='ICON_ZOOMOUT', text="")
+                       col.itemO("object.material_slot_copy", icon='ICON_COPYDOWN', text="")
 
                        if ob.mode == 'EDIT':
                                row = layout.row(align=True)
@@ -74,14 +88,14 @@ class MATERIAL_PT_shading(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
 
                if mat.type in ('SURFACE', 'WIRE'):
                        split = layout.split()
@@ -117,7 +131,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                tan = mat.strand
                
                split = layout.split()
@@ -152,7 +166,7 @@ class MATERIAL_PT_physics(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               phys = context.material.physics
+               phys = context.material.physics # dont use node material
                
                split = layout.split()
                
@@ -171,14 +185,14 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE', 'HALO')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -211,14 +225,14 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -244,14 +258,14 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material  
+               mat = active_node_mat(context.material)
                
                split = layout.split()
                
@@ -298,14 +312,14 @@ class MATERIAL_PT_specular(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
 
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                
                layout.active = (not mat.shadeless)
                
@@ -351,12 +365,12 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw_header(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
                
                self.layout.active = (not mat.shadeless)
@@ -365,7 +379,7 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                sss = mat.subsurface_scattering
 
                layout.active = sss.enabled     
@@ -396,19 +410,19 @@ class MATERIAL_PT_mirror(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
        
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
        
        def draw_header(self, context): 
-               raym = context.material.raytrace_mirror
+               raym = active_node_mat(context.material).raytrace_mirror
 
                self.layout.itemR(raym, "enabled", text="")
        
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                raym = mat.raytrace_mirror
                
                layout.active = raym.enabled
@@ -451,19 +465,19 @@ class MATERIAL_PT_transp(MaterialButtonsPanel):
        COMPAT_ENGINES = set(['BLENDER_RENDER'])
                
        def poll(self, context):
-               mat = context.material
+               mat = active_node_mat(context.material)
                engine = context.scene.render_data.engine
                return mat and (mat.type in ('SURFACE', 'WIRE')) and (engine in self.COMPAT_ENGINES)
 
        def draw_header(self, context): 
-               mat = context.material
+               mat = active_node_mat(context.material)
 
                self.layout.itemR(mat, "transparency", text="")
 
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = active_node_mat(context.material)
                rayt = mat.raytrace_transparency
                
                row = layout.row()
@@ -517,7 +531,7 @@ class MATERIAL_PT_halo(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                halo = mat.halo
 
                split = layout.split()
@@ -569,7 +583,7 @@ class MATERIAL_PT_flare(MaterialButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                halo = mat.halo
 
                layout.active = halo.flare_mode
@@ -618,8 +632,7 @@ class MATERIAL_PT_volume_density(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               mat = context.material
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()
                row = split.row()
@@ -635,7 +648,7 @@ class MATERIAL_PT_volume_shading(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()
                
@@ -660,7 +673,7 @@ class MATERIAL_PT_volume_lighting(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()
                
@@ -695,7 +708,7 @@ class MATERIAL_PT_volume_transp(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
                
-               mat = context.material
+               mat = context.material # dont use node material
                
                layout.itemR(mat, "transparency_method", expand=True)
                
@@ -707,7 +720,7 @@ class MATERIAL_PT_volume_integration(VolumeButtonsPanel):
        def draw(self, context):
                layout = self.layout
 
-               vol = context.material.volume
+               vol = context.material.volume # dont use node material
                
                split = layout.split()