2.5 Buttons:
[blender.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                 
58                 flow = layout.column_flow()
59                 flow.itemR(sss, "error_tolerance")
60                 flow.itemR(sss, "ior")
61                 flow.itemR(sss, "scale")
62                 
63                 row = layout.row()
64                 row.column().itemR(sss, "color")
65                 row.column().itemR(sss, "radius")
66                 
67                 flow = layout.column_flow()
68                 flow.itemR(sss, "color_factor", slider=True)
69                 flow.itemR(sss, "texture_factor", slider=True)
70                 flow.itemR(sss, "front")
71                 flow.itemR(sss, "back")
72                 
73 class MATERIAL_PT_raymir(MaterialButtonsPanel):
74         __idname__= "MATERIAL_PT_raymir"
75         __label__ = "Ray Mirror"
76         
77         def poll(self, context):
78                 ob = context.active_object
79                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
80         
81         def draw_header(self, context):
82                 raym = context.active_object.active_material.raytrace_mirror
83
84                 layout = self.layout
85                 layout.itemR(raym, "enabled", text="")
86         
87         def draw(self, context):
88                 layout = self.layout
89                 raym = context.active_object.active_material.raytrace_mirror
90
91                 split = layout.split()
92                 
93                 sub = split.column()
94                 sub.itemR(raym, "reflect", text="RayMir", slider=True)
95                 sub.itemR(raym, "fresnel")
96                 sub.itemR(raym, "fresnel_fac", text="Fac", slider=True)
97                 
98                 sub = split.column()
99                 sub.itemR(raym, "gloss", slider=True)
100                 sub.itemR(raym, "gloss_threshold", slider=True)
101                 sub.itemR(raym, "gloss_samples")
102                 sub.itemR(raym, "gloss_anisotropic", slider=True)
103                 
104                 row = layout.row()
105                 row.itemR(raym, "distance", text="Max Dist")
106                 row.itemR(raym, "depth")
107                 
108                 layout.itemR(raym, "fade_to")
109                 
110 class MATERIAL_PT_raytransp(MaterialButtonsPanel):
111         __idname__= "MATERIAL_PT_raytransp"
112         __label__= "Ray Transparency"
113         
114         def poll(self, context):
115                 ob = context.active_object
116                 return (ob and ob.active_material and ob.active_material.type == "SURFACE")
117
118         def draw_header(self, context):
119                 rayt = context.active_object.active_material.raytrace_transparency
120
121                 layout = self.layout
122                 layout.itemR(rayt, "enabled", text="")
123
124         def draw(self, context):
125                 layout = self.layout
126                 rayt = context.active_object.active_material.raytrace_transparency
127                 
128                 split = layout.split()
129                 
130                 sub = split.column()
131                 sub.itemR(rayt, "ior")
132                 sub.itemR(rayt, "fresnel")
133                 sub.itemR(rayt, "fresnel_fac", text="Fac", slider=True)
134                 
135                 sub = split.column()
136                 sub.itemR(rayt, "gloss", slider=True)
137                 sub.itemR(rayt, "gloss_threshold", slider=True)
138                 sub.itemR(rayt, "gloss_samples")
139                 
140                 flow = layout.column_flow()
141                 flow.itemR(rayt, "filter", slider=True)
142                 flow.itemR(rayt, "limit")
143                 flow.itemR(rayt, "falloff")
144                 flow.itemR(rayt, "specular_opacity", slider=True)
145                 flow.itemR(rayt, "depth")
146                 
147 class MATERIAL_PT_halo(MaterialButtonsPanel):
148         __idname__= "MATERIAL_PT_halo"
149         __label__= "Halo"
150         
151         def poll(self, context):
152                 ob = context.active_object
153                 return (ob and ob.active_material and ob.active_material.type == "HALO")
154         
155         def draw(self, context):
156                 layout = self.layout
157                 mat = context.active_object.active_material
158                 halo = mat.halo
159
160                 split = layout.split()
161                 
162                 col = split.column(align=True)
163                 col.itemL(text="General Settings:")
164                 col.itemR(halo, "size")
165                 col.itemR(halo, "hardness")
166                 col.itemR(halo, "add", slider=True)
167                 
168                 col.itemL(text="Options:")
169                 col.itemR(halo, "use_texture", text="Texture")
170                 col.itemR(halo, "use_vertex_normal", text="Vertex Normal")
171                 col.itemR(halo, "xalpha")
172                 col.itemR(halo, "shaded")
173                 col.itemR(halo, "soft")
174
175                 col = split.column()
176                 sub = col.column(align=True)
177                 sub.itemL(text="Elements:")
178                 sub.itemR(halo, "ring")
179                 sub.itemR(halo, "lines")
180                 sub.itemR(halo, "star")
181                 sub.itemR(halo, "flare_mode")
182                 
183                 sub = col.column()
184                 if (halo.ring):
185                         sub.itemR(halo, "rings")
186                 if (halo.lines):
187                         sub.itemR(halo, "line_number")
188                 if (halo.ring or halo.lines):
189                         sub.itemR(halo, "seed")
190                 if (halo.star):
191                         sub.itemR(halo, "star_tips")
192                 if (halo.flare_mode):
193                         sub = col.column(align=True)
194                         sub.itemL(text="Flare:")
195                         sub.itemR(halo, "flare_size", text="Size")
196                         sub.itemR(halo, "flare_subsize", text="Subsize")
197                         sub.itemR(halo, "flare_boost", text="Boost")
198                         sub.itemR(halo, "flare_seed", text="Seed")
199                         sub.itemR(halo, "flares_sub", text="Sub")
200                                 
201 bpy.types.register(MATERIAL_PT_preview)
202 bpy.types.register(MATERIAL_PT_material)
203 bpy.types.register(MATERIAL_PT_raymir)
204 bpy.types.register(MATERIAL_PT_raytransp)
205 bpy.types.register(MATERIAL_PT_sss)
206 bpy.types.register(MATERIAL_PT_halo)
207