svn merge -r 21041:21301 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[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 and context.texture.type != 'NONE')
11                 
12 class TEXTURE_PT_preview(TextureButtonsPanel):
13         __idname__= "TEXTURE_PT_preview"
14         __label__ = "Preview"
15
16         def poll(self, context):
17                 return (context.material or context.world or context.lamp or context.texture)
18
19         def draw(self, context):
20                 layout = self.layout
21                 tex = context.texture
22                 
23                 layout.template_preview(tex)
24
25 class TEXTURE_PT_texture(TextureButtonsPanel):
26         __idname__= "TEXTURE_PT_texture"
27         __label__ = "Texture"
28
29         def poll(self, context):
30                 return (context.material or context.world or context.lamp or context.texture)
31
32         def draw(self, context):
33                 layout = self.layout
34                 
35                 tex = context.texture
36                 ma = context.material
37                 la = context.lamp
38                 wo = context.world
39                 space = context.space_data
40                 slot = context.texture_slot
41
42                 split = layout.split(percentage=0.65)
43
44                 if ma or la or wo:
45                         if slot:
46                                 split.template_ID(slot, "texture", new="TEXTURE_OT_new")
47                         else:
48                                 split.itemS()
49
50                         if ma:
51                                 split.itemR(ma, "active_texture_index", text="Active")
52                         elif la:
53                                 split.itemR(la, "active_texture_index", text="Active")
54                         elif wo:
55                                 split.itemR(wo, "active_texture_index", text="Active")
56                 elif tex:
57                         split.template_ID(space, "pin_id")
58                         split.itemS()
59
60                 layout.itemS()
61                 
62                 if tex:
63                         split = layout.split(percentage=0.2)
64                 
65                         col = split.column()
66                         col.itemL(text="Type:")
67                         col = split.column()
68                         col.itemR(tex, "type", text="")
69
70 class TEXTURE_PT_mapping(TextureButtonsPanel):
71         __idname__= "TEXTURE_PT_mapping"
72         __label__ = "Mapping"
73         
74         def poll(self, context):
75                 return (context.texture_slot and context.texture and context.texture.type != 'NONE')
76
77         def draw(self, context):
78                 layout = self.layout
79                 tex = context.texture_slot
80                 textype = context.texture
81
82                 split = layout.split(percentage=0.3)
83                 col = split.column()
84                 col.itemL(text="Coordinates:")
85                 col = split.column()
86                 col.itemR(tex, "texture_coordinates", text="")
87
88                 if tex.texture_coordinates == 'UV':
89                         row = layout.row()
90                         row.itemR(tex, "uv_layer")
91                 elif tex.texture_coordinates == 'OBJECT':
92                         row = layout.row()
93                         row.itemR(tex, "object")
94                 
95                 if textype.type in ('IMAGE', 'ENVIRONMENT_MAP'):
96                         split = layout.split(percentage=0.3)
97                         col = split.column()
98                         col.itemL(text="Projection:")
99                         col = split.column()
100                         col.itemR(tex, "mapping", text="")
101
102                 split = layout.split()
103                 
104                 col = split.column()
105                 col.itemR(tex, "from_dupli")
106                 
107                 col = split.column()
108                 row = col.row()
109                 row.itemR(tex, "x_mapping", text="")
110                 row.itemR(tex, "y_mapping", text="")
111                 row.itemR(tex, "z_mapping", text="")
112
113                 row = layout.row()
114                 row.column().itemR(tex, "offset")
115                 row.column().itemR(tex, "size")
116
117 class TEXTURE_PT_influence(TextureButtonsPanel):
118         __idname__= "TEXTURE_PT_influence"
119         __label__ = "Influence"
120         
121         def poll(self, context):
122                 return (context.texture_slot and context.texture and context.texture.type != 'NONE')
123
124         def draw(self, context):
125                 layout = self.layout
126                 
127                 textype = context.texture
128                 tex = context.texture_slot
129                 
130                 split = layout.split()
131                 
132                 col = split.column()
133                 col.itemR(tex, "map_color", text="Diffuse Color")
134                 colsub = col.column()
135                 colsub.active = tex.map_color
136                 colsub.itemR(tex, "color_factor", text="Opacity", slider=True)
137                 colsub.itemR(tex, "blend_type")
138                 if textype.type == 'IMAGE':
139                         col.itemR(tex, "no_rgb")
140                         
141                         colsub = col.column()
142                         colsub.active = tex.no_rgb
143                         colsub.itemR(tex, "color")
144                 else:
145                         col.itemR(tex, "color")
146                         
147                 col.itemR(tex, "map_colorspec")
148                 col.itemR(tex, "map_normal")
149                 colsub = col.column()
150                 colsub.active = tex.map_normal
151                 colsub.itemR(tex, "normal_factor", text="Amount", slider=True)
152                 col.itemR(tex, "normal_map_space")
153                 col.itemR(tex, "map_warp")
154                 colsub = col.column()
155                 colsub.active = tex.map_warp
156                 colsub.itemR(tex, "warp_factor", text="Amount", slider=True)    
157                 col.itemR(tex, "map_displacement")
158                 colsub = col.column()
159                 colsub.active = tex.map_displacement
160                 colsub.itemR(tex, "displacement_factor", text="Amount", slider=True)
161                 col = split.column()
162                 col.itemR(tex, "map_mirror")
163                 col.itemR(tex, "map_reflection")
164                 col.itemR(tex, "map_specularity")
165                 col.itemR(tex, "map_ambient")
166                 col.itemR(tex, "map_hardness")
167                 col.itemR(tex, "map_raymir")
168                 col.itemR(tex, "map_alpha")
169                 col.itemR(tex, "map_emit")
170                 col.itemR(tex, "map_translucency")
171
172                 colsub = col.column()
173                 colsub.active = tex.map_translucency or tex.map_emit or tex.map_alpha or tex.map_raymir or tex.map_hardness or tex.map_ambient or tex.map_specularity or tex.map_reflection or tex.map_mirror
174                 colsub.itemR(tex, "default_value", text="Amount", slider=True)
175                 
176                 row = layout.row()
177                 row.itemR(tex, "stencil")
178                 row.itemR(tex, "negate", text="Negative")
179
180 class TEXTURE_PT_colors(TextureButtonsPanel):
181         __idname__= "TEXTURE_PT_colors"
182         __label__ = "Colors"
183         __default_closed__ = True
184
185         def draw(self, context):
186                 layout = self.layout
187                 tex = context.texture
188
189                 if tex.color_ramp:
190                         layout.template_color_ramp(tex.color_ramp, expand=True)
191                 else:
192                         split = layout.split()
193                         col = split.column()
194                         col.itemR(tex, "rgb_factor", text="Multiply RGB")
195
196                 col = split.column()
197                 col.itemL(text="Adjust:")
198                 col.itemR(tex, "brightness")
199                 col.itemR(tex, "contrast")
200
201 class TEXTURE_PT_clouds(TextureButtonsPanel):
202         __idname__= "TEXTURE_PT_clouds"
203         __label__ = "Clouds"
204         
205         def poll(self, context):
206                 tex = context.texture
207                 return (tex and tex.type == 'CLOUDS')
208
209         def draw(self, context):
210                 layout = self.layout
211                 tex = context.texture
212                 
213                 layout.itemR(tex, "stype", expand=True)
214                 layout.itemL(text="Noise:")
215                 layout.itemR(tex, "noise_type", text="Type", expand=True)
216                 layout.itemR(tex, "noise_basis", text="Basis")
217                 
218                 col = layout.column_flow()
219                 col.itemR(tex, "noise_size", text="Size")
220                 col.itemR(tex, "noise_depth", text="Depth")
221                 col.itemR(tex, "nabla", text="Nabla")
222
223 class TEXTURE_PT_wood(TextureButtonsPanel):
224         __idname__= "TEXTURE_PT_wood"
225         __label__ = "Wood"
226         
227         def poll(self, context):
228                 tex = context.texture
229                 return (tex and tex.type == 'WOOD')
230
231         def draw(self, context):
232                 layout = self.layout
233                 tex = context.texture
234                 
235                 layout.itemR(tex, "noisebasis2", expand=True)
236                 layout.itemR(tex, "stype", expand=True)
237                 
238                 col = layout.column()
239                 col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
240                 col.itemL(text="Noise:")
241                 col.row().itemR(tex, "noise_type", text="Type", expand=True)
242                 col.itemR(tex, "noise_basis", text="Basis")
243                 
244                 col = layout.column_flow()
245                 col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
246                 col.itemR(tex, "noise_size", text="Size")
247                 col.itemR(tex, "turbulence")
248                 col.itemR(tex, "nabla")
249                 
250 class TEXTURE_PT_marble(TextureButtonsPanel):
251         __idname__= "TEXTURE_PT_marble"
252         __label__ = "Marble"
253         
254         def poll(self, context):
255                 tex = context.texture
256                 return (tex and tex.type == 'MARBLE')
257
258         def draw(self, context):
259                 layout = self.layout
260                 tex = context.texture
261                 
262                 layout.itemR(tex, "stype", expand=True)
263                 layout.itemR(tex, "noisebasis2", expand=True)
264                 layout.itemL(text="Noise:")
265                 layout.itemR(tex, "noise_type", text="Type", expand=True)
266                 layout.itemR(tex, "noise_basis", text="Basis")
267                 
268                 col = layout.column_flow()      
269                 col.itemR(tex, "noise_size", text="Size")
270                 col.itemR(tex, "noise_depth", text="Depth")
271                 col.itemR(tex, "turbulence")
272                 col.itemR(tex, "nabla")
273
274 class TEXTURE_PT_magic(TextureButtonsPanel):
275         __idname__= "TEXTURE_PT_magic"
276         __label__ = "Magic"
277         
278         def poll(self, context):
279                 tex = context.texture
280                 return (tex and tex.type == 'MAGIC')
281
282         def draw(self, context):
283                 layout = self.layout
284                 tex = context.texture
285                         
286                 row = layout.row()
287                 row.itemR(tex, "noise_depth", text="Depth")
288                 row.itemR(tex, "turbulence")
289
290 class TEXTURE_PT_blend(TextureButtonsPanel):
291         __idname__= "TEXTURE_PT_blend"
292         __label__ = "Blend"
293         
294         def poll(self, context):
295                 tex = context.texture
296                 return (tex and tex.type == 'BLEND')
297
298         def draw(self, context):
299                 layout = self.layout
300                 tex = context.texture
301
302                 layout.itemR(tex, "progression")
303                 layout.itemR(tex, "flip_axis")
304                         
305 class TEXTURE_PT_stucci(TextureButtonsPanel):
306         __idname__= "TEXTURE_PT_stucci"
307         __label__ = "Stucci"
308         
309         def poll(self, context):
310                 tex = context.texture
311                 return (tex and tex.type == 'STUCCI')
312
313         def draw(self, context):
314                 layout = self.layout
315                 tex = context.texture
316                 
317                 layout.itemR(tex, "stype", expand=True)
318                 layout.itemL(text="Noise:")
319                 layout.itemR(tex, "noise_type", text="Type", expand=True)
320                 layout.itemR(tex, "noise_basis", text="Basis")
321                 
322                 row = layout.row()
323                 row.itemR(tex, "noise_size", text="Size")
324                 row.itemR(tex, "turbulence")
325                 
326 class TEXTURE_PT_image(TextureButtonsPanel):
327         __idname__= "TEXTURE_PT_image"
328         __label__ = "Image/Movie"
329         
330         def poll(self, context):
331                 tex = context.texture
332                 return (tex and tex.type == 'IMAGE')
333
334         def draw(self, context):
335                 layout = self.layout
336                 tex = context.texture
337                 
338                 split = layout.split()
339                 
340                 sub = split.column()            
341                 sub.itemR(tex, "flip_axis")
342                 sub.itemR(tex, "normal_map")
343                 sub.itemL(text="Filter:")
344                 sub.itemR(tex, "mipmap")
345                 sub.itemR(tex, "mipmap_gauss")
346                 sub.itemR(tex, "interpolation")
347                 sub = split.column() 
348                 sub.itemL(text="Alpha:")
349                 sub.itemR(tex, "use_alpha")
350                 sub.itemR(tex, "calculate_alpha")
351                 sub.itemR(tex, "invert_alpha")
352
353 class TEXTURE_PT_crop(TextureButtonsPanel):
354         __idname__= "TEXTURE_PT_crop"
355         __label__ = "Crop"
356         
357         def poll(self, context):
358                 tex = context.texture
359                 return (tex and tex.type == 'IMAGE')
360
361         def draw(self, context):
362                 layout = self.layout
363                 tex = context.texture
364                                 
365                 split = layout.split()
366                 
367                 sub = split.column()
368                 #sub.itemR(tex, "crop_rectangle")
369                 sub.itemL(text="Crop Minimum:")
370                 sub.itemR(tex, "crop_min_x", text="X")
371                 sub.itemR(tex, "crop_min_y", text="Y")
372                 sub = split.column()
373                 sub.itemL(text="Crop Maximum:")
374                 sub.itemR(tex, "crop_max_x", text="X")
375                 sub.itemR(tex, "crop_max_y", text="Y")
376                 
377                 layout.itemR(tex, "extension")
378                 
379                 split = layout.split()
380                 
381                 sub = split.column()
382                 if tex.extension == 'REPEAT': 
383                         sub.itemL(text="Repeat:")
384                         sub.itemR(tex, "repeat_x", text="X")
385                         sub.itemR(tex, "repeat_y", text="Y")
386                         sub = split.column()
387                         sub.itemL(text="Mirror:")
388                         sub.itemR(tex, "mirror_x", text="X")
389                         sub.itemR(tex, "mirror_y", text="Y")
390                 elif tex.extension == 'CHECKER': 
391                         sub.itemR(tex, "checker_even", text="Even")
392                         sub.itemR(tex, "checker_odd", text="Odd")
393                         sub = split.column()
394                         sub.itemR(tex, "checker_distance", text="Distance")
395         
396 class TEXTURE_PT_plugin(TextureButtonsPanel):
397         __idname__= "TEXTURE_PT_plugin"
398         __label__ = "Plugin"
399         
400         def poll(self, context):
401                 tex = context.texture
402                 return (tex and tex.type == 'PLUGIN')
403
404         def draw(self, context):
405                 layout = self.layout
406                 tex = context.texture
407                 
408                 layout.itemL(text="Nothing yet")
409                 
410 class TEXTURE_PT_envmap(TextureButtonsPanel):
411         __idname__= "TEXTURE_PT_envmap"
412         __label__ = "Environment Map"
413         
414         def poll(self, context):
415                 tex = context.texture
416                 return (tex and tex.type == 'ENVIRONMENT_MAP')
417
418         def draw(self, context):
419                 layout = self.layout
420                 tex = context.texture
421                 
422                 layout.itemL(text="Nothing yet")
423                 
424 class TEXTURE_PT_musgrave(TextureButtonsPanel):
425         __idname__= "TEXTURE_PT_musgrave"
426         __label__ = "Musgrave"
427         
428         def poll(self, context):
429                 tex = context.texture
430                 return (tex and tex.type == 'MUSGRAVE')
431
432         def draw(self, context):
433                 layout = self.layout
434                 tex = context.texture
435                 
436                 layout.itemR(tex, "musgrave_type")      
437                 
438                 split = layout.split()
439                 
440                 sub = split.column()
441                 sub.itemR(tex, "highest_dimension", text="Dimension")
442                 sub.itemR(tex, "lacunarity")
443                 sub.itemR(tex, "octaves")
444                 sub = split.column() 
445                 if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
446                         sub.itemR(tex, "offset")
447                 if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
448                         sub.itemR(tex, "gain")
449                         sub.itemR(tex, "noise_intensity", text="Intensity")
450                 
451                 layout.itemL(text="Noise:")
452                 
453                 layout.itemR(tex, "noise_basis", text="Basis")
454                 
455                 row = layout.row()
456                 row.itemR(tex, "noise_size", text="Size")
457                 row.itemR(tex, "nabla")
458
459 class TEXTURE_PT_voronoi(TextureButtonsPanel):
460         __idname__= "TEXTURE_PT_voronoi"
461         __label__ = "Voronoi"
462         
463         def poll(self, context):
464                 tex = context.texture
465                 return (tex and tex.type == 'VORONOI')
466
467         def draw(self, context):
468                 layout = self.layout
469                 tex = context.texture
470         
471                 layout.itemR(tex, "distance_metric")
472                 layout.itemR(tex, "coloring")
473                 
474                 split = layout.split()
475                 
476                 sub = split.column()   
477                 
478                 sub.itemR(tex, "noise_intensity", text="Intensity")
479                 if tex.distance_metric == 'MINKOVSKY':
480                         sub.itemR(tex, "minkovsky_exponent", text="Exponent")
481                 sub = split.column()
482                 sub.itemR(tex, "feature_weights", slider=True)
483                 
484                 layout.itemL(text="Noise:")
485                 
486                 row = layout.row()
487                 row.itemR(tex, "noise_size", text="Size")
488                 row.itemR(tex, "nabla")
489                         
490 class TEXTURE_PT_distortednoise(TextureButtonsPanel):
491         __idname__= "TEXTURE_PT_distortednoise"
492         __label__ = "Distorted Noise"
493         
494         def poll(self, context):
495                 tex = context.texture
496                 return (tex and tex.type == 'DISTORTED_NOISE')
497
498         def draw(self, context):
499                 layout = self.layout
500                 tex = context.texture
501
502                 layout.itemR(tex, "noise_distortion")
503                 layout.itemR(tex, "noise_basis", text="Basis")
504                 
505                 split = layout.split()
506                 
507                 sub = split.column()
508                 sub.itemR(tex, "distortion_amount", text="Distortion")
509                 sub.itemR(tex, "noise_size", text="Size")
510                 
511                 sub = split.column()
512                 sub.itemR(tex, "nabla") 
513
514 bpy.types.register(TEXTURE_PT_preview)
515 bpy.types.register(TEXTURE_PT_texture)
516 bpy.types.register(TEXTURE_PT_clouds)
517 bpy.types.register(TEXTURE_PT_wood)
518 bpy.types.register(TEXTURE_PT_marble)
519 bpy.types.register(TEXTURE_PT_magic)
520 bpy.types.register(TEXTURE_PT_blend)
521 bpy.types.register(TEXTURE_PT_stucci)
522 bpy.types.register(TEXTURE_PT_image)
523 bpy.types.register(TEXTURE_PT_crop)
524 bpy.types.register(TEXTURE_PT_plugin)
525 bpy.types.register(TEXTURE_PT_envmap)
526 bpy.types.register(TEXTURE_PT_musgrave)
527 bpy.types.register(TEXTURE_PT_voronoi)
528 bpy.types.register(TEXTURE_PT_distortednoise)
529 bpy.types.register(TEXTURE_PT_colors)
530 bpy.types.register(TEXTURE_PT_mapping)
531 bpy.types.register(TEXTURE_PT_influence)
532