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