Attempt to fix T39412
[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         col.prop(brush, "stroke_method", text="")
1123
1124         if brush.use_anchor:
1125             col.separator()
1126             col.prop(brush, "use_edge_to_edge", "Edge To Edge")
1127
1128         if brush.use_airbrush:
1129             col.separator()
1130             col.prop(brush, "rate", text="Rate", slider=True)
1131
1132         if brush.use_space:
1133             col.separator()
1134             row = col.row(align=True)
1135             row.active = brush.use_space
1136             row.prop(brush, "spacing", text="Spacing")
1137             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
1138
1139         if context.sculpt_object:
1140             if brush.sculpt_capabilities.has_jitter:
1141                 col.separator()
1142
1143                 row = col.row(align=True)
1144                 row.prop(brush, "use_relative_jitter", icon_only=True)
1145                 if brush.use_relative_jitter:
1146                     row.prop(brush, "jitter", slider=True)
1147                 else:
1148                     row.prop(brush, "jitter_absolute")
1149                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1150
1151             if brush.sculpt_capabilities.has_smooth_stroke:
1152                 col = layout.column()
1153                 col.separator()
1154
1155                 col.prop(brush, "use_smooth_stroke")
1156
1157                 sub = col.column()
1158                 sub.active = brush.use_smooth_stroke
1159                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1160                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1161         else:
1162             col.separator()
1163
1164             row = col.row(align=True)
1165             row.prop(brush, "use_relative_jitter", icon_only=True)
1166             if brush.use_relative_jitter:
1167                 row.prop(brush, "jitter", slider=True)
1168             else:
1169                 row.prop(brush, "jitter_absolute")
1170             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
1171
1172             col = layout.column()
1173             col.separator()
1174
1175             col.prop(brush, "use_smooth_stroke")
1176
1177             sub = col.column()
1178             sub.active = brush.use_smooth_stroke
1179             sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1180             sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1181
1182         layout.prop(settings, "input_samples")
1183
1184
1185 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
1186     bl_category = "Tools"
1187     bl_label = "Curve"
1188     bl_options = {'DEFAULT_CLOSED'}
1189
1190     @classmethod
1191     def poll(cls, context):
1192         settings = cls.paint_settings(context)
1193         return (settings and settings.brush and settings.brush.curve)
1194
1195     def draw(self, context):
1196         layout = self.layout
1197
1198         settings = self.paint_settings(context)
1199
1200         brush = settings.brush
1201
1202         layout.template_curve_mapping(brush, "curve", brush=True)
1203
1204         row = layout.row(align=True)
1205         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
1206         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
1207         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
1208         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
1209         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
1210         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
1211
1212
1213 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
1214     bl_category = "Tools"
1215     bl_label = "Dyntopo"
1216     bl_options = {'DEFAULT_CLOSED'}
1217
1218     @classmethod
1219     def poll(cls, context):
1220         return (context.sculpt_object and context.tool_settings.sculpt)
1221
1222     def draw(self, context):
1223         layout = self.layout
1224
1225         toolsettings = context.tool_settings
1226         sculpt = toolsettings.sculpt
1227         settings = self.paint_settings(context)
1228         brush = settings.brush
1229
1230         if context.sculpt_object.use_dynamic_topology_sculpting:
1231             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dyntopo")
1232         else:
1233             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dyntopo")
1234
1235         col = layout.column()
1236         col.active = context.sculpt_object.use_dynamic_topology_sculpting
1237         sub = col.column(align=True)
1238         sub.active = brush and brush.sculpt_tool not in ('MASK')
1239         if (sculpt.detail_type_method == 'CONSTANT'):
1240             row = sub.row(align=True)
1241             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
1242             row.prop(sculpt, "constant_detail")
1243         else:
1244             sub.prop(sculpt, "detail_size")
1245         sub.prop(sculpt, "detail_refine_method", text="")
1246         sub.prop(sculpt, "detail_type_method", text="")
1247         col.separator()
1248         col.prop(sculpt, "use_smooth_shading")
1249         col.operator("sculpt.optimize")
1250         if (sculpt.detail_type_method == 'CONSTANT'):
1251            col.operator("sculpt.detail_flood_fill")
1252         col.separator()
1253         col.prop(sculpt, "symmetrize_direction")
1254         col.operator("sculpt.symmetrize")
1255
1256
1257 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
1258     bl_category = "Options"
1259     bl_label = "Options"
1260     bl_options = {'DEFAULT_CLOSED'}
1261
1262     @classmethod
1263     def poll(cls, context):
1264         return (context.sculpt_object and context.tool_settings.sculpt)
1265
1266     def draw(self, context):
1267         layout = self.layout
1268
1269         toolsettings = context.tool_settings
1270         sculpt = toolsettings.sculpt
1271         capabilities = sculpt.brush.sculpt_capabilities
1272
1273         col = layout.column(align=True)
1274         col.active = capabilities.has_gravity
1275         col.label(text="Gravity:")
1276         col.prop(sculpt, "gravity", slider=True, text="Factor")
1277         col.prop(sculpt, "gravity_object")
1278
1279         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1280         layout.prop(sculpt, "show_low_resolution")
1281         layout.prop(sculpt, "use_deform_only")
1282         layout.prop(sculpt, "show_diffuse_color")
1283
1284         self.unified_paint_settings(layout, context)
1285
1286
1287 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
1288     bl_category = "Tools"
1289     bl_label = "Symmetry / Lock"
1290     bl_options = {'DEFAULT_CLOSED'}
1291
1292     @classmethod
1293     def poll(cls, context):
1294         return (context.sculpt_object and context.tool_settings.sculpt)
1295
1296     def draw(self, context):
1297         layout = self.layout
1298
1299         sculpt = context.tool_settings.sculpt
1300
1301         col = layout.column(align=True)
1302         col.label(text="Mirror:")
1303         row = col.row(align=True)
1304         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1305         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1306         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1307
1308         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1309         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1310
1311         layout.label(text="Lock:")
1312
1313         row = layout.row(align=True)
1314         row.prop(sculpt, "lock_x", text="X", toggle=True)
1315         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1316         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1317
1318
1319 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1320     bl_category = "Options"
1321     bl_label = "Appearance"
1322
1323     @classmethod
1324     def poll(cls, context):
1325         toolsettings = context.tool_settings
1326         return ((context.sculpt_object and toolsettings.sculpt) or
1327                 (context.vertex_paint_object and toolsettings.vertex_paint) or
1328                 (context.weight_paint_object and toolsettings.weight_paint) or
1329                 (context.image_paint_object and toolsettings.image_paint))
1330
1331     def draw(self, context):
1332         layout = self.layout
1333
1334         settings = self.paint_settings(context)
1335         brush = settings.brush
1336
1337         if brush is None:  # unlikely but can happen
1338             layout.label(text="Brush Unset")
1339             return
1340
1341         col = layout.column()
1342         col.prop(settings, "show_brush")
1343
1344         sub = col.column()
1345         sub.active = settings.show_brush
1346
1347         if context.sculpt_object and context.tool_settings.sculpt:
1348             if brush.sculpt_capabilities.has_secondary_color:
1349                 sub.row().prop(brush, "cursor_color_add", text="Add")
1350                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1351             else:
1352                 sub.prop(brush, "cursor_color_add", text="")
1353         else:
1354             sub.prop(brush, "cursor_color_add", text="")
1355
1356         col.separator()
1357
1358         col = col.column(align=True)
1359         col.prop(brush, "use_custom_icon")
1360         sub = col.column()
1361         sub.active = brush.use_custom_icon
1362         sub.prop(brush, "icon_filepath", text="")
1363
1364 # ********** default tools for weight-paint ****************
1365
1366
1367 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1368     bl_category = "Tools"
1369     bl_context = "weightpaint"
1370     bl_label = "Weight Tools"
1371
1372     def draw(self, context):
1373         layout = self.layout
1374
1375         col = layout.column()
1376         col.operator("object.vertex_group_normalize_all", text="Normalize All")
1377         col.operator("object.vertex_group_normalize", text="Normalize")
1378         col.operator("object.vertex_group_mirror", text="Mirror")
1379         col.operator("object.vertex_group_invert", text="Invert")
1380         col.operator("object.vertex_group_clean", text="Clean")
1381         col.operator("object.vertex_group_quantize", text="Quantize")
1382         col.operator("object.vertex_group_levels", text="Levels")
1383         col.operator("object.vertex_group_blend", text="Blend")
1384         col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1385         col.operator("object.vertex_group_limit_total", text="Limit Total")
1386         col.operator("object.vertex_group_fix", text="Fix Deforms")
1387         col.operator("paint.weight_gradient")
1388
1389
1390 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1391     bl_category = "Options"
1392     bl_context = "weightpaint"
1393     bl_label = "Options"
1394
1395     def draw(self, context):
1396         layout = self.layout
1397
1398         tool_settings = context.tool_settings
1399         wpaint = tool_settings.weight_paint
1400
1401         col = layout.column()
1402         row = col.row()
1403
1404         row.prop(wpaint, "use_normal")
1405         col = layout.column()
1406         row = col.row()
1407         row.prop(wpaint, "use_spray")
1408         row.prop(wpaint, "use_group_restrict")
1409
1410         obj = context.weight_paint_object
1411         if obj.type == 'MESH':
1412             mesh = obj.data
1413             col.prop(mesh, "use_mirror_x")
1414             row = col.row()
1415             row.active = mesh.use_mirror_x
1416             row.prop(mesh, "use_mirror_topology")
1417
1418         col.label("Show Zero Weights:")
1419         sub = col.row()
1420         sub.active = (not tool_settings.use_multipaint)
1421         sub.prop(tool_settings, "vertex_group_user", expand=True)
1422
1423         self.unified_paint_settings(col, context)
1424
1425 # ********** default tools for vertex-paint ****************
1426
1427
1428 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1429     bl_category = "Options"
1430     bl_context = "vertexpaint"
1431     bl_label = "Options"
1432
1433     def draw(self, context):
1434         layout = self.layout
1435
1436         toolsettings = context.tool_settings
1437         vpaint = toolsettings.vertex_paint
1438
1439         col = layout.column()
1440         row = col.row()
1441         #col.prop(vpaint, "mode", text="")
1442         row.prop(vpaint, "use_normal")
1443         col.prop(vpaint, "use_spray")
1444
1445         self.unified_paint_settings(col, context)
1446
1447 # Commented out because the Apply button isn't an operator yet, making these settings useless
1448 #~         col.label(text="Gamma:")
1449 #~         col.prop(vpaint, "gamma", text="")
1450 #~         col.label(text="Multiply:")
1451 #~         col.prop(vpaint, "mul", text="")
1452
1453 # ********** default tools for texture-paint ****************
1454
1455
1456 class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
1457     bl_category = "Options"
1458     bl_context = "imagepaint"
1459     bl_label = "Project Paint"
1460
1461     @classmethod
1462     def poll(cls, context):
1463         brush = context.tool_settings.image_paint.brush
1464         return (brush is not None)
1465
1466     def draw(self, context):
1467         layout = self.layout
1468
1469         ob = context.active_object
1470         mesh = ob.data
1471         toolsettings = context.tool_settings
1472         ipaint = toolsettings.image_paint
1473         settings = toolsettings.image_paint
1474
1475         col = layout.column()
1476         col.prop(ipaint, "use_occlude")
1477         col.prop(ipaint, "use_backface_culling")
1478
1479         row = layout.row()
1480         row.prop(ipaint, "use_normal_falloff")
1481
1482         sub = row.row()
1483         sub.active = (ipaint.use_normal_falloff)
1484         sub.prop(ipaint, "normal_angle", text="")
1485
1486         split = layout.split()
1487
1488         split.prop(ipaint, "use_stencil_layer", text="Stencil")
1489
1490         row = split.row()
1491         row.active = (ipaint.use_stencil_layer)
1492         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1493         row.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1494         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1495
1496         col = layout.column()
1497         col.active = (settings.brush.image_tool == 'CLONE')
1498         col.prop(ipaint, "use_clone_layer", text="Clone from UV map")
1499         clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
1500         col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False)
1501
1502         layout.prop(ipaint, "seam_bleed")
1503
1504         col = layout.column()
1505         col.label(text="External Editing:")
1506
1507         row = col.split(align=True, percentage=0.55)
1508         row.operator("image.project_edit", text="Quick Edit")
1509         row.operator("image.project_apply", text="Apply")
1510
1511         col.row().prop(ipaint, "screen_grab_size", text="")
1512
1513         col.operator("paint.project_image", text="Apply Camera Image")
1514         col.operator("image.save_dirty", text="Save All Edited")
1515
1516
1517 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1518     bl_category = "Options"
1519     bl_label = "Options"
1520
1521     @classmethod
1522     def poll(cls, context):
1523         return (context.image_paint_object and context.tool_settings.image_paint)
1524
1525     def draw(self, context):
1526         layout = self.layout
1527
1528         col = layout.column()
1529         self.unified_paint_settings(col, context)
1530
1531
1532 class VIEW3D_MT_tools_projectpaint_clone(Menu):
1533     bl_label = "Clone Layer"
1534
1535     def draw(self, context):
1536         layout = self.layout
1537
1538         for i, tex in enumerate(context.active_object.data.uv_textures):
1539             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1540             props.data_path = "active_object.data.uv_texture_clone_index"
1541             props.value = i
1542
1543
1544 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1545     bl_label = "Mask Layer"
1546
1547     def draw(self, context):
1548         layout = self.layout
1549         for i, tex in enumerate(context.active_object.data.uv_textures):
1550             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1551             props.data_path = "active_object.data.uv_texture_stencil_index"
1552             props.value = i
1553
1554
1555 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1556     """Default tools for particle mode"""
1557     bl_context = "particlemode"
1558     bl_label = "Options"
1559     bl_category = "Tools"
1560
1561     def draw(self, context):
1562         layout = self.layout
1563
1564         pe = context.tool_settings.particle_edit
1565         ob = pe.object
1566
1567         layout.prop(pe, "type", text="")
1568
1569         ptcache = None
1570
1571         if pe.type == 'PARTICLES':
1572             if ob.particle_systems:
1573                 if len(ob.particle_systems) > 1:
1574                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1575                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1576
1577                 ptcache = ob.particle_systems.active.point_cache
1578         else:
1579             for md in ob.modifiers:
1580                 if md.type == pe.type:
1581                     ptcache = md.point_cache
1582
1583         if ptcache and len(ptcache.point_caches) > 1:
1584             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1585                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1586
1587         if not pe.is_editable:
1588             layout.label(text="Point cache must be baked")
1589             layout.label(text="in memory to enable editing!")
1590
1591         col = layout.column(align=True)
1592         if pe.is_hair:
1593             col.active = pe.is_editable
1594             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1595             sub = col.row(align=True)
1596             sub.active = pe.use_emitter_deflect
1597             sub.prop(pe, "emitter_distance", text="Distance")
1598
1599         col = layout.column(align=True)
1600         col.active = pe.is_editable
1601         col.label(text="Keep:")
1602         col.prop(pe, "use_preserve_length", text="Lengths")
1603         col.prop(pe, "use_preserve_root", text="Root")
1604         if not pe.is_hair:
1605             col.label(text="Correct:")
1606             col.prop(pe, "use_auto_velocity", text="Velocity")
1607         col.prop(ob.data, "use_mirror_x")
1608
1609         col = layout.column(align=True)
1610         col.active = pe.is_editable
1611         col.label(text="Draw:")
1612         col.prop(pe, "draw_step", text="Path Steps")
1613         if pe.is_hair:
1614             col.prop(pe, "show_particles", text="Children")
1615         else:
1616             if pe.type == 'PARTICLES':
1617                 col.prop(pe, "show_particles", text="Particles")
1618             col.prop(pe, "use_fade_time")
1619             sub = col.row(align=True)
1620             sub.active = pe.use_fade_time
1621             sub.prop(pe, "fade_frames", slider=True)
1622
1623
1624 # Grease Pencil tools
1625 class VIEW3D_PT_tools_grease_pencil(GreasePencilPanel, Panel):
1626     bl_space_type = 'VIEW_3D'
1627     bl_region_type = 'TOOLS'
1628     bl_category = "Grease Pencil"
1629
1630
1631 if __name__ == "__main__":  # only for live edit.
1632     bpy.utils.register_module(__name__)