2.5 Buttons
[blender-staging.git] / release / ui / buttons_material.py
1
2 import bpy
3
4 class MaterialButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "material"
8
9         def poll(self, context):
10                 ob = context.active_object
11                 return (ob and ob.active_material)
12
13 class MATERIAL_PT_preview(MaterialButtonsPanel):
14         __idname__= "MATERIAL_PT_preview"
15         __label__ = "Preview"
16
17         def draw(self, context):
18                 layout = self.layout
19
20                 mat = context.active_object.active_material
21                 layout.template_preview(mat)
22         
23 class MATERIAL_PT_material(MaterialButtonsPanel):
24         __idname__= "MATERIAL_PT_material"
25         __label__ = "Material"
26
27         def draw(self, context):
28                 layout = self.layout
29                 mat = context.active_object.active_material
30         
31                 layout.itemR(mat, "type", expand=True)
32
33                 row = layout.row()
34                 row.column().itemR(mat, "diffuse_color")
35                 row.column().itemR(mat, "specular_color")
36                 row.column().itemR(mat, "mirror_color")
37                 
38                 layout.itemR(mat, "alpha", slider=True)
39                         
40 class MATERIAL_PT_sss(MaterialButtonsPanel):
41         __idname__= "MATERIAL_PT_sss"
42         __label__ = "Subsurface Scattering"
43
44         def poll(self, context):
45                 ob = context.active_object
46                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
47
48         def draw_header(self, context):
49                 sss = context.active_object.active_material.subsurface_scattering
50
51                 layout = self.layout
52                 layout.itemR(sss, "enabled", text="")
53         
54         def draw(self, context):
55                 layout = self.layout
56                 sss = context.active_object.active_material.subsurface_scattering
57                 layout.active = sss.enabled     
58                 
59                 flow = layout.column_flow()
60                 flow.itemR(sss, "error_tolerance")
61                 flow.itemR(sss, "ior")
62                 flow.itemR(sss, "scale")
63                 
64                 row = layout.row()
65                 row.column().itemR(sss, "color")
66                 row.column().itemR(sss, "radius")
67                 
68                 flow = layout.column_flow()
69                 flow.itemR(sss, "color_factor", slider=True)
70                 flow.itemR(sss, "texture_factor", slider=True)
71                 flow.itemR(sss, "front")
72                 flow.itemR(sss, "back")
73                 
74 class MATERIAL_PT_raymir(MaterialButtonsPanel):
75         __idname__= "MATERIAL_PT_raymir"
76         __label__ = "Ray Mirror"
77         
78         def poll(self, context):
79                 ob = context.active_object
80                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
81         
82         def draw_header(self, context):
83                 raym = context.active_object.active_material.raytrace_mirror
84
85                 layout = self.layout
86                 layout.itemR(raym, "enabled", text="")
87         
88         def draw(self, context):
89                 layout = self.layout
90                 raym = context.active_object.active_material.raytrace_mirror
91                 layout.active = raym.enabled    
92                 split = layout.split()
93                 
94                 sub = split.column()
95                 sub.itemR(raym, "reflect", text="RayMir", slider=True)
96                 sub.itemR(raym, "fresnel")
97                 sub.itemR(raym, "fresnel_fac", text="Fac", slider=True)
98                 
99                 sub = split.column()
100                 sub.itemR(raym, "gloss", slider=True)
101                 sub.itemR(raym, "gloss_threshold", slider=True)
102                 sub.itemR(raym, "gloss_samples")
103                 sub.itemR(raym, "gloss_anisotropic", slider=True)
104                 
105                 row = layout.row()
106                 row.itemR(raym, "distance", text="Max Dist")
107                 row.itemR(raym, "depth")
108                 
109                 layout.itemR(raym, "fade_to")
110                 
111 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
112         __idname__= "MATERIAL_PT_raytransp"
113         __label__= "Ray Transparency"
114         
115         def poll(self, context):
116                 ob = context.active_object
117                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
118
119         def draw_header(self, context):
120                 rayt = context.active_object.active_material.raytrace_transparency
121
122                 layout = self.layout
123                 layout.itemR(rayt, "enabled", text="")
124
125         def draw(self, context):
126                 layout = self.layout
127                 rayt = context.active_object.active_material.raytrace_transparency
128                 layout.active = rayt.enabled    
129                 
130                 split = layout.split()
131                 
132                 sub = split.column()
133                 sub.itemR(rayt, "ior")
134                 sub.itemR(rayt, "fresnel")
135                 sub.itemR(rayt, "fresnel_fac", text="Fac", slider=True)
136                 
137                 sub = split.column()
138                 sub.itemR(rayt, "gloss", slider=True)
139                 sub.itemR(rayt, "gloss_threshold", slider=True)
140                 sub.itemR(rayt, "gloss_samples")
141                 
142                 flow = layout.column_flow()
143                 flow.itemR(rayt, "filter", slider=True)
144                 flow.itemR(rayt, "limit")
145                 flow.itemR(rayt, "falloff")
146                 flow.itemR(rayt, "specular_opacity", slider=True)
147                 flow.itemR(rayt, "depth")
148                 
149 class MATERIAL_PT_halo(MaterialButtonsPanel):
150         __idname__= "MATERIAL_PT_halo"
151         __label__= "Halo"
152         
153         def poll(self, context):
154                 ob = context.active_object
155                 return (ob and ob.active_material and ob.active_material.type == "HALO")
156         
157         def draw(self, context):
158                 layout = self.layout
159                 mat = context.active_object.active_material
160                 halo = mat.halo
161
162                 split = layout.split()
163                 
164                 col = split.column(align=True)
165                 col.itemL(text="General Settings:")
166                 col.itemR(halo, "size")
167                 col.itemR(halo, "hardness")
168                 col.itemR(halo, "add", slider=True)
169                 
170                 col.itemL(text="Options:")
171                 col.itemR(halo, "use_texture", text="Texture")
172                 col.itemR(halo, "use_vertex_normal", text="Vertex Normal")
173                 col.itemR(halo, "xalpha")
174                 col.itemR(halo, "shaded")
175                 col.itemR(halo, "soft")
176
177                 col = split.column()
178                 col = col.column(align=True)
179                 col.itemR(halo, "ring")
180                 colsub = col.column()
181                 colsub.active = halo.ring
182                 colsub.itemR(halo, "rings")
183                 col.itemR(halo, "lines")
184                 colsub = col.column()
185                 colsub.active = halo.lines
186                 colsub.itemR(halo, "line_number", text="Lines")
187                 col.itemR(halo, "star")
188                 colsub = col.column()
189                 colsub.active = halo.star
190                 colsub.itemR(halo, "star_tips")
191                 col.itemR(halo, "flare_mode")
192                 colsub = col.column()
193                 colsub.active = halo.flare_mode
194                 colsub.itemR(halo, "flare_size", text="Size")
195                 colsub.itemR(halo, "flare_subsize", text="Subsize")
196                 colsub.itemR(halo, "flare_boost", text="Boost")
197                 colsub.itemR(halo, "flare_seed", text="Seed")
198                 colsub.itemR(halo, "flares_sub", text="Sub")
199
200 bpy.types.register(MATERIAL_PT_preview)
201 bpy.types.register(MATERIAL_PT_material)
202 bpy.types.register(MATERIAL_PT_raymir)
203 bpy.types.register(MATERIAL_PT_raytransp)
204 bpy.types.register(MATERIAL_PT_sss)
205 bpy.types.register(MATERIAL_PT_halo)