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