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