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