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