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