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