Grease Pencil: Merge GPencil_Editing_Stage3 branch into master
[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             # use_original_normal and sculpt_plane
955             if capabilities.has_sculpt_plane:
956                 col.separator()
957                 row = col.row(align=True)
958
959                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
960
961                 row.prop(brush, "sculpt_plane", text="")
962
963             if brush.sculpt_tool == 'MASK':
964                 col.prop(brush, "mask_tool", text="")
965
966             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
967             if capabilities.has_plane_offset:
968                 row = col.row(align=True)
969                 row.prop(brush, "plane_offset", slider=True)
970                 row.prop(brush, "use_offset_pressure", text="")
971
972                 col.separator()
973
974                 row = col.row()
975                 row.prop(brush, "use_plane_trim", text="Trim")
976                 row = col.row()
977                 row.active = brush.use_plane_trim
978                 row.prop(brush, "plane_trim", slider=True, text="Distance")
979
980             # height
981             if capabilities.has_height:
982                 row = col.row()
983                 row.prop(brush, "height", slider=True, text="Height")
984
985             # use_frontface
986             col.separator()
987             row = col.row()
988             row.prop(brush, "use_frontface", text="Front Faces Only")
989
990             # direction
991             col.separator()
992             col.row().prop(brush, "direction", expand=True)
993
994             # use_accumulate
995             if capabilities.has_accumulate:
996                 col.separator()
997
998                 col.prop(brush, "use_accumulate")
999
1000             # use_persistent, set_persistent_base
1001             if capabilities.has_persistence:
1002                 col.separator()
1003
1004                 ob = context.sculpt_object
1005                 do_persistent = True
1006
1007                 # not supported yet for this case
1008                 for md in ob.modifiers:
1009                     if md.type == 'MULTIRES':
1010                         do_persistent = False
1011                         break
1012
1013                 if do_persistent:
1014                     col.prop(brush, "use_persistent")
1015                     col.operator("sculpt.set_persistent_base")
1016
1017         # Texture Paint Mode #
1018
1019         elif context.image_paint_object and brush:
1020             brush_texpaint_common(self, context, layout, brush, settings, True)
1021
1022         # Weight Paint Mode #
1023         elif context.weight_paint_object and brush:
1024
1025             col = layout.column()
1026
1027             row = col.row(align=True)
1028             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
1029
1030             row = col.row(align=True)
1031             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1032             self.prop_unified_size(row, context, brush, "use_pressure_size")
1033
1034             row = col.row(align=True)
1035             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1036             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1037
1038             col.prop(brush, "vertex_tool", text="Blend")
1039
1040             col = layout.column()
1041             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
1042             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
1043
1044         # Vertex Paint Mode #
1045         elif context.vertex_paint_object and brush:
1046             col = layout.column()
1047             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
1048             if settings.palette:
1049                 col.template_palette(settings, "palette", color=True)
1050             self.prop_unified_color(col, context, brush, "color", text="")
1051
1052             col.separator()
1053             row = col.row(align=True)
1054             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1055             self.prop_unified_size(row, context, brush, "use_pressure_size")
1056
1057             row = col.row(align=True)
1058             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1059             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1060
1061             # XXX - TODO
1062             # row = col.row(align=True)
1063             # row.prop(brush, "jitter", slider=True)
1064             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1065             col.separator()
1066             col.prop(brush, "vertex_tool", text="Blend")
1067
1068             col.separator()
1069             col.template_ID(settings, "palette", new="palette.new")
1070
1071
1072 class TEXTURE_UL_texpaintslots(UIList):
1073     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
1074         mat = data
1075
1076         if self.layout_type in {'DEFAULT', 'COMPACT'}:
1077             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
1078             if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1079                 mtex_index = mat.texture_paint_slots[index].index
1080                 layout.prop(mat, "use_textures", text="", index=mtex_index)
1081         elif self.layout_type == 'GRID':
1082             layout.alignment = 'CENTER'
1083             layout.label(text="")
1084
1085
1086 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
1087     bl_label = "Clone Layer"
1088
1089     def draw(self, context):
1090         layout = self.layout
1091
1092         for i, tex in enumerate(context.active_object.data.uv_textures):
1093             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1094             props.data_path = "active_object.data.uv_textures.active_index"
1095             props.value = i
1096
1097
1098 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
1099     bl_context = "imagepaint"
1100     bl_label = "Slots"
1101     bl_category = "Slots"
1102
1103     @classmethod
1104     def poll(cls, context):
1105         brush = context.tool_settings.image_paint.brush
1106         ob = context.active_object
1107         return (brush is not None and ob is not None)
1108
1109     def draw(self, context):
1110         layout = self.layout
1111
1112         settings = context.tool_settings.image_paint
1113         # brush = settings.brush
1114
1115         ob = context.active_object
1116         col = layout.column()
1117
1118         col.label("Painting Mode")
1119         col.prop(settings, "mode", text="")
1120         col.separator()
1121
1122         if settings.mode == 'MATERIAL':
1123             if len(ob.material_slots) > 1:
1124                 col.label("Materials")
1125                 col.template_list("MATERIAL_UL_matslots", "layers",
1126                                   ob, "material_slots",
1127                                   ob, "active_material_index", rows=2)
1128
1129             mat = ob.active_material
1130             if mat:
1131                 col.label("Available Paint Slots")
1132                 col.template_list("TEXTURE_UL_texpaintslots", "",
1133                                   mat, "texture_paint_images",
1134                                   mat, "paint_active_slot", rows=2)
1135
1136                 if mat.texture_paint_slots:
1137                     slot = mat.texture_paint_slots[mat.paint_active_slot]
1138                 else:
1139                     slot = None
1140
1141                 if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1142                     row = col.row(align=True)
1143                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
1144                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
1145
1146                     if slot:
1147                         col.prop(mat.texture_slots[slot.index], "blend_type")
1148                         col.separator()
1149
1150                 if slot and slot.index != -1:
1151                     col.label("UV Map")
1152                     col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1153
1154         elif settings.mode == 'IMAGE':
1155             mesh = ob.data
1156             uv_text = mesh.uv_textures.active.name if mesh.uv_textures.active else ""
1157             col.label("Canvas Image")
1158             col.template_ID(settings, "canvas")
1159             col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
1160             col.label("UV Map")
1161             col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
1162
1163         col.separator()
1164         col.operator("image.save_dirty", text="Save All Images")
1165
1166
1167 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1168     bl_context = "imagepaint"
1169     bl_label = "Mask"
1170     bl_category = "Slots"
1171
1172     @classmethod
1173     def poll(cls, context):
1174         brush = context.tool_settings.image_paint.brush
1175         ob = context.active_object
1176         return (brush is not None and ob is not None)
1177
1178     def draw_header(self, context):
1179         ipaint = context.tool_settings.image_paint
1180         self.layout.prop(ipaint, "use_stencil_layer", text="")
1181
1182     def draw(self, context):
1183         layout = self.layout
1184
1185         toolsettings = context.tool_settings
1186         ipaint = toolsettings.image_paint
1187         ob = context.active_object
1188         mesh = ob.data
1189
1190         col = layout.column()
1191         col.active = ipaint.use_stencil_layer
1192
1193         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1194         col.label("UV Map")
1195         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1196
1197         col.label("Stencil Image")
1198         col.template_ID(ipaint, "stencil_image")
1199         col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
1200
1201         col.label("Visualization")
1202         row = col.row(align=True)
1203         row.prop(ipaint, "stencil_color", text="")
1204         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1205
1206
1207 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1208     bl_category = "Options"
1209     bl_label = "Overlay"
1210
1211     @classmethod
1212     def poll(cls, context):
1213         settings = cls.paint_settings(context)
1214         return (settings and
1215                 settings.brush and
1216                 (context.sculpt_object or
1217                  context.vertex_paint_object or
1218                  context.weight_paint_object or
1219                  context.image_paint_object))
1220
1221     def draw(self, context):
1222         layout = self.layout
1223
1224         settings = self.paint_settings(context)
1225         brush = settings.brush
1226         tex_slot = brush.texture_slot
1227         tex_slot_mask = brush.mask_texture_slot
1228
1229         col = layout.column()
1230
1231         col.label(text="Curve:")
1232
1233         row = col.row(align=True)
1234         if brush.use_cursor_overlay:
1235             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1236         else:
1237             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1238
1239         sub = row.row(align=True)
1240         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1241         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1242
1243         col.active = brush.brush_capabilities.has_overlay
1244
1245         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1246             col.label(text="Texture:")
1247             row = col.row(align=True)
1248             if tex_slot.map_mode != 'STENCIL':
1249                 if brush.use_primary_overlay:
1250                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1251                 else:
1252                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1253
1254             sub = row.row(align=True)
1255             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1256             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1257
1258         if context.image_paint_object:
1259             col.label(text="Mask Texture:")
1260
1261             row = col.row(align=True)
1262             if tex_slot_mask.map_mode != 'STENCIL':
1263                 if brush.use_secondary_overlay:
1264                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1265                 else:
1266                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1267
1268             sub = row.row(align=True)
1269             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1270             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1271
1272
1273 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1274     bl_category = "Tools"
1275     bl_label = "Texture"
1276     bl_options = {'DEFAULT_CLOSED'}
1277
1278     @classmethod
1279     def poll(cls, context):
1280         settings = cls.paint_settings(context)
1281         return (settings and settings.brush and
1282                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1283
1284     def draw(self, context):
1285         layout = self.layout
1286
1287         settings = self.paint_settings(context)
1288         brush = settings.brush
1289
1290         col = layout.column()
1291
1292         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1293
1294         brush_texture_settings(col, brush, context.sculpt_object)
1295
1296
1297 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
1298     bl_category = "Tools"
1299     bl_context = "imagepaint"
1300     bl_label = "Texture Mask"
1301     bl_options = {'DEFAULT_CLOSED'}
1302
1303     @classmethod
1304     def poll(cls, context):
1305         settings = cls.paint_settings(context)
1306         return (settings and settings.brush and context.image_paint_object)
1307
1308     def draw(self, context):
1309         layout = self.layout
1310
1311         brush = context.tool_settings.image_paint.brush
1312
1313         col = layout.column()
1314
1315         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1316
1317         brush_mask_texture_settings(col, brush)
1318
1319
1320 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1321     bl_category = "Tools"
1322     bl_label = "Stroke"
1323     bl_options = {'DEFAULT_CLOSED'}
1324
1325     @classmethod
1326     def poll(cls, context):
1327         settings = cls.paint_settings(context)
1328         return (settings and
1329                 settings.brush and
1330                 (context.sculpt_object or
1331                  context.vertex_paint_object or
1332                  context.weight_paint_object or
1333                  context.image_paint_object))
1334
1335     def draw(self, context):
1336         layout = self.layout
1337
1338         settings = self.paint_settings(context)
1339         brush = settings.brush
1340
1341         col = layout.column()
1342
1343         col.label(text="Stroke Method:")
1344
1345         col.prop(brush, "stroke_method", text="")
1346
1347         if brush.use_anchor:
1348             col.separator()
1349             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1350
1351         if brush.use_airbrush:
1352             col.separator()
1353             col.prop(brush, "rate", text="Rate", slider=True)
1354
1355         if brush.use_space:
1356             col.separator()
1357             row = col.row(align=True)
1358             row.prop(brush, "spacing", text="Spacing")
1359             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1360
1361         if brush.use_line or brush.use_curve:
1362             col.separator()
1363             row = col.row(align=True)
1364             row.prop(brush, "spacing", text="Spacing")
1365
1366         if brush.use_curve:
1367             col.separator()
1368             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1369             col.operator("paintcurve.draw")
1370
1371         if context.sculpt_object:
1372             if brush.sculpt_capabilities.has_jitter:
1373                 col.separator()
1374
1375                 row = col.row(align=True)
1376                 row.prop(brush, "use_relative_jitter", icon_only=True)
1377                 if brush.use_relative_jitter:
1378                     row.prop(brush, "jitter", slider=True)
1379                 else:
1380                     row.prop(brush, "jitter_absolute")
1381                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1382
1383             if brush.sculpt_capabilities.has_smooth_stroke:
1384                 col = layout.column()
1385                 col.separator()
1386
1387                 col.prop(brush, "use_smooth_stroke")
1388
1389                 sub = col.column()
1390                 sub.active = brush.use_smooth_stroke
1391                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1392                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1393         else:
1394             col.separator()
1395
1396             row = col.row(align=True)
1397             row.prop(brush, "use_relative_jitter", icon_only=True)
1398             if brush.use_relative_jitter:
1399                 row.prop(brush, "jitter", slider=True)
1400             else:
1401                 row.prop(brush, "jitter_absolute")
1402             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1403
1404             col = layout.column()
1405             col.separator()
1406
1407             if brush.brush_capabilities.has_smooth_stroke:
1408                 col.prop(brush, "use_smooth_stroke")
1409
1410                 sub = col.column()
1411                 sub.active = brush.use_smooth_stroke
1412                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1413                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1414
1415         layout.prop(settings, "input_samples")
1416
1417
1418 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1419     bl_category = "Tools"
1420     bl_label = "Curve"
1421     bl_options = {'DEFAULT_CLOSED'}
1422
1423     @classmethod
1424     def poll(cls, context):
1425         settings = cls.paint_settings(context)
1426         return (settings and settings.brush and settings.brush.curve)
1427
1428     def draw(self, context):
1429         layout = self.layout
1430
1431         settings = self.paint_settings(context)
1432
1433         brush = settings.brush
1434
1435         layout.template_curve_mapping(brush, "curve", brush=True)
1436
1437         col = layout.column(align=True)
1438         row = col.row(align=True)
1439         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1440         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1441         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1442         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1443         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1444         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1445
1446
1447 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1448     bl_category = "Tools"
1449     bl_label = "Dyntopo"
1450     bl_options = {'DEFAULT_CLOSED'}
1451
1452     @classmethod
1453     def poll(cls, context):
1454         return (context.sculpt_object and context.tool_settings.sculpt)
1455
1456     def draw(self, context):
1457         layout = self.layout
1458
1459         toolsettings = context.tool_settings
1460         sculpt = toolsettings.sculpt
1461         settings = self.paint_settings(context)
1462         brush = settings.brush
1463
1464         if context.sculpt_object.use_dynamic_topology_sculpting:
1465             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1466         else:
1467             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1468
1469         col = layout.column()
1470         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1471         sub = col.column(align=True)
1472         sub.active = (brush and brush.sculpt_tool != 'MASK')
1473         if (sculpt.detail_type_method == 'CONSTANT'):
1474             row = sub.row(align=True)
1475             row.prop(sculpt, "constant_detail")
1476             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1477         elif (sculpt.detail_type_method == 'BRUSH'):
1478             sub.prop(sculpt, "detail_percent")
1479         else:
1480             sub.prop(sculpt, "detail_size")
1481         sub.prop(sculpt, "detail_refine_method", text="")
1482         sub.prop(sculpt, "detail_type_method", text="")
1483         col.separator()
1484         col.prop(sculpt, "use_smooth_shading")
1485         col.operator("sculpt.optimize")
1486         if (sculpt.detail_type_method == 'CONSTANT'):
1487             col.operator("sculpt.detail_flood_fill")
1488         col.separator()
1489         col.prop(sculpt, "symmetrize_direction")
1490         col.operator("sculpt.symmetrize")
1491
1492
1493 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1494     bl_category = "Options"
1495     bl_label = "Options"
1496     bl_options = {'DEFAULT_CLOSED'}
1497
1498     @classmethod
1499     def poll(cls, context):
1500         return (context.sculpt_object and context.tool_settings.sculpt)
1501
1502     def draw(self, context):
1503         layout = self.layout
1504         # scene = context.scene
1505
1506         toolsettings = context.tool_settings
1507         sculpt = toolsettings.sculpt
1508         capabilities = sculpt.brush.sculpt_capabilities
1509
1510         col = layout.column(align=True)
1511         col.active = capabilities.has_gravity
1512         col.label(text="Gravity:")
1513         col.prop(sculpt, "gravity", slider=True, text="Factor")
1514         col.prop(sculpt, "gravity_object")
1515         col.separator()
1516
1517         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1518         layout.prop(sculpt, "show_low_resolution")
1519         layout.prop(sculpt, "use_deform_only")
1520         layout.prop(sculpt, "show_diffuse_color")
1521
1522         self.unified_paint_settings(layout, context)
1523
1524
1525 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1526     bl_category = "Tools"
1527     bl_label = "Symmetry / Lock"
1528     bl_options = {'DEFAULT_CLOSED'}
1529
1530     @classmethod
1531     def poll(cls, context):
1532         return (context.sculpt_object and context.tool_settings.sculpt)
1533
1534     def draw(self, context):
1535         layout = self.layout
1536
1537         sculpt = context.tool_settings.sculpt
1538
1539         col = layout.column(align=True)
1540         col.label(text="Mirror:")
1541         row = col.row(align=True)
1542         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1543         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1544         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1545
1546         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1547         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1548
1549         layout.label(text="Lock:")
1550
1551         row = layout.row(align=True)
1552         row.prop(sculpt, "lock_x", text="X", toggle=True)
1553         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1554         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1555
1556         layout.label(text="Tiling:")
1557
1558         row = layout.row(align=True)
1559         row.prop(sculpt, "tile_x", text="X", toggle=True)
1560         row.prop(sculpt, "tile_y", text="Y", toggle=True)
1561         row.prop(sculpt, "tile_z", text="Z", toggle=True)
1562
1563         layout.column().prop(sculpt, "tile_offset", text="Tile Offset")
1564
1565
1566 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1567     bl_category = "Options"
1568     bl_label = "Appearance"
1569
1570     @classmethod
1571     def poll(cls, context):
1572         settings = cls.paint_settings(context)
1573         return settings
1574
1575     def draw(self, context):
1576         layout = self.layout
1577
1578         settings = self.paint_settings(context)
1579         brush = settings.brush
1580
1581         if brush is None:  # unlikely but can happen
1582             layout.label(text="Brush Unset")
1583             return
1584
1585         col = layout.column()
1586         col.prop(settings, "show_brush")
1587
1588         sub = col.column()
1589         sub.active = settings.show_brush
1590
1591         if context.sculpt_object and context.tool_settings.sculpt:
1592             if brush.sculpt_capabilities.has_secondary_color:
1593                 sub.row().prop(brush, "cursor_color_add", text="Add")
1594                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1595             else:
1596                 sub.prop(brush, "cursor_color_add", text="")
1597         else:
1598             sub.prop(brush, "cursor_color_add", text="")
1599
1600         col.separator()
1601
1602         col = col.column(align=True)
1603         col.prop(brush, "use_custom_icon")
1604         sub = col.column()
1605         sub.active = brush.use_custom_icon
1606         sub.prop(brush, "icon_filepath", text="")
1607
1608 # ********** default tools for weight-paint ****************
1609
1610
1611 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1612     bl_category = "Tools"
1613     bl_context = "weightpaint"
1614     bl_label = "Weight Tools"
1615
1616     def draw(self, context):
1617         layout = self.layout
1618         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1619
1620         col = layout.column()
1621         col.operator("paint.weight_gradient")
1622         props = col.operator("object.data_transfer", text="Transfer Weights")
1623         props.use_reverse_transfer = True
1624         props.data_type = 'VGROUP_WEIGHTS'
1625
1626
1627 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1628     bl_category = "Options"
1629     bl_context = "weightpaint"
1630     bl_label = "Options"
1631
1632     def draw(self, context):
1633         layout = self.layout
1634
1635         tool_settings = context.tool_settings
1636         wpaint = tool_settings.weight_paint
1637
1638         col = layout.column()
1639         row = col.row()
1640
1641         row.prop(wpaint, "use_normal")
1642         col = layout.column()
1643         row = col.row()
1644         row.prop(wpaint, "use_spray")
1645         row.prop(wpaint, "use_group_restrict")
1646
1647         obj = context.weight_paint_object
1648         if obj.type == 'MESH':
1649             mesh = obj.data
1650             col.prop(mesh, "use_mirror_x")
1651             row = col.row()
1652             row.active = mesh.use_mirror_x
1653             row.prop(mesh, "use_mirror_topology")
1654
1655         col.label("Show Zero Weights:")
1656         sub = col.row()
1657         sub.active = (not tool_settings.use_multipaint)
1658         sub.prop(tool_settings, "vertex_group_user", expand=True)
1659
1660         self.unified_paint_settings(col, context)
1661
1662 # ********** default tools for vertex-paint ****************
1663
1664
1665 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1666     bl_category = "Options"
1667     bl_context = "vertexpaint"
1668     bl_label = "Options"
1669
1670     def draw(self, context):
1671         layout = self.layout
1672
1673         toolsettings = context.tool_settings
1674         vpaint = toolsettings.vertex_paint
1675
1676         col = layout.column()
1677         row = col.row()
1678         # col.prop(vpaint, "mode", text="")
1679         row.prop(vpaint, "use_normal")
1680         col.prop(vpaint, "use_spray")
1681
1682         self.unified_paint_settings(col, context)
1683
1684 # Commented out because the Apply button isn't an operator yet, making these settings useless
1685 #~         col.label(text="Gamma:")
1686 #~         col.prop(vpaint, "gamma", text="")
1687 #~         col.label(text="Multiply:")
1688 #~         col.prop(vpaint, "mul", text="")
1689
1690 # ********** default tools for texture-paint ****************
1691
1692
1693 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1694     bl_category = "Tools"
1695     bl_context = "imagepaint"
1696     bl_label = "External"
1697     bl_options = {'DEFAULT_CLOSED'}
1698
1699     def draw(self, context):
1700         layout = self.layout
1701
1702         toolsettings = context.tool_settings
1703         ipaint = toolsettings.image_paint
1704
1705         col = layout.column()
1706         row = col.split(align=True, percentage=0.55)
1707         row.operator("image.project_edit", text="Quick Edit")
1708         row.operator("image.project_apply", text="Apply")
1709
1710         col.row().prop(ipaint, "screen_grab_size", text="")
1711
1712         col.operator("paint.project_image", text="Apply Camera Image")
1713
1714
1715 class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
1716     bl_category = "Tools"
1717     bl_context = "imagepaint"
1718     bl_label = "Symmetry"
1719     bl_options = {'DEFAULT_CLOSED'}
1720
1721     def draw(self, context):
1722         layout = self.layout
1723
1724         toolsettings = context.tool_settings
1725         ipaint = toolsettings.image_paint
1726
1727         col = layout.column(align=True)
1728         row = col.row(align=True)
1729         row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
1730         row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
1731         row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
1732
1733
1734 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1735     bl_category = "Options"
1736     bl_context = "imagepaint"
1737     bl_label = "Project Paint"
1738
1739     @classmethod
1740     def poll(cls, context):
1741         brush = context.tool_settings.image_paint.brush
1742         return (brush is not None)
1743
1744     def draw(self, context):
1745         layout = self.layout
1746
1747         toolsettings = context.tool_settings
1748         ipaint = toolsettings.image_paint
1749
1750         col = layout.column()
1751
1752         col.prop(ipaint, "use_occlude")
1753         col.prop(ipaint, "use_backface_culling")
1754
1755         row = layout.row()
1756         row.prop(ipaint, "use_normal_falloff")
1757
1758         sub = row.row()
1759         sub.active = (ipaint.use_normal_falloff)
1760         sub.prop(ipaint, "normal_angle", text="")
1761
1762         layout.prop(ipaint, "use_cavity")
1763         if ipaint.use_cavity:
1764             layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1765
1766         layout.prop(ipaint, "seam_bleed")
1767         layout.prop(ipaint, "dither")
1768         self.unified_paint_settings(layout, context)
1769
1770
1771 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1772     bl_category = "Options"
1773     bl_label = "Options"
1774
1775     @classmethod
1776     def poll(cls, context):
1777         return (context.image_paint_object and context.tool_settings.image_paint)
1778
1779     def draw(self, context):
1780         layout = self.layout
1781
1782         col = layout.column()
1783         self.unified_paint_settings(col, context)
1784
1785
1786 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1787     bl_label = "Mask Layer"
1788
1789     def draw(self, context):
1790         layout = self.layout
1791         for i, tex in enumerate(context.active_object.data.uv_textures):
1792             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1793             props.data_path = "active_object.data.uv_texture_stencil_index"
1794             props.value = i
1795
1796
1797 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1798     """Default tools for particle mode"""
1799     bl_context = "particlemode"
1800     bl_label = "Options"
1801     bl_category = "Tools"
1802
1803     def draw(self, context):
1804         layout = self.layout
1805
1806         pe = context.tool_settings.particle_edit
1807         ob = pe.object
1808
1809         layout.prop(pe, "type", text="")
1810
1811         ptcache = None
1812
1813         if pe.type == 'PARTICLES':
1814             if ob.particle_systems:
1815                 if len(ob.particle_systems) > 1:
1816                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1817                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1818
1819                 ptcache = ob.particle_systems.active.point_cache
1820         else:
1821             for md in ob.modifiers:
1822                 if md.type == pe.type:
1823                     ptcache = md.point_cache
1824
1825         if ptcache and len(ptcache.point_caches) > 1:
1826             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1827                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1828
1829         if not pe.is_editable:
1830             layout.label(text="Point cache must be baked")
1831             layout.label(text="in memory to enable editing!")
1832
1833         col = layout.column(align=True)
1834         if pe.is_hair:
1835             col.active = pe.is_editable
1836             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1837             sub = col.row(align=True)
1838             sub.active = pe.use_emitter_deflect
1839             sub.prop(pe, "emitter_distance", text="Distance")
1840
1841         col = layout.column(align=True)
1842         col.active = pe.is_editable
1843         col.label(text="Keep:")
1844         col.prop(pe, "use_preserve_length", text="Lengths")
1845         col.prop(pe, "use_preserve_root", text="Root")
1846         if not pe.is_hair:
1847             col.label(text="Correct:")
1848             col.prop(pe, "use_auto_velocity", text="Velocity")
1849         col.prop(ob.data, "use_mirror_x")
1850
1851         col.prop(pe, "shape_object")
1852         col.operator("particle.shape_cut")
1853
1854         col = layout.column(align=True)
1855         col.active = pe.is_editable
1856         col.label(text="Draw:")
1857         col.prop(pe, "draw_step", text="Path Steps")
1858         if pe.is_hair:
1859             col.prop(pe, "show_particles", text="Children")
1860         else:
1861             if pe.type == 'PARTICLES':
1862                 col.prop(pe, "show_particles", text="Particles")
1863             col.prop(pe, "use_fade_time")
1864             sub = col.row(align=True)
1865             sub.active = pe.use_fade_time
1866             sub.prop(pe, "fade_frames", slider=True)
1867
1868
1869 # Grease Pencil drawing tools
1870 class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
1871     bl_space_type = 'VIEW_3D'
1872
1873
1874 # Grease Pencil stroke editing tools
1875 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1876     bl_space_type = 'VIEW_3D'
1877
1878
1879 # Grease Pencil stroke sculpting tools
1880 class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel):
1881     bl_space_type = 'VIEW_3D'
1882
1883
1884 # Note: moved here so that it's always in last position in 'Tools' panels!
1885 class VIEW3D_PT_tools_history(View3DPanel, Panel):
1886     bl_category = "Tools"
1887     # No bl_context, we are always available!
1888     bl_label = "History"
1889     bl_options = {'DEFAULT_CLOSED'}
1890
1891     def draw(self, context):
1892         layout = self.layout
1893         obj = context.object
1894
1895         col = layout.column(align=True)
1896         row = col.row(align=True)
1897         row.operator("ed.undo")
1898         row.operator("ed.redo")
1899         if obj is None or obj.mode != 'SCULPT':
1900             # Sculpt mode does not generate an undo menu it seems...
1901             col.operator("ed.undo_history")
1902
1903         col = layout.column(align=True)
1904         col.label(text="Repeat:")
1905         col.operator("screen.repeat_last")
1906         col.operator("screen.repeat_history", text="History...")
1907
1908
1909 if __name__ == "__main__":  # only for live edit.
1910     bpy.utils.register_module(__name__)