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