Cleanup: pep8
[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
779 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
780     bl_category = "Tools"
781     bl_label = "Brush"
782
783     @classmethod
784     def poll(cls, context):
785         return cls.paint_settings(context)
786
787     def draw(self, context):
788         layout = self.layout
789
790         toolsettings = context.tool_settings
791         settings = self.paint_settings(context)
792         brush = settings.brush
793
794         if not context.particle_edit_object:
795             col = layout.split().column()
796             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
797
798         # Particle Mode #
799         if context.particle_edit_object:
800             tool = settings.tool
801
802             layout.column().prop(settings, "tool", expand=True)
803
804             if tool != 'NONE':
805                 col = layout.column()
806                 col.prop(brush, "size", slider=True)
807                 if tool != 'ADD':
808                     col.prop(brush, "strength", slider=True)
809
810             if tool == 'ADD':
811                 col.prop(brush, "count")
812                 col = layout.column()
813                 col.prop(settings, "use_default_interpolate")
814                 sub = col.column(align=True)
815                 sub.active = settings.use_default_interpolate
816                 sub.prop(brush, "steps", slider=True)
817                 sub.prop(settings, "default_key_count", slider=True)
818             elif tool == 'LENGTH':
819                 layout.prop(brush, "length_mode", expand=True)
820             elif tool == 'PUFF':
821                 layout.prop(brush, "puff_mode", expand=True)
822                 layout.prop(brush, "use_puff_volume")
823
824         # Sculpt Mode #
825
826         elif context.sculpt_object and brush:
827             capabilities = brush.sculpt_capabilities
828
829             col = layout.column()
830
831             col.separator()
832
833             row = col.row(align=True)
834
835             ups = toolsettings.unified_paint_settings
836             if ((ups.use_unified_size and ups.use_locked_size) or
837                     ((not ups.use_unified_size) and brush.use_locked_size)):
838                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
839                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
840             else:
841                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
842                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
843
844             self.prop_unified_size(row, context, brush, "use_pressure_size")
845
846             # strength, use_strength_pressure, and use_strength_attenuation
847             if capabilities.has_strength:
848                 col.separator()
849                 row = col.row(align=True)
850
851                 if capabilities.has_space_attenuation:
852                     row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
853
854                 self.prop_unified_strength(row, context, brush, "strength", text="Strength")
855                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
856
857             # auto_smooth_factor and use_inverse_smooth_pressure
858             if capabilities.has_auto_smooth:
859                 col.separator()
860
861                 row = col.row(align=True)
862                 row.prop(brush, "auto_smooth_factor", slider=True)
863                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
864
865             # normal_weight
866             if capabilities.has_normal_weight:
867                 col.separator()
868                 row = col.row(align=True)
869                 row.prop(brush, "normal_weight", slider=True)
870
871             # crease_pinch_factor
872             if capabilities.has_pinch_factor:
873                 col.separator()
874                 row = col.row(align=True)
875                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
876
877             # use_original_normal and sculpt_plane
878             if capabilities.has_sculpt_plane:
879                 col.separator()
880                 row = col.row(align=True)
881
882                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
883
884                 row.prop(brush, "sculpt_plane", text="")
885
886             if brush.sculpt_tool == 'MASK':
887                 col.prop(brush, "mask_tool", text="")
888
889             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
890             if capabilities.has_plane_offset:
891                 row = col.row(align=True)
892                 row.prop(brush, "plane_offset", slider=True)
893                 row.prop(brush, "use_offset_pressure", text="")
894
895                 col.separator()
896
897                 row = col.row()
898                 row.prop(brush, "use_plane_trim", text="Trim")
899                 row = col.row()
900                 row.active = brush.use_plane_trim
901                 row.prop(brush, "plane_trim", slider=True, text="Distance")
902
903             # height
904             if capabilities.has_height:
905                 row = col.row()
906                 row.prop(brush, "height", slider=True, text="Height")
907
908             # use_frontface
909             col.separator()
910             row = col.row()
911             row.prop(brush, "use_frontface", text="Front Faces Only")
912
913             # direction
914             col.separator()
915             col.row().prop(brush, "direction", expand=True)
916
917             # use_accumulate
918             if capabilities.has_accumulate:
919                 col.separator()
920
921                 col.prop(brush, "use_accumulate")
922
923             # use_persistent, set_persistent_base
924             if capabilities.has_persistence:
925                 col.separator()
926
927                 ob = context.sculpt_object
928                 do_persistent = True
929
930                 # not supported yet for this case
931                 for md in ob.modifiers:
932                     if md.type == 'MULTIRES':
933                         do_persistent = False
934                         break
935
936                 if do_persistent:
937                     col.prop(brush, "use_persistent")
938                     col.operator("sculpt.set_persistent_base")
939
940         # Texture Paint Mode #
941
942         elif context.image_paint_object and brush:
943             brush_texpaint_common(self, context, layout, brush, settings, True)
944
945         # Weight Paint Mode #
946         elif context.weight_paint_object and brush:
947
948             col = layout.column()
949
950             row = col.row(align=True)
951             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
952
953             row = col.row(align=True)
954             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
955             self.prop_unified_size(row, context, brush, "use_pressure_size")
956
957             row = col.row(align=True)
958             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
959             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
960
961             col.prop(brush, "vertex_tool", text="Blend")
962
963             col = layout.column()
964             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
965             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
966
967         # Vertex Paint Mode #
968         elif context.vertex_paint_object and brush:
969             col = layout.column()
970             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
971             if settings.palette:
972                 col.template_palette(settings, "palette", color=True)
973             self.prop_unified_color(col, context, brush, "color", text="")
974
975             col.separator()
976             row = col.row(align=True)
977             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
978             self.prop_unified_size(row, context, brush, "use_pressure_size")
979
980             row = col.row(align=True)
981             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
982             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
983
984             # XXX - TODO
985             # row = col.row(align=True)
986             # row.prop(brush, "jitter", slider=True)
987             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
988             col.separator()
989             col.prop(brush, "vertex_tool", text="Blend")
990
991             col.separator()
992             col.template_ID(settings, "palette", new="palette.new")
993
994
995 class TEXTURE_UL_texpaintslots(UIList):
996     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
997         mat = data
998
999         if self.layout_type in {'DEFAULT', 'COMPACT'}:
1000             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
1001             if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'):
1002                 mtex_index = mat.texture_paint_slots[index].index
1003                 layout.prop(mat, "use_textures", text="", index=mtex_index)
1004         elif self.layout_type in {'GRID'}:
1005             layout.alignment = 'CENTER'
1006             layout.label(text="")
1007
1008
1009 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
1010     bl_context = "imagepaint"
1011     bl_label = "Slots"
1012     bl_category = "Slots"
1013
1014     @classmethod
1015     def poll(cls, context):
1016         brush = context.tool_settings.image_paint.brush
1017         ob = context.active_object
1018         return (brush is not None and ob is not None)
1019
1020     def draw(self, context):
1021         layout = self.layout
1022
1023         settings = context.tool_settings.image_paint
1024         # brush = settings.brush
1025
1026         ob = context.active_object
1027         col = layout.column()
1028
1029         col.label("Painting Mode")
1030         col.prop(settings, "mode", text="")
1031         col.separator()
1032
1033         if settings.mode == 'MATERIAL':
1034             if len(ob.material_slots) > 1:
1035                 col.label("Materials")
1036                 col.template_list("MATERIAL_UL_matslots", "layers",
1037                                   ob, "material_slots",
1038                                   ob, "active_material_index", rows=2)
1039
1040             mat = ob.active_material
1041             if mat:
1042                 col.label("Available Paint Slots")
1043                 col.template_list("TEXTURE_UL_texpaintslots", "",
1044                                   mat, "texture_paint_images",
1045                                   mat, "paint_active_slot", rows=2)
1046
1047                 if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'):
1048                     row = col.row(align=True)
1049                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
1050                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
1051
1052                     if mat.texture_paint_slots:
1053                         slot = mat.texture_paint_slots[mat.paint_active_slot]
1054
1055                         col.prop(mat.texture_slots[slot.index], "blend_type")
1056                         col.separator()
1057                         col.label("UV Map")
1058                         col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1059
1060         elif settings.mode == 'IMAGE':
1061             col.template_ID(settings, "canvas")
1062
1063         col.separator()
1064         col.operator("image.save_dirty", text="Save All Images")
1065
1066
1067 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1068     bl_context = "imagepaint"
1069     bl_label = "Stencil"
1070     bl_category = "Slots"
1071
1072     @classmethod
1073     def poll(cls, context):
1074         brush = context.tool_settings.image_paint.brush
1075         ob = context.active_object
1076         return (brush is not None and ob is not None)
1077
1078     def draw_header(self, context):
1079         ipaint = context.tool_settings.image_paint
1080         self.layout.prop(ipaint, "use_stencil_layer", text="")
1081
1082     def draw(self, context):
1083         layout = self.layout
1084
1085         toolsettings = context.tool_settings
1086         ipaint = toolsettings.image_paint
1087         ob = context.active_object
1088         mesh = ob.data
1089
1090         col = layout.column()
1091         col.active = ipaint.use_stencil_layer
1092
1093         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1094         col.label("UV Map")
1095         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1096
1097         col.label("Image")
1098         row = col.row(align=True)
1099         row.template_ID(ipaint, "stencil_image")
1100  
1101         col.label("Visualization")
1102         row = col.row(align=True)
1103         row.prop(ipaint, "stencil_color", text="")
1104         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1105
1106
1107 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1108     bl_category = "Options"
1109     bl_label = "Overlay"
1110
1111     @classmethod
1112     def poll(cls, context):
1113         settings = cls.paint_settings(context)
1114         return (settings and
1115                 settings.brush and
1116                 (context.sculpt_object or
1117                  context.vertex_paint_object or
1118                  context.weight_paint_object or
1119                  context.image_paint_object))
1120
1121     def draw(self, context):
1122         layout = self.layout
1123
1124         settings = self.paint_settings(context)
1125         brush = settings.brush
1126         tex_slot = brush.texture_slot
1127         tex_slot_mask = brush.mask_texture_slot
1128
1129         col = layout.column()
1130
1131         col.label(text="Curve:")
1132
1133         row = col.row(align=True)
1134         if brush.use_cursor_overlay:
1135             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1136         else:
1137             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1138
1139         sub = row.row(align=True)
1140         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1141         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1142
1143         col.active = brush.brush_capabilities.has_overlay
1144
1145         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1146             col.label(text="Texture:")
1147             row = col.row(align=True)
1148             if tex_slot.map_mode != 'STENCIL':
1149                 if brush.use_primary_overlay:
1150                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1151                 else:
1152                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1153
1154             sub = row.row(align=True)
1155             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1156             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1157
1158         if context.image_paint_object:
1159             col.label(text="Mask Texture:")
1160
1161             row = col.row(align=True)
1162             if tex_slot_mask.map_mode != 'STENCIL':
1163                 if brush.use_secondary_overlay:
1164                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1165                 else:
1166                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1167
1168             sub = row.row(align=True)
1169             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1170             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1171
1172
1173 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1174     bl_category = "Tools"
1175     bl_label = "Texture"
1176     bl_options = {'DEFAULT_CLOSED'}
1177
1178     @classmethod
1179     def poll(cls, context):
1180         settings = cls.paint_settings(context)
1181         return (settings and settings.brush and
1182                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1183
1184     def draw(self, context):
1185         layout = self.layout
1186
1187         settings = self.paint_settings(context)
1188         brush = settings.brush
1189
1190         col = layout.column()
1191
1192         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1193
1194         brush_texture_settings(col, brush, context.sculpt_object)
1195
1196
1197 class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
1198     bl_category = "Tools"
1199     bl_context = "imagepaint"
1200     bl_label = "Texture Mask"
1201     bl_options = {'DEFAULT_CLOSED'}
1202
1203     @classmethod
1204     def poll(cls, context):
1205         brush = context.tool_settings.image_paint.brush
1206         return (context.image_paint_object and brush)
1207
1208     def draw(self, context):
1209         layout = self.layout
1210
1211         brush = context.tool_settings.image_paint.brush
1212
1213         col = layout.column()
1214
1215         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1216
1217         brush_mask_texture_settings(col, brush)
1218
1219
1220 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1221     bl_category = "Tools"
1222     bl_label = "Stroke"
1223     bl_options = {'DEFAULT_CLOSED'}
1224
1225     @classmethod
1226     def poll(cls, context):
1227         settings = cls.paint_settings(context)
1228         return (settings and
1229                 settings.brush and
1230                 (context.sculpt_object or
1231                  context.vertex_paint_object or
1232                  context.weight_paint_object or
1233                  context.image_paint_object))
1234
1235     def draw(self, context):
1236         layout = self.layout
1237
1238         settings = self.paint_settings(context)
1239         brush = settings.brush
1240
1241         col = layout.column()
1242
1243         col.label(text="Stroke Method:")
1244
1245         col.prop(brush, "stroke_method", text="")
1246
1247         if brush.use_anchor:
1248             col.separator()
1249             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1250
1251         if brush.use_airbrush:
1252             col.separator()
1253             col.prop(brush, "rate", text="Rate", slider=True)
1254
1255         if brush.use_space:
1256             col.separator()
1257             row = col.row(align=True)
1258             row.prop(brush, "spacing", text="Spacing")
1259             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1260
1261         if brush.use_line or brush.use_curve:
1262             col.separator()
1263             row = col.row(align=True)
1264             row.prop(brush, "spacing", text="Spacing")
1265
1266         if brush.use_curve:
1267             col.separator()
1268             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1269             col.operator("paintcurve.draw")
1270
1271         if context.sculpt_object:
1272             if brush.sculpt_capabilities.has_jitter:
1273                 col.separator()
1274
1275                 row = col.row(align=True)
1276                 row.prop(brush, "use_relative_jitter", icon_only=True)
1277                 if brush.use_relative_jitter:
1278                     row.prop(brush, "jitter", slider=True)
1279                 else:
1280                     row.prop(brush, "jitter_absolute")
1281                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1282
1283             if brush.sculpt_capabilities.has_smooth_stroke:
1284                 col = layout.column()
1285                 col.separator()
1286
1287                 col.prop(brush, "use_smooth_stroke")
1288
1289                 sub = col.column()
1290                 sub.active = brush.use_smooth_stroke
1291                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1292                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1293         else:
1294             col.separator()
1295
1296             row = col.row(align=True)
1297             row.prop(brush, "use_relative_jitter", icon_only=True)
1298             if brush.use_relative_jitter:
1299                 row.prop(brush, "jitter", slider=True)
1300             else:
1301                 row.prop(brush, "jitter_absolute")
1302             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1303
1304             col = layout.column()
1305             col.separator()
1306
1307             if brush.brush_capabilities.has_smooth_stroke:
1308                 col.prop(brush, "use_smooth_stroke")
1309
1310                 sub = col.column()
1311                 sub.active = brush.use_smooth_stroke
1312                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1313                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1314
1315         layout.prop(settings, "input_samples")
1316
1317
1318 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1319     bl_category = "Tools"
1320     bl_label = "Curve"
1321     bl_options = {'DEFAULT_CLOSED'}
1322
1323     @classmethod
1324     def poll(cls, context):
1325         settings = cls.paint_settings(context)
1326         return (settings and settings.brush and settings.brush.curve)
1327
1328     def draw(self, context):
1329         layout = self.layout
1330
1331         settings = self.paint_settings(context)
1332
1333         brush = settings.brush
1334
1335         layout.template_curve_mapping(brush, "curve", brush=True)
1336
1337         col = layout.column(align=True)
1338         row = col.row(align=True)
1339         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1340         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1341         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1342         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1343         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1344         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1345
1346
1347 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1348     bl_category = "Tools"
1349     bl_label = "Dyntopo"
1350     bl_options = {'DEFAULT_CLOSED'}
1351
1352     @classmethod
1353     def poll(cls, context):
1354         return (context.sculpt_object and context.tool_settings.sculpt)
1355
1356     def draw(self, context):
1357         layout = self.layout
1358
1359         toolsettings = context.tool_settings
1360         sculpt = toolsettings.sculpt
1361         settings = self.paint_settings(context)
1362         brush = settings.brush
1363
1364         if context.sculpt_object.use_dynamic_topology_sculpting:
1365             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1366         else:
1367             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1368
1369         col = layout.column()
1370         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1371         sub = col.column(align=True)
1372         sub.active = (brush and brush.sculpt_tool != 'MASK')
1373         if (sculpt.detail_type_method == 'CONSTANT'):
1374             row = sub.row(align=True)
1375             row.prop(sculpt, "constant_detail")
1376             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1377         else:
1378             sub.prop(sculpt, "detail_size")
1379         sub.prop(sculpt, "detail_refine_method", text="")
1380         sub.prop(sculpt, "detail_type_method", text="")
1381         col.separator()
1382         col.prop(sculpt, "use_smooth_shading")
1383         col.operator("sculpt.optimize")
1384         if (sculpt.detail_type_method == 'CONSTANT'):
1385             col.operator("sculpt.detail_flood_fill")
1386         col.separator()
1387         col.prop(sculpt, "symmetrize_direction")
1388         col.operator("sculpt.symmetrize")
1389
1390
1391 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1392     bl_category = "Options"
1393     bl_label = "Options"
1394     bl_options = {'DEFAULT_CLOSED'}
1395
1396     @classmethod
1397     def poll(cls, context):
1398         return (context.sculpt_object and context.tool_settings.sculpt)
1399
1400     def draw(self, context):
1401         layout = self.layout
1402         # scene = context.scene
1403
1404         toolsettings = context.tool_settings
1405         sculpt = toolsettings.sculpt
1406         capabilities = sculpt.brush.sculpt_capabilities
1407
1408         col = layout.column(align=True)
1409         col.active = capabilities.has_gravity
1410         col.label(text="Gravity:")
1411         col.prop(sculpt, "gravity", slider=True, text="Factor")
1412         col.prop(sculpt, "gravity_object")
1413         col.separator()
1414
1415         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1416         layout.prop(sculpt, "show_low_resolution")
1417         layout.prop(sculpt, "use_deform_only")
1418         layout.prop(sculpt, "show_diffuse_color")
1419
1420         self.unified_paint_settings(layout, context)
1421
1422
1423 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1424     bl_category = "Tools"
1425     bl_label = "Symmetry / Lock"
1426     bl_options = {'DEFAULT_CLOSED'}
1427
1428     @classmethod
1429     def poll(cls, context):
1430         return (context.sculpt_object and context.tool_settings.sculpt)
1431
1432     def draw(self, context):
1433         layout = self.layout
1434
1435         sculpt = context.tool_settings.sculpt
1436
1437         col = layout.column(align=True)
1438         col.label(text="Mirror:")
1439         row = col.row(align=True)
1440         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1441         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1442         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1443
1444         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1445         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1446
1447         layout.label(text="Lock:")
1448
1449         row = layout.row(align=True)
1450         row.prop(sculpt, "lock_x", text="X", toggle=True)
1451         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1452         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1453
1454
1455 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1456     bl_category = "Options"
1457     bl_label = "Appearance"
1458
1459     @classmethod
1460     def poll(cls, context):
1461         toolsettings = context.tool_settings
1462         return ((context.sculpt_object and toolsettings.sculpt) or
1463                 (context.vertex_paint_object and toolsettings.vertex_paint) or
1464                 (context.weight_paint_object and toolsettings.weight_paint) or
1465                 (context.image_paint_object and toolsettings.image_paint))
1466
1467     def draw(self, context):
1468         layout = self.layout
1469
1470         settings = self.paint_settings(context)
1471         brush = settings.brush
1472
1473         if brush is None:  # unlikely but can happen
1474             layout.label(text="Brush Unset")
1475             return
1476
1477         col = layout.column()
1478         col.prop(settings, "show_brush")
1479
1480         sub = col.column()
1481         sub.active = settings.show_brush
1482
1483         if context.sculpt_object and context.tool_settings.sculpt:
1484             if brush.sculpt_capabilities.has_secondary_color:
1485                 sub.row().prop(brush, "cursor_color_add", text="Add")
1486                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1487             else:
1488                 sub.prop(brush, "cursor_color_add", text="")
1489         else:
1490             sub.prop(brush, "cursor_color_add", text="")
1491
1492         col.separator()
1493
1494         col = col.column(align=True)
1495         col.prop(brush, "use_custom_icon")
1496         sub = col.column()
1497         sub.active = brush.use_custom_icon
1498         sub.prop(brush, "icon_filepath", text="")
1499
1500 # ********** default tools for weight-paint ****************
1501
1502
1503 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1504     bl_category = "Tools"
1505     bl_context = "weightpaint"
1506     bl_label = "Weight Tools"
1507
1508     def draw(self, context):
1509         layout = self.layout
1510         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1511
1512         col = layout.column()
1513         col.operator("paint.weight_gradient")
1514         col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1515
1516
1517 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1518     bl_category = "Options"
1519     bl_context = "weightpaint"
1520     bl_label = "Options"
1521
1522     def draw(self, context):
1523         layout = self.layout
1524
1525         tool_settings = context.tool_settings
1526         wpaint = tool_settings.weight_paint
1527
1528         col = layout.column()
1529         row = col.row()
1530
1531         row.prop(wpaint, "use_normal")
1532         col = layout.column()
1533         row = col.row()
1534         row.prop(wpaint, "use_spray")
1535         row.prop(wpaint, "use_group_restrict")
1536
1537         obj = context.weight_paint_object
1538         if obj.type == 'MESH':
1539             mesh = obj.data
1540             col.prop(mesh, "use_mirror_x")
1541             row = col.row()
1542             row.active = mesh.use_mirror_x
1543             row.prop(mesh, "use_mirror_topology")
1544
1545         col.label("Show Zero Weights:")
1546         sub = col.row()
1547         sub.active = (not tool_settings.use_multipaint)
1548         sub.prop(tool_settings, "vertex_group_user", expand=True)
1549
1550         self.unified_paint_settings(col, context)
1551
1552 # ********** default tools for vertex-paint ****************
1553
1554
1555 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1556     bl_category = "Options"
1557     bl_context = "vertexpaint"
1558     bl_label = "Options"
1559
1560     def draw(self, context):
1561         layout = self.layout
1562
1563         toolsettings = context.tool_settings
1564         vpaint = toolsettings.vertex_paint
1565
1566         col = layout.column()
1567         row = col.row()
1568         # col.prop(vpaint, "mode", text="")
1569         row.prop(vpaint, "use_normal")
1570         col.prop(vpaint, "use_spray")
1571
1572         self.unified_paint_settings(col, context)
1573
1574 # Commented out because the Apply button isn't an operator yet, making these settings useless
1575 #~         col.label(text="Gamma:")
1576 #~         col.prop(vpaint, "gamma", text="")
1577 #~         col.label(text="Multiply:")
1578 #~         col.prop(vpaint, "mul", text="")
1579
1580 # ********** default tools for texture-paint ****************
1581
1582
1583 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1584     bl_category = "Tools"
1585     bl_context = "imagepaint"
1586     bl_label = "External"
1587     bl_options = {'DEFAULT_CLOSED'}
1588
1589     def draw(self, context):
1590         layout = self.layout
1591
1592         toolsettings = context.tool_settings
1593         ipaint = toolsettings.image_paint
1594
1595         col = layout.column()
1596         row = col.split(align=True, percentage=0.55)
1597         row.operator("image.project_edit", text="Quick Edit")
1598         row.operator("image.project_apply", text="Apply")
1599
1600         col.row().prop(ipaint, "screen_grab_size", text="")
1601
1602         col.operator("paint.project_image", text="Apply Camera Image")
1603
1604
1605 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1606     bl_category = "Options"
1607     bl_context = "imagepaint"
1608     bl_label = "Project Paint"
1609
1610     @classmethod
1611     def poll(cls, context):
1612         brush = context.tool_settings.image_paint.brush
1613         return (brush is not None)
1614
1615     def draw(self, context):
1616         layout = self.layout
1617
1618         toolsettings = context.tool_settings
1619         ipaint = toolsettings.image_paint
1620
1621         col = layout.column()
1622
1623         col.prop(ipaint, "use_occlude")
1624         col.prop(ipaint, "use_backface_culling")
1625
1626         row = layout.row()
1627         row.prop(ipaint, "use_normal_falloff")
1628
1629         sub = row.row()
1630         sub.active = (ipaint.use_normal_falloff)
1631         sub.prop(ipaint, "normal_angle", text="")
1632
1633         layout.prop(ipaint, "seam_bleed")
1634         self.unified_paint_settings(layout, context)
1635
1636
1637 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1638     bl_category = "Options"
1639     bl_label = "Options"
1640
1641     @classmethod
1642     def poll(cls, context):
1643         return (context.image_paint_object and context.tool_settings.image_paint)
1644
1645     def draw(self, context):
1646         layout = self.layout
1647
1648         col = layout.column()
1649         self.unified_paint_settings(col, context)
1650
1651
1652 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1653     bl_label = "Mask Layer"
1654
1655     def draw(self, context):
1656         layout = self.layout
1657         for i, tex in enumerate(context.active_object.data.uv_textures):
1658             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1659             props.data_path = "active_object.data.uv_texture_stencil_index"
1660             props.value = i
1661
1662
1663 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1664     """Default tools for particle mode"""
1665     bl_context = "particlemode"
1666     bl_label = "Options"
1667     bl_category = "Tools"
1668
1669     def draw(self, context):
1670         layout = self.layout
1671
1672         pe = context.tool_settings.particle_edit
1673         ob = pe.object
1674
1675         layout.prop(pe, "type", text="")
1676
1677         ptcache = None
1678
1679         if pe.type == 'PARTICLES':
1680             if ob.particle_systems:
1681                 if len(ob.particle_systems) > 1:
1682                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1683                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1684
1685                 ptcache = ob.particle_systems.active.point_cache
1686         else:
1687             for md in ob.modifiers:
1688                 if md.type == pe.type:
1689                     ptcache = md.point_cache
1690
1691         if ptcache and len(ptcache.point_caches) > 1:
1692             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1693                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1694
1695         if not pe.is_editable:
1696             layout.label(text="Point cache must be baked")
1697             layout.label(text="in memory to enable editing!")
1698
1699         col = layout.column(align=True)
1700         if pe.is_hair:
1701             col.active = pe.is_editable
1702             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1703             sub = col.row(align=True)
1704             sub.active = pe.use_emitter_deflect
1705             sub.prop(pe, "emitter_distance", text="Distance")
1706
1707         col = layout.column(align=True)
1708         col.active = pe.is_editable
1709         col.label(text="Keep:")
1710         col.prop(pe, "use_preserve_length", text="Lengths")
1711         col.prop(pe, "use_preserve_root", text="Root")
1712         if not pe.is_hair:
1713             col.label(text="Correct:")
1714             col.prop(pe, "use_auto_velocity", text="Velocity")
1715         col.prop(ob.data, "use_mirror_x")
1716
1717         col = layout.column(align=True)
1718         col.active = pe.is_editable
1719         col.label(text="Draw:")
1720         col.prop(pe, "draw_step", text="Path Steps")
1721         if pe.is_hair:
1722             col.prop(pe, "show_particles", text="Children")
1723         else:
1724             if pe.type == 'PARTICLES':
1725                 col.prop(pe, "show_particles", text="Particles")
1726             col.prop(pe, "use_fade_time")
1727             sub = col.row(align=True)
1728             sub.active = pe.use_fade_time
1729             sub.prop(pe, "fade_frames", slider=True)
1730
1731
1732 # Grease Pencil tools
1733 class VIEW3D_PT_tools_grease_pencil(GreasePencilPanel, Panel):
1734     bl_space_type = 'VIEW_3D'
1735     bl_region_type = 'TOOLS'
1736     bl_category = "Grease Pencil"
1737
1738
1739 # Note: moved here so that it's always in last position in 'Tools' panels!
1740 class VIEW3D_PT_tools_history(View3DPanel, Panel):
1741     bl_category = "Tools"
1742     # No bl_context, we are always available!
1743     bl_label = "History"
1744     bl_options = {'DEFAULT_CLOSED'}
1745
1746     def draw(self, context):
1747         layout = self.layout
1748         obj = context.object
1749
1750         col = layout.column(align=True)
1751         row = col.row(align=True)
1752         row.operator("ed.undo")
1753         row.operator("ed.redo")
1754         if obj is None or obj.mode not in {'SCULPT'}:
1755             # Sculpt mode does not generate an undo menu it seems...
1756             col.operator("ed.undo_history")
1757
1758         col = layout.column(align=True)
1759         col.label(text="Repeat:")
1760         col.operator("screen.repeat_last")
1761         col.operator("screen.repeat_history", text="History...")
1762
1763
1764 if __name__ == "__main__":  # only for live edit.
1765     bpy.utils.register_module(__name__)