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