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