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