Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / space_view3d_toolbar.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 bpy.types import Menu, Panel, UIList
22 from .properties_grease_pencil_common import (
23     GreasePencilStrokeEditPanel,
24     GreasePencilStrokeSculptPanel,
25     GreasePencilSculptOptionsPanel,
26     GreasePencilAppearancePanel,
27 )
28 from .properties_paint_common import (
29     UnifiedPaintPanel,
30     brush_texture_settings,
31     brush_texpaint_common,
32     brush_mask_texture_settings,
33 )
34 from bl_operators.presets import PresetMenu
35
36
37 class View3DPanel:
38     bl_space_type = 'PROPERTIES'
39     bl_region_type = 'WINDOW'
40
41
42 # **************** standard tool clusters ******************
43
44 # Keyframing tools
45 def draw_keyframing_tools(context, layout):
46     col = layout.column(align=True)
47     col.label(text="Keyframes:")
48     row = col.row(align=True)
49     row.operator("anim.keyframe_insert_menu", text="Insert")
50     row.operator("anim.keyframe_delete_v3d", text="Remove")
51
52
53 # Used by vertex & weight paint
54 def draw_vpaint_symmetry(layout, vpaint):
55
56     split = layout.split()
57
58     col = split.column()
59     col.alignment = 'RIGHT'
60     col.label(text="Mirror")
61
62     col = split.column()
63     row = col.row(align=True)
64     row.prop(vpaint, "use_symmetry_x", text="X", toggle=True)
65     row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True)
66     row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True)
67
68     col = layout.column()
69     col.use_property_split = True
70     col.use_property_decorate = False
71     col.prop(vpaint, "radial_symmetry", text="Radial")
72
73 # Most of these panels should not be visible in GP edit modes
74
75
76 def is_not_gpencil_edit_mode(context):
77     is_gpmode = (
78         context.active_object and
79         context.active_object.mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
80     )
81     return not is_gpmode
82
83
84 # ********** default tools for editmode_mesh ****************
85
86
87 class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
88     bl_category = "Options"
89     bl_context = ".mesh_edit"  # dot on purpose (access from topbar)
90     bl_label = "Mesh Options"
91     bl_options = {'DEFAULT_CLOSED'}
92
93     @classmethod
94     def poll(cls, context):
95         return context.active_object
96
97     def draw(self, context):
98         layout = self.layout
99
100         layout.use_property_split = True
101         layout.use_property_decorate = False
102
103         ob = context.active_object
104
105         tool_settings = context.tool_settings
106         mesh = ob.data
107
108         col = layout.column(align=True)
109         col.prop(mesh, "use_mirror_x")
110
111         row = col.row(align=True)
112         row.active = ob.data.use_mirror_x
113         row.prop(mesh, "use_mirror_topology")
114
115         layout.prop(tool_settings, "edge_path_live_unwrap")
116         layout.prop(tool_settings, "use_mesh_automerge")
117
118         layout.prop(tool_settings, "double_threshold")
119         layout.prop(tool_settings, "edge_path_mode")
120
121 # ********** default tools for editmode_curve ****************
122
123
124 class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
125     bl_category = "Options"
126     bl_context = ".curve_edit"  # dot on purpose (access from topbar)
127     bl_label = "Curve Stroke"
128
129     def draw(self, context):
130         layout = self.layout
131
132         tool_settings = context.tool_settings
133         cps = tool_settings.curve_paint_settings
134
135         col = layout.column()
136
137         col.prop(cps, "curve_type")
138
139         if cps.curve_type == 'BEZIER':
140             col.label(text="Bezier Options:")
141             col.prop(cps, "error_threshold")
142             col.prop(cps, "fit_method")
143             col.prop(cps, "use_corners_detect")
144
145             col = layout.column()
146             col.active = cps.use_corners_detect
147             col.prop(cps, "corner_angle")
148
149         col.label(text="Pressure Radius:")
150         row = layout.row(align=True)
151         rowsub = row.row(align=True)
152         rowsub.prop(cps, "radius_min", text="Min")
153         rowsub.prop(cps, "radius_max", text="Max")
154
155         row.prop(cps, "use_pressure_radius", text="", icon_only=True)
156
157         col = layout.column()
158         col.label(text="Taper Radius:")
159         row = layout.row(align=True)
160         row.prop(cps, "radius_taper_start", text="Start")
161         row.prop(cps, "radius_taper_end", text="End")
162
163         col = layout.column()
164         col.label(text="Projection Depth:")
165         row = layout.row(align=True)
166         row.prop(cps, "depth_mode", expand=True)
167
168         col = layout.column()
169         if cps.depth_mode == 'SURFACE':
170             col.prop(cps, "surface_offset")
171             col.prop(cps, "use_offset_absolute")
172             col.prop(cps, "use_stroke_endpoints")
173             if cps.use_stroke_endpoints:
174                 colsub = layout.column(align=True)
175                 colsub.prop(cps, "surface_plane", expand=True)
176
177
178 # ********** default tools for editmode_armature ****************
179
180
181 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
182     bl_category = "Options"
183     bl_context = ".armature_edit"  # dot on purpose (access from topbar)
184     bl_label = "Armature Options"
185
186     def draw(self, context):
187         arm = context.active_object.data
188
189         self.layout.prop(arm, "use_mirror_x")
190
191
192 # ********** default tools for pose-mode ****************
193
194 class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
195     bl_category = "Options"
196     bl_context = ".posemode"  # dot on purpose (access from topbar)
197     bl_label = "Pose Options"
198
199     def draw(self, context):
200         arm = context.active_object.data
201
202         self.layout.prop(arm, "use_auto_ik")
203         self.layout.prop(arm, "use_mirror_x")
204
205 # ********** default tools for paint modes ****************
206
207
208 class View3DPaintPanel(UnifiedPaintPanel):
209     bl_space_type = 'PROPERTIES'
210     bl_region_type = 'WINDOW'
211
212
213 # TODO, move to space_view3d.py
214 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
215     bl_context = ".paint_common"  # dot on purpose (access from topbar)
216     bl_label = "Brush"
217
218     @classmethod
219     def poll(cls, context):
220         return cls.paint_settings(context)
221
222     def draw(self, context):
223         layout = self.layout
224
225         toolsettings = context.tool_settings
226         settings = self.paint_settings(context)
227         brush = settings.brush
228
229         if not context.particle_edit_object:
230             col = layout.split().column()
231             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
232
233         # Particle Mode #
234         if context.particle_edit_object:
235             tool = settings.tool
236
237             if tool != 'NONE':
238                 layout.column().prop(settings, "tool")
239                 col = layout.column()
240                 col.prop(brush, "size", slider=True)
241                 if tool == 'ADD':
242                     col.prop(brush, "count")
243
244                     col = layout.column()
245                     col.prop(settings, "use_default_interpolate")
246                     col.prop(brush, "steps", slider=True)
247                     col.prop(settings, "default_key_count", slider=True)
248                 else:
249                     col.prop(brush, "strength", slider=True)
250
251                     if tool == 'LENGTH':
252                         layout.row().prop(brush, "length_mode", expand=True)
253                     elif tool == 'PUFF':
254                         layout.row().prop(brush, "puff_mode", expand=True)
255                         layout.prop(brush, "use_puff_volume")
256
257         # Sculpt Mode #
258
259         elif context.sculpt_object and brush:
260             capabilities = brush.sculpt_capabilities
261
262             col = layout.column()
263
264             col.separator()
265
266             row = col.row(align=True)
267
268             ups = toolsettings.unified_paint_settings
269             if ((ups.use_unified_size and ups.use_locked_size) or
270                     ((not ups.use_unified_size) and brush.use_locked_size)):
271                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
272                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
273             else:
274                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
275                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
276
277             self.prop_unified_size(row, context, brush, "use_pressure_size")
278
279             # strength, use_strength_pressure, and use_strength_attenuation
280             col.separator()
281             row = col.row(align=True)
282
283             if capabilities.has_space_attenuation:
284                 row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
285
286             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
287
288             if capabilities.has_strength_pressure:
289                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
290
291             # auto_smooth_factor and use_inverse_smooth_pressure
292             if capabilities.has_auto_smooth:
293                 col.separator()
294
295                 row = col.row(align=True)
296                 row.prop(brush, "auto_smooth_factor", slider=True)
297                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
298
299             # normal_weight
300             if capabilities.has_normal_weight:
301                 col.separator()
302                 row = col.row(align=True)
303                 row.prop(brush, "normal_weight", slider=True)
304
305             # crease_pinch_factor
306             if capabilities.has_pinch_factor:
307                 col.separator()
308                 row = col.row(align=True)
309                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
310
311             # rake_factor
312             if capabilities.has_rake_factor:
313                 col.separator()
314                 row = col.row(align=True)
315                 row.prop(brush, "rake_factor", slider=True)
316
317             # use_original_normal and sculpt_plane
318             if capabilities.has_sculpt_plane:
319                 col.separator()
320                 row = col.row(align=True)
321
322                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
323
324                 row.prop(brush, "sculpt_plane", text="")
325
326             if brush.sculpt_tool == 'MASK':
327                 col.prop(brush, "mask_tool", text="")
328
329             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
330             if capabilities.has_plane_offset:
331                 row = col.row(align=True)
332                 row.prop(brush, "plane_offset", slider=True)
333                 row.prop(brush, "use_offset_pressure", text="")
334
335                 col.separator()
336
337                 row = col.row()
338                 row.prop(brush, "use_plane_trim", text="Trim")
339                 row = col.row()
340                 row.active = brush.use_plane_trim
341                 row.prop(brush, "plane_trim", slider=True, text="Distance")
342
343             # height
344             if capabilities.has_height:
345                 row = col.row()
346                 row.prop(brush, "height", slider=True, text="Height")
347
348             # use_frontface
349             col.separator()
350             col.prop(brush, "use_frontface", text="Front Faces Only")
351             col.prop(brush, "use_projected")
352
353             # direction
354             col.separator()
355             col.row().prop(brush, "direction", expand=True)
356
357             # use_accumulate
358             if capabilities.has_accumulate:
359                 col.separator()
360
361                 col.prop(brush, "use_accumulate")
362
363             # use_persistent, set_persistent_base
364             if capabilities.has_persistence:
365                 col.separator()
366
367                 ob = context.sculpt_object
368                 do_persistent = True
369
370                 # not supported yet for this case
371                 for md in ob.modifiers:
372                     if md.type == 'MULTIRES':
373                         do_persistent = False
374                         break
375
376                 if do_persistent:
377                     col.prop(brush, "use_persistent")
378                     col.operator("sculpt.set_persistent_base")
379
380         # Texture Paint Mode #
381
382         elif context.image_paint_object and brush:
383             brush_texpaint_common(self, context, layout, brush, settings, True)
384
385         # Weight Paint Mode #
386         elif context.weight_paint_object and brush:
387
388             col = layout.column()
389
390             row = col.row(align=True)
391             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
392
393             row = col.row(align=True)
394             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
395             self.prop_unified_size(row, context, brush, "use_pressure_size")
396
397             row = col.row(align=True)
398             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
399             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
400
401             col.separator()
402             col.prop(brush, "blend", text="Blend")
403
404             if brush.weight_tool != 'SMEAR':
405                 col.prop(brush, "use_accumulate")
406                 col.separator()
407
408             col.prop(brush, "use_frontface", text="Front Faces Only")
409             row = col.row()
410             row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
411             sub = row.row()
412             sub.active = brush.use_frontface_falloff
413             sub.prop(brush, "falloff_angle", text="")
414
415             col.prop(brush, "use_projected")
416
417             col = layout.column()
418             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
419             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
420
421         # Vertex Paint Mode #
422         elif context.vertex_paint_object and brush:
423             col = layout.column()
424             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
425             if settings.palette:
426                 col.template_palette(settings, "palette", color=True)
427             row = col.row(align=True)
428             self.prop_unified_color(row, context, brush, "color", text="")
429             self.prop_unified_color(row, context, brush, "secondary_color", text="")
430             row.separator()
431             row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
432
433             col.separator()
434             row = col.row(align=True)
435             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
436             self.prop_unified_size(row, context, brush, "use_pressure_size")
437
438             row = col.row(align=True)
439             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
440             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
441
442             col.separator()
443             col.prop(brush, "blend", text="Blend")
444             col.prop(brush, "use_alpha")
445
446             if brush.vertex_tool != 'SMEAR':
447                 col.prop(brush, "use_accumulate")
448                 col.separator()
449
450             col.prop(brush, "use_frontface", text="Front Faces Only")
451             row = col.row()
452             row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
453             sub = row.row()
454             sub.active = brush.use_frontface_falloff
455             sub.prop(brush, "falloff_angle", text="")
456
457             col.prop(brush, "use_projected")
458
459             col.separator()
460             col.template_ID(settings, "palette", new="palette.new")
461
462
463 class TEXTURE_UL_texpaintslots(UIList):
464     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
465         # mat = data
466
467         if self.layout_type in {'DEFAULT', 'COMPACT'}:
468             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
469         elif self.layout_type == 'GRID':
470             layout.alignment = 'CENTER'
471             layout.label(text="")
472
473
474 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
475     bl_label = "Clone Layer"
476
477     def draw(self, context):
478         layout = self.layout
479
480         for i, uv_layer in enumerate(context.active_object.data.uv_layers):
481             props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
482             props.data_path = "active_object.data.uv_layers.active_index"
483             props.value = i
484
485
486 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
487     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
488     bl_label = "Texture Slots"
489
490     @classmethod
491     def poll(cls, context):
492         brush = context.tool_settings.image_paint.brush
493         ob = context.active_object
494         return (brush is not None and ob is not None)
495
496     def draw(self, context):
497         layout = self.layout
498         layout.use_property_split = True
499         layout.use_property_decorate = False
500
501         settings = context.tool_settings.image_paint
502
503         ob = context.active_object
504
505         layout.prop(settings, "mode", text="Mode")
506         layout.separator()
507
508         if settings.mode == 'MATERIAL':
509             if len(ob.material_slots) > 1:
510                 layout.template_list("MATERIAL_UL_matslots", "layers",
511                                      ob, "material_slots",
512                                      ob, "active_material_index", rows=2)
513             mat = ob.active_material
514             if mat and mat.texture_paint_images:
515                 row = layout.row()
516                 row.template_list("TEXTURE_UL_texpaintslots", "",
517                                   mat, "texture_paint_images",
518                                   mat, "paint_active_slot", rows=2)
519
520                 if mat.texture_paint_slots:
521                     slot = mat.texture_paint_slots[mat.paint_active_slot]
522                 else:
523                     slot = None
524
525                 have_image = slot is not None
526             else:
527                 row = layout.row()
528
529                 box = row.box()
530                 box.label(text="No Textures")
531                 have_image = False
532
533             sub = row.column(align=True)
534             sub.operator_menu_enum("paint.add_texture_paint_slot", "type", icon='ADD', text="")
535
536         elif settings.mode == 'IMAGE':
537             mesh = ob.data
538             uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else ""
539             layout.template_ID(settings, "canvas", new="image.new", open="image.open")
540             if settings.missing_uvs:
541                 layout.operator("paint.add_simple_uvs", icon='ADD', text="Add UVs")
542             else:
543                 layout.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
544             have_image = settings.canvas is not None
545
546         if settings.missing_uvs:
547             layout.separator()
548             split = layout.split()
549             split.label(text="UV Map Needed", icon='INFO')
550             split.operator("paint.add_simple_uvs", icon='ADD', text="Add Simple UVs")
551         elif have_image:
552             layout.separator()
553             layout.operator("image.save_dirty", text="Save All Images", icon='FILE_TICK')
554
555 # TODO, move to space_view3d.py
556
557
558 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
559     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
560     bl_label = "Mask"
561     bl_options = {'DEFAULT_CLOSED'}
562
563     @classmethod
564     def poll(cls, context):
565         brush = context.tool_settings.image_paint.brush
566         ob = context.active_object
567         return (brush is not None and ob is not None)
568
569     def draw_header(self, context):
570         ipaint = context.tool_settings.image_paint
571         self.layout.prop(ipaint, "use_stencil_layer", text="")
572
573     def draw(self, context):
574         layout = self.layout
575         layout.use_property_split = True
576         layout.use_property_decorate = False
577
578         toolsettings = context.tool_settings
579         ipaint = toolsettings.image_paint
580         ob = context.active_object
581         mesh = ob.data
582
583         col = layout.column()
584         col.active = ipaint.use_stencil_layer
585
586         stencil_text = mesh.uv_layer_stencil.name if mesh.uv_layer_stencil else ""
587         split = col.split(factor=0.5)
588         colsub = split.column()
589         colsub.alignment = 'RIGHT'
590         colsub.label(text="UV Layer")
591         split.column().menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
592
593         # todo this should be combinded into a single row
594         split = col.split(factor=0.5)
595         colsub = split.column()
596         colsub.alignment = 'RIGHT'
597         colsub.label(text="Stencil Image")
598         colsub = split.column()
599         colsub.template_ID(ipaint, "stencil_image", new="image.new", open="image.open")
600
601         row = col.row(align=True)
602         row.prop(ipaint, "stencil_color", text="Display Color")
603         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
604
605
606 # TODO, move to space_view3d.py
607 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
608     bl_context = ".paint_common"  # dot on purpose (access from topbar)
609     bl_label = "Overlay"
610     bl_options = {'DEFAULT_CLOSED'}
611
612     @classmethod
613     def poll(cls, context):
614         settings = cls.paint_settings(context)
615         return (settings and
616                 settings.brush and
617                 (context.sculpt_object or
618                  context.vertex_paint_object or
619                  context.weight_paint_object or
620                  context.image_paint_object))
621
622     def draw(self, context):
623         layout = self.layout
624         layout.use_property_split = True
625         layout.use_property_decorate = False
626
627         settings = self.paint_settings(context)
628         brush = settings.brush
629         tex_slot = brush.texture_slot
630         tex_slot_mask = brush.mask_texture_slot
631
632         col = layout.column()
633
634
635         row = col.row(align=True)
636
637         sub = row.row(align=True)
638         sub.prop(brush, "cursor_overlay_alpha", text="Curve Alpha")
639         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
640         row.prop(brush,"use_cursor_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_cursor_overlay else 'HIDE_ON')
641
642         col.active = brush.brush_capabilities.has_overlay
643
644         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
645             row = col.row(align=True)
646
647             sub = row.row(align=True)
648             sub.prop(brush, "texture_overlay_alpha", text="Texture Alpha")
649             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
650             if tex_slot.map_mode != 'STENCIL':
651                 row.prop(brush, "use_primary_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_primary_overlay else 'HIDE_ON')
652
653         if context.image_paint_object:
654             row = col.row(align=True)
655
656             sub = row.row(align=True)
657             sub.prop(brush, "mask_overlay_alpha", text="Mask Texture Alpha")
658             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
659             if tex_slot_mask.map_mode != 'STENCIL':
660                 row.prop(brush, "use_secondary_overlay", text="", toggle=True, icon='HIDE_OFF' if brush.use_secondary_overlay else 'HIDE_ON')
661
662
663 # TODO, move to space_view3d.py
664 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
665     bl_context = ".paint_common"  # dot on purpose (access from topbar)
666     bl_label = "Texture"
667     bl_options = {'DEFAULT_CLOSED'}
668
669     @classmethod
670     def poll(cls, context):
671         settings = cls.paint_settings(context)
672         return (settings and settings.brush and
673                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
674
675     def draw(self, context):
676         layout = self.layout
677
678         settings = self.paint_settings(context)
679         brush = settings.brush
680
681         col = layout.column()
682
683         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
684
685         brush_texture_settings(col, brush, context.sculpt_object)
686
687
688 # TODO, move to space_view3d.py
689 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
690     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
691     bl_label = "Texture Mask"
692     bl_options = {'DEFAULT_CLOSED'}
693
694     @classmethod
695     def poll(cls, context):
696         settings = cls.paint_settings(context)
697         return (settings and settings.brush and context.image_paint_object)
698
699     def draw(self, context):
700         layout = self.layout
701
702         brush = context.tool_settings.image_paint.brush
703
704         col = layout.column()
705
706         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
707
708         brush_mask_texture_settings(col, brush)
709
710
711 # TODO, move to space_view3d.py
712 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
713     bl_context = ".paint_common"  # dot on purpose (access from topbar)
714     bl_label = "Stroke"
715     bl_options = {'DEFAULT_CLOSED'}
716
717     @classmethod
718     def poll(cls, context):
719         settings = cls.paint_settings(context)
720         return (settings and
721                 settings.brush and
722                 (context.sculpt_object or
723                  context.vertex_paint_object or
724                  context.weight_paint_object or
725                  context.image_paint_object))
726
727     def draw(self, context):
728         layout = self.layout
729
730         settings = self.paint_settings(context)
731         brush = settings.brush
732         layout.use_property_split = True
733         layout.use_property_decorate = False
734
735         col = layout.column()
736
737         col.prop(brush, "stroke_method")
738
739         if brush.use_anchor:
740             col.prop(brush, "use_edge_to_edge", text="Edge To Edge")
741
742         if brush.use_airbrush:
743             col.prop(brush, "rate", text="Rate", slider=True)
744
745         if brush.use_space:
746             row = col.row(align=True)
747             row.prop(brush, "spacing", text="Spacing")
748             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
749
750         if brush.use_line or brush.use_curve:
751             row = col.row(align=True)
752             row.prop(brush, "spacing", text="Spacing")
753
754         if brush.use_curve:
755             col.template_ID(brush, "paint_curve", new="paintcurve.new")
756             col.operator("paintcurve.draw")
757
758         if context.sculpt_object:
759             if brush.sculpt_capabilities.has_jitter:
760
761                 row = col.row(align=True)
762                 if brush.use_relative_jitter:
763                     row.prop(brush, "jitter", slider=True)
764                 else:
765                     row.prop(brush, "jitter_absolute")
766                 row.prop(brush, "use_relative_jitter", icon_only=True)
767                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
768
769         else:
770
771             row = col.row(align=True)
772             if brush.use_relative_jitter:
773                 row.prop(brush, "jitter", slider=True)
774             else:
775                 row.prop(brush, "jitter_absolute")
776             row.prop(brush, "use_relative_jitter", icon_only=True)
777             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
778
779             col = layout.column()
780
781         layout.prop(settings, "input_samples")
782
783
784 class VIEW3D_PT_tools_brush_stroke_smooth_stroke(Panel, View3DPaintPanel):
785     bl_context = ".paint_common"  # dot on purpose (access from topbar)
786     bl_label = "Smooth Stroke"
787     bl_parent_id = "VIEW3D_PT_tools_brush_stroke"
788     bl_options = {'DEFAULT_CLOSED'}
789
790     @classmethod
791     def poll(cls, context):
792         settings = cls.paint_settings(context)
793         brush = settings.brush
794         if brush.brush_capabilities.has_smooth_stroke:
795             return True
796
797     def draw_header(self, context):
798         settings = self.paint_settings(context)
799         brush = settings.brush
800
801         self.layout.prop(brush, "use_smooth_stroke", text="")
802
803     def draw(self, context):
804         layout = self.layout
805         layout.use_property_split = True
806         layout.use_property_decorate = False
807
808         settings = self.paint_settings(context)
809         brush = settings.brush
810
811         col = layout.column()
812         col.active = brush.use_smooth_stroke
813         col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
814         col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
815
816
817 # TODO, move to space_view3d.py
818 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
819     bl_context = ".paint_common"  # dot on purpose (access from topbar)
820     bl_label = "Curve"
821     bl_options = {'DEFAULT_CLOSED'}
822
823     @classmethod
824     def poll(cls, context):
825         settings = cls.paint_settings(context)
826         return (settings and settings.brush and settings.brush.curve)
827
828     def draw(self, context):
829         layout = self.layout
830
831         settings = self.paint_settings(context)
832
833         brush = settings.brush
834
835         layout.template_curve_mapping(brush, "curve", brush=True)
836
837         col = layout.column(align=True)
838         row = col.row(align=True)
839         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
840         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
841         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
842         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
843         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
844         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
845
846
847 # TODO, move to space_view3d.py
848 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
849     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
850     bl_label = "Dyntopo"
851     bl_options = {'DEFAULT_CLOSED'}
852     bl_ui_units_x = 12
853
854     @classmethod
855     def poll(cls, context):
856         return (context.sculpt_object and context.tool_settings.sculpt)
857
858     def draw_header(self, context):
859         is_popover = self.is_popover
860         layout = self.layout
861         layout.operator(
862             "sculpt.dynamic_topology_toggle",
863             icon='CHECKBOX_HLT' if context.sculpt_object.use_dynamic_topology_sculpting else 'CHECKBOX_DEHLT',
864             text="",
865             emboss=is_popover,
866         )
867
868     def draw(self, context):
869         layout = self.layout
870         layout.use_property_split = True
871         layout.use_property_decorate = False
872
873         toolsettings = context.tool_settings
874         sculpt = toolsettings.sculpt
875         settings = self.paint_settings(context)
876         brush = settings.brush
877
878         col = layout.column()
879         col.active = context.sculpt_object.use_dynamic_topology_sculpting
880
881         sub = col.column()
882         sub.active = (brush and brush.sculpt_tool != 'MASK')
883         if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
884             row = sub.row(align=True)
885             row.prop(sculpt, "constant_detail_resolution")
886             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
887         elif (sculpt.detail_type_method == 'BRUSH'):
888             sub.prop(sculpt, "detail_percent")
889         else:
890             sub.prop(sculpt, "detail_size")
891         sub.prop(sculpt, "detail_refine_method", text="Refine Method")
892         sub.prop(sculpt, "detail_type_method", text="Detailing")
893
894         col.prop(sculpt, "use_smooth_shading")
895
896
897 class VIEW3D_PT_sculpt_dyntopo_remesh(Panel, View3DPaintPanel):
898     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
899     bl_label = "Remesh"
900     bl_parent_id = "VIEW3D_PT_sculpt_dyntopo"
901     bl_options = {'DEFAULT_CLOSED'}
902     bl_ui_units_x = 12
903
904     def draw(self, context):
905         layout = self.layout
906         layout.use_property_split = True
907         layout.use_property_decorate = False
908
909         toolsettings = context.tool_settings
910         sculpt = toolsettings.sculpt
911
912         col = layout.column()
913         col.active = context.sculpt_object.use_dynamic_topology_sculpting
914
915         col.prop(sculpt, "symmetrize_direction")
916
917         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
918
919         col = flow.column()
920         col.operator("sculpt.symmetrize")
921         col = flow.column()
922         col.operator("sculpt.optimize")
923         if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
924             col = flow.column()
925             col.operator("sculpt.detail_flood_fill")
926
927 # TODO, move to space_view3d.py
928 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
929     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
930     bl_label = "Options"
931     bl_options = {'DEFAULT_CLOSED'}
932
933     @classmethod
934     def poll(cls, context):
935         return (context.sculpt_object and context.tool_settings.sculpt)
936
937     def draw(self, context):
938         layout = self.layout
939         layout.use_property_split = True
940         layout.use_property_decorate = False
941
942         toolsettings = context.tool_settings
943         sculpt = toolsettings.sculpt
944
945         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
946
947         col = flow.column()
948         col.prop(sculpt, "use_threaded", text="Threaded Sculpt")
949         col = flow.column()
950         col.prop(sculpt, "show_low_resolution")
951         col = flow.column()
952         col.prop(sculpt, "use_deform_only")
953         col = flow.column()
954         col.prop(sculpt, "show_diffuse_color")
955         col = flow.column()
956         col.prop(sculpt, "show_mask")
957
958
959 class VIEW3D_PT_sculpt_options_unified(Panel, View3DPaintPanel):
960     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
961     bl_parent_id = "VIEW3D_PT_sculpt_options"
962     bl_label = "Unified Brush"
963
964     @classmethod
965     def poll(cls, context):
966         return (context.sculpt_object and context.tool_settings.sculpt)
967
968     def draw(self, context):
969         layout = self.layout
970         layout.use_property_split = True
971         layout.use_property_decorate = False
972
973         self.unified_paint_settings(layout, context)
974
975 class VIEW3D_PT_sculpt_options_gravity(Panel, View3DPaintPanel):
976     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
977     bl_parent_id = "VIEW3D_PT_sculpt_options"
978     bl_label = "Gravity"
979
980     @classmethod
981     def poll(cls, context):
982         return (context.sculpt_object and context.tool_settings.sculpt)
983
984     def draw(self, context):
985         layout = self.layout
986         layout.use_property_split = True
987         layout.use_property_decorate = False
988
989         toolsettings = context.tool_settings
990         sculpt = toolsettings.sculpt
991         capabilities = sculpt.brush.sculpt_capabilities
992
993         col = layout.column()
994         col.active = capabilities.has_gravity
995         col.prop(sculpt, "gravity", slider=True, text="Factor")
996         col.prop(sculpt, "gravity_object")
997
998
999 # TODO, move to space_view3d.py
1000 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1001     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
1002     bl_label = "Symmetry/Lock"
1003     bl_options = {'DEFAULT_CLOSED'}
1004
1005     @classmethod
1006     def poll(cls, context):
1007         return (context.sculpt_object and context.tool_settings.sculpt)
1008
1009     def draw(self, context):
1010         layout = self.layout
1011
1012         sculpt = context.tool_settings.sculpt
1013
1014         split = layout.split()
1015
1016         col = split.column()
1017         col.alignment = 'RIGHT'
1018         col.label(text="Mirror")
1019
1020         col = split.column()
1021
1022         row = col.row(align=True)
1023         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1024         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1025         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1026
1027         split = layout.split()
1028
1029         col = split.column()
1030         col.alignment = 'RIGHT'
1031         col.label(text="Lock")
1032
1033         col = split.column()
1034
1035         row = col.row(align=True)
1036         row.prop(sculpt, "lock_x", text="X", toggle=True)
1037         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1038         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1039
1040         split = layout.split()
1041
1042         col = split.column()
1043         col.alignment = 'RIGHT'
1044         col.label(text="Tiling")
1045
1046         col = split.column()
1047
1048         row = col.row(align=True)
1049         row.prop(sculpt, "tile_x", text="X", toggle=True)
1050         row.prop(sculpt, "tile_y", text="Y", toggle=True)
1051         row.prop(sculpt, "tile_z", text="Z", toggle=True)
1052
1053         layout.use_property_split = True
1054         layout.use_property_decorate = False
1055
1056         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1057         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1058         layout.column().prop(sculpt, "tile_offset", text="Tile Offset")
1059
1060
1061 # TODO, move to space_view3d.py
1062 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1063     bl_context = ".paint_common"  # dot on purpose (access from topbar)
1064     bl_label = "Appearance"
1065     bl_parent_id = "VIEW3D_PT_tools_brush_overlay"
1066     bl_options = {'DEFAULT_CLOSED'}
1067
1068     @classmethod
1069     def poll(cls, context):
1070         settings = cls.paint_settings(context)
1071         return (settings is not None) and (not isinstance(settings, bpy.types.ParticleEdit))
1072
1073     def draw(self, context):
1074         layout = self.layout
1075
1076         settings = self.paint_settings(context)
1077         brush = settings.brush
1078
1079         if brush is None:  # unlikely but can happen
1080             layout.label(text="Brush Unset")
1081             return
1082
1083
1084 class VIEW3D_PT_tools_brush_appearance_show_brush(Panel, View3DPaintPanel):
1085     bl_context = ".paint_common"  # dot on purpose (access from topbar)
1086     bl_label = "Show Brush"
1087     bl_parent_id = "VIEW3D_PT_tools_brush_appearance"
1088     bl_options = {'DEFAULT_CLOSED'}
1089
1090     def draw_header(self, context):
1091         settings = self.paint_settings(context)
1092
1093         self.layout.prop(settings, "show_brush", text="")
1094
1095     def draw(self, context):
1096         layout = self.layout
1097
1098         layout.use_property_split = True
1099         layout.use_property_decorate = False
1100
1101         settings = self.paint_settings(context)
1102         brush = settings.brush
1103
1104         col = layout.column()
1105         col.active = settings.show_brush
1106
1107         if context.sculpt_object and context.tool_settings.sculpt:
1108             if brush.sculpt_capabilities.has_secondary_color:
1109                 col.prop(brush, "cursor_color_add", text="Add")
1110                 col.prop(brush, "cursor_color_subtract", text="Subtract")
1111             else:
1112                 col.prop(brush, "cursor_color_add", text="Color")
1113         else:
1114             col.prop(brush, "cursor_color_add", text="Color")
1115
1116
1117 class VIEW3D_PT_tools_brush_appearance_custom_icon(Panel, View3DPaintPanel):
1118     bl_context = ".paint_common"  # dot on purpose (access from topbar)
1119     bl_label = "Custom Icon"
1120     bl_parent_id = "VIEW3D_PT_tools_brush_appearance"
1121     bl_options = {'DEFAULT_CLOSED'}
1122
1123     def draw_header(self, context):
1124         settings = self.paint_settings(context)
1125         brush = settings.brush
1126
1127         self.layout.prop(brush, "use_custom_icon", text="")
1128
1129     def draw(self, context):
1130         layout = self.layout
1131
1132         layout.use_property_split = True
1133         layout.use_property_decorate = False
1134
1135         settings = self.paint_settings(context)
1136         brush = settings.brush
1137
1138         col = layout.column()
1139         col.active = brush.use_custom_icon
1140         col.prop(brush, "icon_filepath", text="")
1141
1142 # ********** default tools for weight-paint ****************
1143
1144
1145 # TODO, move to space_view3d.py
1146 class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
1147     bl_context = ".weightpaint"
1148     bl_options = {'DEFAULT_CLOSED'}
1149     bl_label = "Symmetry"
1150
1151     def draw(self, context):
1152         layout = self.layout
1153         toolsettings = context.tool_settings
1154         wpaint = toolsettings.weight_paint
1155         draw_vpaint_symmetry(layout, wpaint)
1156
1157
1158 # TODO, move to space_view3d.py
1159 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1160     bl_context = ".weightpaint"
1161     bl_label = "Options"
1162
1163     def draw(self, context):
1164         layout = self.layout
1165
1166         tool_settings = context.tool_settings
1167         wpaint = tool_settings.weight_paint
1168
1169         col = layout.column()
1170         col.prop(wpaint, "use_group_restrict")
1171
1172         obj = context.weight_paint_object
1173         if obj.type == 'MESH':
1174             mesh = obj.data
1175             col.prop(mesh, "use_mirror_x")
1176             row = col.row()
1177             row.active = mesh.use_mirror_x
1178             row.prop(mesh, "use_mirror_topology")
1179
1180         self.unified_paint_settings(col, context)
1181
1182 # ********** default tools for vertex-paint ****************
1183
1184
1185 # TODO, move to space_view3d.py
1186 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1187     bl_context = ".vertexpaint"  # dot on purpose (access from topbar)
1188     bl_label = "Options"
1189
1190     def draw(self, context):
1191         layout = self.layout
1192
1193         col = layout.column()
1194
1195         self.unified_paint_settings(col, context)
1196
1197
1198 # TODO, move to space_view3d.py
1199 class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
1200     bl_context = ".vertexpaint"  # dot on purpose (access from topbar)
1201     bl_options = {'DEFAULT_CLOSED'}
1202     bl_label = "Symmetry"
1203
1204     def draw(self, context):
1205         layout = self.layout
1206         toolsettings = context.tool_settings
1207         vpaint = toolsettings.vertex_paint
1208         draw_vpaint_symmetry(layout, vpaint)
1209
1210
1211 # ********** default tools for texture-paint ****************
1212
1213
1214 # TODO, move to space_view3d.py
1215 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1216     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1217     bl_label = "External"
1218     bl_options = {'DEFAULT_CLOSED'}
1219
1220     def draw(self, context):
1221         layout = self.layout
1222         layout.use_property_split = True
1223         layout.use_property_decorate = False
1224
1225         toolsettings = context.tool_settings
1226         ipaint = toolsettings.image_paint
1227
1228         layout.prop(ipaint, "screen_grab_size", text="Screen Grab Size")
1229
1230         layout.separator()
1231
1232         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
1233         col = flow.column()
1234         col.operator("image.project_edit", text="Quick Edit")
1235         col = flow.column()
1236         col.operator("image.project_apply", text="Apply")
1237         col = flow.column()
1238         col.operator("paint.project_image", text="Apply Camera Image")
1239
1240
1241 # TODO, move to space_view3d.py
1242 class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
1243     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1244     bl_label = "Symmetry"
1245     bl_options = {'DEFAULT_CLOSED'}
1246
1247     def draw(self, context):
1248         layout = self.layout
1249
1250         toolsettings = context.tool_settings
1251         ipaint = toolsettings.image_paint
1252
1253         split = layout.split()
1254
1255         col = split.column()
1256         col.alignment = 'RIGHT'
1257         col.label(text="Mirror")
1258
1259         col = split.column()
1260
1261         row = col.row(align=True)
1262         row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
1263         row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
1264         row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
1265
1266
1267 # TODO, move to space_view3d.py
1268 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1269     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1270     bl_label = "Project Paint"
1271     bl_options = {'DEFAULT_CLOSED'}
1272
1273     @classmethod
1274     def poll(cls, context):
1275         brush = context.tool_settings.image_paint.brush
1276         return (brush is not None)
1277
1278     def draw(self, context):
1279         layout = self.layout
1280
1281         layout.use_property_split = True
1282         layout.use_property_decorate = False
1283
1284         toolsettings = context.tool_settings
1285         ipaint = toolsettings.image_paint
1286
1287         row = layout.row()
1288         row.prop(ipaint, "use_normal_falloff")
1289
1290         sub = row.row()
1291         sub.active = (ipaint.use_normal_falloff)
1292         sub.prop(ipaint, "normal_angle", text="")
1293
1294         layout.prop(ipaint, "seam_bleed")
1295         layout.prop(ipaint, "dither")
1296
1297         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
1298
1299         col = flow.column()
1300         col.prop(ipaint, "use_occlude")
1301
1302         col = flow.column()
1303         col.prop(ipaint, "use_backface_culling")
1304
1305 class VIEW3D_PT_tools_projectpaint_unified(Panel, View3DPaintPanel):
1306     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1307     bl_parent_id = "VIEW3D_PT_tools_projectpaint"
1308     bl_label = "Unified Brush"
1309
1310     def draw(self, context):
1311         layout = self.layout
1312         layout.use_property_split = True
1313         layout.use_property_decorate = False
1314
1315         self.unified_paint_settings(layout, context)
1316
1317 class VIEW3D_PT_tools_projectpaint_cavity(View3DPaintPanel, Panel):
1318     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1319     bl_label = "Cavity Mask"
1320     bl_parent_id = "VIEW3D_PT_tools_projectpaint"
1321     bl_options = {'DEFAULT_CLOSED'}
1322
1323     def draw_header(self, context):
1324         toolsettings = context.tool_settings
1325         ipaint = toolsettings.image_paint
1326
1327         self.layout.prop(ipaint, "use_cavity", text="")
1328
1329     def draw(self, context):
1330         layout = self.layout
1331
1332         toolsettings = context.tool_settings
1333         ipaint = toolsettings.image_paint
1334
1335         layout.active = ipaint.use_cavity
1336
1337         layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1338
1339
1340 # TODO, move to space_view3d.py
1341 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1342     bl_label = "Options"
1343
1344     @classmethod
1345     def poll(cls, context):
1346         return (context.image_paint_object and context.tool_settings.image_paint)
1347
1348     def draw(self, context):
1349         layout = self.layout
1350
1351         col = layout.column()
1352         self.unified_paint_settings(col, context)
1353
1354
1355 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1356     bl_label = "Mask Layer"
1357
1358     def draw(self, context):
1359         layout = self.layout
1360         for i, uv_layer in enumerate(context.active_object.data.uv_layers):
1361             props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
1362             props.data_path = "active_object.data.uv_layer_stencil_index"
1363             props.value = i
1364
1365
1366 # TODO, move to space_view3d.py
1367 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1368     """Default tools for particle mode"""
1369     bl_context = ".particlemode"
1370     bl_label = "Options"
1371
1372     def draw(self, context):
1373         layout = self.layout
1374
1375         pe = context.tool_settings.particle_edit
1376         ob = pe.object
1377
1378         layout.prop(pe, "type", text="")
1379
1380         ptcache = None
1381
1382         if pe.type == 'PARTICLES':
1383             if ob.particle_systems:
1384                 if len(ob.particle_systems) > 1:
1385                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1386                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1387
1388                 ptcache = ob.particle_systems.active.point_cache
1389         else:
1390             for md in ob.modifiers:
1391                 if md.type == pe.type:
1392                     ptcache = md.point_cache
1393
1394         if ptcache and len(ptcache.point_caches) > 1:
1395             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1396                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1397
1398         if not pe.is_editable:
1399             layout.label(text="Point cache must be baked")
1400             layout.label(text="in memory to enable editing!")
1401
1402         col = layout.column(align=True)
1403         if pe.is_hair:
1404             col.active = pe.is_editable
1405             col.prop(pe, "use_emitter_deflect", text="Deflect Emitter")
1406             sub = col.row(align=True)
1407             sub.active = pe.use_emitter_deflect
1408             sub.prop(pe, "emitter_distance", text="Distance")
1409
1410         col = layout.column(align=True)
1411         col.active = pe.is_editable
1412         col.label(text="Keep:")
1413         col.prop(pe, "use_preserve_length", text="Lengths")
1414         col.prop(pe, "use_preserve_root", text="Root")
1415         if not pe.is_hair:
1416             col.label(text="Correct:")
1417             col.prop(pe, "use_auto_velocity", text="Velocity")
1418         col.prop(ob.data, "use_mirror_x")
1419
1420         col.prop(pe, "shape_object")
1421         col.operator("particle.shape_cut")
1422
1423         col = layout.column(align=True)
1424         col.active = pe.is_editable
1425         col.label(text="Display:")
1426         col.prop(pe, "display_step", text="Path Steps")
1427         if pe.is_hair:
1428             col.prop(pe, "show_particles", text="Children")
1429         else:
1430             if pe.type == 'PARTICLES':
1431                 col.prop(pe, "show_particles", text="Particles")
1432             col.prop(pe, "use_fade_time")
1433             sub = col.row(align=True)
1434             sub.active = pe.use_fade_time
1435             sub.prop(pe, "fade_frames", slider=True)
1436
1437
1438 class VIEW3D_PT_tools_normal(View3DPanel, Panel):
1439     bl_category = ""
1440     bl_context = ".mesh_edit"
1441     bl_label = "Normals"
1442     bl_options = {'DEFAULT_CLOSED'}
1443
1444     def draw(self, context):
1445         layout = self.layout
1446         layout.use_property_split = True
1447         layout.use_property_decorate = False  # No animation.
1448
1449         toolsettings = context.tool_settings
1450
1451         layout.prop(toolsettings, "normal_vector", text="Normal Vector")
1452         layout.prop(toolsettings, "face_strength", text="Face Strength")
1453
1454 # ********** grease pencil object tool panels ****************
1455
1456 # Grease Pencil drawing brushes
1457 class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
1458     bl_context = ".greasepencil_paint"
1459     bl_label = "Brush"
1460
1461     @classmethod
1462     def poll(cls, context):
1463         is_3d_view = context.space_data.type == 'VIEW_3D'
1464         if is_3d_view:
1465             if context.gpencil_data is None:
1466                 return False
1467
1468             gpd = context.gpencil_data
1469             return bool(gpd.is_stroke_paint_mode)
1470         else:
1471             return True
1472
1473     @staticmethod
1474     def draw(self, context):
1475         layout = self.layout
1476         layout.use_property_split = True
1477         layout.use_property_decorate = False
1478
1479         ts = context.scene.tool_settings
1480         settings = ts.gpencil_paint
1481
1482         row = layout.row()
1483         col = row.column()
1484         col.template_ID_preview(settings, "brush", new="brush.add_gpencil", rows=3, cols=8)
1485
1486         col = row.column()
1487         brush = context.active_gpencil_brush
1488         gp_settings = brush.gpencil_settings
1489
1490         sub = col.column(align=True)
1491         sub.operator("gpencil.brush_presets_create", icon='HELP', text="")
1492
1493         if brush is not None:
1494             # XXX: Items in "sub" currently show up beside the brush selector in a separate column
1495             if brush.gpencil_tool == 'ERASE':
1496                 sub.prop(gp_settings, "use_default_eraser", text="")
1497
1498             # Brush details
1499             if brush.gpencil_tool == 'ERASE':
1500                 row = layout.row(align=True)
1501                 row.prop(brush, "size", text="Radius")
1502                 row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
1503
1504                 if gp_settings.eraser_mode == 'SOFT':
1505                     row = layout.row(align=True)
1506                     row.prop(gp_settings, "pen_strength", slider=True)
1507                     row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
1508                     row = layout.row(align=True)
1509                     row.prop(gp_settings, "eraser_strength_factor")
1510                     row = layout.row(align=True)
1511                     row.prop(gp_settings, "eraser_thickness_factor")
1512             elif brush.gpencil_tool == 'FILL':
1513                 col = layout.column(align=True)
1514                 col.prop(gp_settings, "fill_leak", text="Leak Size")
1515                 col.separator()
1516                 col.prop(brush, "size", text="Thickness")
1517                 col.prop(gp_settings, "fill_simplify_level", text="Simplify")
1518
1519                 col = layout.row(align=True)
1520                 col.template_ID(gp_settings, "material")
1521
1522                 row = layout.row(align=True)
1523                 row.prop(gp_settings, "fill_draw_mode", text="Boundary Draw Mode")
1524                 row.prop(gp_settings, "show_fill_boundary", text="", icon='GRID')
1525
1526                 col = layout.column(align=True)
1527                 col.enabled = gp_settings.fill_draw_mode != 'STROKE'
1528                 col.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
1529                 sub = col.row(align=True)
1530                 sub.enabled = not gp_settings.show_fill
1531                 sub.prop(gp_settings, "fill_threshold", text="Threshold")
1532             else:  # bgpsettings.tool == 'DRAW':
1533                 row = layout.row(align=True)
1534                 row.prop(brush, "size", text="Radius")
1535                 row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
1536                 row = layout.row(align=True)
1537                 row.prop(gp_settings, "pen_strength", slider=True)
1538                 row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
1539
1540                 row = layout.row(align=True)
1541                 row.template_ID(gp_settings, "material")
1542
1543
1544 # Grease Pencil drawing brushes options
1545 class VIEW3D_PT_tools_grease_pencil_brush_option(View3DPanel, Panel):
1546     bl_context = ".greasepencil_paint"
1547     bl_label = "Options"
1548     bl_options = {'DEFAULT_CLOSED'}
1549
1550     @classmethod
1551     def poll(cls, context):
1552         brush = context.active_gpencil_brush
1553         return brush is not None and brush.gpencil_tool != 'ERASE'
1554
1555     def draw_header_preset(self, context):
1556         VIEW3D_PT_gpencil_brush_presets.draw_panel_header(self.layout)
1557
1558     @staticmethod
1559     def draw(self, context):
1560         layout = self.layout
1561         layout.use_property_split = True
1562         layout.use_property_decorate = False
1563
1564         brush = context.active_gpencil_brush
1565         gp_settings = brush.gpencil_settings
1566
1567         if brush is not None:
1568             col = layout.column(align=True)
1569             col.prop(gp_settings, "input_samples")
1570             col.separator()
1571
1572             col.prop(gp_settings, "active_smooth_factor")
1573             col.separator()
1574
1575             col.prop(gp_settings, "angle", slider=True)
1576             col.prop(gp_settings, "angle_factor", text="Factor", slider=True)
1577             col.separator()
1578
1579
1580 class VIEW3D_PT_tools_grease_pencil_brush_stabilizer(View3DPanel, Panel):
1581     bl_context = ".greasepencil_paint"
1582     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1583     bl_label = "Stabilizer Settings"
1584     bl_options = {'DEFAULT_CLOSED'}
1585
1586     @classmethod
1587     def poll(cls, context):
1588         brush = context.active_gpencil_brush
1589         return brush is not None and brush.gpencil_tool == 'DRAW'
1590
1591     def draw_header(self, context):
1592         brush = context.active_gpencil_brush
1593         gp_settings = brush.gpencil_settings
1594         self.layout.prop(gp_settings, "use_settings_stabilizer", text="")
1595
1596     @staticmethod
1597     def draw(self, context):
1598         layout = self.layout
1599         layout.use_property_split = True
1600         layout.use_property_decorate = False
1601
1602         brush = context.active_gpencil_brush
1603         gp_settings = brush.gpencil_settings
1604         layout.active = gp_settings.use_settings_stabilizer
1605
1606         layout.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1607         layout.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1608
1609
1610 class VIEW3D_PT_tools_grease_pencil_brush_settings(View3DPanel, Panel):
1611     bl_context = ".greasepencil_paint"
1612     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1613     bl_label = "Post-processing Settings"
1614     bl_options = {'DEFAULT_CLOSED'}
1615
1616     @classmethod
1617     def poll(cls, context):
1618         brush = context.active_gpencil_brush
1619         return brush is not None and brush.gpencil_tool != 'ERASE'
1620
1621     def draw_header(self, context):
1622         brush = context.active_gpencil_brush
1623         gp_settings = brush.gpencil_settings
1624         self.layout.prop(gp_settings, "use_settings_postprocess", text="")
1625
1626     @staticmethod
1627     def draw(self, context):
1628         layout = self.layout
1629         layout.use_property_split = True
1630         layout.use_property_decorate = False
1631
1632         brush = context.active_gpencil_brush
1633         gp_settings = brush.gpencil_settings
1634         layout.active = gp_settings.use_settings_postprocess
1635
1636         col = layout.column(align=True)
1637         col.prop(gp_settings, "pen_smooth_factor")
1638         col.prop(gp_settings, "pen_smooth_steps")
1639
1640         col = layout.column(align=True)
1641         col.prop(gp_settings, "pen_thick_smooth_factor")
1642         col.prop(gp_settings, "pen_thick_smooth_steps", text="Iterations")
1643
1644         col = layout.column(align=True)
1645         col.prop(gp_settings, "pen_subdivision_steps")
1646         col.prop(gp_settings, "random_subdiv", text="Randomness", slider=True)
1647
1648
1649 class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
1650     bl_context = ".greasepencil_paint"
1651     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1652     bl_label = "Random Settings"
1653     bl_options = {'DEFAULT_CLOSED'}
1654
1655     @classmethod
1656     def poll(cls, context):
1657         brush = context.active_gpencil_brush
1658         return brush is not None and brush.gpencil_tool != 'ERASE'
1659
1660     def draw_header(self, context):
1661         brush = context.active_gpencil_brush
1662         gp_settings = brush.gpencil_settings
1663         self.layout.prop(gp_settings, "use_settings_random", text="")
1664
1665     @staticmethod
1666     def draw(self, context):
1667         layout = self.layout
1668         layout.use_property_split = True
1669         layout.use_property_decorate = False
1670
1671         brush = context.active_gpencil_brush
1672         gp_settings = brush.gpencil_settings
1673         layout.active = gp_settings.use_settings_random
1674
1675         layout.prop(gp_settings, "random_pressure", text="Pressure", slider=True)
1676         layout.prop(gp_settings, "random_strength", text="Strength", slider=True)
1677         layout.prop(gp_settings, "uv_random", text="UV", slider=True)
1678
1679         row = layout.row(align=True)
1680         row.prop(gp_settings, "pen_jitter", slider=True)
1681         row.prop(gp_settings, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
1682
1683
1684 # Grease Pencil drawingcurves
1685 class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
1686     bl_context = ".greasepencil_paint"
1687     bl_label = "Curves"
1688     bl_options = {'DEFAULT_CLOSED'}
1689
1690     @classmethod
1691     def poll(cls, context):
1692         brush = context.active_gpencil_brush
1693         return brush is not None and brush.gpencil_tool != 'ERASE'
1694
1695     @staticmethod
1696     def draw(self, context):
1697         layout = self.layout
1698
1699
1700 class VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity(View3DPanel, Panel):
1701     bl_context = ".greasepencil_paint"
1702     bl_label = "Sensitivity"
1703     bl_parent_id ="VIEW3D_PT_tools_grease_pencil_brushcurves"
1704
1705     @staticmethod
1706     def draw(self, context):
1707         layout = self.layout
1708         layout.use_property_split = True
1709
1710         brush = context.active_gpencil_brush
1711         gp_settings = brush.gpencil_settings
1712
1713         layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True)
1714
1715
1716 class VIEW3D_PT_tools_grease_pencil_brushcurves_strength(View3DPanel, Panel):
1717     bl_context = ".greasepencil_paint"
1718     bl_label = "Strength"
1719     bl_parent_id ="VIEW3D_PT_tools_grease_pencil_brushcurves"
1720
1721     @staticmethod
1722     def draw(self, context):
1723         layout = self.layout
1724         layout.use_property_split = True
1725
1726         brush = context.active_gpencil_brush
1727         gp_settings = brush.gpencil_settings
1728
1729         layout.template_curve_mapping(gp_settings, "curve_strength", brush=True)
1730
1731
1732 class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
1733     bl_context = ".greasepencil_paint"
1734     bl_label = "Jitter"
1735     bl_parent_id ="VIEW3D_PT_tools_grease_pencil_brushcurves"
1736
1737     @staticmethod
1738     def draw(self, context):
1739         layout = self.layout
1740         layout.use_property_split = True
1741
1742         brush = context.active_gpencil_brush
1743         gp_settings = brush.gpencil_settings
1744
1745         layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True)
1746
1747
1748 # Grease Pencil stroke editing tools
1749 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1750     bl_space_type = 'VIEW_3D'
1751
1752
1753 # Grease Pencil stroke interpolation tools
1754 class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
1755     bl_space_type = 'VIEW_3D'
1756     bl_region_type = 'HEADER'
1757     bl_label = "Interpolate"
1758
1759     @classmethod
1760     def poll(cls, context):
1761         if context.gpencil_data is None:
1762             return False
1763
1764         gpd = context.gpencil_data
1765         return bool(context.editable_gpencil_strokes) and bool(gpd.use_stroke_edit_mode)
1766
1767     @staticmethod
1768     def draw(self, context):
1769         layout = self.layout
1770         settings = context.tool_settings.gpencil_interpolate
1771
1772         col = layout.column(align=True)
1773         col.label(text="Interpolate Strokes")
1774         col.operator("gpencil.interpolate", text="Interpolate")
1775         col.operator("gpencil.interpolate_sequence", text="Sequence")
1776         col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
1777
1778         col = layout.column(align=True)
1779         col.label(text="Options:")
1780         col.prop(settings, "interpolate_all_layers")
1781         col.prop(settings, "interpolate_selected_only")
1782
1783         col = layout.column(align=True)
1784         col.label(text="Sequence Options:")
1785         col.prop(settings, "type")
1786         if settings.type == 'CUSTOM':
1787             # TODO: Options for loading/saving curve presets?
1788             col.template_curve_mapping(settings, "interpolation_curve", brush=True)
1789         elif settings.type != 'LINEAR':
1790             col.prop(settings, "easing")
1791
1792             if settings.type == 'BACK':
1793                 layout.prop(settings, "back")
1794             elif setting.type == 'ELASTIC':
1795                 sub = layout.column(align=True)
1796                 sub.prop(settings, "amplitude")
1797                 sub.prop(settings, "period")
1798
1799
1800 # Grease Pencil stroke sculpting tools
1801 class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, View3DPanel, Panel):
1802     bl_context = ".greasepencil_sculpt"
1803     bl_category = "Tools"
1804     bl_label = "Brush"
1805
1806
1807 # Grease Pencil weight painting tools
1808 class VIEW3D_PT_tools_grease_pencil_weight_paint(View3DPanel, Panel):
1809     bl_context = ".greasepencil_weight"
1810     bl_category = "Tools"
1811     bl_label = "Brush"
1812
1813     @staticmethod
1814     def draw(self, context):
1815         layout = self.layout
1816         layout.use_property_split = True
1817         layout.use_property_decorate = False
1818
1819         settings = context.tool_settings.gpencil_sculpt
1820         brush = settings.brush
1821
1822         layout.template_icon_view(settings, "weight_tool", show_labels=True)
1823
1824         col = layout.column()
1825         col.prop(brush, "size", slider=True)
1826         row = col.row(align=True)
1827         row.prop(brush, "strength", slider=True)
1828         row.prop(brush, "use_pressure_strength", text="")
1829
1830         col.prop(brush, "use_falloff")
1831
1832
1833 # Grease Pencil Brush Appeareance (one for each mode)
1834 class VIEW3D_PT_tools_grease_pencil_paint_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1835     bl_context = ".greasepencil_paint"
1836     bl_label = "Appearance"
1837
1838
1839 class VIEW3D_PT_tools_grease_pencil_sculpt_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1840     bl_context = ".greasepencil_sculpt"
1841     bl_label = "Appearance"
1842
1843
1844 class VIEW3D_PT_tools_grease_pencil_sculpt_options(GreasePencilSculptOptionsPanel, View3DPanel, Panel):
1845     bl_context = ".greasepencil_sculpt"
1846     bl_label = "Sculpt Strokes"
1847     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_sculpt'
1848
1849
1850 class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1851     bl_context = ".greasepencil_weight"
1852     bl_label = "Appearance"
1853
1854
1855 class VIEW3D_PT_gpencil_brush_presets(PresetMenu):
1856     """Brush settings"""
1857     bl_label = "Brush Presets"
1858     preset_subdir = "gpencil_brush"
1859     preset_operator = "script.execute_preset"
1860     preset_add_operator = "scene.gpencil_brush_preset_add"
1861
1862
1863 classes = (
1864     VIEW3D_PT_tools_meshedit_options,
1865     VIEW3D_PT_tools_curveedit_options_stroke,
1866     VIEW3D_PT_tools_armatureedit_options,
1867     VIEW3D_PT_tools_posemode_options,
1868     VIEW3D_PT_slots_projectpaint,
1869     VIEW3D_PT_tools_brush,
1870     TEXTURE_UL_texpaintslots,
1871     VIEW3D_MT_tools_projectpaint_uvlayer,
1872     VIEW3D_PT_stencil_projectpaint,
1873     VIEW3D_PT_tools_brush_overlay,
1874     VIEW3D_PT_tools_brush_texture,
1875     VIEW3D_PT_tools_mask_texture,
1876     VIEW3D_PT_tools_brush_stroke,
1877     VIEW3D_PT_tools_brush_stroke_smooth_stroke,
1878     VIEW3D_PT_tools_brush_curve,
1879     VIEW3D_PT_sculpt_dyntopo,
1880     VIEW3D_PT_sculpt_dyntopo_remesh,
1881     VIEW3D_PT_sculpt_options,
1882     VIEW3D_PT_sculpt_options_unified,
1883     VIEW3D_PT_sculpt_options_gravity,
1884     VIEW3D_PT_sculpt_symmetry,
1885     VIEW3D_PT_tools_brush_appearance,
1886     VIEW3D_PT_tools_brush_appearance_show_brush,
1887     VIEW3D_PT_tools_brush_appearance_custom_icon,
1888     VIEW3D_PT_tools_weightpaint_symmetry,
1889     VIEW3D_PT_tools_weightpaint_options,
1890     VIEW3D_PT_tools_vertexpaint,
1891     VIEW3D_PT_tools_vertexpaint_symmetry,
1892     VIEW3D_PT_tools_imagepaint_external,
1893     VIEW3D_PT_tools_imagepaint_symmetry,
1894     VIEW3D_PT_tools_projectpaint,
1895     VIEW3D_PT_tools_projectpaint_unified,
1896     VIEW3D_PT_tools_projectpaint_cavity,
1897     VIEW3D_MT_tools_projectpaint_stencil,
1898     VIEW3D_PT_tools_particlemode,
1899
1900     VIEW3D_PT_gpencil_brush_presets,
1901     VIEW3D_PT_tools_grease_pencil_brush,
1902     VIEW3D_PT_tools_grease_pencil_brush_option,
1903     VIEW3D_PT_tools_grease_pencil_brush_settings,
1904     VIEW3D_PT_tools_grease_pencil_brush_stabilizer,
1905     VIEW3D_PT_tools_grease_pencil_brush_random,
1906     VIEW3D_PT_tools_grease_pencil_brushcurves,
1907     VIEW3D_PT_tools_grease_pencil_brushcurves_sensitivity,
1908     VIEW3D_PT_tools_grease_pencil_brushcurves_strength,
1909     VIEW3D_PT_tools_grease_pencil_brushcurves_jitter,
1910     VIEW3D_PT_tools_grease_pencil_sculpt,
1911     VIEW3D_PT_tools_grease_pencil_weight_paint,
1912     VIEW3D_PT_tools_grease_pencil_paint_appearance,
1913     VIEW3D_PT_tools_grease_pencil_sculpt_options,
1914     VIEW3D_PT_tools_grease_pencil_sculpt_appearance,
1915     VIEW3D_PT_tools_grease_pencil_weight_appearance,
1916     VIEW3D_PT_tools_grease_pencil_interpolate,
1917     VIEW3D_PT_tools_normal,
1918 )
1919
1920 if __name__ == "__main__":  # only for live edit.
1921     from bpy.utils import register_class
1922     for cls in classes:
1923         register_class(cls)