pep8 warnings
[blender.git] / release / scripts / ui / properties_texture.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23 narrowui = 180
24
25
26 class TEXTURE_MT_specials(bpy.types.Menu):
27     bl_label = "Texture Specials"
28
29     def draw(self, context):
30         layout = self.layout
31
32         layout.operator("material.mtex_copy", icon='COPYDOWN')
33         layout.operator("material.mtex_paste", icon='PASTEDOWN')
34
35
36 class TEXTURE_MT_envmap_specials(bpy.types.Menu):
37     bl_label = "Environment Map Specials"
38
39     def draw(self, context):
40         layout = self.layout
41
42         layout.operator("texture.envmap_save", icon='IMAGEFILE')
43         layout.operator("texture.envmap_clear", icon='FILE_REFRESH')
44         layout.operator("texture.envmap_clear_all", icon='FILE_REFRESH')
45
46
47 def active_node_mat(mat):
48     if mat:
49         mat_node = mat.active_node_material
50         if mat_node:
51             return mat_node
52         else:
53             return mat
54
55     return None
56
57
58 def context_tex_datablock(context):
59     idblock = active_node_mat(context.material)
60     if idblock:
61         return idblock
62
63     idblock = context.lamp
64     if idblock:
65         return idblock
66
67     idblock = context.world
68     if idblock:
69         return idblock
70
71     idblock = context.brush
72     return idblock
73
74
75 class TextureButtonsPanel(bpy.types.Panel):
76     bl_space_type = 'PROPERTIES'
77     bl_region_type = 'WINDOW'
78     bl_context = "texture"
79
80     def poll(self, context):
81         tex = context.texture
82         return (tex and (tex.type != 'NONE' or tex.use_nodes))
83
84
85 class TEXTURE_PT_preview(TextureButtonsPanel):
86     bl_label = "Preview"
87
88     def draw(self, context):
89         layout = self.layout
90
91         tex = context.texture
92         slot = context.texture_slot
93
94         idblock = context_tex_datablock(context)
95
96         if idblock:
97             layout.template_preview(tex, parent=idblock, slot=slot)
98         else:
99             layout.template_preview(tex, slot=slot)
100
101
102 class TEXTURE_PT_context_texture(TextureButtonsPanel):
103     bl_label = ""
104     bl_show_header = False
105
106     def poll(self, context):
107         return (context.material or context.world or context.lamp or context.brush or context.texture)
108
109     def draw(self, context):
110         layout = self.layout
111         slot = context.texture_slot
112         node = context.texture_node
113         space = context.space_data
114         tex = context.texture
115         wide_ui = context.region.width > narrowui
116         idblock = context_tex_datablock(context)
117         tex_collection = space.pin_id == None and type(idblock) != bpy.types.Brush and not node
118
119         if tex_collection:
120             row = layout.row()
121
122             row.template_list(idblock, "texture_slots", idblock, "active_texture_index", rows=2)
123
124             col = row.column(align=True)
125             col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
126             col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
127             col.menu("TEXTURE_MT_specials", icon='DOWNARROW_HLT', text="")
128
129         if wide_ui:
130             split = layout.split(percentage=0.65)
131             col = split.column()
132         else:
133             col = layout.column()
134
135         if tex_collection:
136             col.template_ID(idblock, "active_texture", new="texture.new")
137         elif node:
138             col.template_ID(node, "texture", new="texture.new")
139         elif idblock:
140             col.template_ID(idblock, "texture", new="texture.new")
141
142         if space.pin_id:
143             col.template_ID(space, "pin_id")
144
145         if wide_ui:
146             col = split.column()
147
148         if not space.pin_id:
149             col.prop(space, "brush_texture", text="Brush", toggle=True)
150
151         if tex:
152             split = layout.split(percentage=0.2)
153
154             if tex.use_nodes:
155
156                 if slot:
157                     split.label(text="Output:")
158                     split.prop(slot, "output_node", text="")
159
160             else:
161                 if wide_ui:
162                     split.label(text="Type:")
163                     split.prop(tex, "type", text="")
164                 else:
165                     layout.prop(tex, "type", text="")
166
167
168 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel):
169     _context_path = "texture"
170
171     def poll(self, context): # use alternate poll since NONE texture type is ok
172         return context.texture
173
174
175 class TEXTURE_PT_colors(TextureButtonsPanel):
176     bl_label = "Colors"
177     bl_default_closed = True
178
179     def draw(self, context):
180         layout = self.layout
181
182         tex = context.texture
183         wide_ui = context.region.width > narrowui
184
185         layout.prop(tex, "use_color_ramp", text="Ramp")
186         if tex.use_color_ramp:
187             layout.template_color_ramp(tex, "color_ramp", expand=True)
188
189         split = layout.split()
190
191         col = split.column()
192         col.label(text="RGB Multiply:")
193         sub = col.column(align=True)
194         sub.prop(tex, "factor_red", text="R")
195         sub.prop(tex, "factor_green", text="G")
196         sub.prop(tex, "factor_blue", text="B")
197
198         if wide_ui:
199             col = split.column()
200         col.label(text="Adjust:")
201         col.prop(tex, "brightness")
202         col.prop(tex, "contrast")
203
204 # Texture Slot Panels #
205
206
207 class TextureSlotPanel(TextureButtonsPanel):
208
209     def poll(self, context):
210         return (context.texture_slot and
211                 TextureButtonsPanel.poll(self, context))
212
213
214 class TEXTURE_PT_mapping(TextureSlotPanel):
215     bl_label = "Mapping"
216
217     def draw(self, context):
218         layout = self.layout
219
220         idblock = context_tex_datablock(context)
221
222         tex = context.texture_slot
223         # textype = context.texture
224         wide_ui = context.region.width > narrowui
225
226         if type(idblock) != bpy.types.Brush:
227             split = layout.split(percentage=0.3)
228             col = split.column()
229             col.label(text="Coordinates:")
230             col = split.column()
231             col.prop(tex, "texture_coordinates", text="")
232
233             if tex.texture_coordinates == 'ORCO':
234                 """
235                 ob = context.object
236                 if ob and ob.type == 'MESH':
237                     split = layout.split(percentage=0.3)
238                     split.label(text="Mesh:")
239                     split.prop(ob.data, "texco_mesh", text="")
240                 """
241             elif tex.texture_coordinates == 'UV':
242                 split = layout.split(percentage=0.3)
243                 split.label(text="Layer:")
244                 ob = context.object
245                 if ob and ob.type == 'MESH':
246                     split.prop_object(tex, "uv_layer", ob.data, "uv_textures", text="")
247                 else:
248                     split.prop(tex, "uv_layer", text="")
249
250             elif tex.texture_coordinates == 'OBJECT':
251                 split = layout.split(percentage=0.3)
252                 split.label(text="Object:")
253                 split.prop(tex, "object", text="")
254
255         if type(idblock) == bpy.types.Brush:
256             layout.prop(tex, "map_mode", expand=True)
257
258             row = layout.row()
259             row.active = tex.map_mode in ('FIXED', 'TILED')
260             row.prop(tex, "angle")
261
262             row = layout.row()
263             row.active = tex.map_mode in ('TILED', '3D')
264             row.column().prop(tex, "size")
265         else:
266             if type(idblock) == bpy.types.Material:
267                 split = layout.split(percentage=0.3)
268                 split.label(text="Projection:")
269                 split.prop(tex, "mapping", text="")
270
271                 split = layout.split()
272
273                 col = split.column()
274                 if tex.texture_coordinates in ('ORCO', 'UV'):
275                     col.prop(tex, "from_dupli")
276                 elif tex.texture_coordinates == 'OBJECT':
277                     col.prop(tex, "from_original")
278                 elif wide_ui:
279                     col.label()
280
281                 if wide_ui:
282                     col = split.column()
283                 row = col.row()
284                 row.prop(tex, "x_mapping", text="")
285                 row.prop(tex, "y_mapping", text="")
286                 row.prop(tex, "z_mapping", text="")
287
288             # any non brush
289             split = layout.split()
290
291             col = split.column()
292             col.prop(tex, "offset")
293
294             if wide_ui:
295                 col = split.column()
296             col.prop(tex, "size")
297
298
299 class TEXTURE_PT_influence(TextureSlotPanel):
300     bl_label = "Influence"
301
302     def poll(self, context):
303         idblock = context_tex_datablock(context)
304         if type(idblock) == bpy.types.Brush:
305             return False
306
307         return context.texture_slot
308
309     def draw(self, context):
310
311         layout = self.layout
312
313         idblock = context_tex_datablock(context)
314
315         # textype = context.texture
316         tex = context.texture_slot
317         wide_ui = context.region.width > narrowui
318
319         def factor_but(layout, active, toggle, factor, name):
320             row = layout.row(align=True)
321             row.prop(tex, toggle, text="")
322             sub = row.row()
323             sub.active = active
324             sub.prop(tex, factor, text=name, slider=True)
325
326         if type(idblock) == bpy.types.Material:
327             if idblock.type in ('SURFACE', 'HALO', 'WIRE'):
328                 split = layout.split()
329
330                 col = split.column()
331                 col.label(text="Diffuse:")
332                 factor_but(col, tex.map_diffuse, "map_diffuse", "diffuse_factor", "Intensity")
333                 factor_but(col, tex.map_colordiff, "map_colordiff", "colordiff_factor", "Color")
334                 factor_but(col, tex.map_alpha, "map_alpha", "alpha_factor", "Alpha")
335                 factor_but(col, tex.map_translucency, "map_translucency", "translucency_factor", "Translucency")
336
337                 col.label(text="Specular:")
338                 factor_but(col, tex.map_specular, "map_specular", "specular_factor", "Intensity")
339                 factor_but(col, tex.map_colorspec, "map_colorspec", "colorspec_factor", "Color")
340                 factor_but(col, tex.map_hardness, "map_hardness", "hardness_factor", "Hardness")
341
342                 if wide_ui:
343                     col = split.column()
344                 col.label(text="Shading:")
345                 factor_but(col, tex.map_ambient, "map_ambient", "ambient_factor", "Ambient")
346                 factor_but(col, tex.map_emit, "map_emit", "emit_factor", "Emit")
347                 factor_but(col, tex.map_mirror, "map_mirror", "mirror_factor", "Mirror")
348                 factor_but(col, tex.map_raymir, "map_raymir", "raymir_factor", "Ray Mirror")
349
350                 col.label(text="Geometry:")
351                 factor_but(col, tex.map_normal, "map_normal", "normal_factor", "Normal")
352                 factor_but(col, tex.map_warp, "map_warp", "warp_factor", "Warp")
353                 factor_but(col, tex.map_displacement, "map_displacement", "displacement_factor", "Displace")
354
355                 #sub = col.column()
356                 #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
357                 #sub.prop(tex, "default_value", text="Amount", slider=True)
358             elif idblock.type == 'VOLUME':
359                 split = layout.split()
360
361                 col = split.column()
362                 factor_but(col, tex.map_density, "map_density", "density_factor", "Density")
363                 factor_but(col, tex.map_emission, "map_emission", "emission_factor", "Emission")
364                 factor_but(col, tex.map_scattering, "map_scattering", "scattering_factor", "Scattering")
365                 factor_but(col, tex.map_reflection, "map_reflection", "reflection_factor", "Reflection")
366
367                 if wide_ui:
368                     col = split.column()
369                     col.label(text=" ")
370                 factor_but(col, tex.map_coloremission, "map_coloremission", "coloremission_factor", "Emission Color")
371                 factor_but(col, tex.map_colortransmission, "map_colortransmission", "colortransmission_factor", "Transmission Color")
372                 factor_but(col, tex.map_colorreflection, "map_colorreflection", "colorreflection_factor", "Reflection Color")
373
374         elif type(idblock) == bpy.types.Lamp:
375             split = layout.split()
376
377             col = split.column()
378             factor_but(col, tex.map_color, "map_color", "color_factor", "Color")
379
380             if wide_ui:
381                 col = split.column()
382             factor_but(col, tex.map_shadow, "map_shadow", "shadow_factor", "Shadow")
383
384         elif type(idblock) == bpy.types.World:
385             split = layout.split()
386
387             col = split.column()
388             factor_but(col, tex.map_blend, "map_blend", "blend_factor", "Blend")
389             factor_but(col, tex.map_horizon, "map_horizon", "horizon_factor", "Horizon")
390
391             if wide_ui:
392                 col = split.column()
393             factor_but(col, tex.map_zenith_up, "map_zenith_up", "zenith_up_factor", "Zenith Up")
394             factor_but(col, tex.map_zenith_down, "map_zenith_down", "zenith_down_factor", "Zenith Down")
395
396         layout.separator()
397
398         split = layout.split()
399
400         col = split.column()
401         col.prop(tex, "blend_type", text="Blend")
402         col.prop(tex, "rgb_to_intensity")
403         sub = col.column()
404         sub.active = tex.rgb_to_intensity
405         sub.prop(tex, "color", text="")
406
407         if wide_ui:
408             col = split.column()
409         col.prop(tex, "negate", text="Negative")
410         col.prop(tex, "stencil")
411
412         if type(idblock) in (bpy.types.Material, bpy.types.World):
413             col.prop(tex, "default_value", text="DVar", slider=True)
414
415 # Texture Type Panels #
416
417
418 class TextureTypePanel(TextureButtonsPanel):
419
420     def poll(self, context):
421         tex = context.texture
422         return (tex and tex.type == self.tex_type and not tex.use_nodes)
423
424
425 class TEXTURE_PT_clouds(TextureTypePanel):
426     bl_label = "Clouds"
427     tex_type = 'CLOUDS'
428
429     def draw(self, context):
430         layout = self.layout
431
432         tex = context.texture
433         wide_ui = context.region.width > narrowui
434
435         layout.prop(tex, "stype", expand=True)
436         layout.label(text="Noise:")
437         layout.prop(tex, "noise_type", text="Type", expand=True)
438         if wide_ui:
439             layout.prop(tex, "noise_basis", text="Basis")
440         else:
441             layout.prop(tex, "noise_basis", text="")
442
443         split = layout.split()
444
445         col = split.column()
446         col.prop(tex, "noise_size", text="Size")
447         col.prop(tex, "noise_depth", text="Depth")
448
449         if wide_ui:
450             col = split.column()
451         col.prop(tex, "nabla", text="Nabla")
452
453
454 class TEXTURE_PT_wood(TextureTypePanel):
455     bl_label = "Wood"
456     tex_type = 'WOOD'
457
458     def draw(self, context):
459         layout = self.layout
460
461         tex = context.texture
462         wide_ui = context.region.width > narrowui
463
464         layout.prop(tex, "noisebasis2", expand=True)
465         if wide_ui:
466             layout.prop(tex, "stype", expand=True)
467         else:
468             layout.prop(tex, "stype", text="")
469
470         col = layout.column()
471         col.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
472         col.label(text="Noise:")
473         col.row().prop(tex, "noise_type", text="Type", expand=True)
474         if wide_ui:
475             layout.prop(tex, "noise_basis", text="Basis")
476         else:
477             layout.prop(tex, "noise_basis", text="")
478
479         split = layout.split()
480         split.active = tex.stype in ('RINGNOISE', 'BANDNOISE')
481
482         col = split.column()
483         col.prop(tex, "noise_size", text="Size")
484         col.prop(tex, "turbulence")
485
486         col = split.column()
487         col.prop(tex, "nabla")
488
489
490 class TEXTURE_PT_marble(TextureTypePanel):
491     bl_label = "Marble"
492     tex_type = 'MARBLE'
493
494     def draw(self, context):
495         layout = self.layout
496
497         tex = context.texture
498         wide_ui = context.region.width > narrowui
499
500         layout.prop(tex, "stype", expand=True)
501         layout.prop(tex, "noisebasis2", expand=True)
502         layout.label(text="Noise:")
503         layout.prop(tex, "noise_type", text="Type", expand=True)
504         if wide_ui:
505             layout.prop(tex, "noise_basis", text="Basis")
506         else:
507             layout.prop(tex, "noise_basis", text="")
508
509         split = layout.split()
510
511         col = split.column()
512         col.prop(tex, "noise_size", text="Size")
513         col.prop(tex, "noise_depth", text="Depth")
514
515         if wide_ui:
516             col = split.column()
517         col.prop(tex, "turbulence")
518         col.prop(tex, "nabla")
519
520
521 class TEXTURE_PT_magic(TextureTypePanel):
522     bl_label = "Magic"
523     tex_type = 'MAGIC'
524
525     def draw(self, context):
526         layout = self.layout
527
528         tex = context.texture
529         wide_ui = context.region.width > narrowui
530
531         split = layout.split()
532
533         col = split.column()
534         col.prop(tex, "noise_depth", text="Depth")
535
536         if wide_ui:
537             col = split.column()
538         col.prop(tex, "turbulence")
539
540
541 class TEXTURE_PT_blend(TextureTypePanel):
542     bl_label = "Blend"
543     tex_type = 'BLEND'
544
545     def draw(self, context):
546         layout = self.layout
547
548         tex = context.texture
549         wide_ui = context.region.width > narrowui
550
551         if wide_ui:
552             layout.prop(tex, "progression")
553         else:
554             layout.prop(tex, "progression", text="")
555
556         sub = layout.row()
557
558         sub.active = (tex.progression in ('LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'))
559         sub.prop(tex, "flip_axis", expand=True)
560
561
562 class TEXTURE_PT_stucci(TextureTypePanel):
563     bl_label = "Stucci"
564     tex_type = 'STUCCI'
565
566     def draw(self, context):
567         layout = self.layout
568
569         tex = context.texture
570         wide_ui = context.region.width > narrowui
571
572         layout.prop(tex, "stype", expand=True)
573         layout.label(text="Noise:")
574         layout.prop(tex, "noise_type", text="Type", expand=True)
575         if wide_ui:
576             layout.prop(tex, "noise_basis", text="Basis")
577         else:
578             layout.prop(tex, "noise_basis", text="")
579
580         split = layout.split()
581
582         col = split.column()
583         col.prop(tex, "noise_size", text="Size")
584
585         if wide_ui:
586             col = split.column()
587         col.prop(tex, "turbulence")
588
589
590 class TEXTURE_PT_image(TextureTypePanel):
591     bl_label = "Image"
592     tex_type = 'IMAGE'
593
594     def draw(self, context):
595         layout = self.layout
596
597         tex = context.texture
598
599         layout.template_image(tex, "image", tex.image_user)
600
601
602 def texture_filter_common(tex, layout):
603     layout.label(text="Filter:")
604     layout.prop(tex, "filter", text="")
605     if tex.mipmap and tex.filter in ('AREA', 'EWA', 'FELINE'):
606         if tex.filter == 'FELINE':
607             layout.prop(tex, "filter_probes", text="Probes")
608         else:
609             layout.prop(tex, "filter_eccentricity", text="Eccentricity")
610
611     layout.prop(tex, "filter_size")
612     layout.prop(tex, "filter_size_minimum")
613
614
615 class TEXTURE_PT_image_sampling(TextureTypePanel):
616     bl_label = "Image Sampling"
617     bl_default_closed = True
618     tex_type = 'IMAGE'
619
620     def draw(self, context):
621         layout = self.layout
622
623         tex = context.texture
624         # slot = context.texture_slot
625         wide_ui = context.region.width > narrowui
626
627         split = layout.split()
628
629         col = split.column()
630         col.label(text="Alpha:")
631         col.prop(tex, "use_alpha", text="Use")
632         col.prop(tex, "calculate_alpha", text="Calculate")
633         col.prop(tex, "invert_alpha", text="Invert")
634         col.separator()
635         col.prop(tex, "flip_axis", text="Flip X/Y Axis")
636
637         if wide_ui:
638             col = split.column()
639         else:
640             col.separator()
641         col.prop(tex, "normal_map")
642         row = col.row()
643         row.active = tex.normal_map
644         row.prop(tex, "normal_space", text="")
645
646         col.prop(tex, "mipmap")
647         row = col.row()
648         row.active = tex.mipmap
649         row.prop(tex, "mipmap_gauss")
650         col.prop(tex, "interpolation")
651
652         texture_filter_common(tex, col)
653
654
655 class TEXTURE_PT_image_mapping(TextureTypePanel):
656     bl_label = "Image Mapping"
657     bl_default_closed = True
658     tex_type = 'IMAGE'
659
660     def draw(self, context):
661         layout = self.layout
662
663         tex = context.texture
664         wide_ui = context.region.width > narrowui
665
666         if wide_ui:
667             layout.prop(tex, "extension")
668         else:
669             layout.prop(tex, "extension", text="")
670
671         split = layout.split()
672
673         if tex.extension == 'REPEAT':
674             col = split.column(align=True)
675             col.label(text="Repeat:")
676             col.prop(tex, "repeat_x", text="X")
677             col.prop(tex, "repeat_y", text="Y")
678
679             if wide_ui:
680                 col = split.column(align=True)
681             col.label(text="Mirror:")
682             col.prop(tex, "mirror_x", text="X")
683             col.prop(tex, "mirror_y", text="Y")
684             layout.separator()
685
686         elif tex.extension == 'CHECKER':
687             col = split.column(align=True)
688             row = col.row()
689             row.prop(tex, "checker_even", text="Even")
690             row.prop(tex, "checker_odd", text="Odd")
691
692             if wide_ui:
693                 col = split.column()
694             col.prop(tex, "checker_distance", text="Distance")
695
696             layout.separator()
697
698         split = layout.split()
699
700         col = split.column(align=True)
701         #col.prop(tex, "crop_rectangle")
702         col.label(text="Crop Minimum:")
703         col.prop(tex, "crop_min_x", text="X")
704         col.prop(tex, "crop_min_y", text="Y")
705
706         if wide_ui:
707             col = split.column(align=True)
708         col.label(text="Crop Maximum:")
709         col.prop(tex, "crop_max_x", text="X")
710         col.prop(tex, "crop_max_y", text="Y")
711
712
713 class TEXTURE_PT_plugin(TextureTypePanel):
714     bl_label = "Plugin"
715     tex_type = 'PLUGIN'
716
717     def draw(self, context):
718         layout = self.layout
719
720         # tex = context.texture
721
722         layout.label(text="Nothing yet")
723
724
725 class TEXTURE_PT_envmap(TextureTypePanel):
726     bl_label = "Environment Map"
727     tex_type = 'ENVIRONMENT_MAP'
728
729     def draw(self, context):
730         layout = self.layout
731
732         tex = context.texture
733         env = tex.environment_map
734
735         wide_ui = context.region.width > narrowui
736
737         row = layout.row()
738         row.prop(env, "source", expand=True)
739         row.menu("TEXTURE_MT_envmap_specials", icon='DOWNARROW_HLT', text="")
740
741         if env.source == 'IMAGE_FILE':
742             layout.template_ID(tex, "image", open="image.open")
743             layout.template_image(tex, "image", tex.image_user, compact=True)
744         else:
745             layout.prop(env, "mapping")
746             if env.mapping == 'PLANE':
747                 layout.prop(env, "zoom")
748             layout.prop(env, "viewpoint_object")
749
750             split = layout.split()
751
752             col = split.column()
753             col.prop(env, "ignore_layers")
754             col.prop(env, "resolution")
755             col.prop(env, "depth")
756
757             if wide_ui:
758                 col = split.column(align=True)
759
760             col.label(text="Clipping:")
761             col.prop(env, "clip_start", text="Start")
762             col.prop(env, "clip_end", text="End")
763
764
765 class TEXTURE_PT_envmap_sampling(TextureTypePanel):
766     bl_label = "Environment Map Sampling"
767     bl_default_closed = True
768     tex_type = 'ENVIRONMENT_MAP'
769
770     def draw(self, context):
771         layout = self.layout
772
773         tex = context.texture
774
775         texture_filter_common(tex, layout)
776
777
778 class TEXTURE_PT_musgrave(TextureTypePanel):
779     bl_label = "Musgrave"
780     tex_type = 'MUSGRAVE'
781
782     def draw(self, context):
783         layout = self.layout
784
785         tex = context.texture
786         wide_ui = context.region.width > narrowui
787
788         if wide_ui:
789             layout.prop(tex, "musgrave_type")
790         else:
791             layout.prop(tex, "musgrave_type", text="")
792
793         split = layout.split()
794
795         col = split.column()
796         col.prop(tex, "highest_dimension", text="Dimension")
797         col.prop(tex, "lacunarity")
798         col.prop(tex, "octaves")
799
800         if wide_ui:
801             col = split.column()
802         if (tex.musgrave_type in ('HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
803             col.prop(tex, "offset")
804         if (tex.musgrave_type in ('RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL')):
805             col.prop(tex, "gain")
806             col.prop(tex, "noise_intensity", text="Intensity")
807
808         layout.label(text="Noise:")
809
810         if wide_ui:
811             layout.prop(tex, "noise_basis", text="Basis")
812         else:
813             layout.prop(tex, "noise_basis", text="")
814
815         split = layout.split()
816
817         col = split.column()
818         col.prop(tex, "noise_size", text="Size")
819
820         if wide_ui:
821             col = split.column()
822         col.prop(tex, "nabla")
823
824
825 class TEXTURE_PT_voronoi(TextureTypePanel):
826     bl_label = "Voronoi"
827     tex_type = 'VORONOI'
828
829     def draw(self, context):
830         layout = self.layout
831
832         tex = context.texture
833         wide_ui = context.region.width > narrowui
834
835         split = layout.split()
836
837         col = split.column()
838         col.label(text="Distance Metric:")
839         col.prop(tex, "distance_metric", text="")
840         sub = col.column()
841         sub.active = tex.distance_metric == 'MINKOVSKY'
842         sub.prop(tex, "minkovsky_exponent", text="Exponent")
843         col.label(text="Coloring:")
844         col.prop(tex, "coloring", text="")
845         col.prop(tex, "noise_intensity", text="Intensity")
846
847         if wide_ui:
848             col = split.column()
849         sub = col.column(align=True)
850         sub.label(text="Feature Weights:")
851         sub.prop(tex, "weight_1", text="1", slider=True)
852         sub.prop(tex, "weight_2", text="2", slider=True)
853         sub.prop(tex, "weight_3", text="3", slider=True)
854         sub.prop(tex, "weight_4", text="4", slider=True)
855
856         layout.label(text="Noise:")
857
858         split = layout.split()
859
860         col = split.column()
861         col.prop(tex, "noise_size", text="Size")
862
863         if wide_ui:
864             col = split.column()
865         col.prop(tex, "nabla")
866
867
868 class TEXTURE_PT_distortednoise(TextureTypePanel):
869     bl_label = "Distorted Noise"
870     tex_type = 'DISTORTED_NOISE'
871
872     def draw(self, context):
873         layout = self.layout
874
875         tex = context.texture
876         wide_ui = context.region.width > narrowui
877
878         if wide_ui:
879             layout.prop(tex, "noise_distortion")
880             layout.prop(tex, "noise_basis", text="Basis")
881         else:
882             layout.prop(tex, "noise_distortion", text="")
883             layout.prop(tex, "noise_basis", text="")
884
885         split = layout.split()
886
887         col = split.column()
888         col.prop(tex, "distortion", text="Distortion")
889         col.prop(tex, "noise_size", text="Size")
890
891         if wide_ui:
892             col = split.column()
893         col.prop(tex, "nabla")
894
895
896 class TEXTURE_PT_voxeldata(TextureButtonsPanel):
897     bl_label = "Voxel Data"
898
899     def poll(self, context):
900         tex = context.texture
901         return (tex and tex.type == 'VOXEL_DATA')
902
903     def draw(self, context):
904         layout = self.layout
905
906         tex = context.texture
907         vd = tex.voxeldata
908
909         layout.prop(vd, "file_format")
910         if vd.file_format in ['BLENDER_VOXEL', 'RAW_8BIT']:
911             layout.prop(vd, "source_path")
912         if vd.file_format == 'RAW_8BIT':
913             layout.prop(vd, "resolution")
914         elif vd.file_format == 'SMOKE':
915             layout.prop(vd, "domain_object")
916             layout.prop(vd, "smoke_data_type")
917         elif vd.file_format == 'IMAGE_SEQUENCE':
918             layout.template_image(tex, "image", tex.image_user)
919
920         layout.prop(vd, "still")
921         row = layout.row()
922         row.active = vd.still
923         row.prop(vd, "still_frame_number")
924
925         layout.prop(vd, "interpolation")
926         layout.prop(vd, "extension")
927         layout.prop(vd, "intensity")
928
929
930 class TEXTURE_PT_pointdensity(TextureButtonsPanel):
931     bl_label = "Point Density"
932
933     def poll(self, context):
934         tex = context.texture
935         return (tex and tex.type == 'POINT_DENSITY')
936
937     def draw(self, context):
938         layout = self.layout
939
940         tex = context.texture
941         pd = tex.pointdensity
942         wide_ui = context.region.width > narrowui
943
944         if wide_ui:
945             layout.prop(pd, "point_source", expand=True)
946         else:
947             layout.prop(pd, "point_source", text="")
948
949         split = layout.split()
950
951         col = split.column()
952         if pd.point_source == 'PARTICLE_SYSTEM':
953             col.label(text="Object:")
954             col.prop(pd, "object", text="")
955
956             sub = col.column()
957             sub.enabled = bool(pd.object)
958             if pd.object:
959                 sub.label(text="System:")
960                 sub.prop_object(pd, "particle_system", pd.object, "particle_systems", text="")
961             sub.label(text="Cache:")
962             sub.prop(pd, "particle_cache", text="")
963         else:
964             col.label(text="Object:")
965             col.prop(pd, "object", text="")
966             col.label(text="Cache:")
967             col.prop(pd, "vertices_cache", text="")
968
969         col.separator()
970
971         col.label(text="Color Source:")
972         col.prop(pd, "color_source", text="")
973         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_VELOCITY'):
974             col.prop(pd, "speed_scale")
975         if pd.color_source in ('PARTICLE_SPEED', 'PARTICLE_AGE'):
976             layout.template_color_ramp(pd, "color_ramp", expand=True)
977
978         if wide_ui:
979             col = split.column()
980         col.label()
981         col.prop(pd, "radius")
982         col.label(text="Falloff:")
983         col.prop(pd, "falloff", text="")
984         if pd.falloff == 'SOFT':
985             col.prop(pd, "falloff_softness")
986
987
988 class TEXTURE_PT_pointdensity_turbulence(TextureButtonsPanel):
989     bl_label = "Turbulence"
990
991     def poll(self, context):
992         tex = context.texture
993         return (tex and tex.type == 'POINT_DENSITY')
994
995     def draw_header(self, context):
996         layout = self.layout
997
998         tex = context.texture
999         pd = tex.pointdensity
1000
1001         layout.prop(pd, "turbulence", text="")
1002
1003     def draw(self, context):
1004         layout = self.layout
1005
1006         tex = context.texture
1007         pd = tex.pointdensity
1008         layout.active = pd.turbulence
1009         wide_ui = context.region.width > narrowui
1010
1011         split = layout.split()
1012
1013         col = split.column()
1014         col.label(text="Influence:")
1015         col.prop(pd, "turbulence_influence", text="")
1016         col.label(text="Noise Basis:")
1017         col.prop(pd, "noise_basis", text="")
1018
1019         if wide_ui:
1020             col = split.column()
1021             col.label()
1022         col.prop(pd, "turbulence_size")
1023         col.prop(pd, "turbulence_depth")
1024         col.prop(pd, "turbulence_strength")
1025
1026
1027 classes = [
1028     TEXTURE_MT_specials,
1029     TEXTURE_MT_envmap_specials,
1030
1031     TEXTURE_PT_context_texture,
1032     TEXTURE_PT_preview,
1033
1034     TEXTURE_PT_clouds, # Texture Type Panels
1035     TEXTURE_PT_wood,
1036     TEXTURE_PT_marble,
1037     TEXTURE_PT_magic,
1038     TEXTURE_PT_blend,
1039     TEXTURE_PT_stucci,
1040     TEXTURE_PT_image,
1041     TEXTURE_PT_image_sampling,
1042     TEXTURE_PT_image_mapping,
1043     TEXTURE_PT_plugin,
1044     TEXTURE_PT_envmap,
1045     TEXTURE_PT_envmap_sampling,
1046     TEXTURE_PT_musgrave,
1047     TEXTURE_PT_voronoi,
1048     TEXTURE_PT_distortednoise,
1049     TEXTURE_PT_voxeldata,
1050     TEXTURE_PT_pointdensity,
1051     TEXTURE_PT_pointdensity_turbulence,
1052
1053     TEXTURE_PT_colors,
1054     TEXTURE_PT_mapping,
1055     TEXTURE_PT_influence,
1056
1057     TEXTURE_PT_custom_props]
1058
1059
1060 def register():
1061     register = bpy.types.register
1062     for cls in classes:
1063         register(cls)
1064
1065
1066 def unregister():
1067     unregister = bpy.types.unregister
1068     for cls in classes:
1069         unregister(cls)
1070
1071 if __name__ == "__main__":
1072     register()