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