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