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