Fix T44821: Making warp shortcut fails
[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 == '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("transform.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         props = row.operator("mesh.mark_sharp", text="Smooth")
411         props.use_verts = True
412         props.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("transform.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.spin")
577         col.operator("curve.subdivide")
578
579         col = layout.column(align=True)
580         col.label(text="Deform:")
581         col.operator("transform.vertex_random")
582
583
584 class VIEW3D_PT_tools_add_surface_edit(View3DPanel, Panel):
585     bl_category = "Create"
586     bl_context = "surface_edit"
587     bl_label = "Add Surfaces"
588
589     def draw(self, context):
590         layout = self.layout
591
592         col = layout.column(align=True)
593
594         VIEW3D_PT_tools_add_object.draw_add_surface(col)
595
596
597 # ********** default tools for editmode_text ****************
598
599
600 class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
601     bl_category = "Tools"
602     bl_context = "text_edit"
603     bl_label = "Text Tools"
604
605     def draw(self, context):
606         layout = self.layout
607
608         col = layout.column(align=True)
609         col.label(text="Set Case:")
610         col.operator("font.case_set", text="To Upper").case = 'UPPER'
611         col.operator("font.case_set", text="To Lower").case = 'LOWER'
612
613         col = layout.column(align=True)
614         col.label(text="Style:")
615         col.operator("font.style_toggle", text="Bold").style = 'BOLD'
616         col.operator("font.style_toggle", text="Italic").style = 'ITALIC'
617         col.operator("font.style_toggle", text="Underline").style = 'UNDERLINE'
618
619
620 # ********** default tools for editmode_armature ****************
621
622
623 class VIEW3D_PT_tools_armatureedit_transform(View3DPanel, Panel):
624     bl_category = "Tools"
625     bl_context = "armature_edit"
626     bl_label = "Transform"
627
628     def draw(self, context):
629         layout = self.layout
630
631         col = layout.column(align=True)
632         col.operator("transform.translate")
633         col.operator("transform.rotate")
634         col.operator("transform.resize", text="Scale")
635
636
637 class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
638     bl_category = "Tools"
639     bl_context = "armature_edit"
640     bl_label = "Armature Tools"
641
642     def draw(self, context):
643         layout = self.layout
644
645         col = layout.column(align=True)
646         col.label(text="Bones:")
647         col.operator("armature.bone_primitive_add", text="Add")
648         col.operator("armature.duplicate_move", text="Duplicate")
649         col.operator("armature.delete", text="Delete")
650
651         col = layout.column(align=True)
652         col.label(text="Modeling:")
653         col.operator("armature.extrude_move")
654         col.operator("armature.subdivide", text="Subdivide")
655
656         col = layout.column(align=True)
657         col.label(text="Deform:")
658         col.operator("transform.vertex_random")
659
660
661 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
662     bl_category = "Options"
663     bl_context = "armature_edit"
664     bl_label = "Armature Options"
665
666     def draw(self, context):
667         arm = context.active_object.data
668
669         self.layout.prop(arm, "use_mirror_x")
670
671
672 # ********** default tools for editmode_mball ****************
673
674
675 class VIEW3D_PT_tools_mballedit(View3DPanel, Panel):
676     bl_category = "Tools"
677     bl_context = "mball_edit"
678     bl_label = "Meta Tools"
679
680     def draw(self, context):
681         layout = self.layout
682
683         col = layout.column(align=True)
684         col.label(text="Transform:")
685         col.operator("transform.translate")
686         col.operator("transform.rotate")
687         col.operator("transform.resize", text="Scale")
688
689         col = layout.column(align=True)
690         col.label(text="Deform:")
691         col.operator("transform.vertex_random")
692
693
694 class VIEW3D_PT_tools_add_mball_edit(View3DPanel, Panel):
695     bl_category = "Create"
696     bl_context = "mball_edit"
697     bl_label = "Add Metaball"
698
699     def draw(self, context):
700         layout = self.layout
701
702         col = layout.column(align=True)
703
704         VIEW3D_PT_tools_add_object.draw_add_mball(col)
705
706
707 # ********** default tools for editmode_lattice ****************
708
709
710 class VIEW3D_PT_tools_latticeedit(View3DPanel, Panel):
711     bl_category = "Tools"
712     bl_context = "lattice_edit"
713     bl_label = "Lattice Tools"
714
715     def draw(self, context):
716         layout = self.layout
717
718         col = layout.column(align=True)
719         col.label(text="Transform:")
720         col.operator("transform.translate")
721         col.operator("transform.rotate")
722         col.operator("transform.resize", text="Scale")
723
724         col = layout.column(align=True)
725         col.operator("lattice.make_regular")
726
727         col = layout.column(align=True)
728         col.label(text="Deform:")
729         col.operator("transform.vertex_random")
730
731
732 # ********** default tools for pose-mode ****************
733
734
735 class VIEW3D_PT_tools_posemode(View3DPanel, Panel):
736     bl_category = "Tools"
737     bl_context = "posemode"
738     bl_label = "Pose Tools"
739
740     def draw(self, context):
741         layout = self.layout
742
743         col = layout.column(align=True)
744         col.label(text="Transform:")
745         col.operator("transform.translate")
746         col.operator("transform.rotate")
747         col.operator("transform.resize", text="Scale")
748
749         col = layout.column(align=True)
750         col.label(text="In-Between:")
751         row = col.row(align=True)
752         row.operator("pose.push", text="Push")
753         row.operator("pose.relax", text="Relax")
754         col.operator("pose.breakdown", text="Breakdowner")
755
756         col = layout.column(align=True)
757         col.label(text="Pose:")
758         row = col.row(align=True)
759         row.operator("pose.copy", text="Copy")
760         row.operator("pose.paste", text="Paste")
761
762         row = layout.row(align=True)
763         row.operator("pose.propagate", text="Propagate")
764         row.menu("VIEW3D_MT_pose_propagate", icon='TRIA_RIGHT', text="")
765
766         col = layout.column(align=True)
767         col.operator("poselib.pose_add", text="Add To Library")
768
769         draw_keyframing_tools(context, layout)
770
771         col = layout.column(align=True)
772         col.label(text="Motion Paths:")
773         row = col.row(align=True)
774         row.operator("pose.paths_calculate", text="Calculate")
775         row.operator("pose.paths_clear", text="Clear")
776
777
778 class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
779     bl_category = "Options"
780     bl_context = "posemode"
781     bl_label = "Pose Options"
782
783     def draw(self, context):
784         arm = context.active_object.data
785
786         self.layout.prop(arm, "use_auto_ik")
787
788 # ********** default tools for paint modes ****************
789
790
791 class View3DPaintPanel(UnifiedPaintPanel):
792     bl_space_type = 'VIEW_3D'
793     bl_region_type = 'TOOLS'
794
795
796 class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
797     bl_category = "Tools"
798     bl_label = "Missing Data"
799
800     @classmethod
801     def poll(cls, context):
802         toolsettings = context.tool_settings.image_paint
803         return context.image_paint_object and not toolsettings.detect_data()
804
805     def draw(self, context):
806         layout = self.layout
807         toolsettings = context.tool_settings.image_paint
808
809         col = layout.column()
810         col.label("Missing Data", icon='ERROR')
811         if toolsettings.missing_uvs:
812             col.separator()
813             col.label("Missing UVs", icon='INFO')
814             col.label("Unwrap the mesh in edit mode or generate a simple UV layer")
815             col.operator("paint.add_simple_uvs")
816
817         if toolsettings.mode == 'MATERIAL':
818             if toolsettings.missing_materials:
819                 col.separator()
820                 col.label("Missing Materials", icon='INFO')
821                 col.label("Add a material and paint slot below")
822                 col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
823             elif toolsettings.missing_texture:
824                 ob = context.active_object
825                 mat = ob.active_material
826
827                 col.separator()
828                 if mat:
829                     col.label("Missing Texture Slots", icon='INFO')
830                     col.label("Add a paint slot below")
831                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
832                 else:
833                     col.label("Missing Materials", icon='INFO')
834                     col.label("Add a material and paint slot below")
835                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
836
837         elif toolsettings.mode == 'IMAGE':
838             if toolsettings.missing_texture:
839                 col.separator()
840                 col.label("Missing Canvas", icon='INFO')
841                 col.label("Add or assign a canvas image below")
842                 col.label("Canvas Image")
843                 col.template_ID(toolsettings, "canvas")
844                 col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
845
846         if toolsettings.missing_stencil:
847             col.separator()
848             col.label("Missing Stencil", icon='INFO')
849             col.label("Add or assign a stencil image below")
850             col.label("Stencil Image")
851             col.template_ID(toolsettings, "stencil_image")
852             col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
853
854
855 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
856     bl_category = "Tools"
857     bl_label = "Brush"
858
859     @classmethod
860     def poll(cls, context):
861         return cls.paint_settings(context)
862
863     def draw(self, context):
864         layout = self.layout
865
866         toolsettings = context.tool_settings
867         settings = self.paint_settings(context)
868         brush = settings.brush
869
870         if not context.particle_edit_object:
871             col = layout.split().column()
872             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
873
874         # Particle Mode #
875         if context.particle_edit_object:
876             tool = settings.tool
877
878             layout.column().prop(settings, "tool", expand=True)
879
880             if tool != 'NONE':
881                 col = layout.column()
882                 col.prop(brush, "size", slider=True)
883                 if tool != 'ADD':
884                     col.prop(brush, "strength", slider=True)
885
886             if tool == 'ADD':
887                 col.prop(brush, "count")
888                 col = layout.column()
889                 col.prop(settings, "use_default_interpolate")
890                 col.prop(brush, "steps", slider=True)
891                 col.prop(settings, "default_key_count", slider=True)
892             elif tool == 'LENGTH':
893                 layout.prop(brush, "length_mode", expand=True)
894             elif tool == 'PUFF':
895                 layout.prop(brush, "puff_mode", expand=True)
896                 layout.prop(brush, "use_puff_volume")
897
898         # Sculpt Mode #
899
900         elif context.sculpt_object and brush:
901             capabilities = brush.sculpt_capabilities
902
903             col = layout.column()
904
905             col.separator()
906
907             row = col.row(align=True)
908
909             ups = toolsettings.unified_paint_settings
910             if ((ups.use_unified_size and ups.use_locked_size) or
911                     ((not ups.use_unified_size) and brush.use_locked_size)):
912                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
913                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
914             else:
915                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
916                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
917
918             self.prop_unified_size(row, context, brush, "use_pressure_size")
919
920             # strength, use_strength_pressure, and use_strength_attenuation
921             col.separator()
922             row = col.row(align=True)
923
924             if capabilities.has_space_attenuation:
925                 row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
926
927             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
928
929             if capabilities.has_strength_pressure:
930                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
931
932             # auto_smooth_factor and use_inverse_smooth_pressure
933             if capabilities.has_auto_smooth:
934                 col.separator()
935
936                 row = col.row(align=True)
937                 row.prop(brush, "auto_smooth_factor", slider=True)
938                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
939
940             # normal_weight
941             if capabilities.has_normal_weight:
942                 col.separator()
943                 row = col.row(align=True)
944                 row.prop(brush, "normal_weight", slider=True)
945
946             # crease_pinch_factor
947             if capabilities.has_pinch_factor:
948                 col.separator()
949                 row = col.row(align=True)
950                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
951
952             # use_original_normal and sculpt_plane
953             if capabilities.has_sculpt_plane:
954                 col.separator()
955                 row = col.row(align=True)
956
957                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
958
959                 row.prop(brush, "sculpt_plane", text="")
960
961             if brush.sculpt_tool == 'MASK':
962                 col.prop(brush, "mask_tool", text="")
963
964             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
965             if capabilities.has_plane_offset:
966                 row = col.row(align=True)
967                 row.prop(brush, "plane_offset", slider=True)
968                 row.prop(brush, "use_offset_pressure", text="")
969
970                 col.separator()
971
972                 row = col.row()
973                 row.prop(brush, "use_plane_trim", text="Trim")
974                 row = col.row()
975                 row.active = brush.use_plane_trim
976                 row.prop(brush, "plane_trim", slider=True, text="Distance")
977
978             # height
979             if capabilities.has_height:
980                 row = col.row()
981                 row.prop(brush, "height", slider=True, text="Height")
982
983             # use_frontface
984             col.separator()
985             row = col.row()
986             row.prop(brush, "use_frontface", text="Front Faces Only")
987
988             # direction
989             col.separator()
990             col.row().prop(brush, "direction", expand=True)
991
992             # use_accumulate
993             if capabilities.has_accumulate:
994                 col.separator()
995
996                 col.prop(brush, "use_accumulate")
997
998             # use_persistent, set_persistent_base
999             if capabilities.has_persistence:
1000                 col.separator()
1001
1002                 ob = context.sculpt_object
1003                 do_persistent = True
1004
1005                 # not supported yet for this case
1006                 for md in ob.modifiers:
1007                     if md.type == 'MULTIRES':
1008                         do_persistent = False
1009                         break
1010
1011                 if do_persistent:
1012                     col.prop(brush, "use_persistent")
1013                     col.operator("sculpt.set_persistent_base")
1014
1015         # Texture Paint Mode #
1016
1017         elif context.image_paint_object and brush:
1018             brush_texpaint_common(self, context, layout, brush, settings, True)
1019
1020         # Weight Paint Mode #
1021         elif context.weight_paint_object and brush:
1022
1023             col = layout.column()
1024
1025             row = col.row(align=True)
1026             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
1027
1028             row = col.row(align=True)
1029             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1030             self.prop_unified_size(row, context, brush, "use_pressure_size")
1031
1032             row = col.row(align=True)
1033             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1034             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1035
1036             col.prop(brush, "vertex_tool", text="Blend")
1037
1038             col = layout.column()
1039             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
1040             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
1041
1042         # Vertex Paint Mode #
1043         elif context.vertex_paint_object and brush:
1044             col = layout.column()
1045             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
1046             if settings.palette:
1047                 col.template_palette(settings, "palette", color=True)
1048             self.prop_unified_color(col, context, brush, "color", text="")
1049
1050             col.separator()
1051             row = col.row(align=True)
1052             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1053             self.prop_unified_size(row, context, brush, "use_pressure_size")
1054
1055             row = col.row(align=True)
1056             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1057             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1058
1059             # XXX - TODO
1060             # row = col.row(align=True)
1061             # row.prop(brush, "jitter", slider=True)
1062             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1063             col.separator()
1064             col.prop(brush, "vertex_tool", text="Blend")
1065
1066             col.separator()
1067             col.template_ID(settings, "palette", new="palette.new")
1068
1069
1070 class TEXTURE_UL_texpaintslots(UIList):
1071     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
1072         mat = data
1073
1074         if self.layout_type in {'DEFAULT', 'COMPACT'}:
1075             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
1076             if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1077                 mtex_index = mat.texture_paint_slots[index].index
1078                 layout.prop(mat, "use_textures", text="", index=mtex_index)
1079         elif self.layout_type == 'GRID':
1080             layout.alignment = 'CENTER'
1081             layout.label(text="")
1082
1083
1084 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
1085     bl_label = "Clone Layer"
1086
1087     def draw(self, context):
1088         layout = self.layout
1089
1090         for i, tex in enumerate(context.active_object.data.uv_textures):
1091             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1092             props.data_path = "active_object.data.uv_textures.active_index"
1093             props.value = i
1094
1095
1096 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
1097     bl_context = "imagepaint"
1098     bl_label = "Slots"
1099     bl_category = "Slots"
1100
1101     @classmethod
1102     def poll(cls, context):
1103         brush = context.tool_settings.image_paint.brush
1104         ob = context.active_object
1105         return (brush is not None and ob is not None)
1106
1107     def draw(self, context):
1108         layout = self.layout
1109
1110         settings = context.tool_settings.image_paint
1111         # brush = settings.brush
1112
1113         ob = context.active_object
1114         col = layout.column()
1115
1116         col.label("Painting Mode")
1117         col.prop(settings, "mode", text="")
1118         col.separator()
1119
1120         if settings.mode == 'MATERIAL':
1121             if len(ob.material_slots) > 1:
1122                 col.label("Materials")
1123                 col.template_list("MATERIAL_UL_matslots", "layers",
1124                                   ob, "material_slots",
1125                                   ob, "active_material_index", rows=2)
1126
1127             mat = ob.active_material
1128             if mat:
1129                 col.label("Available Paint Slots")
1130                 col.template_list("TEXTURE_UL_texpaintslots", "",
1131                                   mat, "texture_paint_images",
1132                                   mat, "paint_active_slot", rows=2)
1133
1134                 if mat.texture_paint_slots:
1135                     slot = mat.texture_paint_slots[mat.paint_active_slot]
1136                 else:
1137                     slot = None
1138
1139                 if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1140                     row = col.row(align=True)
1141                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
1142                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
1143
1144                     if slot:
1145                         col.prop(mat.texture_slots[slot.index], "blend_type")
1146                         col.separator()
1147
1148                 if slot and slot.index != -1:
1149                     col.label("UV Map")
1150                     col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1151
1152         elif settings.mode == 'IMAGE':
1153             mesh = ob.data
1154             uv_text = mesh.uv_textures.active.name if mesh.uv_textures.active else ""
1155             col.label("Canvas Image")
1156             col.template_ID(settings, "canvas")
1157             col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
1158             col.label("UV Map")
1159             col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
1160
1161         col.separator()
1162         col.operator("image.save_dirty", text="Save All Images")
1163
1164
1165 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1166     bl_context = "imagepaint"
1167     bl_label = "Mask"
1168     bl_category = "Slots"
1169
1170     @classmethod
1171     def poll(cls, context):
1172         brush = context.tool_settings.image_paint.brush
1173         ob = context.active_object
1174         return (brush is not None and ob is not None)
1175
1176     def draw_header(self, context):
1177         ipaint = context.tool_settings.image_paint
1178         self.layout.prop(ipaint, "use_stencil_layer", text="")
1179
1180     def draw(self, context):
1181         layout = self.layout
1182
1183         toolsettings = context.tool_settings
1184         ipaint = toolsettings.image_paint
1185         ob = context.active_object
1186         mesh = ob.data
1187
1188         col = layout.column()
1189         col.active = ipaint.use_stencil_layer
1190
1191         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1192         col.label("UV Map")
1193         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1194
1195         col.label("Stencil Image")
1196         col.template_ID(ipaint, "stencil_image")
1197         col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
1198
1199         col.label("Visualization")
1200         row = col.row(align=True)
1201         row.prop(ipaint, "stencil_color", text="")
1202         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1203
1204
1205 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1206     bl_category = "Options"
1207     bl_label = "Overlay"
1208
1209     @classmethod
1210     def poll(cls, context):
1211         settings = cls.paint_settings(context)
1212         return (settings and
1213                 settings.brush and
1214                 (context.sculpt_object or
1215                  context.vertex_paint_object or
1216                  context.weight_paint_object or
1217                  context.image_paint_object))
1218
1219     def draw(self, context):
1220         layout = self.layout
1221
1222         settings = self.paint_settings(context)
1223         brush = settings.brush
1224         tex_slot = brush.texture_slot
1225         tex_slot_mask = brush.mask_texture_slot
1226
1227         col = layout.column()
1228
1229         col.label(text="Curve:")
1230
1231         row = col.row(align=True)
1232         if brush.use_cursor_overlay:
1233             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1234         else:
1235             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1236
1237         sub = row.row(align=True)
1238         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1239         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1240
1241         col.active = brush.brush_capabilities.has_overlay
1242
1243         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1244             col.label(text="Texture:")
1245             row = col.row(align=True)
1246             if tex_slot.map_mode != 'STENCIL':
1247                 if brush.use_primary_overlay:
1248                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1249                 else:
1250                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1251
1252             sub = row.row(align=True)
1253             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1254             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1255
1256         if context.image_paint_object:
1257             col.label(text="Mask Texture:")
1258
1259             row = col.row(align=True)
1260             if tex_slot_mask.map_mode != 'STENCIL':
1261                 if brush.use_secondary_overlay:
1262                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1263                 else:
1264                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1265
1266             sub = row.row(align=True)
1267             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1268             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1269
1270
1271 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1272     bl_category = "Tools"
1273     bl_label = "Texture"
1274     bl_options = {'DEFAULT_CLOSED'}
1275
1276     @classmethod
1277     def poll(cls, context):
1278         settings = cls.paint_settings(context)
1279         return (settings and settings.brush and
1280                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1281
1282     def draw(self, context):
1283         layout = self.layout
1284
1285         settings = self.paint_settings(context)
1286         brush = settings.brush
1287
1288         col = layout.column()
1289
1290         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1291
1292         brush_texture_settings(col, brush, context.sculpt_object)
1293
1294
1295 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
1296     bl_category = "Tools"
1297     bl_context = "imagepaint"
1298     bl_label = "Texture Mask"
1299     bl_options = {'DEFAULT_CLOSED'}
1300
1301     @classmethod
1302     def poll(cls, context):
1303         settings = cls.paint_settings(context)
1304         return (settings and settings.brush and context.image_paint_object)
1305
1306     def draw(self, context):
1307         layout = self.layout
1308
1309         brush = context.tool_settings.image_paint.brush
1310
1311         col = layout.column()
1312
1313         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1314
1315         brush_mask_texture_settings(col, brush)
1316
1317
1318 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1319     bl_category = "Tools"
1320     bl_label = "Stroke"
1321     bl_options = {'DEFAULT_CLOSED'}
1322
1323     @classmethod
1324     def poll(cls, context):
1325         settings = cls.paint_settings(context)
1326         return (settings and
1327                 settings.brush and
1328                 (context.sculpt_object or
1329                  context.vertex_paint_object or
1330                  context.weight_paint_object or
1331                  context.image_paint_object))
1332
1333     def draw(self, context):
1334         layout = self.layout
1335
1336         settings = self.paint_settings(context)
1337         brush = settings.brush
1338
1339         col = layout.column()
1340
1341         col.label(text="Stroke Method:")
1342
1343         col.prop(brush, "stroke_method", text="")
1344
1345         if brush.use_anchor:
1346             col.separator()
1347             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1348
1349         if brush.use_airbrush:
1350             col.separator()
1351             col.prop(brush, "rate", text="Rate", slider=True)
1352
1353         if brush.use_space:
1354             col.separator()
1355             row = col.row(align=True)
1356             row.prop(brush, "spacing", text="Spacing")
1357             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1358
1359         if brush.use_line or brush.use_curve:
1360             col.separator()
1361             row = col.row(align=True)
1362             row.prop(brush, "spacing", text="Spacing")
1363
1364         if brush.use_curve:
1365             col.separator()
1366             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1367             col.operator("paintcurve.draw")
1368
1369         if context.sculpt_object:
1370             if brush.sculpt_capabilities.has_jitter:
1371                 col.separator()
1372
1373                 row = col.row(align=True)
1374                 row.prop(brush, "use_relative_jitter", icon_only=True)
1375                 if brush.use_relative_jitter:
1376                     row.prop(brush, "jitter", slider=True)
1377                 else:
1378                     row.prop(brush, "jitter_absolute")
1379                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1380
1381             if brush.sculpt_capabilities.has_smooth_stroke:
1382                 col = layout.column()
1383                 col.separator()
1384
1385                 col.prop(brush, "use_smooth_stroke")
1386
1387                 sub = col.column()
1388                 sub.active = brush.use_smooth_stroke
1389                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1390                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1391         else:
1392             col.separator()
1393
1394             row = col.row(align=True)
1395             row.prop(brush, "use_relative_jitter", icon_only=True)
1396             if brush.use_relative_jitter:
1397                 row.prop(brush, "jitter", slider=True)
1398             else:
1399                 row.prop(brush, "jitter_absolute")
1400             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1401
1402             col = layout.column()
1403             col.separator()
1404
1405             if brush.brush_capabilities.has_smooth_stroke:
1406                 col.prop(brush, "use_smooth_stroke")
1407
1408                 sub = col.column()
1409                 sub.active = brush.use_smooth_stroke
1410                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1411                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1412
1413         layout.prop(settings, "input_samples")
1414
1415
1416 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1417     bl_category = "Tools"
1418     bl_label = "Curve"
1419     bl_options = {'DEFAULT_CLOSED'}
1420
1421     @classmethod
1422     def poll(cls, context):
1423         settings = cls.paint_settings(context)
1424         return (settings and settings.brush and settings.brush.curve)
1425
1426     def draw(self, context):
1427         layout = self.layout
1428
1429         settings = self.paint_settings(context)
1430
1431         brush = settings.brush
1432
1433         layout.template_curve_mapping(brush, "curve", brush=True)
1434
1435         col = layout.column(align=True)
1436         row = col.row(align=True)
1437         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1438         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1439         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1440         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1441         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1442         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1443
1444
1445 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1446     bl_category = "Tools"
1447     bl_label = "Dyntopo"
1448     bl_options = {'DEFAULT_CLOSED'}
1449
1450     @classmethod
1451     def poll(cls, context):
1452         return (context.sculpt_object and context.tool_settings.sculpt)
1453
1454     def draw(self, context):
1455         layout = self.layout
1456
1457         toolsettings = context.tool_settings
1458         sculpt = toolsettings.sculpt
1459         settings = self.paint_settings(context)
1460         brush = settings.brush
1461
1462         if context.sculpt_object.use_dynamic_topology_sculpting:
1463             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1464         else:
1465             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1466
1467         col = layout.column()
1468         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1469         sub = col.column(align=True)
1470         sub.active = (brush and brush.sculpt_tool != 'MASK')
1471         if (sculpt.detail_type_method == 'CONSTANT'):
1472             row = sub.row(align=True)
1473             row.prop(sculpt, "constant_detail")
1474             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1475         elif (sculpt.detail_type_method == 'BRUSH'):
1476             sub.prop(sculpt, "detail_percent")
1477         else:
1478             sub.prop(sculpt, "detail_size")
1479         sub.prop(sculpt, "detail_refine_method", text="")
1480         sub.prop(sculpt, "detail_type_method", text="")
1481         col.separator()
1482         col.prop(sculpt, "use_smooth_shading")
1483         col.operator("sculpt.optimize")
1484         if (sculpt.detail_type_method == 'CONSTANT'):
1485             col.operator("sculpt.detail_flood_fill")
1486         col.separator()
1487         col.prop(sculpt, "symmetrize_direction")
1488         col.operator("sculpt.symmetrize")
1489
1490
1491 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1492     bl_category = "Options"
1493     bl_label = "Options"
1494     bl_options = {'DEFAULT_CLOSED'}
1495
1496     @classmethod
1497     def poll(cls, context):
1498         return (context.sculpt_object and context.tool_settings.sculpt)
1499
1500     def draw(self, context):
1501         layout = self.layout
1502         # scene = context.scene
1503
1504         toolsettings = context.tool_settings
1505         sculpt = toolsettings.sculpt
1506         capabilities = sculpt.brush.sculpt_capabilities
1507
1508         col = layout.column(align=True)
1509         col.active = capabilities.has_gravity
1510         col.label(text="Gravity:")
1511         col.prop(sculpt, "gravity", slider=True, text="Factor")
1512         col.prop(sculpt, "gravity_object")
1513         col.separator()
1514
1515         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1516         layout.prop(sculpt, "show_low_resolution")
1517         layout.prop(sculpt, "use_deform_only")
1518         layout.prop(sculpt, "show_diffuse_color")
1519
1520         self.unified_paint_settings(layout, context)
1521
1522
1523 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1524     bl_category = "Tools"
1525     bl_label = "Symmetry / Lock"
1526     bl_options = {'DEFAULT_CLOSED'}
1527
1528     @classmethod
1529     def poll(cls, context):
1530         return (context.sculpt_object and context.tool_settings.sculpt)
1531
1532     def draw(self, context):
1533         layout = self.layout
1534
1535         sculpt = context.tool_settings.sculpt
1536
1537         col = layout.column(align=True)
1538         col.label(text="Mirror:")
1539         row = col.row(align=True)
1540         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1541         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1542         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1543
1544         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1545         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1546
1547         layout.label(text="Lock:")
1548
1549         row = layout.row(align=True)
1550         row.prop(sculpt, "lock_x", text="X", toggle=True)
1551         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1552         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1553
1554
1555 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1556     bl_category = "Options"
1557     bl_label = "Appearance"
1558
1559     @classmethod
1560     def poll(cls, context):
1561         settings = cls.paint_settings(context)
1562         return settings
1563
1564     def draw(self, context):
1565         layout = self.layout
1566
1567         settings = self.paint_settings(context)
1568         brush = settings.brush
1569
1570         if brush is None:  # unlikely but can happen
1571             layout.label(text="Brush Unset")
1572             return
1573
1574         col = layout.column()
1575         col.prop(settings, "show_brush")
1576
1577         sub = col.column()
1578         sub.active = settings.show_brush
1579
1580         if context.sculpt_object and context.tool_settings.sculpt:
1581             if brush.sculpt_capabilities.has_secondary_color:
1582                 sub.row().prop(brush, "cursor_color_add", text="Add")
1583                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1584             else:
1585                 sub.prop(brush, "cursor_color_add", text="")
1586         else:
1587             sub.prop(brush, "cursor_color_add", text="")
1588
1589         col.separator()
1590
1591         col = col.column(align=True)
1592         col.prop(brush, "use_custom_icon")
1593         sub = col.column()
1594         sub.active = brush.use_custom_icon
1595         sub.prop(brush, "icon_filepath", text="")
1596
1597 # ********** default tools for weight-paint ****************
1598
1599
1600 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1601     bl_category = "Tools"
1602     bl_context = "weightpaint"
1603     bl_label = "Weight Tools"
1604
1605     def draw(self, context):
1606         layout = self.layout
1607         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1608
1609         col = layout.column()
1610         col.operator("paint.weight_gradient")
1611         props = col.operator("object.data_transfer", text="Transfer Weights")
1612         props.use_reverse_transfer = True
1613         props.data_type = 'VGROUP_WEIGHTS'
1614
1615
1616 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1617     bl_category = "Options"
1618     bl_context = "weightpaint"
1619     bl_label = "Options"
1620
1621     def draw(self, context):
1622         layout = self.layout
1623
1624         tool_settings = context.tool_settings
1625         wpaint = tool_settings.weight_paint
1626
1627         col = layout.column()
1628         row = col.row()
1629
1630         row.prop(wpaint, "use_normal")
1631         col = layout.column()
1632         row = col.row()
1633         row.prop(wpaint, "use_spray")
1634         row.prop(wpaint, "use_group_restrict")
1635
1636         obj = context.weight_paint_object
1637         if obj.type == 'MESH':
1638             mesh = obj.data
1639             col.prop(mesh, "use_mirror_x")
1640             row = col.row()
1641             row.active = mesh.use_mirror_x
1642             row.prop(mesh, "use_mirror_topology")
1643
1644         col.label("Show Zero Weights:")
1645         sub = col.row()
1646         sub.active = (not tool_settings.use_multipaint)
1647         sub.prop(tool_settings, "vertex_group_user", expand=True)
1648
1649         self.unified_paint_settings(col, context)
1650
1651 # ********** default tools for vertex-paint ****************
1652
1653
1654 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1655     bl_category = "Options"
1656     bl_context = "vertexpaint"
1657     bl_label = "Options"
1658
1659     def draw(self, context):
1660         layout = self.layout
1661
1662         toolsettings = context.tool_settings
1663         vpaint = toolsettings.vertex_paint
1664
1665         col = layout.column()
1666         row = col.row()
1667         # col.prop(vpaint, "mode", text="")
1668         row.prop(vpaint, "use_normal")
1669         col.prop(vpaint, "use_spray")
1670
1671         self.unified_paint_settings(col, context)
1672
1673 # Commented out because the Apply button isn't an operator yet, making these settings useless
1674 #~         col.label(text="Gamma:")
1675 #~         col.prop(vpaint, "gamma", text="")
1676 #~         col.label(text="Multiply:")
1677 #~         col.prop(vpaint, "mul", text="")
1678
1679 # ********** default tools for texture-paint ****************
1680
1681
1682 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1683     bl_category = "Tools"
1684     bl_context = "imagepaint"
1685     bl_label = "External"
1686     bl_options = {'DEFAULT_CLOSED'}
1687
1688     def draw(self, context):
1689         layout = self.layout
1690
1691         toolsettings = context.tool_settings
1692         ipaint = toolsettings.image_paint
1693
1694         col = layout.column()
1695         row = col.split(align=True, percentage=0.55)
1696         row.operator("image.project_edit", text="Quick Edit")
1697         row.operator("image.project_apply", text="Apply")
1698
1699         col.row().prop(ipaint, "screen_grab_size", text="")
1700
1701         col.operator("paint.project_image", text="Apply Camera Image")
1702
1703
1704 class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
1705     bl_category = "Tools"
1706     bl_context = "imagepaint"
1707     bl_label = "Symmetry"
1708     bl_options = {'DEFAULT_CLOSED'}
1709
1710     def draw(self, context):
1711         layout = self.layout
1712
1713         toolsettings = context.tool_settings
1714         ipaint = toolsettings.image_paint
1715
1716         col = layout.column(align=True)
1717         row = col.row(align=True)
1718         row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
1719         row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
1720         row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
1721
1722
1723 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1724     bl_category = "Options"
1725     bl_context = "imagepaint"
1726     bl_label = "Project Paint"
1727
1728     @classmethod
1729     def poll(cls, context):
1730         brush = context.tool_settings.image_paint.brush
1731         return (brush is not None)
1732
1733     def draw(self, context):
1734         layout = self.layout
1735
1736         toolsettings = context.tool_settings
1737         ipaint = toolsettings.image_paint
1738
1739         col = layout.column()
1740
1741         col.prop(ipaint, "use_occlude")
1742         col.prop(ipaint, "use_backface_culling")
1743
1744         row = layout.row()
1745         row.prop(ipaint, "use_normal_falloff")
1746
1747         sub = row.row()
1748         sub.active = (ipaint.use_normal_falloff)
1749         sub.prop(ipaint, "normal_angle", text="")
1750
1751         layout.prop(ipaint, "use_cavity")
1752         if ipaint.use_cavity:
1753             layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1754
1755         layout.prop(ipaint, "seam_bleed")
1756         layout.prop(ipaint, "dither")
1757         self.unified_paint_settings(layout, context)
1758
1759
1760 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1761     bl_category = "Options"
1762     bl_label = "Options"
1763
1764     @classmethod
1765     def poll(cls, context):
1766         return (context.image_paint_object and context.tool_settings.image_paint)
1767
1768     def draw(self, context):
1769         layout = self.layout
1770
1771         col = layout.column()
1772         self.unified_paint_settings(col, context)
1773
1774
1775 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1776     bl_label = "Mask Layer"
1777
1778     def draw(self, context):
1779         layout = self.layout
1780         for i, tex in enumerate(context.active_object.data.uv_textures):
1781             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1782             props.data_path = "active_object.data.uv_texture_stencil_index"
1783             props.value = i
1784
1785
1786 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1787     """Default tools for particle mode"""
1788     bl_context = "particlemode"
1789     bl_label = "Options"
1790     bl_category = "Tools"
1791
1792     def draw(self, context):
1793         layout = self.layout
1794
1795         pe = context.tool_settings.particle_edit
1796         ob = pe.object
1797
1798         layout.prop(pe, "type", text="")
1799
1800         ptcache = None
1801
1802         if pe.type == 'PARTICLES':
1803             if ob.particle_systems:
1804                 if len(ob.particle_systems) > 1:
1805                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1806                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1807
1808                 ptcache = ob.particle_systems.active.point_cache
1809         else:
1810             for md in ob.modifiers:
1811                 if md.type == pe.type:
1812                     ptcache = md.point_cache
1813
1814         if ptcache and len(ptcache.point_caches) > 1:
1815             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1816                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1817
1818         if not pe.is_editable:
1819             layout.label(text="Point cache must be baked")
1820             layout.label(text="in memory to enable editing!")
1821
1822         col = layout.column(align=True)
1823         if pe.is_hair:
1824             col.active = pe.is_editable
1825             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1826             sub = col.row(align=True)
1827             sub.active = pe.use_emitter_deflect
1828             sub.prop(pe, "emitter_distance", text="Distance")
1829
1830         col = layout.column(align=True)
1831         col.active = pe.is_editable
1832         col.label(text="Keep:")
1833         col.prop(pe, "use_preserve_length", text="Lengths")
1834         col.prop(pe, "use_preserve_root", text="Root")
1835         if not pe.is_hair:
1836             col.label(text="Correct:")
1837             col.prop(pe, "use_auto_velocity", text="Velocity")
1838         col.prop(ob.data, "use_mirror_x")
1839
1840         col.prop(pe, "shape_object")
1841         col.operator("particle.shape_cut")
1842
1843         col = layout.column(align=True)
1844         col.active = pe.is_editable
1845         col.label(text="Draw:")
1846         col.prop(pe, "draw_step", text="Path Steps")
1847         if pe.is_hair:
1848             col.prop(pe, "show_particles", text="Children")
1849         else:
1850             if pe.type == 'PARTICLES':
1851                 col.prop(pe, "show_particles", text="Particles")
1852             col.prop(pe, "use_fade_time")
1853             sub = col.row(align=True)
1854             sub.active = pe.use_fade_time
1855             sub.prop(pe, "fade_frames", slider=True)
1856
1857
1858 # Grease Pencil drawing tools
1859 class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
1860     bl_space_type = 'VIEW_3D'
1861
1862
1863 # Grease Pencil stroke editing tools
1864 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1865     bl_space_type = 'VIEW_3D'
1866
1867
1868 # Note: moved here so that it's always in last position in 'Tools' panels!
1869 class VIEW3D_PT_tools_history(View3DPanel, Panel):
1870     bl_category = "Tools"
1871     # No bl_context, we are always available!
1872     bl_label = "History"
1873     bl_options = {'DEFAULT_CLOSED'}
1874
1875     def draw(self, context):
1876         layout = self.layout
1877         obj = context.object
1878
1879         col = layout.column(align=True)
1880         row = col.row(align=True)
1881         row.operator("ed.undo")
1882         row.operator("ed.redo")
1883         if obj is None or obj.mode != 'SCULPT':
1884             # Sculpt mode does not generate an undo menu it seems...
1885             col.operator("ed.undo_history")
1886
1887         col = layout.column(align=True)
1888         col.label(text="Repeat:")
1889         col.operator("screen.repeat_last")
1890         col.operator("screen.repeat_history", text="History...")
1891
1892
1893 if __name__ == "__main__":  # only for live edit.
1894     bpy.utils.register_module(__name__)