Expose the Pose Propagate tool a bit more in the UI
[blender-staging.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 bl_ui.properties_grease_pencil_common import (
23         GreasePencilDrawingToolsPanel,
24         GreasePencilStrokeEditPanel
25         )
26 from bl_ui.properties_paint_common import (
27         UnifiedPaintPanel,
28         brush_texture_settings,
29         brush_texpaint_common,
30         brush_mask_texture_settings,
31         )
32
33
34 class View3DPanel:
35     bl_space_type = 'VIEW_3D'
36     bl_region_type = 'TOOLS'
37
38
39 # **************** standard tool clusters ******************
40
41 # Keyframing tools
42 def draw_keyframing_tools(context, layout):
43     col = layout.column(align=True)
44     col.label(text="Keyframes:")
45     row = col.row(align=True)
46     row.operator("anim.keyframe_insert_menu", text="Insert")
47     row.operator("anim.keyframe_delete_v3d", text="Remove")
48
49
50 # ********** default tools for object-mode ****************
51
52
53 class VIEW3D_PT_tools_transform(View3DPanel, Panel):
54     bl_category = "Tools"
55     bl_context = "objectmode"
56     bl_label = "Transform"
57
58     def draw(self, context):
59         layout = self.layout
60
61         col = layout.column(align=True)
62         col.operator("transform.translate")
63         col.operator("transform.rotate")
64         col.operator("transform.resize", text="Scale")
65
66         col = layout.column(align=True)
67         col.operator("transform.mirror", text="Mirror")
68
69
70 class VIEW3D_PT_tools_object(View3DPanel, Panel):
71     bl_category = "Tools"
72     bl_context = "objectmode"
73     bl_label = "Edit"
74
75     def draw(self, context):
76         layout = self.layout
77
78         col = layout.column(align=True)
79         col.operator("object.duplicate_move", text="Duplicate")
80         col.operator("object.duplicate_move_linked", text="Duplicate Linked")
81
82         col.operator("object.delete")
83
84         obj = context.active_object
85         if obj:
86             obj_type = obj.type
87
88             if obj_type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE'}:
89                 col = layout.column(align=True)
90                 col.operator("object.join")
91
92             if obj_type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE', 'FONT', 'LATTICE'}:
93                 col = layout.column(align=True)
94                 col.operator_menu_enum("object.origin_set", "type", text="Set Origin")
95
96             if obj_type in {'MESH', 'CURVE', 'SURFACE'}:
97                 col = layout.column(align=True)
98                 col.label(text="Shading:")
99                 row = col.row(align=True)
100                 row.operator("object.shade_smooth", text="Smooth")
101                 row.operator("object.shade_flat", text="Flat")
102
103             if obj_type in {'MESH'}:
104                 col = layout.column(align=True)
105                 col.label(text="Data Transfer:")
106                 row = col.row(align=True)
107                 row.operator("object.data_transfer", text="Data")
108                 row.operator("object.datalayout_transfer", text="Data Layout")
109
110
111 class VIEW3D_PT_tools_add_object(View3DPanel, Panel):
112     bl_category = "Create"
113     bl_context = "objectmode"
114     bl_label = "Add Primitive"
115
116     @staticmethod
117     def draw_add_mesh(layout, label=False):
118         if label:
119             layout.label(text="Primitives:")
120         layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
121         layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
122         layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
123         layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
124         layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
125         layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
126         layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
127         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
128
129         if label:
130             layout.label(text="Special:")
131         else:
132             layout.separator()
133         layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
134         layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
135
136     @staticmethod
137     def draw_add_curve(layout, label=False):
138         if label:
139             layout.label(text="Bezier:")
140         layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
141         layout.operator("curve.primitive_bezier_circle_add", text="Circle", icon='CURVE_BEZCIRCLE')
142
143         if label:
144             layout.label(text="Nurbs:")
145         else:
146             layout.separator()
147         layout.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon='CURVE_NCURVE')
148         layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
149         layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
150
151     @staticmethod
152     def draw_add_surface(layout):
153         layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
154         layout.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon='SURFACE_NCIRCLE')
155         layout.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon='SURFACE_NSURFACE')
156         layout.operator("surface.primitive_nurbs_surface_cylinder_add", text="Nurbs Cylinder", icon='SURFACE_NCYLINDER')
157         layout.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon='SURFACE_NSPHERE')
158         layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS')
159
160     @staticmethod
161     def draw_add_mball(layout):
162         layout.operator_enum("object.metaball_add", "type")
163
164     @staticmethod
165     def draw_add_lamp(layout):
166         layout.operator_enum("object.lamp_add", "type")
167
168     @staticmethod
169     def draw_add_other(layout):
170         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
171         layout.operator("object.armature_add", text="Armature", icon='OUTLINER_OB_ARMATURE')
172         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
173         layout.operator("object.empty_add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'PLAIN_AXES'
174         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
175         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
176
177     def draw(self, context):
178         layout = self.layout
179
180         col = layout.column(align=True)
181         col.label(text="Mesh:")
182         self.draw_add_mesh(col)
183
184         col = layout.column(align=True)
185         col.label(text="Curve:")
186         self.draw_add_curve(col)
187
188         # not used here:
189         # draw_add_surface
190         # draw_add_mball
191
192         col = layout.column(align=True)
193         col.label(text="Lamp:")
194         self.draw_add_lamp(col)
195
196         col = layout.column(align=True)
197         col.label(text="Other:")
198         self.draw_add_other(col)
199
200
201 class VIEW3D_PT_tools_relations(View3DPanel, Panel):
202     bl_category = "Relations"
203     bl_context = "objectmode"
204     bl_label = "Relations"
205
206     def draw(self, context):
207         layout = self.layout
208
209         col = layout.column(align=True)
210
211         col.label(text="Group:")
212         col.operator("group.create", text="New Group")
213         col.operator("group.objects_add_active", text="Add to Active")
214         col.operator("group.objects_remove", text="Remove from Group")
215
216         col.separator()
217
218         col.label(text="Parent:")
219         row = col.row(align=True)
220         row.operator("object.parent_set", text="Set")
221         row.operator("object.parent_clear", text="Clear")
222
223         col.separator()
224
225         col.label(text="Object Data:")
226         col.operator("object.make_links_data")
227         col.operator("object.make_single_user")
228
229         col.separator()
230
231         col.label(text="Linked Objects:")
232         col.operator("object.make_local")
233         col.operator("object.proxy_make")
234
235
236 class VIEW3D_PT_tools_animation(View3DPanel, Panel):
237     bl_category = "Animation"
238     bl_context = "objectmode"
239     bl_label = "Animation"
240
241     def draw(self, context):
242         layout = self.layout
243
244         draw_keyframing_tools(context, layout)
245
246         col = layout.column(align=True)
247         col.label(text="Motion Paths:")
248         row = col.row(align=True)
249         row.operator("object.paths_calculate", text="Calculate")
250         row.operator("object.paths_clear", text="Clear")
251
252         col.separator()
253
254         col.label(text="Action:")
255         col.operator("nla.bake", text="Bake Action")
256
257
258 class VIEW3D_PT_tools_rigid_body(View3DPanel, Panel):
259     bl_category = "Physics"
260     bl_context = "objectmode"
261     bl_label = "Rigid Body Tools"
262
263     def draw(self, context):
264         layout = self.layout
265
266         col = layout.column(align=True)
267         col.label(text="Add/Remove:")
268         row = col.row(align=True)
269         row.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
270         row.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
271         row = col.row(align=True)
272         row.operator("rigidbody.objects_remove", text="Remove")
273
274         col = layout.column(align=True)
275         col.label(text="Object Tools:")
276         col.operator("rigidbody.shape_change", text="Change Shape")
277         col.operator("rigidbody.mass_calculate", text="Calculate Mass")
278         col.operator("rigidbody.object_settings_copy", text="Copy from Active")
279         col.operator("object.visual_transform_apply", text="Apply Transformation")
280         col.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
281         col.label(text="Constraints:")
282         col.operator("rigidbody.connect", text="Connect")
283
284
285 # ********** default tools for editmode_mesh ****************
286
287 class VIEW3D_PT_tools_transform_mesh(View3DPanel, Panel):
288     bl_category = "Tools"
289     bl_context = "mesh_edit"
290     bl_label = "Transform"
291
292     def draw(self, context):
293         layout = self.layout
294
295         col = layout.column(align=True)
296         col.operator("transform.translate")
297         col.operator("transform.rotate")
298         col.operator("transform.resize", text="Scale")
299         col.operator("transform.shrink_fatten", text="Shrink/Fatten")
300         col.operator("transform.push_pull", text="Push/Pull")
301
302
303 class VIEW3D_PT_tools_meshedit(View3DPanel, Panel):
304     bl_category = "Tools"
305     bl_context = "mesh_edit"
306     bl_label = "Mesh Tools"
307
308     def draw(self, context):
309         layout = self.layout
310
311         col = layout.column(align=True)
312         col.label(text="Deform:")
313         row = col.row(align=True)
314         row.operator("transform.edge_slide", text="Slide Edge")
315         row.operator("transform.vert_slide", text="Vertex")
316         col.operator("mesh.noise")
317         col.operator("mesh.vertices_smooth")
318         col.operator("object.vertex_random")
319
320         col = layout.column(align=True)
321         col.label(text="Add:")
322
323         col.menu("VIEW3D_MT_edit_mesh_extrude")
324         col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
325         col.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
326         col.operator("mesh.inset", text="Inset Faces")
327         col.operator("mesh.edge_face_add")
328         col.operator("mesh.subdivide")
329         col.operator("mesh.loopcut_slide")
330         col.operator("mesh.duplicate_move", text="Duplicate")
331         row = col.row(align=True)
332         row.operator("mesh.spin")
333         row.operator("mesh.screw")
334
335         row = col.row(align=True)
336         props = row.operator("mesh.knife_tool", text="Knife")
337         props.use_occlude_geometry = True
338         props.only_selected = False
339         props = row.operator("mesh.knife_tool", text="Select")
340         props.use_occlude_geometry = False
341         props.only_selected = True
342         col.operator("mesh.knife_project")
343         col.operator("mesh.bisect")
344
345         col = layout.column(align=True)
346         col.label(text="Remove:")
347         col.menu("VIEW3D_MT_edit_mesh_delete")
348         col.operator_menu_enum("mesh.merge", "type")
349         col.operator("mesh.remove_doubles")
350
351
352 class VIEW3D_PT_tools_meshweight(View3DPanel, Panel):
353     bl_category = "Tools"
354     bl_context = "mesh_edit"
355     bl_label = "Weight Tools"
356     bl_options = {'DEFAULT_CLOSED'}
357
358     # Used for Weight-Paint mode and Edit-Mode
359     @staticmethod
360     def draw_generic(layout):
361         col = layout.column()
362         col.operator("object.vertex_group_normalize_all", text="Normalize All")
363         col.operator("object.vertex_group_normalize", text="Normalize")
364         col.operator("object.vertex_group_mirror", text="Mirror")
365         col.operator("object.vertex_group_invert", text="Invert")
366         col.operator("object.vertex_group_clean", text="Clean")
367         col.operator("object.vertex_group_quantize", text="Quantize")
368         col.operator("object.vertex_group_levels", text="Levels")
369         col.operator("object.vertex_group_blend", text="Blend")
370         col.operator("object.vertex_group_limit_total", text="Limit Total")
371         col.operator("object.vertex_group_fix", text="Fix Deforms")
372
373     def draw(self, context):
374         layout = self.layout
375         self.draw_generic(layout)
376
377
378 class VIEW3D_PT_tools_add_mesh_edit(View3DPanel, Panel):
379     bl_category = "Create"
380     bl_context = "mesh_edit"
381     bl_label = "Add Meshes"
382
383     def draw(self, context):
384         layout = self.layout
385
386         col = layout.column(align=True)
387
388         VIEW3D_PT_tools_add_object.draw_add_mesh(col, label=True)
389
390
391 class VIEW3D_PT_tools_shading(View3DPanel, Panel):
392     bl_category = "Shading / UVs"
393     bl_context = "mesh_edit"
394     bl_label = "Shading"
395
396     def draw(self, context):
397         layout = self.layout
398
399         col = layout.column(align=True)
400         col.label(text="Faces:")
401         row = col.row(align=True)
402         row.operator("mesh.faces_shade_smooth", text="Smooth")
403         row.operator("mesh.faces_shade_flat", text="Flat")
404         col.label(text="Edges:")
405         row = col.row(align=True)
406         row.operator("mesh.mark_sharp", text="Smooth").clear = True
407         row.operator("mesh.mark_sharp", text="Sharp")
408         col.label(text="Vertices:")
409         row = col.row(align=True)
410         op = row.operator("mesh.mark_sharp", text="Smooth")
411         op.use_verts = True
412         op.clear = True
413         row.operator("mesh.mark_sharp", text="Sharp").use_verts = True
414
415         col = layout.column(align=True)
416         col.label(text="Normals:")
417         col.operator("mesh.normals_make_consistent", text="Recalculate")
418         col.operator("mesh.flip_normals", text="Flip Direction")
419
420
421 class VIEW3D_PT_tools_uvs(View3DPanel, Panel):
422     bl_category = "Shading / UVs"
423     bl_context = "mesh_edit"
424     bl_label = "UVs"
425
426     def draw(self, context):
427         layout = self.layout
428
429         col = layout.column(align=True)
430         col.label(text="UV Mapping:")
431         col.menu("VIEW3D_MT_uv_map", text="Unwrap")
432         col.operator("mesh.mark_seam").clear = False
433         col.operator("mesh.mark_seam", text="Clear Seam").clear = True
434
435
436 class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
437     bl_category = "Options"
438     bl_context = "mesh_edit"
439     bl_label = "Mesh Options"
440
441     @classmethod
442     def poll(cls, context):
443         return context.active_object
444
445     def draw(self, context):
446         layout = self.layout
447
448         ob = context.active_object
449
450         tool_settings = context.tool_settings
451         mesh = ob.data
452
453         col = layout.column(align=True)
454         col.prop(mesh, "use_mirror_x")
455
456         row = col.row(align=True)
457         row.active = ob.data.use_mirror_x
458         row.prop(mesh, "use_mirror_topology")
459
460         col = layout.column(align=True)
461         col.label("Edge Select Mode:")
462         col.prop(tool_settings, "edge_path_mode", text="")
463         col.prop(tool_settings, "edge_path_live_unwrap")
464         col.label("Double Threshold:")
465         col.prop(tool_settings, "double_threshold", text="")
466
467         if mesh.show_weight:
468             col.label("Show Zero Weights:")
469             col.row().prop(tool_settings, "vertex_group_user", expand=True)
470
471 # ********** default tools for editmode_curve ****************
472
473
474 class VIEW3D_PT_tools_transform_curve(View3DPanel, Panel):
475     bl_category = "Tools"
476     bl_context = "curve_edit"
477     bl_label = "Transform"
478
479     def draw(self, context):
480         layout = self.layout
481
482         col = layout.column(align=True)
483         col.operator("transform.translate")
484         col.operator("transform.rotate")
485         col.operator("transform.resize", text="Scale")
486
487         col = layout.column(align=True)
488         col.operator("transform.tilt", text="Tilt")
489         col.operator("transform.transform", text="Shrink/Fatten").mode = 'CURVE_SHRINKFATTEN'
490
491
492 class VIEW3D_PT_tools_curveedit(View3DPanel, Panel):
493     bl_category = "Tools"
494     bl_context = "curve_edit"
495     bl_label = "Curve Tools"
496
497     def draw(self, context):
498         layout = self.layout
499
500         col = layout.column(align=True)
501         col.label(text="Curve:")
502         col.operator("curve.duplicate_move", text="Duplicate")
503         col.operator("curve.delete")
504         col.operator("curve.cyclic_toggle")
505         col.operator("curve.switch_direction")
506         col.operator("curve.spline_type_set")
507         col.operator("curve.radius_set")
508
509         col = layout.column(align=True)
510         col.label(text="Handles:")
511         row = col.row(align=True)
512         row.operator("curve.handle_type_set", text="Auto").type = 'AUTOMATIC'
513         row.operator("curve.handle_type_set", text="Vector").type = 'VECTOR'
514         row = col.row(align=True)
515         row.operator("curve.handle_type_set", text="Align").type = 'ALIGNED'
516         row.operator("curve.handle_type_set", text="Free").type = 'FREE_ALIGN'
517
518         col = layout.column(align=True)
519         col.operator("curve.normals_make_consistent")
520
521         col = layout.column(align=True)
522         col.label(text="Modeling:")
523         col.operator("curve.extrude_move", text="Extrude")
524         col.operator("curve.subdivide")
525         col.operator("curve.smooth")
526         col.operator("object.vertex_random")
527
528
529 class VIEW3D_PT_tools_add_curve_edit(View3DPanel, Panel):
530     bl_category = "Create"
531     bl_context = "curve_edit"
532     bl_label = "Add Curves"
533
534     def draw(self, context):
535         layout = self.layout
536
537         col = layout.column(align=True)
538
539         VIEW3D_PT_tools_add_object.draw_add_curve(col, label=True)
540
541 # ********** default tools for editmode_surface ****************
542
543
544 class VIEW3D_PT_tools_transform_surface(View3DPanel, Panel):
545     bl_category = "Tools"
546     bl_context = "surface_edit"
547     bl_label = "Transform"
548
549     def draw(self, context):
550         layout = self.layout
551
552         col = layout.column(align=True)
553         col.operator("transform.translate")
554         col.operator("transform.rotate")
555         col.operator("transform.resize", text="Scale")
556
557
558 class VIEW3D_PT_tools_surfaceedit(View3DPanel, Panel):
559     bl_category = "Tools"
560     bl_context = "surface_edit"
561     bl_label = "Surface Tools"
562
563     def draw(self, context):
564         layout = self.layout
565
566         col = layout.column(align=True)
567         col.label(text="Curve:")
568         col.operator("curve.duplicate_move", text="Duplicate")
569         col.operator("curve.delete")
570         col.operator("curve.cyclic_toggle")
571         col.operator("curve.switch_direction")
572
573         col = layout.column(align=True)
574         col.label(text="Modeling:")
575         col.operator("curve.extrude", text="Extrude")
576         col.operator("curve.subdivide")
577
578         col = layout.column(align=True)
579         col.label(text="Deform:")
580         col.operator("object.vertex_random")
581
582
583 class VIEW3D_PT_tools_add_surface_edit(View3DPanel, Panel):
584     bl_category = "Create"
585     bl_context = "surface_edit"
586     bl_label = "Add Surfaces"
587
588     def draw(self, context):
589         layout = self.layout
590
591         col = layout.column(align=True)
592
593         VIEW3D_PT_tools_add_object.draw_add_surface(col)
594
595
596 # ********** default tools for editmode_text ****************
597
598
599 class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
600     bl_category = "Tools"
601     bl_context = "text_edit"
602     bl_label = "Text Tools"
603
604     def draw(self, context):
605         layout = self.layout
606
607         col = layout.column(align=True)
608         col.label(text="Set Case:")
609         col.operator("font.case_set", text="To Upper").case = 'UPPER'
610         col.operator("font.case_set", text="To Lower").case = 'LOWER'
611
612         col = layout.column(align=True)
613         col.label(text="Style:")
614         col.operator("font.style_toggle", text="Bold").style = 'BOLD'
615         col.operator("font.style_toggle", text="Italic").style = 'ITALIC'
616         col.operator("font.style_toggle", text="Underline").style = 'UNDERLINE'
617
618
619 # ********** default tools for editmode_armature ****************
620
621
622 class VIEW3D_PT_tools_armatureedit_transform(View3DPanel, Panel):
623     bl_category = "Tools"
624     bl_context = "armature_edit"
625     bl_label = "Transform"
626
627     def draw(self, context):
628         layout = self.layout
629
630         col = layout.column(align=True)
631         col.operator("transform.translate")
632         col.operator("transform.rotate")
633         col.operator("transform.resize", text="Scale")
634
635
636 class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
637     bl_category = "Tools"
638     bl_context = "armature_edit"
639     bl_label = "Armature Tools"
640
641     def draw(self, context):
642         layout = self.layout
643
644         col = layout.column(align=True)
645         col.label(text="Bones:")
646         col.operator("armature.bone_primitive_add", text="Add")
647         col.operator("armature.duplicate_move", text="Duplicate")
648         col.operator("armature.delete", text="Delete")
649
650         col = layout.column(align=True)
651         col.label(text="Modeling:")
652         col.operator("armature.extrude_move")
653         col.operator("armature.subdivide", text="Subdivide")
654
655         col = layout.column(align=True)
656         col.label(text="Deform:")
657         col.operator("object.vertex_random")
658
659
660 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
661     bl_category = "Options"
662     bl_context = "armature_edit"
663     bl_label = "Armature Options"
664
665     def draw(self, context):
666         arm = context.active_object.data
667
668         self.layout.prop(arm, "use_mirror_x")
669
670
671 # ********** default tools for editmode_mball ****************
672
673
674 class VIEW3D_PT_tools_mballedit(View3DPanel, Panel):
675     bl_category = "Tools"
676     bl_context = "mball_edit"
677     bl_label = "Meta Tools"
678
679     def draw(self, context):
680         layout = self.layout
681
682         col = layout.column(align=True)
683         col.label(text="Transform:")
684         col.operator("transform.translate")
685         col.operator("transform.rotate")
686         col.operator("transform.resize", text="Scale")
687
688         col = layout.column(align=True)
689         col.label(text="Deform:")
690         col.operator("object.vertex_random")
691
692
693 class VIEW3D_PT_tools_add_mball_edit(View3DPanel, Panel):
694     bl_category = "Create"
695     bl_context = "mball_edit"
696     bl_label = "Add Metaball"
697
698     def draw(self, context):
699         layout = self.layout
700
701         col = layout.column(align=True)
702
703         VIEW3D_PT_tools_add_object.draw_add_mball(col)
704
705
706 # ********** default tools for editmode_lattice ****************
707
708
709 class VIEW3D_PT_tools_latticeedit(View3DPanel, Panel):
710     bl_category = "Tools"
711     bl_context = "lattice_edit"
712     bl_label = "Lattice Tools"
713
714     def draw(self, context):
715         layout = self.layout
716
717         col = layout.column(align=True)
718         col.label(text="Transform:")
719         col.operator("transform.translate")
720         col.operator("transform.rotate")
721         col.operator("transform.resize", text="Scale")
722
723         col = layout.column(align=True)
724         col.operator("lattice.make_regular")
725
726         col = layout.column(align=True)
727         col.label(text="Deform:")
728         col.operator("object.vertex_random")
729
730
731 # ********** default tools for pose-mode ****************
732
733
734 class VIEW3D_PT_tools_posemode(View3DPanel, Panel):
735     bl_category = "Tools"
736     bl_context = "posemode"
737     bl_label = "Pose Tools"
738
739     def draw(self, context):
740         layout = self.layout
741
742         col = layout.column(align=True)
743         col.label(text="Transform:")
744         col.operator("transform.translate")
745         col.operator("transform.rotate")
746         col.operator("transform.resize", text="Scale")
747
748         col = layout.column(align=True)
749         col.label(text="In-Between:")
750         row = col.row(align=True)
751         row.operator("pose.push", text="Push")
752         row.operator("pose.relax", text="Relax")
753         col.operator("pose.breakdown", text="Breakdowner")
754
755         col = layout.column(align=True)
756         col.label(text="Pose:")
757         row = col.row(align=True)
758         row.operator("pose.copy", text="Copy")
759         row.operator("pose.paste", text="Paste")
760
761         row = layout.row(align=True)
762         row.operator("pose.propagate", text="Propagate")
763         row.menu("VIEW3D_MT_pose_propagate", icon='TRIA_RIGHT', text="")
764
765         col = layout.column(align=True)
766         col.operator("poselib.pose_add", text="Add To Library")
767
768         draw_keyframing_tools(context, layout)
769
770         col = layout.column(align=True)
771         col.label(text="Motion Paths:")
772         row = col.row(align=True)
773         row.operator("pose.paths_calculate", text="Calculate")
774         row.operator("pose.paths_clear", text="Clear")
775
776
777 class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
778     bl_category = "Options"
779     bl_context = "posemode"
780     bl_label = "Pose Options"
781
782     def draw(self, context):
783         arm = context.active_object.data
784
785         self.layout.prop(arm, "use_auto_ik")
786
787 # ********** default tools for paint modes ****************
788
789
790 class View3DPaintPanel(UnifiedPaintPanel):
791     bl_space_type = 'VIEW_3D'
792     bl_region_type = 'TOOLS'
793
794
795 class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
796     bl_category = "Tools"
797     bl_label = "Missing Data"
798
799     @classmethod
800     def poll(cls, context):
801         toolsettings = context.tool_settings.image_paint
802         return context.image_paint_object and not toolsettings.detect_data()
803
804     def draw(self, context):
805         layout = self.layout
806         toolsettings = context.tool_settings.image_paint
807
808         col = layout.column()
809         col.label("Missing Data", icon='ERROR')
810         if toolsettings.missing_uvs:
811             col.separator()
812             col.label("Missing UVs", icon='INFO')
813             col.label("Unwrap the mesh in edit mode or generate a simple UV layer")
814             col.operator("paint.add_simple_uvs")
815
816         if toolsettings.mode == 'MATERIAL':
817             if toolsettings.missing_materials:
818                 col.separator()
819                 col.label("Missing Materials", icon='INFO')
820                 col.label("Add a material and paint slot below")
821                 col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
822             elif toolsettings.missing_texture:
823                 ob = context.active_object
824                 mat = ob.active_material
825
826                 col.separator()
827                 if mat:
828                     col.label("Missing Texture Slots", icon='INFO')
829                     col.label("Add a paint slot below")
830                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
831                 else:
832                     col.label("Missing Materials", icon='INFO')
833                     col.label("Add a material and paint slot below")
834                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
835
836         elif toolsettings.mode == 'IMAGE':
837             if toolsettings.missing_texture:
838                 col.separator()
839                 col.label("Missing Canvas", icon='INFO')
840                 col.label("Add or assign a canvas image below")
841                 col.label("Canvas Image")
842                 col.template_ID(toolsettings, "canvas")
843                 col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
844
845         if toolsettings.missing_stencil:
846             col.separator()
847             col.label("Missing Stencil", icon='INFO')
848             col.label("Add or assign a stencil image below")
849             col.label("Stencil Image")
850             col.template_ID(toolsettings, "stencil_image")
851             col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
852
853
854 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
855     bl_category = "Tools"
856     bl_label = "Brush"
857
858     @classmethod
859     def poll(cls, context):
860         return cls.paint_settings(context)
861
862     def draw(self, context):
863         layout = self.layout
864
865         toolsettings = context.tool_settings
866         settings = self.paint_settings(context)
867         brush = settings.brush
868
869         if not context.particle_edit_object:
870             col = layout.split().column()
871             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
872
873         # Particle Mode #
874         if context.particle_edit_object:
875             tool = settings.tool
876
877             layout.column().prop(settings, "tool", expand=True)
878
879             if tool != 'NONE':
880                 col = layout.column()
881                 col.prop(brush, "size", slider=True)
882                 if tool != 'ADD':
883                     col.prop(brush, "strength", slider=True)
884
885             if tool == 'ADD':
886                 col.prop(brush, "count")
887                 col = layout.column()
888                 col.prop(settings, "use_default_interpolate")
889                 col.prop(brush, "steps", slider=True)
890                 col.prop(settings, "default_key_count", slider=True)
891             elif tool == 'LENGTH':
892                 layout.prop(brush, "length_mode", expand=True)
893             elif tool == 'PUFF':
894                 layout.prop(brush, "puff_mode", expand=True)
895                 layout.prop(brush, "use_puff_volume")
896
897         # Sculpt Mode #
898
899         elif context.sculpt_object and brush:
900             capabilities = brush.sculpt_capabilities
901
902             col = layout.column()
903
904             col.separator()
905
906             row = col.row(align=True)
907
908             ups = toolsettings.unified_paint_settings
909             if ((ups.use_unified_size and ups.use_locked_size) or
910                     ((not ups.use_unified_size) and brush.use_locked_size)):
911                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
912                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
913             else:
914                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
915                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
916
917             self.prop_unified_size(row, context, brush, "use_pressure_size")
918
919             # strength, use_strength_pressure, and use_strength_attenuation
920             col.separator()
921             row = col.row(align=True)
922
923             if capabilities.has_space_attenuation:
924                 row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
925
926             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
927
928             if capabilities.has_strength_pressure:
929                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
930
931             # auto_smooth_factor and use_inverse_smooth_pressure
932             if capabilities.has_auto_smooth:
933                 col.separator()
934
935                 row = col.row(align=True)
936                 row.prop(brush, "auto_smooth_factor", slider=True)
937                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
938
939             # normal_weight
940             if capabilities.has_normal_weight:
941                 col.separator()
942                 row = col.row(align=True)
943                 row.prop(brush, "normal_weight", slider=True)
944
945             # crease_pinch_factor
946             if capabilities.has_pinch_factor:
947                 col.separator()
948                 row = col.row(align=True)
949                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
950
951             # use_original_normal and sculpt_plane
952             if capabilities.has_sculpt_plane:
953                 col.separator()
954                 row = col.row(align=True)
955
956                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
957
958                 row.prop(brush, "sculpt_plane", text="")
959
960             if brush.sculpt_tool == 'MASK':
961                 col.prop(brush, "mask_tool", text="")
962
963             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
964             if capabilities.has_plane_offset:
965                 row = col.row(align=True)
966                 row.prop(brush, "plane_offset", slider=True)
967                 row.prop(brush, "use_offset_pressure", text="")
968
969                 col.separator()
970
971                 row = col.row()
972                 row.prop(brush, "use_plane_trim", text="Trim")
973                 row = col.row()
974                 row.active = brush.use_plane_trim
975                 row.prop(brush, "plane_trim", slider=True, text="Distance")
976
977             # height
978             if capabilities.has_height:
979                 row = col.row()
980                 row.prop(brush, "height", slider=True, text="Height")
981
982             # use_frontface
983             col.separator()
984             row = col.row()
985             row.prop(brush, "use_frontface", text="Front Faces Only")
986
987             # direction
988             col.separator()
989             col.row().prop(brush, "direction", expand=True)
990
991             # use_accumulate
992             if capabilities.has_accumulate:
993                 col.separator()
994
995                 col.prop(brush, "use_accumulate")
996
997             # use_persistent, set_persistent_base
998             if capabilities.has_persistence:
999                 col.separator()
1000
1001                 ob = context.sculpt_object
1002                 do_persistent = True
1003
1004                 # not supported yet for this case
1005                 for md in ob.modifiers:
1006                     if md.type == 'MULTIRES':
1007                         do_persistent = False
1008                         break
1009
1010                 if do_persistent:
1011                     col.prop(brush, "use_persistent")
1012                     col.operator("sculpt.set_persistent_base")
1013
1014         # Texture Paint Mode #
1015
1016         elif context.image_paint_object and brush:
1017             brush_texpaint_common(self, context, layout, brush, settings, True)
1018
1019         # Weight Paint Mode #
1020         elif context.weight_paint_object and brush:
1021
1022             col = layout.column()
1023
1024             row = col.row(align=True)
1025             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
1026
1027             row = col.row(align=True)
1028             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1029             self.prop_unified_size(row, context, brush, "use_pressure_size")
1030
1031             row = col.row(align=True)
1032             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1033             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1034
1035             col.prop(brush, "vertex_tool", text="Blend")
1036
1037             col = layout.column()
1038             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
1039             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
1040
1041         # Vertex Paint Mode #
1042         elif context.vertex_paint_object and brush:
1043             col = layout.column()
1044             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
1045             if settings.palette:
1046                 col.template_palette(settings, "palette", color=True)
1047             self.prop_unified_color(col, context, brush, "color", text="")
1048
1049             col.separator()
1050             row = col.row(align=True)
1051             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1052             self.prop_unified_size(row, context, brush, "use_pressure_size")
1053
1054             row = col.row(align=True)
1055             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1056             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1057
1058             # XXX - TODO
1059             # row = col.row(align=True)
1060             # row.prop(brush, "jitter", slider=True)
1061             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1062             col.separator()
1063             col.prop(brush, "vertex_tool", text="Blend")
1064
1065             col.separator()
1066             col.template_ID(settings, "palette", new="palette.new")
1067
1068
1069 class TEXTURE_UL_texpaintslots(UIList):
1070     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
1071         mat = data
1072
1073         if self.layout_type in {'DEFAULT', 'COMPACT'}:
1074             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
1075             if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1076                 mtex_index = mat.texture_paint_slots[index].index
1077                 layout.prop(mat, "use_textures", text="", index=mtex_index)
1078         elif self.layout_type in {'GRID'}:
1079             layout.alignment = 'CENTER'
1080             layout.label(text="")
1081
1082
1083 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
1084     bl_label = "Clone Layer"
1085
1086     def draw(self, context):
1087         layout = self.layout
1088
1089         for i, tex in enumerate(context.active_object.data.uv_textures):
1090             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1091             props.data_path = "active_object.data.uv_textures.active_index"
1092             props.value = i
1093
1094
1095 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
1096     bl_context = "imagepaint"
1097     bl_label = "Slots"
1098     bl_category = "Slots"
1099
1100     @classmethod
1101     def poll(cls, context):
1102         brush = context.tool_settings.image_paint.brush
1103         ob = context.active_object
1104         return (brush is not None and ob is not None)
1105
1106     def draw(self, context):
1107         layout = self.layout
1108
1109         settings = context.tool_settings.image_paint
1110         # brush = settings.brush
1111
1112         ob = context.active_object
1113         col = layout.column()
1114
1115         col.label("Painting Mode")
1116         col.prop(settings, "mode", text="")
1117         col.separator()
1118
1119         if settings.mode == 'MATERIAL':
1120             if len(ob.material_slots) > 1:
1121                 col.label("Materials")
1122                 col.template_list("MATERIAL_UL_matslots", "layers",
1123                                   ob, "material_slots",
1124                                   ob, "active_material_index", rows=2)
1125
1126             mat = ob.active_material
1127             if mat:
1128                 col.label("Available Paint Slots")
1129                 col.template_list("TEXTURE_UL_texpaintslots", "",
1130                                   mat, "texture_paint_images",
1131                                   mat, "paint_active_slot", rows=2)
1132
1133                 if mat.texture_paint_slots:
1134                     slot = mat.texture_paint_slots[mat.paint_active_slot]
1135                 else:
1136                     slot = None
1137
1138                 if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1139                     row = col.row(align=True)
1140                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
1141                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
1142
1143                     if slot:
1144                         col.prop(mat.texture_slots[slot.index], "blend_type")
1145                         col.separator()
1146
1147                 if slot and slot.index != -1:
1148                     col.label("UV Map")
1149                     col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1150
1151         elif settings.mode == 'IMAGE':
1152             mesh = ob.data
1153             uv_text = mesh.uv_textures.active.name if mesh.uv_textures.active else ""
1154             col.label("Canvas Image")
1155             col.template_ID(settings, "canvas")
1156             col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
1157             col.label("UV Map")
1158             col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
1159
1160         col.separator()
1161         col.operator("image.save_dirty", text="Save All Images")
1162
1163
1164 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1165     bl_context = "imagepaint"
1166     bl_label = "Mask"
1167     bl_category = "Slots"
1168
1169     @classmethod
1170     def poll(cls, context):
1171         brush = context.tool_settings.image_paint.brush
1172         ob = context.active_object
1173         return (brush is not None and ob is not None)
1174
1175     def draw_header(self, context):
1176         ipaint = context.tool_settings.image_paint
1177         self.layout.prop(ipaint, "use_stencil_layer", text="")
1178
1179     def draw(self, context):
1180         layout = self.layout
1181
1182         toolsettings = context.tool_settings
1183         ipaint = toolsettings.image_paint
1184         ob = context.active_object
1185         mesh = ob.data
1186
1187         col = layout.column()
1188         col.active = ipaint.use_stencil_layer
1189
1190         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1191         col.label("UV Map")
1192         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1193
1194         col.label("Stencil Image")
1195         col.template_ID(ipaint, "stencil_image")
1196         col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
1197
1198         col.label("Visualization")
1199         row = col.row(align=True)
1200         row.prop(ipaint, "stencil_color", text="")
1201         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1202
1203
1204 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1205     bl_category = "Options"
1206     bl_label = "Overlay"
1207
1208     @classmethod
1209     def poll(cls, context):
1210         settings = cls.paint_settings(context)
1211         return (settings and
1212                 settings.brush and
1213                 (context.sculpt_object or
1214                  context.vertex_paint_object or
1215                  context.weight_paint_object or
1216                  context.image_paint_object))
1217
1218     def draw(self, context):
1219         layout = self.layout
1220
1221         settings = self.paint_settings(context)
1222         brush = settings.brush
1223         tex_slot = brush.texture_slot
1224         tex_slot_mask = brush.mask_texture_slot
1225
1226         col = layout.column()
1227
1228         col.label(text="Curve:")
1229
1230         row = col.row(align=True)
1231         if brush.use_cursor_overlay:
1232             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1233         else:
1234             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1235
1236         sub = row.row(align=True)
1237         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1238         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1239
1240         col.active = brush.brush_capabilities.has_overlay
1241
1242         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1243             col.label(text="Texture:")
1244             row = col.row(align=True)
1245             if tex_slot.map_mode != 'STENCIL':
1246                 if brush.use_primary_overlay:
1247                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1248                 else:
1249                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1250
1251             sub = row.row(align=True)
1252             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1253             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1254
1255         if context.image_paint_object:
1256             col.label(text="Mask Texture:")
1257
1258             row = col.row(align=True)
1259             if tex_slot_mask.map_mode != 'STENCIL':
1260                 if brush.use_secondary_overlay:
1261                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1262                 else:
1263                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1264
1265             sub = row.row(align=True)
1266             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1267             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1268
1269
1270 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1271     bl_category = "Tools"
1272     bl_label = "Texture"
1273     bl_options = {'DEFAULT_CLOSED'}
1274
1275     @classmethod
1276     def poll(cls, context):
1277         settings = cls.paint_settings(context)
1278         return (settings and settings.brush and
1279                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1280
1281     def draw(self, context):
1282         layout = self.layout
1283
1284         settings = self.paint_settings(context)
1285         brush = settings.brush
1286
1287         col = layout.column()
1288
1289         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1290
1291         brush_texture_settings(col, brush, context.sculpt_object)
1292
1293
1294 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
1295     bl_category = "Tools"
1296     bl_context = "imagepaint"
1297     bl_label = "Texture Mask"
1298     bl_options = {'DEFAULT_CLOSED'}
1299
1300     @classmethod
1301     def poll(cls, context):
1302         settings = cls.paint_settings(context)
1303         return (settings and settings.brush and context.image_paint_object)
1304
1305     def draw(self, context):
1306         layout = self.layout
1307
1308         brush = context.tool_settings.image_paint.brush
1309
1310         col = layout.column()
1311
1312         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1313
1314         brush_mask_texture_settings(col, brush)
1315
1316
1317 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1318     bl_category = "Tools"
1319     bl_label = "Stroke"
1320     bl_options = {'DEFAULT_CLOSED'}
1321
1322     @classmethod
1323     def poll(cls, context):
1324         settings = cls.paint_settings(context)
1325         return (settings and
1326                 settings.brush and
1327                 (context.sculpt_object or
1328                  context.vertex_paint_object or
1329                  context.weight_paint_object or
1330                  context.image_paint_object))
1331
1332     def draw(self, context):
1333         layout = self.layout
1334
1335         settings = self.paint_settings(context)
1336         brush = settings.brush
1337
1338         col = layout.column()
1339
1340         col.label(text="Stroke Method:")
1341
1342         col.prop(brush, "stroke_method", text="")
1343
1344         if brush.use_anchor:
1345             col.separator()
1346             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1347
1348         if brush.use_airbrush:
1349             col.separator()
1350             col.prop(brush, "rate", text="Rate", slider=True)
1351
1352         if brush.use_space:
1353             col.separator()
1354             row = col.row(align=True)
1355             row.prop(brush, "spacing", text="Spacing")
1356             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1357
1358         if brush.use_line or brush.use_curve:
1359             col.separator()
1360             row = col.row(align=True)
1361             row.prop(brush, "spacing", text="Spacing")
1362
1363         if brush.use_curve:
1364             col.separator()
1365             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1366             col.operator("paintcurve.draw")
1367
1368         if context.sculpt_object:
1369             if brush.sculpt_capabilities.has_jitter:
1370                 col.separator()
1371
1372                 row = col.row(align=True)
1373                 row.prop(brush, "use_relative_jitter", icon_only=True)
1374                 if brush.use_relative_jitter:
1375                     row.prop(brush, "jitter", slider=True)
1376                 else:
1377                     row.prop(brush, "jitter_absolute")
1378                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1379
1380             if brush.sculpt_capabilities.has_smooth_stroke:
1381                 col = layout.column()
1382                 col.separator()
1383
1384                 col.prop(brush, "use_smooth_stroke")
1385
1386                 sub = col.column()
1387                 sub.active = brush.use_smooth_stroke
1388                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1389                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1390         else:
1391             col.separator()
1392
1393             row = col.row(align=True)
1394             row.prop(brush, "use_relative_jitter", icon_only=True)
1395             if brush.use_relative_jitter:
1396                 row.prop(brush, "jitter", slider=True)
1397             else:
1398                 row.prop(brush, "jitter_absolute")
1399             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1400
1401             col = layout.column()
1402             col.separator()
1403
1404             if brush.brush_capabilities.has_smooth_stroke:
1405                 col.prop(brush, "use_smooth_stroke")
1406
1407                 sub = col.column()
1408                 sub.active = brush.use_smooth_stroke
1409                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1410                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1411
1412         layout.prop(settings, "input_samples")
1413
1414
1415 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1416     bl_category = "Tools"
1417     bl_label = "Curve"
1418     bl_options = {'DEFAULT_CLOSED'}
1419
1420     @classmethod
1421     def poll(cls, context):
1422         settings = cls.paint_settings(context)
1423         return (settings and settings.brush and settings.brush.curve)
1424
1425     def draw(self, context):
1426         layout = self.layout
1427
1428         settings = self.paint_settings(context)
1429
1430         brush = settings.brush
1431
1432         layout.template_curve_mapping(brush, "curve", brush=True)
1433
1434         col = layout.column(align=True)
1435         row = col.row(align=True)
1436         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1437         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1438         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1439         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1440         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1441         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1442
1443
1444 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1445     bl_category = "Tools"
1446     bl_label = "Dyntopo"
1447     bl_options = {'DEFAULT_CLOSED'}
1448
1449     @classmethod
1450     def poll(cls, context):
1451         return (context.sculpt_object and context.tool_settings.sculpt)
1452
1453     def draw(self, context):
1454         layout = self.layout
1455
1456         toolsettings = context.tool_settings
1457         sculpt = toolsettings.sculpt
1458         settings = self.paint_settings(context)
1459         brush = settings.brush
1460
1461         if context.sculpt_object.use_dynamic_topology_sculpting:
1462             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1463         else:
1464             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1465
1466         col = layout.column()
1467         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1468         sub = col.column(align=True)
1469         sub.active = (brush and brush.sculpt_tool != 'MASK')
1470         if (sculpt.detail_type_method == 'CONSTANT'):
1471             row = sub.row(align=True)
1472             row.prop(sculpt, "constant_detail")
1473             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1474         else:
1475             sub.prop(sculpt, "detail_size")
1476         sub.prop(sculpt, "detail_refine_method", text="")
1477         sub.prop(sculpt, "detail_type_method", text="")
1478         col.separator()
1479         col.prop(sculpt, "use_smooth_shading")
1480         col.operator("sculpt.optimize")
1481         if (sculpt.detail_type_method == 'CONSTANT'):
1482             col.operator("sculpt.detail_flood_fill")
1483         col.separator()
1484         col.prop(sculpt, "symmetrize_direction")
1485         col.operator("sculpt.symmetrize")
1486
1487
1488 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1489     bl_category = "Options"
1490     bl_label = "Options"
1491     bl_options = {'DEFAULT_CLOSED'}
1492
1493     @classmethod
1494     def poll(cls, context):
1495         return (context.sculpt_object and context.tool_settings.sculpt)
1496
1497     def draw(self, context):
1498         layout = self.layout
1499         # scene = context.scene
1500
1501         toolsettings = context.tool_settings
1502         sculpt = toolsettings.sculpt
1503         capabilities = sculpt.brush.sculpt_capabilities
1504
1505         col = layout.column(align=True)
1506         col.active = capabilities.has_gravity
1507         col.label(text="Gravity:")
1508         col.prop(sculpt, "gravity", slider=True, text="Factor")
1509         col.prop(sculpt, "gravity_object")
1510         col.separator()
1511
1512         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1513         layout.prop(sculpt, "show_low_resolution")
1514         layout.prop(sculpt, "use_deform_only")
1515         layout.prop(sculpt, "show_diffuse_color")
1516
1517         self.unified_paint_settings(layout, context)
1518
1519
1520 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1521     bl_category = "Tools"
1522     bl_label = "Symmetry / Lock"
1523     bl_options = {'DEFAULT_CLOSED'}
1524
1525     @classmethod
1526     def poll(cls, context):
1527         return (context.sculpt_object and context.tool_settings.sculpt)
1528
1529     def draw(self, context):
1530         layout = self.layout
1531
1532         sculpt = context.tool_settings.sculpt
1533
1534         col = layout.column(align=True)
1535         col.label(text="Mirror:")
1536         row = col.row(align=True)
1537         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1538         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1539         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1540
1541         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1542         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1543
1544         layout.label(text="Lock:")
1545
1546         row = layout.row(align=True)
1547         row.prop(sculpt, "lock_x", text="X", toggle=True)
1548         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1549         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1550
1551
1552 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1553     bl_category = "Options"
1554     bl_label = "Appearance"
1555
1556     @classmethod
1557     def poll(cls, context):
1558         settings = cls.paint_settings(context)
1559         return settings
1560
1561     def draw(self, context):
1562         layout = self.layout
1563
1564         settings = self.paint_settings(context)
1565         brush = settings.brush
1566
1567         if brush is None:  # unlikely but can happen
1568             layout.label(text="Brush Unset")
1569             return
1570
1571         col = layout.column()
1572         col.prop(settings, "show_brush")
1573
1574         sub = col.column()
1575         sub.active = settings.show_brush
1576
1577         if context.sculpt_object and context.tool_settings.sculpt:
1578             if brush.sculpt_capabilities.has_secondary_color:
1579                 sub.row().prop(brush, "cursor_color_add", text="Add")
1580                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1581             else:
1582                 sub.prop(brush, "cursor_color_add", text="")
1583         else:
1584             sub.prop(brush, "cursor_color_add", text="")
1585
1586         col.separator()
1587
1588         col = col.column(align=True)
1589         col.prop(brush, "use_custom_icon")
1590         sub = col.column()
1591         sub.active = brush.use_custom_icon
1592         sub.prop(brush, "icon_filepath", text="")
1593
1594 # ********** default tools for weight-paint ****************
1595
1596
1597 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1598     bl_category = "Tools"
1599     bl_context = "weightpaint"
1600     bl_label = "Weight Tools"
1601
1602     def draw(self, context):
1603         layout = self.layout
1604         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1605
1606         col = layout.column()
1607         col.operator("paint.weight_gradient")
1608         prop = col.operator("object.data_transfer", text="Transfer Weights")
1609         prop.use_reverse_transfer = True
1610         prop.data_type = 'VGROUP_WEIGHTS'
1611
1612
1613 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1614     bl_category = "Options"
1615     bl_context = "weightpaint"
1616     bl_label = "Options"
1617
1618     def draw(self, context):
1619         layout = self.layout
1620
1621         tool_settings = context.tool_settings
1622         wpaint = tool_settings.weight_paint
1623
1624         col = layout.column()
1625         row = col.row()
1626
1627         row.prop(wpaint, "use_normal")
1628         col = layout.column()
1629         row = col.row()
1630         row.prop(wpaint, "use_spray")
1631         row.prop(wpaint, "use_group_restrict")
1632
1633         obj = context.weight_paint_object
1634         if obj.type == 'MESH':
1635             mesh = obj.data
1636             col.prop(mesh, "use_mirror_x")
1637             row = col.row()
1638             row.active = mesh.use_mirror_x
1639             row.prop(mesh, "use_mirror_topology")
1640
1641         col.label("Show Zero Weights:")
1642         sub = col.row()
1643         sub.active = (not tool_settings.use_multipaint)
1644         sub.prop(tool_settings, "vertex_group_user", expand=True)
1645
1646         self.unified_paint_settings(col, context)
1647
1648 # ********** default tools for vertex-paint ****************
1649
1650
1651 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1652     bl_category = "Options"
1653     bl_context = "vertexpaint"
1654     bl_label = "Options"
1655
1656     def draw(self, context):
1657         layout = self.layout
1658
1659         toolsettings = context.tool_settings
1660         vpaint = toolsettings.vertex_paint
1661
1662         col = layout.column()
1663         row = col.row()
1664         # col.prop(vpaint, "mode", text="")
1665         row.prop(vpaint, "use_normal")
1666         col.prop(vpaint, "use_spray")
1667
1668         self.unified_paint_settings(col, context)
1669
1670 # Commented out because the Apply button isn't an operator yet, making these settings useless
1671 #~         col.label(text="Gamma:")
1672 #~         col.prop(vpaint, "gamma", text="")
1673 #~         col.label(text="Multiply:")
1674 #~         col.prop(vpaint, "mul", text="")
1675
1676 # ********** default tools for texture-paint ****************
1677
1678
1679 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1680     bl_category = "Tools"
1681     bl_context = "imagepaint"
1682     bl_label = "External"
1683     bl_options = {'DEFAULT_CLOSED'}
1684
1685     def draw(self, context):
1686         layout = self.layout
1687
1688         toolsettings = context.tool_settings
1689         ipaint = toolsettings.image_paint
1690
1691         col = layout.column()
1692         row = col.split(align=True, percentage=0.55)
1693         row.operator("image.project_edit", text="Quick Edit")
1694         row.operator("image.project_apply", text="Apply")
1695
1696         col.row().prop(ipaint, "screen_grab_size", text="")
1697
1698         col.operator("paint.project_image", text="Apply Camera Image")
1699
1700
1701 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1702     bl_category = "Options"
1703     bl_context = "imagepaint"
1704     bl_label = "Project Paint"
1705
1706     @classmethod
1707     def poll(cls, context):
1708         brush = context.tool_settings.image_paint.brush
1709         return (brush is not None)
1710
1711     def draw(self, context):
1712         layout = self.layout
1713
1714         toolsettings = context.tool_settings
1715         ipaint = toolsettings.image_paint
1716
1717         col = layout.column()
1718
1719         col.prop(ipaint, "use_occlude")
1720         col.prop(ipaint, "use_backface_culling")
1721
1722         row = layout.row()
1723         row.prop(ipaint, "use_normal_falloff")
1724
1725         sub = row.row()
1726         sub.active = (ipaint.use_normal_falloff)
1727         sub.prop(ipaint, "normal_angle", text="")
1728
1729         layout.prop(ipaint, "use_cavity")
1730         if ipaint.use_cavity:
1731             layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1732
1733         layout.prop(ipaint, "seam_bleed")
1734         layout.prop(ipaint, "dither")
1735         self.unified_paint_settings(layout, context)
1736
1737
1738 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1739     bl_category = "Options"
1740     bl_label = "Options"
1741
1742     @classmethod
1743     def poll(cls, context):
1744         return (context.image_paint_object and context.tool_settings.image_paint)
1745
1746     def draw(self, context):
1747         layout = self.layout
1748
1749         col = layout.column()
1750         self.unified_paint_settings(col, context)
1751
1752
1753 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1754     bl_label = "Mask Layer"
1755
1756     def draw(self, context):
1757         layout = self.layout
1758         for i, tex in enumerate(context.active_object.data.uv_textures):
1759             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1760             props.data_path = "active_object.data.uv_texture_stencil_index"
1761             props.value = i
1762
1763
1764 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1765     """Default tools for particle mode"""
1766     bl_context = "particlemode"
1767     bl_label = "Options"
1768     bl_category = "Tools"
1769
1770     def draw(self, context):
1771         layout = self.layout
1772
1773         pe = context.tool_settings.particle_edit
1774         ob = pe.object
1775
1776         layout.prop(pe, "type", text="")
1777
1778         ptcache = None
1779
1780         if pe.type == 'PARTICLES':
1781             if ob.particle_systems:
1782                 if len(ob.particle_systems) > 1:
1783                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1784                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1785
1786                 ptcache = ob.particle_systems.active.point_cache
1787         else:
1788             for md in ob.modifiers:
1789                 if md.type == pe.type:
1790                     ptcache = md.point_cache
1791
1792         if ptcache and len(ptcache.point_caches) > 1:
1793             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1794                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1795
1796         if not pe.is_editable:
1797             layout.label(text="Point cache must be baked")
1798             layout.label(text="in memory to enable editing!")
1799
1800         col = layout.column(align=True)
1801         if pe.is_hair:
1802             col.active = pe.is_editable
1803             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1804             sub = col.row(align=True)
1805             sub.active = pe.use_emitter_deflect
1806             sub.prop(pe, "emitter_distance", text="Distance")
1807
1808         col = layout.column(align=True)
1809         col.active = pe.is_editable
1810         col.label(text="Keep:")
1811         col.prop(pe, "use_preserve_length", text="Lengths")
1812         col.prop(pe, "use_preserve_root", text="Root")
1813         if not pe.is_hair:
1814             col.label(text="Correct:")
1815             col.prop(pe, "use_auto_velocity", text="Velocity")
1816         col.prop(ob.data, "use_mirror_x")
1817
1818         col.prop(pe, "shape_object")
1819         col.operator("particle.shape_cut")
1820
1821         col = layout.column(align=True)
1822         col.active = pe.is_editable
1823         col.label(text="Draw:")
1824         col.prop(pe, "draw_step", text="Path Steps")
1825         if pe.is_hair:
1826             col.prop(pe, "show_particles", text="Children")
1827         else:
1828             if pe.type == 'PARTICLES':
1829                 col.prop(pe, "show_particles", text="Particles")
1830             col.prop(pe, "use_fade_time")
1831             sub = col.row(align=True)
1832             sub.active = pe.use_fade_time
1833             sub.prop(pe, "fade_frames", slider=True)
1834
1835
1836 # Grease Pencil drawing tools
1837 class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
1838     bl_space_type = 'VIEW_3D'
1839
1840
1841 # Grease Pencil stroke editing tools
1842 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1843     bl_space_type = 'VIEW_3D'
1844
1845
1846 # Note: moved here so that it's always in last position in 'Tools' panels!
1847 class VIEW3D_PT_tools_history(View3DPanel, Panel):
1848     bl_category = "Tools"
1849     # No bl_context, we are always available!
1850     bl_label = "History"
1851     bl_options = {'DEFAULT_CLOSED'}
1852
1853     def draw(self, context):
1854         layout = self.layout
1855         obj = context.object
1856
1857         col = layout.column(align=True)
1858         row = col.row(align=True)
1859         row.operator("ed.undo")
1860         row.operator("ed.redo")
1861         if obj is None or obj.mode not in {'SCULPT'}:
1862             # Sculpt mode does not generate an undo menu it seems...
1863             col.operator("ed.undo_history")
1864
1865         col = layout.column(align=True)
1866         col.label(text="Repeat:")
1867         col.operator("screen.repeat_last")
1868         col.operator("screen.repeat_history", text="History...")
1869
1870
1871 if __name__ == "__main__":  # only for live edit.
1872     bpy.utils.register_module(__name__)