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