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