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