Minor changes:
[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 = "Slots"
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) and (context.scene.render.engine == 'BLENDER_RENDER'):
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 Map")
1088                 col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1089
1090
1091
1092 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1093     bl_context = "imagepaint"
1094     bl_label = "Stencil"
1095     bl_category = "Slots"
1096
1097     @classmethod
1098     def poll(cls, context):
1099         brush = context.tool_settings.image_paint.brush
1100         ob = context.active_object
1101         return (brush is not None and ob is not None)
1102
1103     def draw_header(self, context):
1104         ipaint = context.tool_settings.image_paint
1105         self.layout.prop(ipaint, "use_stencil_layer", text="")
1106
1107     def draw(self, context):
1108         layout = self.layout
1109
1110         toolsettings = context.tool_settings
1111         ipaint = toolsettings.image_paint
1112         ob = context.active_object
1113         mesh = ob.data
1114
1115         col = layout.column()
1116         col.active = ipaint.use_stencil_layer
1117
1118         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1119         col.label("UV Map")
1120         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1121
1122         col.label("Image")
1123         row = col.row(align=True)
1124         row.operator("image.new", icon='ZOOMIN', text="Add New").texstencil = True;
1125         row.template_ID(ipaint, "stencil_image")
1126  
1127         col.label("Visualization")
1128         row = col.row(align=True)
1129         row.prop(ipaint, "stencil_color", text="")
1130         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1131
1132
1133 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1134     bl_category = "Options"
1135     bl_label = "Overlay"
1136
1137     @classmethod
1138     def poll(cls, context):
1139         settings = cls.paint_settings(context)
1140         return (settings and
1141                 settings.brush and
1142                 (context.sculpt_object or
1143                  context.vertex_paint_object or
1144                  context.weight_paint_object or
1145                  context.image_paint_object))
1146
1147     def draw(self, context):
1148         layout = self.layout
1149
1150         settings = self.paint_settings(context)
1151         brush = settings.brush
1152         tex_slot = brush.texture_slot
1153         tex_slot_mask = brush.mask_texture_slot
1154
1155         col = layout.column()
1156
1157         col.label(text="Curve:")
1158
1159         row = col.row(align=True)
1160         if brush.use_cursor_overlay:
1161             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1162         else:
1163             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1164
1165         sub = row.row(align=True)
1166         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1167         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1168
1169         col.active = brush.brush_capabilities.has_overlay
1170
1171         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1172             col.label(text="Texture:")
1173             row = col.row(align=True)
1174             if tex_slot.map_mode != 'STENCIL':
1175                 if brush.use_primary_overlay:
1176                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1177                 else:
1178                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1179
1180             sub = row.row(align=True)
1181             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1182             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1183
1184         if context.image_paint_object:
1185             col.label(text="Mask Texture:")
1186
1187             row = col.row(align=True)
1188             if tex_slot_mask.map_mode != 'STENCIL':
1189                 if brush.use_secondary_overlay:
1190                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1191                 else:
1192                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1193
1194             sub = row.row(align=True)
1195             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1196             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1197
1198
1199 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1200     bl_category = "Tools"
1201     bl_label = "Texture"
1202     bl_options = {'DEFAULT_CLOSED'}
1203
1204     @classmethod
1205     def poll(cls, context):
1206         settings = cls.paint_settings(context)
1207         return (settings and settings.brush and
1208                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1209
1210     def draw(self, context):
1211         layout = self.layout
1212
1213         settings = self.paint_settings(context)
1214         brush = settings.brush
1215
1216         col = layout.column()
1217
1218         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1219
1220         brush_texture_settings(col, brush, context.sculpt_object)
1221
1222
1223 class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
1224     bl_category = "Tools"
1225     bl_context = "imagepaint"
1226     bl_label = "Texture Mask"
1227     bl_options = {'DEFAULT_CLOSED'}
1228
1229     @classmethod
1230     def poll(cls, context):
1231         brush = context.tool_settings.image_paint.brush
1232         return (context.image_paint_object and brush)
1233
1234     def draw(self, context):
1235         layout = self.layout
1236
1237         brush = context.tool_settings.image_paint.brush
1238
1239         col = layout.column()
1240
1241         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1242
1243         brush_mask_texture_settings(col, brush)
1244
1245
1246 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1247     bl_category = "Tools"
1248     bl_label = "Stroke"
1249     bl_options = {'DEFAULT_CLOSED'}
1250
1251     @classmethod
1252     def poll(cls, context):
1253         settings = cls.paint_settings(context)
1254         return (settings and
1255                 settings.brush and
1256                 (context.sculpt_object or
1257                  context.vertex_paint_object or
1258                  context.weight_paint_object or
1259                  context.image_paint_object))
1260
1261     def draw(self, context):
1262         layout = self.layout
1263
1264         settings = self.paint_settings(context)
1265         brush = settings.brush
1266
1267         col = layout.column()
1268
1269         col.label(text="Stroke Method:")
1270
1271         col.prop(brush, "stroke_method", text="")
1272
1273         if brush.use_anchor:
1274             col.separator()
1275             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1276
1277         if brush.use_airbrush:
1278             col.separator()
1279             col.prop(brush, "rate", text="Rate", slider=True)
1280
1281         if brush.use_space:
1282             col.separator()
1283             row = col.row(align=True)
1284             row.prop(brush, "spacing", text="Spacing")
1285             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1286
1287         if brush.use_line or brush.use_curve:
1288             col.separator()
1289             row = col.row(align=True)
1290             row.prop(brush, "spacing", text="Spacing")
1291
1292         if brush.use_curve:
1293             col.separator()
1294             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1295             col.operator("paintcurve.draw")
1296
1297         if context.sculpt_object:
1298             if brush.sculpt_capabilities.has_jitter:
1299                 col.separator()
1300
1301                 row = col.row(align=True)
1302                 row.prop(brush, "use_relative_jitter", icon_only=True)
1303                 if brush.use_relative_jitter:
1304                     row.prop(brush, "jitter", slider=True)
1305                 else:
1306                     row.prop(brush, "jitter_absolute")
1307                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1308
1309             if brush.sculpt_capabilities.has_smooth_stroke:
1310                 col = layout.column()
1311                 col.separator()
1312
1313                 col.prop(brush, "use_smooth_stroke")
1314
1315                 sub = col.column()
1316                 sub.active = brush.use_smooth_stroke
1317                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1318                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1319         else:
1320             col.separator()
1321
1322             row = col.row(align=True)
1323             row.prop(brush, "use_relative_jitter", icon_only=True)
1324             if brush.use_relative_jitter:
1325                 row.prop(brush, "jitter", slider=True)
1326             else:
1327                 row.prop(brush, "jitter_absolute")
1328             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1329
1330             col = layout.column()
1331             col.separator()
1332
1333             if brush.brush_capabilities.has_smooth_stroke:
1334                 col.prop(brush, "use_smooth_stroke")
1335
1336                 sub = col.column()
1337                 sub.active = brush.use_smooth_stroke
1338                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1339                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1340
1341         layout.prop(settings, "input_samples")
1342
1343
1344 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1345     bl_category = "Tools"
1346     bl_label = "Curve"
1347     bl_options = {'DEFAULT_CLOSED'}
1348
1349     @classmethod
1350     def poll(cls, context):
1351         settings = cls.paint_settings(context)
1352         return (settings and settings.brush and settings.brush.curve)
1353
1354     def draw(self, context):
1355         layout = self.layout
1356
1357         settings = self.paint_settings(context)
1358
1359         brush = settings.brush
1360
1361         layout.template_curve_mapping(brush, "curve", brush=True)
1362
1363         col = layout.column(align=True)
1364         row = col.row(align=True)
1365         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1366         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1367         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1368         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1369         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1370         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1371
1372
1373 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1374     bl_category = "Tools"
1375     bl_label = "Dyntopo"
1376     bl_options = {'DEFAULT_CLOSED'}
1377
1378     @classmethod
1379     def poll(cls, context):
1380         return (context.sculpt_object and context.tool_settings.sculpt)
1381
1382     def draw(self, context):
1383         layout = self.layout
1384
1385         toolsettings = context.tool_settings
1386         sculpt = toolsettings.sculpt
1387         settings = self.paint_settings(context)
1388         brush = settings.brush
1389
1390         if context.sculpt_object.use_dynamic_topology_sculpting:
1391             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1392         else:
1393             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1394
1395         col = layout.column()
1396         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1397         sub = col.column(align=True)
1398         sub.active = (brush and brush.sculpt_tool != 'MASK')
1399         if (sculpt.detail_type_method == 'CONSTANT'):
1400             row = sub.row(align=True)
1401             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1402             row.prop(sculpt, "constant_detail")
1403         else:
1404             sub.prop(sculpt, "detail_size")
1405         sub.prop(sculpt, "detail_refine_method", text="")
1406         sub.prop(sculpt, "detail_type_method", text="")
1407         col.separator()
1408         col.prop(sculpt, "use_smooth_shading")
1409         col.operator("sculpt.optimize")
1410         if (sculpt.detail_type_method == 'CONSTANT'):
1411             col.operator("sculpt.detail_flood_fill")
1412         col.separator()
1413         col.prop(sculpt, "symmetrize_direction")
1414         col.operator("sculpt.symmetrize")
1415
1416
1417 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1418     bl_category = "Options"
1419     bl_label = "Options"
1420     bl_options = {'DEFAULT_CLOSED'}
1421
1422     @classmethod
1423     def poll(cls, context):
1424         return (context.sculpt_object and context.tool_settings.sculpt)
1425
1426     def draw(self, context):
1427         layout = self.layout
1428         # scene = context.scene
1429
1430         toolsettings = context.tool_settings
1431         sculpt = toolsettings.sculpt
1432         capabilities = sculpt.brush.sculpt_capabilities
1433
1434         col = layout.column(align=True)
1435         col.active = capabilities.has_gravity
1436         col.label(text="Gravity:")
1437         col.prop(sculpt, "gravity", slider=True, text="Factor")
1438         col.prop(sculpt, "gravity_object")
1439         col.separator()
1440
1441         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1442         layout.prop(sculpt, "show_low_resolution")
1443         layout.prop(sculpt, "use_deform_only")
1444         layout.prop(sculpt, "show_diffuse_color")
1445
1446         self.unified_paint_settings(layout, context)
1447
1448
1449 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1450     bl_category = "Tools"
1451     bl_label = "Symmetry / Lock"
1452     bl_options = {'DEFAULT_CLOSED'}
1453
1454     @classmethod
1455     def poll(cls, context):
1456         return (context.sculpt_object and context.tool_settings.sculpt)
1457
1458     def draw(self, context):
1459         layout = self.layout
1460
1461         sculpt = context.tool_settings.sculpt
1462
1463         col = layout.column(align=True)
1464         col.label(text="Mirror:")
1465         row = col.row(align=True)
1466         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1467         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1468         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1469
1470         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1471         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1472
1473         layout.label(text="Lock:")
1474
1475         row = layout.row(align=True)
1476         row.prop(sculpt, "lock_x", text="X", toggle=True)
1477         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1478         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1479
1480
1481 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1482     bl_category = "Options"
1483     bl_label = "Appearance"
1484
1485     @classmethod
1486     def poll(cls, context):
1487         toolsettings = context.tool_settings
1488         return ((context.sculpt_object and toolsettings.sculpt) or
1489                 (context.vertex_paint_object and toolsettings.vertex_paint) or
1490                 (context.weight_paint_object and toolsettings.weight_paint) or
1491                 (context.image_paint_object and toolsettings.image_paint))
1492
1493     def draw(self, context):
1494         layout = self.layout
1495
1496         settings = self.paint_settings(context)
1497         brush = settings.brush
1498
1499         if brush is None:  # unlikely but can happen
1500             layout.label(text="Brush Unset")
1501             return
1502
1503         col = layout.column()
1504         col.prop(settings, "show_brush")
1505
1506         sub = col.column()
1507         sub.active = settings.show_brush
1508
1509         if context.sculpt_object and context.tool_settings.sculpt:
1510             if brush.sculpt_capabilities.has_secondary_color:
1511                 sub.row().prop(brush, "cursor_color_add", text="Add")
1512                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1513             else:
1514                 sub.prop(brush, "cursor_color_add", text="")
1515         else:
1516             sub.prop(brush, "cursor_color_add", text="")
1517
1518         col.separator()
1519
1520         col = col.column(align=True)
1521         col.prop(brush, "use_custom_icon")
1522         sub = col.column()
1523         sub.active = brush.use_custom_icon
1524         sub.prop(brush, "icon_filepath", text="")
1525
1526 # ********** default tools for weight-paint ****************
1527
1528
1529 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1530     bl_category = "Tools"
1531     bl_context = "weightpaint"
1532     bl_label = "Weight Tools"
1533
1534     def draw(self, context):
1535         layout = self.layout
1536         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1537
1538         col = layout.column()
1539         col.operator("paint.weight_gradient")
1540         col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1541
1542
1543 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1544     bl_category = "Options"
1545     bl_context = "weightpaint"
1546     bl_label = "Options"
1547
1548     def draw(self, context):
1549         layout = self.layout
1550
1551         tool_settings = context.tool_settings
1552         wpaint = tool_settings.weight_paint
1553
1554         col = layout.column()
1555         row = col.row()
1556
1557         row.prop(wpaint, "use_normal")
1558         col = layout.column()
1559         row = col.row()
1560         row.prop(wpaint, "use_spray")
1561         row.prop(wpaint, "use_group_restrict")
1562
1563         obj = context.weight_paint_object
1564         if obj.type == 'MESH':
1565             mesh = obj.data
1566             col.prop(mesh, "use_mirror_x")
1567             row = col.row()
1568             row.active = mesh.use_mirror_x
1569             row.prop(mesh, "use_mirror_topology")
1570
1571         col.label("Show Zero Weights:")
1572         sub = col.row()
1573         sub.active = (not tool_settings.use_multipaint)
1574         sub.prop(tool_settings, "vertex_group_user", expand=True)
1575
1576         self.unified_paint_settings(col, context)
1577
1578 # ********** default tools for vertex-paint ****************
1579
1580
1581 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1582     bl_category = "Options"
1583     bl_context = "vertexpaint"
1584     bl_label = "Options"
1585
1586     def draw(self, context):
1587         layout = self.layout
1588
1589         toolsettings = context.tool_settings
1590         vpaint = toolsettings.vertex_paint
1591
1592         col = layout.column()
1593         row = col.row()
1594         # col.prop(vpaint, "mode", text="")
1595         row.prop(vpaint, "use_normal")
1596         col.prop(vpaint, "use_spray")
1597
1598         self.unified_paint_settings(col, context)
1599
1600 # Commented out because the Apply button isn't an operator yet, making these settings useless
1601 #~         col.label(text="Gamma:")
1602 #~         col.prop(vpaint, "gamma", text="")
1603 #~         col.label(text="Multiply:")
1604 #~         col.prop(vpaint, "mul", text="")
1605
1606 # ********** default tools for texture-paint ****************
1607
1608
1609 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1610     bl_category = "Tools"
1611     bl_context = "imagepaint"
1612     bl_label = "External"
1613     bl_options = {'DEFAULT_CLOSED'}
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         row = col.split(align=True, percentage=0.55)
1623         row.operator("image.project_edit", text="Quick Edit")
1624         row.operator("image.project_apply", text="Apply")
1625
1626         col.row().prop(ipaint, "screen_grab_size", text="")
1627
1628         col.operator("paint.project_image", text="Apply Camera Image")
1629         col.operator("image.save_dirty", text="Save All Edited")
1630
1631
1632 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1633     bl_category = "Options"
1634     bl_context = "imagepaint"
1635     bl_label = "Project Paint"
1636
1637     @classmethod
1638     def poll(cls, context):
1639         brush = context.tool_settings.image_paint.brush
1640         return (brush is not None)
1641
1642     def draw(self, context):
1643         layout = self.layout
1644
1645         toolsettings = context.tool_settings
1646         ipaint = toolsettings.image_paint
1647
1648         col = layout.column()
1649
1650         col.prop(ipaint, "use_occlude")
1651         col.prop(ipaint, "use_backface_culling")
1652
1653         row = layout.row()
1654         row.prop(ipaint, "use_normal_falloff")
1655
1656         sub = row.row()
1657         sub.active = (ipaint.use_normal_falloff)
1658         sub.prop(ipaint, "normal_angle", text="")
1659
1660         layout.prop(ipaint, "seam_bleed")
1661         self.unified_paint_settings(layout, context)
1662
1663
1664 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1665     bl_category = "Options"
1666     bl_label = "Options"
1667
1668     @classmethod
1669     def poll(cls, context):
1670         return (context.image_paint_object and context.tool_settings.image_paint)
1671
1672     def draw(self, context):
1673         layout = self.layout
1674
1675         col = layout.column()
1676         self.unified_paint_settings(col, context)
1677
1678
1679 class VIEW3D_MT_tools_projectpaint_clone(Menu):
1680     bl_label = "Clone Layer"
1681
1682     def draw(self, context):
1683         layout = self.layout
1684
1685         for i, tex in enumerate(context.active_object.data.uv_textures):
1686             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1687             props.data_path = "active_object.data.uv_texture_clone_index"
1688             props.value = i
1689
1690
1691 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1692     bl_label = "Mask Layer"
1693
1694     def draw(self, context):
1695         layout = self.layout
1696         for i, tex in enumerate(context.active_object.data.uv_textures):
1697             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1698             props.data_path = "active_object.data.uv_texture_stencil_index"
1699             props.value = i
1700
1701
1702 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1703     """Default tools for particle mode"""
1704     bl_context = "particlemode"
1705     bl_label = "Options"
1706     bl_category = "Tools"
1707
1708     def draw(self, context):
1709         layout = self.layout
1710
1711         pe = context.tool_settings.particle_edit
1712         ob = pe.object
1713
1714         layout.prop(pe, "type", text="")
1715
1716         ptcache = None
1717
1718         if pe.type == 'PARTICLES':
1719             if ob.particle_systems:
1720                 if len(ob.particle_systems) > 1:
1721                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1722                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1723
1724                 ptcache = ob.particle_systems.active.point_cache
1725         else:
1726             for md in ob.modifiers:
1727                 if md.type == pe.type:
1728                     ptcache = md.point_cache
1729
1730         if ptcache and len(ptcache.point_caches) > 1:
1731             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1732                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1733
1734         if not pe.is_editable:
1735             layout.label(text="Point cache must be baked")
1736             layout.label(text="in memory to enable editing!")
1737
1738         col = layout.column(align=True)
1739         if pe.is_hair:
1740             col.active = pe.is_editable
1741             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1742             sub = col.row(align=True)
1743             sub.active = pe.use_emitter_deflect
1744             sub.prop(pe, "emitter_distance", text="Distance")
1745
1746         col = layout.column(align=True)
1747         col.active = pe.is_editable
1748         col.label(text="Keep:")
1749         col.prop(pe, "use_preserve_length", text="Lengths")
1750         col.prop(pe, "use_preserve_root", text="Root")
1751         if not pe.is_hair:
1752             col.label(text="Correct:")
1753             col.prop(pe, "use_auto_velocity", text="Velocity")
1754         col.prop(ob.data, "use_mirror_x")
1755
1756         col = layout.column(align=True)
1757         col.active = pe.is_editable
1758         col.label(text="Draw:")
1759         col.prop(pe, "draw_step", text="Path Steps")
1760         if pe.is_hair:
1761             col.prop(pe, "show_particles", text="Children")
1762         else:
1763             if pe.type == 'PARTICLES':
1764                 col.prop(pe, "show_particles", text="Particles")
1765             col.prop(pe, "use_fade_time")
1766             sub = col.row(align=True)
1767             sub.active = pe.use_fade_time
1768             sub.prop(pe, "fade_frames", slider=True)
1769
1770
1771 # Grease Pencil tools
1772 class VIEW3D_PT_tools_grease_pencil(GreasePencilPanel, Panel):
1773     bl_space_type = 'VIEW_3D'
1774     bl_region_type = 'TOOLS'
1775     bl_category = "Grease Pencil"
1776
1777
1778 if __name__ == "__main__":  # only for live edit.
1779     bpy.utils.register_module(__name__)