Fix T43408: Putting steps and keys properties into an inactive sublayout
[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                 col.prop(brush, "steps", slider=True)
885                 col.prop(settings, "default_key_count", slider=True)
886             elif tool == 'LENGTH':
887                 layout.prop(brush, "length_mode", expand=True)
888             elif tool == 'PUFF':
889                 layout.prop(brush, "puff_mode", expand=True)
890                 layout.prop(brush, "use_puff_volume")
891
892         # Sculpt Mode #
893
894         elif context.sculpt_object and brush:
895             capabilities = brush.sculpt_capabilities
896
897             col = layout.column()
898
899             col.separator()
900
901             row = col.row(align=True)
902
903             ups = toolsettings.unified_paint_settings
904             if ((ups.use_unified_size and ups.use_locked_size) or
905                     ((not ups.use_unified_size) and brush.use_locked_size)):
906                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
907                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
908             else:
909                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
910                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
911
912             self.prop_unified_size(row, context, brush, "use_pressure_size")
913
914             # strength, use_strength_pressure, and use_strength_attenuation
915             col.separator()
916             row = col.row(align=True)
917
918             if capabilities.has_space_attenuation:
919                 row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
920
921             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
922
923             if capabilities.has_strength_pressure:
924                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
925
926             # auto_smooth_factor and use_inverse_smooth_pressure
927             if capabilities.has_auto_smooth:
928                 col.separator()
929
930                 row = col.row(align=True)
931                 row.prop(brush, "auto_smooth_factor", slider=True)
932                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
933
934             # normal_weight
935             if capabilities.has_normal_weight:
936                 col.separator()
937                 row = col.row(align=True)
938                 row.prop(brush, "normal_weight", slider=True)
939
940             # crease_pinch_factor
941             if capabilities.has_pinch_factor:
942                 col.separator()
943                 row = col.row(align=True)
944                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
945
946             # use_original_normal and sculpt_plane
947             if capabilities.has_sculpt_plane:
948                 col.separator()
949                 row = col.row(align=True)
950
951                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
952
953                 row.prop(brush, "sculpt_plane", text="")
954
955             if brush.sculpt_tool == 'MASK':
956                 col.prop(brush, "mask_tool", text="")
957
958             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
959             if capabilities.has_plane_offset:
960                 row = col.row(align=True)
961                 row.prop(brush, "plane_offset", slider=True)
962                 row.prop(brush, "use_offset_pressure", text="")
963
964                 col.separator()
965
966                 row = col.row()
967                 row.prop(brush, "use_plane_trim", text="Trim")
968                 row = col.row()
969                 row.active = brush.use_plane_trim
970                 row.prop(brush, "plane_trim", slider=True, text="Distance")
971
972             # height
973             if capabilities.has_height:
974                 row = col.row()
975                 row.prop(brush, "height", slider=True, text="Height")
976
977             # use_frontface
978             col.separator()
979             row = col.row()
980             row.prop(brush, "use_frontface", text="Front Faces Only")
981
982             # direction
983             col.separator()
984             col.row().prop(brush, "direction", expand=True)
985
986             # use_accumulate
987             if capabilities.has_accumulate:
988                 col.separator()
989
990                 col.prop(brush, "use_accumulate")
991
992             # use_persistent, set_persistent_base
993             if capabilities.has_persistence:
994                 col.separator()
995
996                 ob = context.sculpt_object
997                 do_persistent = True
998
999                 # not supported yet for this case
1000                 for md in ob.modifiers:
1001                     if md.type == 'MULTIRES':
1002                         do_persistent = False
1003                         break
1004
1005                 if do_persistent:
1006                     col.prop(brush, "use_persistent")
1007                     col.operator("sculpt.set_persistent_base")
1008
1009         # Texture Paint Mode #
1010
1011         elif context.image_paint_object and brush:
1012             brush_texpaint_common(self, context, layout, brush, settings, True)
1013
1014         # Weight Paint Mode #
1015         elif context.weight_paint_object and brush:
1016
1017             col = layout.column()
1018
1019             row = col.row(align=True)
1020             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
1021
1022             row = col.row(align=True)
1023             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1024             self.prop_unified_size(row, context, brush, "use_pressure_size")
1025
1026             row = col.row(align=True)
1027             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1028             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1029
1030             col.prop(brush, "vertex_tool", text="Blend")
1031
1032             col = layout.column()
1033             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
1034             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
1035
1036         # Vertex Paint Mode #
1037         elif context.vertex_paint_object and brush:
1038             col = layout.column()
1039             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
1040             if settings.palette:
1041                 col.template_palette(settings, "palette", color=True)
1042             self.prop_unified_color(col, context, brush, "color", text="")
1043
1044             col.separator()
1045             row = col.row(align=True)
1046             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
1047             self.prop_unified_size(row, context, brush, "use_pressure_size")
1048
1049             row = col.row(align=True)
1050             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
1051             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
1052
1053             # XXX - TODO
1054             # row = col.row(align=True)
1055             # row.prop(brush, "jitter", slider=True)
1056             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1057             col.separator()
1058             col.prop(brush, "vertex_tool", text="Blend")
1059
1060             col.separator()
1061             col.template_ID(settings, "palette", new="palette.new")
1062
1063
1064 class TEXTURE_UL_texpaintslots(UIList):
1065     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
1066         mat = data
1067
1068         if self.layout_type in {'DEFAULT', 'COMPACT'}:
1069             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
1070             if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1071                 mtex_index = mat.texture_paint_slots[index].index
1072                 layout.prop(mat, "use_textures", text="", index=mtex_index)
1073         elif self.layout_type in {'GRID'}:
1074             layout.alignment = 'CENTER'
1075             layout.label(text="")
1076
1077 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
1078     bl_label = "Clone Layer"
1079
1080     def draw(self, context):
1081         layout = self.layout
1082
1083         for i, tex in enumerate(context.active_object.data.uv_textures):
1084             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1085             props.data_path = "active_object.data.uv_textures.active_index"
1086             props.value = i
1087
1088
1089 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
1090     bl_context = "imagepaint"
1091     bl_label = "Slots"
1092     bl_category = "Slots"
1093
1094     @classmethod
1095     def poll(cls, context):
1096         brush = context.tool_settings.image_paint.brush
1097         ob = context.active_object
1098         return (brush is not None and ob is not None)
1099
1100     def draw(self, context):
1101         layout = self.layout
1102
1103         settings = context.tool_settings.image_paint
1104         # brush = settings.brush
1105
1106         ob = context.active_object
1107         col = layout.column()
1108
1109         col.label("Painting Mode")
1110         col.prop(settings, "mode", text="")
1111         col.separator()
1112
1113         if settings.mode == 'MATERIAL':
1114             if len(ob.material_slots) > 1:
1115                 col.label("Materials")
1116                 col.template_list("MATERIAL_UL_matslots", "layers",
1117                                   ob, "material_slots",
1118                                   ob, "active_material_index", rows=2)
1119
1120             mat = ob.active_material
1121             if mat:
1122                 col.label("Available Paint Slots")
1123                 col.template_list("TEXTURE_UL_texpaintslots", "",
1124                                   mat, "texture_paint_images",
1125                                   mat, "paint_active_slot", rows=2)
1126
1127                 if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}:
1128                     row = col.row(align=True)
1129                     row.operator_menu_enum("paint.add_texture_paint_slot", "type")
1130                     row.operator("paint.delete_texture_paint_slot", text="", icon='X')
1131
1132                     if mat.texture_paint_slots:
1133                         slot = mat.texture_paint_slots[mat.paint_active_slot]
1134
1135                         col.prop(mat.texture_slots[slot.index], "blend_type")
1136                         col.separator()
1137                         col.label("UV Map")
1138                         col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
1139
1140         elif settings.mode == 'IMAGE':
1141             mesh = ob.data
1142             uv_text = mesh.uv_textures.active.name if mesh.uv_textures.active else ""
1143             col.label("Canvas Image")
1144             col.template_ID(settings, "canvas")
1145             col.operator("image.new", text="New").gen_context = 'PAINT_CANVAS'
1146             col.label("UV Map")
1147             col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
1148
1149         col.separator()
1150         col.operator("image.save_dirty", text="Save All Images")
1151
1152
1153 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
1154     bl_context = "imagepaint"
1155     bl_label = "Mask"
1156     bl_category = "Slots"
1157
1158     @classmethod
1159     def poll(cls, context):
1160         brush = context.tool_settings.image_paint.brush
1161         ob = context.active_object
1162         return (brush is not None and ob is not None)
1163
1164     def draw_header(self, context):
1165         ipaint = context.tool_settings.image_paint
1166         self.layout.prop(ipaint, "use_stencil_layer", text="")
1167
1168     def draw(self, context):
1169         layout = self.layout
1170
1171         toolsettings = context.tool_settings
1172         ipaint = toolsettings.image_paint
1173         ob = context.active_object
1174         mesh = ob.data
1175
1176         col = layout.column()
1177         col.active = ipaint.use_stencil_layer
1178
1179         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1180         col.label("UV Map")
1181         col.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1182
1183         col.label("Stencil Image")
1184         col.template_ID(ipaint, "stencil_image")
1185         col.operator("image.new", text="New").gen_context = 'PAINT_STENCIL'
1186
1187  
1188         col.label("Visualization")
1189         row = col.row(align=True)
1190         row.prop(ipaint, "stencil_color", text="")
1191         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1192
1193
1194 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
1195     bl_category = "Options"
1196     bl_label = "Overlay"
1197
1198     @classmethod
1199     def poll(cls, context):
1200         settings = cls.paint_settings(context)
1201         return (settings and
1202                 settings.brush and
1203                 (context.sculpt_object or
1204                  context.vertex_paint_object or
1205                  context.weight_paint_object or
1206                  context.image_paint_object))
1207
1208     def draw(self, context):
1209         layout = self.layout
1210
1211         settings = self.paint_settings(context)
1212         brush = settings.brush
1213         tex_slot = brush.texture_slot
1214         tex_slot_mask = brush.mask_texture_slot
1215
1216         col = layout.column()
1217
1218         col.label(text="Curve:")
1219
1220         row = col.row(align=True)
1221         if brush.use_cursor_overlay:
1222             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1223         else:
1224             row.prop(brush, "use_cursor_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1225
1226         sub = row.row(align=True)
1227         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
1228         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1229
1230         col.active = brush.brush_capabilities.has_overlay
1231
1232         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
1233             col.label(text="Texture:")
1234             row = col.row(align=True)
1235             if tex_slot.map_mode != 'STENCIL':
1236                 if brush.use_primary_overlay:
1237                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1238                 else:
1239                     row.prop(brush, "use_primary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1240
1241             sub = row.row(align=True)
1242             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
1243             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1244
1245         if context.image_paint_object:
1246             col.label(text="Mask Texture:")
1247
1248             row = col.row(align=True)
1249             if tex_slot_mask.map_mode != 'STENCIL':
1250                 if brush.use_secondary_overlay:
1251                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
1252                 else:
1253                     row.prop(brush, "use_secondary_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
1254
1255             sub = row.row(align=True)
1256             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
1257             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
1258
1259
1260 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
1261     bl_category = "Tools"
1262     bl_label = "Texture"
1263     bl_options = {'DEFAULT_CLOSED'}
1264
1265     @classmethod
1266     def poll(cls, context):
1267         settings = cls.paint_settings(context)
1268         return (settings and settings.brush and
1269                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
1270
1271     def draw(self, context):
1272         layout = self.layout
1273
1274         settings = self.paint_settings(context)
1275         brush = settings.brush
1276
1277         col = layout.column()
1278
1279         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
1280
1281         brush_texture_settings(col, brush, context.sculpt_object)
1282
1283
1284 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
1285     bl_category = "Tools"
1286     bl_context = "imagepaint"
1287     bl_label = "Texture Mask"
1288     bl_options = {'DEFAULT_CLOSED'}
1289
1290     @classmethod
1291     def poll(cls, context):
1292         settings = cls.paint_settings(context)
1293         return (settings and settings.brush and context.image_paint_object)
1294
1295     def draw(self, context):
1296         layout = self.layout
1297
1298         brush = context.tool_settings.image_paint.brush
1299
1300         col = layout.column()
1301
1302         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
1303
1304         brush_mask_texture_settings(col, brush)
1305
1306
1307 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
1308     bl_category = "Tools"
1309     bl_label = "Stroke"
1310     bl_options = {'DEFAULT_CLOSED'}
1311
1312     @classmethod
1313     def poll(cls, context):
1314         settings = cls.paint_settings(context)
1315         return (settings and
1316                 settings.brush and
1317                 (context.sculpt_object or
1318                  context.vertex_paint_object or
1319                  context.weight_paint_object or
1320                  context.image_paint_object))
1321
1322     def draw(self, context):
1323         layout = self.layout
1324
1325         settings = self.paint_settings(context)
1326         brush = settings.brush
1327
1328         col = layout.column()
1329
1330         col.label(text="Stroke Method:")
1331
1332         col.prop(brush, "stroke_method", text="")
1333
1334         if brush.use_anchor:
1335             col.separator()
1336             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1337
1338         if brush.use_airbrush:
1339             col.separator()
1340             col.prop(brush, "rate", text="Rate", slider=True)
1341
1342         if brush.use_space:
1343             col.separator()
1344             row = col.row(align=True)
1345             row.prop(brush, "spacing", text="Spacing")
1346             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1347
1348         if brush.use_line or brush.use_curve:
1349             col.separator()
1350             row = col.row(align=True)
1351             row.prop(brush, "spacing", text="Spacing")
1352
1353         if brush.use_curve:
1354             col.separator()
1355             col.template_ID(brush, "paint_curve", new="paintcurve.new")
1356             col.operator("paintcurve.draw")
1357
1358         if context.sculpt_object:
1359             if brush.sculpt_capabilities.has_jitter:
1360                 col.separator()
1361
1362                 row = col.row(align=True)
1363                 row.prop(brush, "use_relative_jitter", icon_only=True)
1364                 if brush.use_relative_jitter:
1365                     row.prop(brush, "jitter", slider=True)
1366                 else:
1367                     row.prop(brush, "jitter_absolute")
1368                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1369
1370             if brush.sculpt_capabilities.has_smooth_stroke:
1371                 col = layout.column()
1372                 col.separator()
1373
1374                 col.prop(brush, "use_smooth_stroke")
1375
1376                 sub = col.column()
1377                 sub.active = brush.use_smooth_stroke
1378                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1379                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1380         else:
1381             col.separator()
1382
1383             row = col.row(align=True)
1384             row.prop(brush, "use_relative_jitter", icon_only=True)
1385             if brush.use_relative_jitter:
1386                 row.prop(brush, "jitter", slider=True)
1387             else:
1388                 row.prop(brush, "jitter_absolute")
1389             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1390
1391             col = layout.column()
1392             col.separator()
1393
1394             if brush.brush_capabilities.has_smooth_stroke:
1395                 col.prop(brush, "use_smooth_stroke")
1396
1397                 sub = col.column()
1398                 sub.active = brush.use_smooth_stroke
1399                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1400                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1401
1402         layout.prop(settings, "input_samples")
1403
1404
1405 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1406     bl_category = "Tools"
1407     bl_label = "Curve"
1408     bl_options = {'DEFAULT_CLOSED'}
1409
1410     @classmethod
1411     def poll(cls, context):
1412         settings = cls.paint_settings(context)
1413         return (settings and settings.brush and settings.brush.curve)
1414
1415     def draw(self, context):
1416         layout = self.layout
1417
1418         settings = self.paint_settings(context)
1419
1420         brush = settings.brush
1421
1422         layout.template_curve_mapping(brush, "curve", brush=True)
1423
1424         col = layout.column(align=True)
1425         row = col.row(align=True)
1426         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1427         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1428         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1429         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1430         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1431         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1432
1433
1434 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1435     bl_category = "Tools"
1436     bl_label = "Dyntopo"
1437     bl_options = {'DEFAULT_CLOSED'}
1438
1439     @classmethod
1440     def poll(cls, context):
1441         return (context.sculpt_object and context.tool_settings.sculpt)
1442
1443     def draw(self, context):
1444         layout = self.layout
1445
1446         toolsettings = context.tool_settings
1447         sculpt = toolsettings.sculpt
1448         settings = self.paint_settings(context)
1449         brush = settings.brush
1450
1451         if context.sculpt_object.use_dynamic_topology_sculpting:
1452             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1453         else:
1454             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1455
1456         col = layout.column()
1457         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1458         sub = col.column(align=True)
1459         sub.active = (brush and brush.sculpt_tool != 'MASK')
1460         if (sculpt.detail_type_method == 'CONSTANT'):
1461             row = sub.row(align=True)
1462             row.prop(sculpt, "constant_detail")
1463             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1464         else:
1465             sub.prop(sculpt, "detail_size")
1466         sub.prop(sculpt, "detail_refine_method", text="")
1467         sub.prop(sculpt, "detail_type_method", text="")
1468         col.separator()
1469         col.prop(sculpt, "use_smooth_shading")
1470         col.operator("sculpt.optimize")
1471         if (sculpt.detail_type_method == 'CONSTANT'):
1472             col.operator("sculpt.detail_flood_fill")
1473         col.separator()
1474         col.prop(sculpt, "symmetrize_direction")
1475         col.operator("sculpt.symmetrize")
1476
1477
1478 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1479     bl_category = "Options"
1480     bl_label = "Options"
1481     bl_options = {'DEFAULT_CLOSED'}
1482
1483     @classmethod
1484     def poll(cls, context):
1485         return (context.sculpt_object and context.tool_settings.sculpt)
1486
1487     def draw(self, context):
1488         layout = self.layout
1489         # scene = context.scene
1490
1491         toolsettings = context.tool_settings
1492         sculpt = toolsettings.sculpt
1493         capabilities = sculpt.brush.sculpt_capabilities
1494
1495         col = layout.column(align=True)
1496         col.active = capabilities.has_gravity
1497         col.label(text="Gravity:")
1498         col.prop(sculpt, "gravity", slider=True, text="Factor")
1499         col.prop(sculpt, "gravity_object")
1500         col.separator()
1501
1502         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1503         layout.prop(sculpt, "show_low_resolution")
1504         layout.prop(sculpt, "use_deform_only")
1505         layout.prop(sculpt, "show_diffuse_color")
1506
1507         self.unified_paint_settings(layout, context)
1508
1509
1510 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1511     bl_category = "Tools"
1512     bl_label = "Symmetry / Lock"
1513     bl_options = {'DEFAULT_CLOSED'}
1514
1515     @classmethod
1516     def poll(cls, context):
1517         return (context.sculpt_object and context.tool_settings.sculpt)
1518
1519     def draw(self, context):
1520         layout = self.layout
1521
1522         sculpt = context.tool_settings.sculpt
1523
1524         col = layout.column(align=True)
1525         col.label(text="Mirror:")
1526         row = col.row(align=True)
1527         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1528         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1529         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1530
1531         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1532         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1533
1534         layout.label(text="Lock:")
1535
1536         row = layout.row(align=True)
1537         row.prop(sculpt, "lock_x", text="X", toggle=True)
1538         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1539         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1540
1541
1542 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1543     bl_category = "Options"
1544     bl_label = "Appearance"
1545
1546     @classmethod
1547     def poll(cls, context):
1548         settings = cls.paint_settings(context)
1549         return settings
1550
1551     def draw(self, context):
1552         layout = self.layout
1553
1554         settings = self.paint_settings(context)
1555         brush = settings.brush
1556
1557         if brush is None:  # unlikely but can happen
1558             layout.label(text="Brush Unset")
1559             return
1560
1561         col = layout.column()
1562         col.prop(settings, "show_brush")
1563
1564         sub = col.column()
1565         sub.active = settings.show_brush
1566
1567         if context.sculpt_object and context.tool_settings.sculpt:
1568             if brush.sculpt_capabilities.has_secondary_color:
1569                 sub.row().prop(brush, "cursor_color_add", text="Add")
1570                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1571             else:
1572                 sub.prop(brush, "cursor_color_add", text="")
1573         else:
1574             sub.prop(brush, "cursor_color_add", text="")
1575
1576         col.separator()
1577
1578         col = col.column(align=True)
1579         col.prop(brush, "use_custom_icon")
1580         sub = col.column()
1581         sub.active = brush.use_custom_icon
1582         sub.prop(brush, "icon_filepath", text="")
1583
1584 # ********** default tools for weight-paint ****************
1585
1586
1587 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1588     bl_category = "Tools"
1589     bl_context = "weightpaint"
1590     bl_label = "Weight Tools"
1591
1592     def draw(self, context):
1593         layout = self.layout
1594         VIEW3D_PT_tools_meshweight.draw_generic(layout)
1595
1596         col = layout.column()
1597         col.operator("paint.weight_gradient")
1598         prop = col.operator("object.data_transfer", text="Transfer Weights")
1599         prop.use_reverse_transfer = True
1600         prop.data_type = 'VGROUP_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.prop(pe, "shape_object")
1804         col.operator("particle.shape_cut")
1805
1806         col = layout.column(align=True)
1807         col.active = pe.is_editable
1808         col.label(text="Draw:")
1809         col.prop(pe, "draw_step", text="Path Steps")
1810         if pe.is_hair:
1811             col.prop(pe, "show_particles", text="Children")
1812         else:
1813             if pe.type == 'PARTICLES':
1814                 col.prop(pe, "show_particles", text="Particles")
1815             col.prop(pe, "use_fade_time")
1816             sub = col.row(align=True)
1817             sub.active = pe.use_fade_time
1818             sub.prop(pe, "fade_frames", slider=True)
1819
1820
1821 # Grease Pencil drawing tools
1822 class VIEW3D_PT_tools_grease_pencil_draw(GreasePencilDrawingToolsPanel, Panel):
1823     bl_space_type = 'VIEW_3D'
1824
1825
1826 # Grease Pencil stroke editing tools
1827 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1828     bl_space_type = 'VIEW_3D'
1829
1830
1831 # Note: moved here so that it's always in last position in 'Tools' panels!
1832 class VIEW3D_PT_tools_history(View3DPanel, Panel):
1833     bl_category = "Tools"
1834     # No bl_context, we are always available!
1835     bl_label = "History"
1836     bl_options = {'DEFAULT_CLOSED'}
1837
1838     def draw(self, context):
1839         layout = self.layout
1840         obj = context.object
1841
1842         col = layout.column(align=True)
1843         row = col.row(align=True)
1844         row.operator("ed.undo")
1845         row.operator("ed.redo")
1846         if obj is None or obj.mode not in {'SCULPT'}:
1847             # Sculpt mode does not generate an undo menu it seems...
1848             col.operator("ed.undo_history")
1849
1850         col = layout.column(align=True)
1851         col.label(text="Repeat:")
1852         col.operator("screen.repeat_last")
1853         col.operator("screen.repeat_history", text="History...")
1854
1855
1856 if __name__ == "__main__":  # only for live edit.
1857     bpy.utils.register_module(__name__)