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