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