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