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