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