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