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