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