Merge from 2.5 rev 20515 through 20647.
[blender.git] / release / ui / buttons_texture.py
1
2 import bpy
3
4 class TextureButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "texture"
8         
9         def poll(self, context):
10                 return (context.texture != None)
11
12 class TEXTURE_PT_preview(TextureButtonsPanel):
13         __idname__= "TEXTURE_PT_preview"
14         __label__ = "Preview"
15
16         def draw(self, context):
17                 layout = self.layout
18
19                 tex = context.texture
20                 layout.template_preview(tex)
21
22 class TEXTURE_PT_texture(TextureButtonsPanel):
23         __idname__= "TEXTURE_PT_texture"
24         __label__ = "Texture"
25
26         def draw(self, context):
27                 layout = self.layout
28                 tex = context.texture
29                 
30                 layout.itemR(tex, "type")
31
32 class TEXTURE_PT_colors(TextureButtonsPanel):
33         __idname__= "TEXTURE_PT_colors"
34         __label__ = "Colors"
35
36         def draw(self, context):
37                 layout = self.layout
38                 tex = context.texture
39
40                 if tex.color_ramp:
41                         layout.template_color_ramp(tex.color_ramp, expand=True)
42                 else:
43                         layout.itemR(tex, "rgb_factor")
44
45                 row = layout.row()
46                 row.itemR(tex, "brightness")
47                 row.itemR(tex, "contrast")
48
49 class TEXTURE_PT_clouds(TextureButtonsPanel):
50         __idname__= "TEXTURE_PT_clouds"
51         __label__ = "Clouds"
52         
53         def poll(self, context):
54                 tex = context.texture
55                 return (tex and tex.type == 'CLOUDS')
56
57         def draw(self, context):
58                 layout = self.layout
59                 tex = context.texture
60                 
61                 layout.itemR(tex, "stype", expand=True)
62                 layout.itemL(text="Noise:")
63                 layout.itemR(tex, "noise_type", text="Type", expand=True)
64                 layout.itemR(tex, "noise_basis", text="Basis")
65                 
66                 col = layout.column_flow()
67                 col.itemR(tex, "noise_size", text="Size")
68                 col.itemR(tex, "noise_depth", text="Depth")
69                 col.itemR(tex, "nabla", text="Nabla")
70
71 class TEXTURE_PT_wood(TextureButtonsPanel):
72         __idname__= "TEXTURE_PT_wood"
73         __label__ = "Wood"
74         
75         def poll(self, context):
76                 tex = context.texture
77                 return (tex and tex.type == 'WOOD')
78
79         def draw(self, context):
80                 layout = self.layout
81                 tex = context.texture
82                 
83                 layout.itemR(tex, "stype", expand=True)
84                 layout.itemR(tex, "noisebasis2", expand=True)
85                 layout.itemL(text="Noise:")
86                 layout.itemR(tex, "noise_type", text="Type", expand=True)
87                 layout.itemR(tex, "noise_basis", text="Basis")
88                 
89                 col = layout.column_flow()
90                 col.itemR(tex, "noise_size", text="Size")
91                 col.itemR(tex, "turbulence")
92                 col.itemR(tex, "nabla")
93                 
94 class TEXTURE_PT_marble(TextureButtonsPanel):
95         __idname__= "TEXTURE_PT_marble"
96         __label__ = "Marble"
97         
98         def poll(self, context):
99                 tex = context.texture
100                 return (tex and tex.type == 'MARBLE')
101
102         def draw(self, context):
103                 layout = self.layout
104                 tex = context.texture
105                 
106                 layout.itemR(tex, "stype", expand=True)
107                 layout.itemR(tex, "noisebasis2", expand=True)
108                 layout.itemL(text="Noise:")
109                 layout.itemR(tex, "noise_type", text="Type", expand=True)
110                 layout.itemR(tex, "noise_basis", text="Basis")
111                 
112                 col = layout.column_flow()      
113                 col.itemR(tex, "noise_size", text="Size")
114                 col.itemR(tex, "noise_depth", text="Depth")
115                 col.itemR(tex, "turbulence")
116                 col.itemR(tex, "nabla")
117
118 class TEXTURE_PT_magic(TextureButtonsPanel):
119         __idname__= "TEXTURE_PT_magic"
120         __label__ = "Magic"
121         
122         def poll(self, context):
123                 tex = context.texture
124                 return (tex and tex.type == 'MAGIC')
125
126         def draw(self, context):
127                 layout = self.layout
128                 tex = context.texture
129                         
130                 row = layout.row()
131                 row.itemR(tex, "noise_depth", text="Depth")
132                 row.itemR(tex, "turbulence")
133
134 class TEXTURE_PT_blend(TextureButtonsPanel):
135         __idname__= "TEXTURE_PT_blend"
136         __label__ = "Blend"
137         
138         def poll(self, context):
139                 tex = context.texture
140                 return (tex and tex.type == 'BLEND')
141
142         def draw(self, context):
143                 layout = self.layout
144                 tex = context.texture
145
146                 layout.itemR(tex, "progression")
147                 layout.itemR(tex, "flip_axis")
148                         
149 class TEXTURE_PT_stucci(TextureButtonsPanel):
150         __idname__= "TEXTURE_PT_stucci"
151         __label__ = "Stucci"
152         
153         def poll(self, context):
154                 tex = context.texture
155                 return (tex and tex.type == 'STUCCI')
156
157         def draw(self, context):
158                 layout = self.layout
159                 tex = context.texture
160                 
161                 layout.itemR(tex, "stype", expand=True)
162                 layout.itemL(text="Noise:")
163                 layout.itemR(tex, "noise_type", text="Type", expand=True)
164                 layout.itemR(tex, "noise_basis", text="Basis")
165                 
166                 row = layout.row()
167                 row.itemR(tex, "noise_size", text="Size")
168                 row.itemR(tex, "turbulence")
169                 
170 class TEXTURE_PT_image(TextureButtonsPanel):
171         __idname__= "TEXTURE_PT_image"
172         __label__ = "Image/Movie"
173         
174         def poll(self, context):
175                 tex = context.texture
176                 return (tex and tex.type == 'IMAGE')
177
178         def draw(self, context):
179                 layout = self.layout
180                 tex = context.texture
181                 
182                 split = layout.split()
183                 
184                 sub = split.column()            
185                 sub.itemR(tex, "flip_axis")
186                 sub.itemR(tex, "normal_map")
187                 sub.itemL(text="Filter:")
188                 sub.itemR(tex, "mipmap")
189                 sub.itemR(tex, "mipmap_gauss")
190                 sub.itemR(tex, "interpolation")
191                 sub = split.column() 
192                 sub.itemL(text="Alpha:")
193                 sub.itemR(tex, "use_alpha")
194                 sub.itemR(tex, "calculate_alpha")
195                 sub.itemR(tex, "invert_alpha")
196
197 class TEXTURE_PT_mapping(TextureButtonsPanel):
198         __idname__= "TEXTURE_PT_mapping"
199         __label__ = "Mapping"
200         
201         def poll(self, context):
202                 tex = context.texture
203                 return (tex and tex.type == 'IMAGE')
204
205         def draw(self, context):
206                 layout = self.layout
207                 tex = context.texture
208                                 
209                 split = layout.split()
210                 
211                 sub = split.column()
212                 #sub.itemR(tex, "crop_rectangle")
213                 sub.itemL(text="Crop Minimum:")
214                 sub.itemR(tex, "crop_min_x", text="X")
215                 sub.itemR(tex, "crop_min_y", text="Y")
216                 sub = split.column()
217                 sub.itemL(text="Crop Maximum:")
218                 sub.itemR(tex, "crop_max_x", text="X")
219                 sub.itemR(tex, "crop_max_y", text="Y")
220                 
221                 layout.itemR(tex, "extension")
222                 
223                 split = layout.split()
224                 
225                 sub = split.column()
226                 if tex.extension == 'REPEAT': 
227                         sub.itemL(text="Repeat:")
228                         sub.itemR(tex, "repeat_x", text="X")
229                         sub.itemR(tex, "repeat_y", text="Y")
230                         sub = split.column()
231                         sub.itemL(text="Mirror:")
232                         sub.itemR(tex, "mirror_x", text="X")
233                         sub.itemR(tex, "mirror_y", text="Y")
234                 elif tex.extension == 'CHECKER': 
235                         sub.itemR(tex, "checker_even", text="Even")
236                         sub.itemR(tex, "checker_odd", text="Odd")
237                         sub = split.column()
238                         sub.itemR(tex, "checker_distance", text="Distance")
239         
240 class TEXTURE_PT_plugin(TextureButtonsPanel):
241         __idname__= "TEXTURE_PT_plugin"
242         __label__ = "Plugin"
243         
244         def poll(self, context):
245                 tex = context.texture
246                 return (tex and tex.type == 'PLUGIN')
247
248         def draw(self, context):
249                 layout = self.layout
250                 tex = context.texture
251                 
252                 layout.itemL(text="Nothing yet")
253                 
254 class TEXTURE_PT_envmap(TextureButtonsPanel):
255         __idname__= "TEXTURE_PT_envmap"
256         __label__ = "Environment Map"
257         
258         def poll(self, context):
259                 tex = context.texture
260                 return (tex and tex.type == 'ENVIRONMENT_MAP')
261
262         def draw(self, context):
263                 layout = self.layout
264                 tex = context.texture
265                 
266                 layout.itemL(text="Nothing yet")
267                 
268 class TEXTURE_PT_musgrave(TextureButtonsPanel):
269         __idname__= "TEXTURE_PT_musgrave"
270         __label__ = "Musgrave"
271         
272         def poll(self, context):
273                 tex = context.texture
274                 return (tex and tex.type == 'MUSGRAVE')
275
276         def draw(self, context):
277                 layout = self.layout
278                 tex = context.texture
279                 
280                 layout.itemR(tex, "musgrave_type")      
281                 
282                 split = layout.split()
283                 
284                 sub = split.column()
285                 sub.itemR(tex, "highest_dimension", text="Dimension")
286                 sub.itemR(tex, "lacunarity")
287                 sub.itemR(tex, "octaves")
288                 sub = split.column() 
289                 if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
290                         sub.itemR(tex, "offset")
291                 if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
292                         sub.itemR(tex, "gain")
293                         sub.itemR(tex, "noise_intensity", text="Intensity")
294                 
295                 layout.itemL(text="Noise:")
296                 
297                 layout.itemR(tex, "noise_basis", text="Basis")
298                 
299                 row = layout.row()
300                 row.itemR(tex, "noise_size", text="Size")
301                 row.itemR(tex, "nabla")
302
303 class TEXTURE_PT_voronoi(TextureButtonsPanel):
304         __idname__= "TEXTURE_PT_voronoi"
305         __label__ = "Voronoi"
306         
307         def poll(self, context):
308                 tex = context.texture
309                 return (tex and tex.type == 'VORONOI')
310
311         def draw(self, context):
312                 layout = self.layout
313                 tex = context.texture
314         
315                 layout.itemR(tex, "distance_metric")
316                 layout.itemR(tex, "coloring")
317                 
318                 split = layout.split()
319                 
320                 sub = split.column()   
321                 
322                 sub.itemR(tex, "noise_intensity", text="Intensity")
323                 if tex.distance_metric == 'MINKOVSKY':
324                         sub.itemR(tex, "minkovsky_exponent", text="Exponent")
325                 sub = split.column()
326                 sub.itemR(tex, "feature_weights", slider=True)
327                 
328                 layout.itemL(text="Noise:")
329                 
330                 row = layout.row()
331                 row.itemR(tex, "noise_size", text="Size")
332                 row.itemR(tex, "nabla")
333                         
334 class TEXTURE_PT_distortednoise(TextureButtonsPanel):
335         __idname__= "TEXTURE_PT_distortednoise"
336         __label__ = "Distorted Noise"
337         
338         def poll(self, context):
339                 tex = context.texture
340                 return (tex and tex.type == 'DISTORTED_NOISE')
341
342         def draw(self, context):
343                 layout = self.layout
344                 tex = context.texture
345
346                 layout.itemR(tex, "noise_distortion")
347                 layout.itemR(tex, "noise_basis", text="Basis")
348                 
349                 split = layout.split()
350                 
351                 sub = split.column()
352                 sub.itemR(tex, "distortion_amount", text="Amount")
353                 sub.itemR(tex, "noise_size", text="Size")
354                 
355                 sub = split.column()
356                 sub.itemR(tex, "nabla") 
357
358 bpy.types.register(TEXTURE_PT_preview)
359 bpy.types.register(TEXTURE_PT_texture)
360 bpy.types.register(TEXTURE_PT_colors)
361 bpy.types.register(TEXTURE_PT_clouds)
362 bpy.types.register(TEXTURE_PT_wood)
363 bpy.types.register(TEXTURE_PT_marble)
364 bpy.types.register(TEXTURE_PT_magic)
365 bpy.types.register(TEXTURE_PT_blend)
366 bpy.types.register(TEXTURE_PT_stucci)
367 bpy.types.register(TEXTURE_PT_image)
368 bpy.types.register(TEXTURE_PT_mapping)
369 bpy.types.register(TEXTURE_PT_plugin)
370 bpy.types.register(TEXTURE_PT_envmap)
371 bpy.types.register(TEXTURE_PT_musgrave)
372 bpy.types.register(TEXTURE_PT_voronoi)
373 bpy.types.register(TEXTURE_PT_distortednoise)
374