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