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