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