Industry Compat keymap: Fix paint mode context menus
[blender.git] / release / scripts / startup / bl_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
21 import bpy
22 from bpy.types import (
23     Menu,
24     Panel,
25     UIList,
26 )
27 from bpy.types import (
28     Brush,
29     FreestyleLineStyle,
30     ParticleSettings,
31     Texture,
32 )
33
34 from rna_prop_ui import PropertyPanel
35 from bl_ui.properties_paint_common import brush_texture_settings
36
37
38 class TEXTURE_MT_context_menu(Menu):
39     bl_label = "Texture Specials"
40     COMPAT_ENGINES = {'BLENDER_RENDER'}
41
42     def draw(self, _context):
43         layout = self.layout
44
45         layout.operator("texture.slot_copy", icon='COPYDOWN')
46         layout.operator("texture.slot_paste", icon='PASTEDOWN')
47
48
49 class TEXTURE_UL_texslots(UIList):
50
51     def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
52         slot = item
53         tex = slot.texture if slot else None
54
55         if self.layout_type in {'DEFAULT', 'COMPACT'}:
56             if tex:
57                 layout.prop(tex, "name", text="", emboss=False, icon_value=icon)
58             else:
59                 layout.label(text="", icon_value=icon)
60         elif self.layout_type == 'GRID':
61             layout.alignment = 'CENTER'
62             layout.label(text="", icon_value=icon)
63
64
65 def context_tex_datablock(context):
66     idblock = context.brush
67     if idblock:
68         return idblock
69
70     idblock = context.line_style
71     if idblock:
72         return idblock
73
74     if context.particle_system:
75         idblock = context.particle_system.settings
76
77     return idblock
78
79
80 class TextureButtonsPanel:
81     bl_space_type = 'PROPERTIES'
82     bl_region_type = 'WINDOW'
83     bl_context = "texture"
84
85
86 class TEXTURE_PT_preview(TextureButtonsPanel, Panel):
87     bl_label = "Preview"
88     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
89
90     @classmethod
91     def poll(cls, context):
92         tex = context.texture
93         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
94
95     def draw(self, context):
96         layout = self.layout
97
98         tex = context.texture
99         slot = getattr(context, "texture_slot", None)
100         idblock = context_tex_datablock(context)
101
102         if idblock:
103             layout.template_preview(tex, parent=idblock, slot=slot)
104         else:
105             layout.template_preview(tex, slot=slot)
106
107         # Show Alpha Button for Brush Textures, see #29502
108         idblock = context_tex_datablock(context)
109         if isinstance(idblock, Brush):
110             layout.prop(tex, "use_preview_alpha")
111
112
113 class TEXTURE_PT_context(TextureButtonsPanel, Panel):
114     bl_label = ""
115     bl_context = "texture"
116     bl_options = {'HIDE_HEADER'}
117     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
118
119     def draw(self, context):
120         layout = self.layout
121
122         tex = context.texture
123         space = context.space_data
124         pin_id = space.pin_id
125         use_pin_id = space.use_pin_id
126         user = context.texture_user
127
128         col = layout.column()
129
130         if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
131             pin_id = None
132
133         if not pin_id:
134             col.template_texture_user()
135
136         if user or pin_id:
137             col.separator()
138
139             if pin_id:
140                 col.template_ID(space, "pin_id")
141             else:
142                 propname = context.texture_user_property.identifier
143                 col.template_ID(user, propname, new="texture.new")
144
145             if tex:
146                 col.separator()
147
148                 split = col.split(factor=0.2)
149                 split.label(text="Type")
150                 split.prop(tex, "type", text="")
151
152
153 class TEXTURE_PT_node(TextureButtonsPanel, Panel):
154     bl_label = "Node"
155     bl_context = "texture"
156     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
157
158     @classmethod
159     def poll(cls, context):
160         node = context.texture_node
161         return node and (context.engine in cls.COMPAT_ENGINES)
162
163     def draw(self, context):
164         layout = self.layout
165
166         node = context.texture_node
167         ntree = node.id_data
168         layout.template_node_view(ntree, node, None)
169
170
171 class TextureTypePanel(TextureButtonsPanel):
172
173     @classmethod
174     def poll(cls, context):
175         tex = context.texture
176         engine = context.engine
177         return tex and ((tex.type == cls.tex_type and not tex.use_nodes) and (engine in cls.COMPAT_ENGINES))
178
179
180 class TEXTURE_PT_clouds(TextureTypePanel, Panel):
181     bl_label = "Clouds"
182     tex_type = 'CLOUDS'
183     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
184
185     def draw(self, context):
186         layout = self.layout
187         layout.use_property_split = True
188         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
189
190         tex = context.texture
191
192         col = flow.column()
193         col.prop(tex, "noise_basis", text="Noise Basis")
194
195         col.separator()
196
197         col.prop(tex, "noise_type", text="Type")
198
199         col.separator()
200
201         col = flow.column()
202         col.prop(tex, "cloud_type")
203
204         col.separator()
205
206         col = flow.column()
207         col.prop(tex, "noise_scale", text="Size")
208         col.prop(tex, "noise_depth", text="Depth")
209         col.prop(tex, "nabla", text="Nabla")
210
211
212 class TEXTURE_PT_wood(TextureTypePanel, Panel):
213     bl_label = "Wood"
214     tex_type = 'WOOD'
215     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
216
217     def draw(self, context):
218         layout = self.layout
219         layout.use_property_split = True
220         flow = layout.grid_flow(row_major=True, columns=0, even_columns=False, even_rows=False, align=False)
221
222         tex = context.texture
223
224         col = flow.column()
225         col.prop(tex, "noise_basis", text="Noise Basis")
226
227         col.separator()
228
229         col.prop(tex, "wood_type")
230
231         col.separator()
232
233         col = flow.column()
234         col.prop(tex, "noise_basis_2", text="Second Basis")
235
236         col = col.column()
237         col.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
238         col.prop(tex, "noise_type", text="Type")
239
240         col.separator()
241
242         sub = flow.column()
243         sub.active = tex.wood_type in {'RINGNOISE', 'BANDNOISE'}
244         sub.prop(tex, "noise_scale", text="Size")
245         sub.prop(tex, "turbulence")
246         sub.prop(tex, "nabla")
247
248
249 class TEXTURE_PT_marble(TextureTypePanel, Panel):
250     bl_label = "Marble"
251     tex_type = 'MARBLE'
252     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
253
254     def draw(self, context):
255         layout = self.layout
256         layout.use_property_split = True
257         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
258
259         tex = context.texture
260
261         col = flow.column()
262         col.prop(tex, "noise_basis", text="Noise Basis")
263
264         col.separator()
265
266         col.prop(tex, "marble_type")
267
268         col.separator()
269
270         col = flow.column()
271         col.prop(tex, "noise_basis_2", text="Second Basis")
272         col.prop(tex, "noise_type", text="Type")
273
274         col.separator()
275
276         col = flow.column()
277         col.prop(tex, "noise_scale", text="Size")
278         col.prop(tex, "noise_depth", text="Depth")
279         col.prop(tex, "turbulence")
280         col.prop(tex, "nabla")
281
282
283 class TEXTURE_PT_magic(TextureTypePanel, Panel):
284     bl_label = "Magic"
285     tex_type = 'MAGIC'
286     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
287
288     def draw(self, context):
289         layout = self.layout
290         layout.use_property_split = True
291         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
292
293         tex = context.texture
294
295         col = flow.column()
296         col.prop(tex, "noise_depth", text="Depth")
297
298         col = flow.column()
299         col.prop(tex, "turbulence")
300
301
302 class TEXTURE_PT_blend(TextureTypePanel, Panel):
303     bl_label = "Blend"
304     tex_type = 'BLEND'
305     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
306
307     def draw(self, context):
308         layout = self.layout
309         layout.use_property_split = True
310         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
311
312         tex = context.texture
313
314         col = flow.column()
315         col.prop(tex, "progression")
316
317         col.separator()
318
319         col = flow.column()
320         col.active = (tex.progression in {'LINEAR', 'QUADRATIC', 'EASING', 'RADIAL'})
321         col.prop(tex, "use_flip_axis", text="Orientation")
322
323
324 class TEXTURE_PT_stucci(TextureTypePanel, Panel):
325     bl_label = "Stucci"
326     tex_type = 'STUCCI'
327     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
328
329     def draw(self, context):
330         layout = self.layout
331         layout.use_property_split = True
332         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
333
334         tex = context.texture
335
336         col = flow.column()
337         col.prop(tex, "noise_basis", text="Noise Basis")
338
339         col.separator()
340
341         col.row().prop(tex, "stucci_type")
342
343         col.separator()
344
345         col = flow.column()
346         col.prop(tex, "noise_type", text="Type")
347
348         col.separator()
349
350         col = flow.column()
351         col.prop(tex, "noise_scale", text="Size")
352         col.prop(tex, "turbulence")
353
354
355 class TEXTURE_PT_image(TextureTypePanel, Panel):
356     bl_label = "Image"
357     tex_type = 'IMAGE'
358     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
359
360     def draw(self, _context):
361         # TODO: maybe expose the template_ID from the template image here.
362         layout = self.layout
363         del layout
364
365
366 class TEXTURE_PT_image_settings(TextureTypePanel, Panel):
367     bl_label = "Settings"
368     bl_parent_id = 'TEXTURE_PT_image'
369     tex_type = 'IMAGE'
370     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
371
372     def draw(self, context):
373         layout = self.layout
374
375         tex = context.texture
376         layout.template_image(tex, "image", tex.image_user)
377
378
379 def texture_filter_common(tex, layout):
380     layout.prop(tex, "filter_type", text="Filter Type")
381
382     if tex.use_mipmap and tex.filter_type in {'AREA', 'EWA', 'FELINE'}:
383         col = layout.column()
384         if tex.filter_type == 'FELINE':
385             col.prop(tex, "filter_lightprobes", text="Light Probes")
386         else:
387             col.prop(tex, "filter_eccentricity", text="Eccentricity")
388
389     layout.prop(tex, "filter_size", text="Size")
390     layout.prop(tex, "use_filter_size_min", text="Minimum Size")
391
392
393 class TEXTURE_PT_image_sampling(TextureTypePanel, Panel):
394     bl_label = "Sampling"
395     bl_options = {'DEFAULT_CLOSED'}
396     bl_parent_id = 'TEXTURE_PT_image'
397     tex_type = 'IMAGE'
398     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
399
400     def draw(self, context):
401         layout = self.layout
402         layout.use_property_split = True
403         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
404
405         tex = context.texture
406
407         col = flow.column()
408         col.prop(tex, "use_interpolation")
409
410         col.separator()
411
412         col = flow.column()
413         col.prop(tex, "use_mipmap")
414         sub = col.column()
415         sub.active = tex.use_mipmap
416         sub.prop(tex, "use_mipmap_gauss", text="Gaussian Filter")
417
418         col.separator()
419
420         texture_filter_common(tex, flow)
421
422
423 class TEXTURE_PT_image_alpha(TextureTypePanel, Panel):
424     bl_label = "Alpha"
425     bl_options = {'DEFAULT_CLOSED'}
426     bl_parent_id = 'TEXTURE_PT_image'
427     tex_type = 'IMAGE'
428     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
429
430     def draw_header(self, context):
431         tex = context.texture
432         self.layout.prop(tex, "use_alpha", text="")
433
434     def draw(self, context):
435         layout = self.layout
436         layout.use_property_split = True
437
438         tex = context.texture
439
440         col = layout.column()
441         col.active = bool(tex.image and tex.image.alpha_mode != 'NONE')
442         col.prop(tex, "use_calculate_alpha", text="Calculate")
443         col.prop(tex, "invert_alpha", text="Invert")
444
445
446 class TEXTURE_PT_image_mapping(TextureTypePanel, Panel):
447     bl_label = "Mapping"
448     bl_options = {'DEFAULT_CLOSED'}
449     bl_parent_id = 'TEXTURE_PT_image'
450     tex_type = 'IMAGE'
451     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
452
453     def draw(self, context):
454         layout = self.layout
455         layout.use_property_split = True
456
457         tex = context.texture
458
459         col = layout.column()
460         col.prop(tex, "use_flip_axis", text="Flip Axes")
461
462         col.separator()
463
464         subcol = layout.column()
465         subcol.prop(tex, "extension")  # use layout, to keep the same location in case of button cycling.
466
467         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
468
469         if tex.extension == 'REPEAT':
470
471             col = flow.column()
472             sub = col.column(align=True)
473             sub.prop(tex, "repeat_x", text="Repeat X")
474             sub.prop(tex, "repeat_y", text="Y")
475
476             col = flow.column()
477             sub = col.column()
478             sub.active = (tex.repeat_x > 1)
479             sub.prop(tex, "use_mirror_x", text="Mirror X")
480
481             sub = col.column()
482             sub.active = (tex.repeat_y > 1)
483             sub.prop(tex, "use_mirror_y", text="Y")
484
485         elif tex.extension == 'CHECKER':
486             subcol.separator()
487
488             col = flow.column()
489             col.prop(tex, "checker_distance", text="Distance")
490
491             col = flow.column()
492             col.prop(tex, "use_checker_even", text="Tiles Even")
493             col.prop(tex, "use_checker_odd", text="Odd")
494         else:
495             del flow
496
497
498 class TEXTURE_PT_image_mapping_crop(TextureTypePanel, Panel):
499     bl_label = "Crop"
500     bl_options = {'DEFAULT_CLOSED'}
501     bl_parent_id = 'TEXTURE_PT_image_mapping'
502     tex_type = 'IMAGE'
503     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE'}
504
505     def draw(self, context):
506         layout = self.layout
507         layout.use_property_split = True
508         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
509
510         tex = context.texture
511
512         col = flow.column(align=True)
513         # col.prop(tex, "crop_rectangle")
514         col.prop(tex, "crop_min_x", text="Minimum X")
515         col.prop(tex, "crop_min_y", text="Y")
516
517         col = flow.column(align=True)
518         col.prop(tex, "crop_max_x", text="Maximum X")
519         col.prop(tex, "crop_max_y", text="Y")
520
521
522 class TEXTURE_PT_musgrave(TextureTypePanel, Panel):
523     bl_label = "Musgrave"
524     tex_type = 'MUSGRAVE'
525     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
526
527     def draw(self, context):
528         layout = self.layout
529         layout.use_property_split = True
530         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
531
532         tex = context.texture
533
534         col = flow.column()
535         col.prop(tex, "noise_basis", text="Noise Basis")
536
537         col.separator()
538
539         col.prop(tex, "musgrave_type")
540
541         col.separator()
542
543         col.prop(tex, "noise_scale", text="Size")
544         col.prop(tex, "nabla")
545
546         col.separator()
547
548         col = flow.column()
549         col.prop(tex, "dimension_max", text="Dimension")
550         col.prop(tex, "lacunarity")
551         col.prop(tex, "octaves")
552
553         col.separator()
554
555         musgrave_type = tex.musgrave_type
556
557         col = flow.column()
558
559         if musgrave_type in {'HETERO_TERRAIN', 'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
560             col.prop(tex, "offset")
561         col.prop(tex, "noise_intensity", text="Intensity")
562
563         if musgrave_type in {'RIDGED_MULTIFRACTAL', 'HYBRID_MULTIFRACTAL'}:
564             col.prop(tex, "gain")
565
566
567 class TEXTURE_PT_voronoi(TextureTypePanel, Panel):
568     bl_label = "Voronoi"
569     tex_type = 'VORONOI'
570     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
571
572     def draw(self, context):
573         layout = self.layout
574         layout.use_property_split = True
575         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
576
577         tex = context.texture
578
579         col = flow.column()
580         col.prop(tex, "distance_metric")
581
582         sub = col.column()
583         sub.active = tex.distance_metric == 'MINKOVSKY'
584         sub.prop(tex, "minkovsky_exponent", text="Exponent")
585
586         sub.separator()
587
588         col = flow.column()
589         col.prop(tex, "color_mode")
590         col.prop(tex, "noise_intensity", text="Intensity")
591
592         col.separator()
593
594         col = flow.column()
595         col.prop(tex, "noise_scale", text="Size")
596         col.prop(tex, "nabla")
597
598
599 class TEXTURE_PT_voronoi_feature_weights(TextureTypePanel, Panel):
600     bl_label = "Feature Weights"
601     bl_parent_id = "TEXTURE_PT_voronoi"
602     tex_type = 'VORONOI'
603     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
604
605     def draw(self, context):
606         layout = self.layout
607         layout.use_property_split = True
608         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
609
610         tex = context.texture
611
612         col = flow.column(align=True)
613         col.prop(tex, "weight_1", text="First", slider=True)
614         col.prop(tex, "weight_2", text="Second", slider=True)
615
616         sub = flow.column(align=True)
617         sub.prop(tex, "weight_3", text="Third", slider=True)
618         sub.prop(tex, "weight_4", text="Fourth", slider=True)
619
620
621 class TEXTURE_PT_distortednoise(TextureTypePanel, Panel):
622     bl_label = "Distorted Noise"
623     tex_type = 'DISTORTED_NOISE'
624     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
625
626     def draw(self, context):
627         layout = self.layout
628         layout.use_property_split = True
629         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
630
631         tex = context.texture
632
633         col = flow.column()
634         col.prop(tex, "noise_basis", text="Noise Basis")
635
636         col.separator()
637
638         col.prop(tex, "noise_distortion", text="Distortion")
639
640         col.separator()
641
642         col = flow.column()
643         col.prop(tex, "distortion", text="Amount")
644         col.prop(tex, "noise_scale", text="Size")
645         col.prop(tex, "nabla")
646
647
648 class TextureSlotPanel(TextureButtonsPanel):
649     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
650
651     @classmethod
652     def poll(cls, context):
653         if not hasattr(context, "texture_slot"):
654             return False
655
656         return (context.engine in cls.COMPAT_ENGINES)
657
658
659 class TEXTURE_PT_mapping(TextureSlotPanel, Panel):
660     bl_label = "Mapping"
661     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
662
663     @classmethod
664     def poll(cls, context):
665         idblock = context_tex_datablock(context)
666         if isinstance(idblock, Brush) and not context.sculpt_object:
667             return False
668
669         if not getattr(context, "texture_slot", None):
670             return False
671
672         engine = context.engine
673         return (engine in cls.COMPAT_ENGINES)
674
675     def draw(self, context):
676         layout = self.layout
677         layout.use_property_split = True
678         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
679
680         idblock = context_tex_datablock(context)
681
682         tex = context.texture_slot
683
684         if isinstance(idblock, Brush):
685             if context.sculpt_object or context.image_paint_object:
686                 brush_texture_settings(layout, idblock, context.sculpt_object)
687         else:
688             col = flow.column()
689
690             col.prop(tex, "texture_coords", text="Coordinates")
691
692             # Note: the ORCO case used to call ob.data, "texco_mesh" prop.
693             if tex.texture_coords == 'UV':
694                 ob = context.object
695
696                 if ob and ob.type == 'MESH':
697                     col.prop_search(tex, "uv_layer", ob.data, "uv_layers", text="Map")
698                 else:
699                     col.prop(tex, "uv_layer", text="Map")
700
701             elif tex.texture_coords == 'OBJECT':
702                 col.prop(tex, "object", text="Object")
703
704             col.separator()
705
706             if isinstance(idblock, FreestyleLineStyle):
707                 col = flow.column()
708                 col.prop(tex, "mapping", text="Projection")
709
710                 col.separator()
711
712                 col = flow.column()
713                 col.prop(tex, "mapping_x", text="Mapping X")
714                 col.prop(tex, "mapping_y", text="Y")
715                 col.prop(tex, "mapping_z", text="Z")
716
717                 col.separator()
718
719             col = flow.column(align=True)
720             col.column().prop(tex, "offset")
721
722             col = flow.column(align=True)
723             col.column().prop(tex, "scale")
724
725
726 class TEXTURE_PT_influence(TextureSlotPanel, Panel):
727     bl_label = "Influence"
728     bl_options = {'DEFAULT_CLOSED'}
729     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
730
731     @classmethod
732     def poll(cls, context):
733         idblock = context_tex_datablock(context)
734         if isinstance(idblock, Brush):
735             return False
736
737         if not getattr(context, "texture_slot", None):
738             return False
739
740         engine = context.engine
741         return (engine in cls.COMPAT_ENGINES)
742
743     def draw(self, context):
744         layout = self.layout
745         layout.use_property_split = True
746         flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
747
748         idblock = context_tex_datablock(context)
749         tex = context.texture_slot
750
751         def factor_but(layout, toggle, factor, name):
752             row = layout.row(align=True)
753             row.active = getattr(tex, toggle)
754
755             row.prop(tex, factor, text=name, slider=True)
756             sub = row.row(align=True)
757             sub.prop(tex, toggle, text="")
758             return sub  # XXX, temp. use_map_normal needs to override.
759
760         if isinstance(idblock, ParticleSettings):
761             col = flow.column()
762             factor_but(col, "use_map_time", "time_factor", "General Time")
763             factor_but(col, "use_map_life", "life_factor", "Lifetime")
764             factor_but(col, "use_map_density", "density_factor", "Density")
765             factor_but(col, "use_map_size", "size_factor", "Size")
766
767             col.separator()
768
769             col = flow.column()
770             factor_but(col, "use_map_velocity", "velocity_factor", "Physics Velocity")
771             factor_but(col, "use_map_damp", "damp_factor", "Damp")
772             factor_but(col, "use_map_gravity", "gravity_factor", "Gravity")
773             factor_but(col, "use_map_field", "field_factor", "Force Fields")
774
775             col.separator()
776
777             col = flow.column()
778             factor_but(col, "use_map_length", "length_factor", "Hair Length")
779             factor_but(col, "use_map_clump", "clump_factor", "Clump")
780             factor_but(col, "use_map_twist", "twist_factor", "Twist")
781
782             col = flow.column()
783             factor_but(col, "use_map_kink_amp", "kink_amp_factor", "Kink Amplitude")
784             factor_but(col, "use_map_kink_freq", "kink_freq_factor", "Kink Frequency")
785             factor_but(col, "use_map_rough", "rough_factor", "Rough")
786
787         elif isinstance(idblock, FreestyleLineStyle):
788             col = flow.column()
789             factor_but(col, "use_map_color_diffuse", "diffuse_color_factor", "Color")
790             factor_but(col, "use_map_alpha", "alpha_factor", "Alpha")
791
792         if not isinstance(idblock, ParticleSettings):
793             col = flow.column()
794
795             col.prop(tex, "blend_type", text="Blend")
796
797             # Color is used on gray-scale textures
798             col.prop(tex, "color", text="")
799
800
801 class TextureColorsPoll:
802     @classmethod
803     def poll(cls, context):
804         tex = context.texture
805         return tex and (tex.type != 'NONE' or tex.use_nodes) and (context.engine in cls.COMPAT_ENGINES)
806
807
808 class TEXTURE_PT_colors(TextureButtonsPanel, TextureColorsPoll, Panel):
809     bl_label = "Colors"
810     bl_options = {'DEFAULT_CLOSED'}
811     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
812
813     def draw(self, context):
814         layout = self.layout
815         layout.use_property_split = True
816         flow = layout.grid_flow(row_major=False, columns=0, even_columns=False, even_rows=False, align=False)
817
818         tex = context.texture
819
820         col = flow.column()
821         col.prop(tex, "use_clamp", text="Clamp")
822
823         col = flow.column(align=True)
824         col.prop(tex, "factor_red", text="Multiply R")
825         col.prop(tex, "factor_green", text="G")
826         col.prop(tex, "factor_blue", text="B")
827
828         col.separator()
829
830         col = flow.column()
831         col.prop(tex, "intensity")
832         col.prop(tex, "contrast")
833         col.prop(tex, "saturation")
834
835
836 class TEXTURE_PT_colors_ramp(TextureButtonsPanel, TextureColorsPoll, Panel):
837     bl_label = "Color Ramp"
838     bl_options = {'DEFAULT_CLOSED'}
839     bl_parent_id = 'TEXTURE_PT_colors'
840     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
841
842     def draw_header(self, context):
843         tex = context.texture
844         self.layout.prop(tex, "use_color_ramp", text="")
845
846     def draw(self, context):
847         layout = self.layout
848
849         tex = context.texture
850
851         # Note: TODO after creation of a new texture, the template_color_ramp will be blank.
852         #       Possibly needs to be fixed in the template itself.
853         is_active = bool(tex and tex.use_color_ramp)
854         if is_active:
855             layout.template_color_ramp(tex, "color_ramp", expand=True)
856         else:
857             layout.alignment = 'RIGHT'
858             layout.label(text="Enable the Color Ramp first")
859
860
861 class TEXTURE_PT_custom_props(TextureButtonsPanel, PropertyPanel, Panel):
862     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
863     _context_path = "texture"
864     _property_type = Texture
865
866     @classmethod
867     def poll(cls, context):
868         return context.texture and (context.engine in cls.COMPAT_ENGINES)
869
870
871 classes = (
872     TEXTURE_MT_context_menu,
873     TEXTURE_UL_texslots,
874     TEXTURE_PT_preview,
875     TEXTURE_PT_context,
876     TEXTURE_PT_node,
877     TEXTURE_PT_clouds,
878     TEXTURE_PT_wood,
879     TEXTURE_PT_marble,
880     TEXTURE_PT_magic,
881     TEXTURE_PT_blend,
882     TEXTURE_PT_stucci,
883     TEXTURE_PT_image,
884     TEXTURE_PT_image_settings,
885     TEXTURE_PT_image_alpha,
886     TEXTURE_PT_image_mapping,
887     TEXTURE_PT_image_mapping_crop,
888     TEXTURE_PT_image_sampling,
889     TEXTURE_PT_musgrave,
890     TEXTURE_PT_voronoi,
891     TEXTURE_PT_voronoi_feature_weights,
892     TEXTURE_PT_distortednoise,
893     TEXTURE_PT_influence,
894     TEXTURE_PT_mapping,
895     TEXTURE_PT_colors,
896     TEXTURE_PT_colors_ramp,
897     TEXTURE_PT_custom_props,
898 )
899
900 if __name__ == "__main__":  # only for live edit.
901     from bpy.utils import register_class
902     for cls in classes:
903         register_class(cls)