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