Merge branch 'blender2.8' into soc-2018-bevel
[blender.git] / release / scripts / startup / bl_ui / space_view3d.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 Header, Menu, Panel
22 from .properties_grease_pencil_common import (
23     GreasePencilDataPanel,
24     GreasePencilPaletteColorPanel,
25 )
26 from .properties_paint_common import UnifiedPaintPanel
27 from bpy.app.translations import contexts as i18n_contexts
28
29
30 class VIEW3D_HT_header(Header):
31     bl_space_type = 'VIEW_3D'
32
33     def draw(self, context):
34         layout = self.layout
35
36         view = context.space_data
37         shading = view.shading
38         # mode_string = context.mode
39         obj = context.active_object
40         overlay = view.overlay
41         tool_settings = context.tool_settings
42
43         row = layout.row(align=True)
44         row.template_header()
45
46         object_mode = 'OBJECT' if obj is None else obj.mode
47
48         act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode]
49         layout.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
50         del act_mode_item
51
52         layout.template_header_3D_mode()
53
54         # Contains buttons like Mode, Pivot, Layer, Mesh Select Mode...
55         shading_type = view.shading.type
56         shading_item = bpy.types.View3DShading.bl_rna.properties["type"].enum_items[shading_type]
57
58         if obj:
59             # Set above:
60             # object_mode = obj.mode
61
62             # Particle edit
63             if object_mode == 'PARTICLE_EDIT':
64                 row = layout.row()
65                 row.prop(tool_settings.particle_edit, "select_mode", text="", expand=True)
66
67             # Occlude geometry
68             if (
69                     (((shading.type not in {'SOLID', 'TEXTURED'}) or not shading.show_xray) and
70                      (object_mode == 'PARTICLE_EDIT' or (object_mode == 'EDIT' and obj.type == 'MESH'))) or
71                     (object_mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})
72             ):
73                 row = layout.row()
74                 row.prop(view, "use_occlude_geometry", text="")
75
76         # Pose
77         if obj and object_mode == 'POSE':
78             row = layout.row(align=True)
79             row.operator("pose.copy", text="", icon='COPYDOWN')
80             row.operator("pose.paste", text="", icon='PASTEDOWN').flipped = False
81             row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = True
82
83         # GPencil
84         if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
85             row = layout.row(align=True)
86             row.operator("gpencil.copy", text="", icon='COPYDOWN')
87             row.operator("gpencil.paste", text="", icon='PASTEDOWN')
88
89             # XXX: icon
90             layout.prop(context.gpencil_data, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
91
92             row = layout.row(align=True)
93             row.prop(tool_settings.gpencil_sculpt, "use_select_mask")
94             row.prop(tool_settings.gpencil_sculpt, "selection_alpha", slider=True)
95
96         VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
97
98         layout.separator_spacer()
99
100         # Mode & Transform Settings
101         scene = context.scene
102
103         # Orientation
104         if object_mode in {'OBJECT', 'EDIT', 'POSE'}:
105             orientation = scene.transform_orientation
106             current_orientation = scene.current_orientation
107
108             if not current_orientation:
109                 trans_orientation = \
110                     bpy.types.Scene.bl_rna.properties["transform_orientation"].enum_items[orientation]
111                 trans_icon = getattr(trans_orientation, "icon", "BLANK1")
112                 trans_name = getattr(trans_orientation, "name", "Orientation")
113             else:
114                 trans_icon = 'VISIBLE_IPO_OFF'
115                 trans_name = getattr(current_orientation, "name", "Orientation")
116
117             row = layout.row(align=True)
118             row.popover(
119                 panel="VIEW3D_PT_transform_orientations",
120                 text=trans_name,
121                 icon=trans_icon,
122             )
123
124         # Snap
125         show_snap = False
126         if obj is None:
127             show_snap = True
128         else:
129             if object_mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
130                 show_snap = True
131             else:
132
133                 from .properties_paint_common import UnifiedPaintPanel
134                 paint_settings = UnifiedPaintPanel.paint_settings(context)
135
136                 if paint_settings:
137                     brush = paint_settings.brush
138                     if brush and brush.stroke_method == 'CURVE':
139                         show_snap = True
140
141         if show_snap:
142             snap_items = bpy.types.ToolSettings.bl_rna.properties['snap_elements'].enum_items
143             for elem in tool_settings.snap_elements:
144                 # TODO: Display multiple icons.
145                 # (Currently only one of the enabled modes icons is displayed)
146                 icon = snap_items[elem].icon
147                 break
148             else:
149                 icon = 'NONE'
150
151             row = layout.row(align=True)
152             row.prop(tool_settings, "use_snap", text="")
153
154             sub = row.row(align=True)
155             sub.popover(
156                 panel="VIEW3D_PT_snapping",
157                 icon=icon,
158                 text="",
159             )
160
161         # Proportional editing
162         if obj:
163             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
164                 row = layout.row(align=True)
165                 row.prop(tool_settings, "proportional_edit", icon_only=True)
166
167                 sub = row.row(align=True)
168                 sub.active = tool_settings.proportional_edit != 'DISABLED'
169                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
170
171             elif object_mode in {'EDIT', 'PARTICLE_EDIT'}:
172                 row = layout.row(align=True)
173                 row.prop(tool_settings, "proportional_edit", icon_only=True)
174                 sub = row.row(align=True)
175                 sub.active = tool_settings.proportional_edit != 'DISABLED'
176                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
177
178             elif object_mode == 'OBJECT':
179                 row = layout.row(align=True)
180                 row.prop(tool_settings, "use_proportional_edit_objects", icon_only=True)
181                 sub = row.row(align=True)
182                 sub.active = tool_settings.use_proportional_edit_objects
183                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
184         else:
185             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
186                 row = layout.row(align=True)
187                 row.prop(tool_settings, "proportional_edit", icon_only=True)
188                 sub = row.row(align=True)
189                 sub.active = tool_settings.proportional_edit != 'DISABLED'
190                 sub.prop(tool_settings, "proportional_edit_falloff", icon_only=True)
191
192         # Pivot
193         if object_mode in {'OBJECT', 'EDIT', 'POSE'}:
194             pivot_point = tool_settings.transform_pivot_point
195             act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point]
196             row = layout.row(align=True)
197             row.popover(
198                 panel="VIEW3D_PT_pivot_point",
199                 icon=act_pivot_point.icon,
200                 text="",
201             )
202
203         layout.separator_spacer()
204
205         # Viewport Settings
206         layout.popover(
207             panel="VIEW3D_PT_object_type_visibility",
208             icon_value=view.icon_from_show_object_viewport,
209             text="",
210         )
211
212         row = layout.row(align=True)
213         row.prop(overlay, "show_overlays", icon='WIRE', text="")
214         sub = row.row(align=True)
215         sub.active = overlay.show_overlays
216         sub.popover(panel="VIEW3D_PT_overlay")
217
218         row = layout.row(align=True)
219         row.prop(shading, "type", text="", expand=True)
220         sub = row.row(align=True)
221         sub.enabled = shading.type != 'RENDERED'
222         sub.popover(panel="VIEW3D_PT_shading")
223
224
225 class VIEW3D_MT_editor_menus(Menu):
226     bl_space_type = 'VIEW3D_MT_editor_menus'
227     bl_label = ""
228
229     def draw(self, context):
230         self.draw_menus(self.layout, context)
231
232     @staticmethod
233     def draw_menus(layout, context):
234         obj = context.active_object
235         mode_string = context.mode
236         edit_object = context.edit_object
237         gp_edit = context.gpencil_data and context.gpencil_data.use_stroke_edit_mode
238
239         layout.menu("VIEW3D_MT_view")
240
241         # Select Menu
242         if gp_edit:
243             layout.menu("VIEW3D_MT_select_gpencil")
244         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
245             mesh = obj.data
246             if mesh.use_paint_mask:
247                 layout.menu("VIEW3D_MT_select_paint_mask")
248             elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
249                 layout.menu("VIEW3D_MT_select_paint_mask_vertex")
250         elif mode_string != 'SCULPT':
251             layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
252
253         if gp_edit:
254             pass
255         elif mode_string == 'OBJECT':
256             layout.menu("INFO_MT_add", text="Add")
257         elif mode_string == 'EDIT_MESH':
258             layout.menu("INFO_MT_mesh_add", text="Add")
259         elif mode_string == 'EDIT_CURVE':
260             layout.menu("INFO_MT_curve_add", text="Add")
261         elif mode_string == 'EDIT_SURFACE':
262             layout.menu("INFO_MT_surface_add", text="Add")
263         elif mode_string == 'EDIT_METABALL':
264             layout.menu("INFO_MT_metaball_add", text="Add")
265         elif mode_string == 'EDIT_ARMATURE':
266             layout.menu("INFO_MT_edit_armature_add", text="Add")
267
268         if gp_edit:
269             layout.menu("VIEW3D_MT_edit_gpencil")
270         elif edit_object:
271             layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
272
273             if mode_string == 'EDIT_MESH':
274                 layout.menu("VIEW3D_MT_edit_mesh_vertices")
275                 layout.menu("VIEW3D_MT_edit_mesh_edges")
276                 layout.menu("VIEW3D_MT_edit_mesh_faces")
277
278         elif obj:
279             if mode_string != 'PAINT_TEXTURE':
280                 layout.menu("VIEW3D_MT_%s" % mode_string.lower())
281             if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
282                 layout.menu("VIEW3D_MT_brush")
283             if mode_string == 'SCULPT':
284                 layout.menu("VIEW3D_MT_hide_mask")
285         else:
286             layout.menu("VIEW3D_MT_object")
287
288
289 # ********** Menu **********
290
291
292 # ********** Utilities **********
293
294
295 class ShowHideMenu:
296     bl_label = "Show/Hide"
297     _operator_name = ""
298
299     def draw(self, context):
300         layout = self.layout
301
302         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
303         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
304         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
305
306
307 # Standard transforms which apply to all cases
308 # NOTE: this doesn't seem to be able to be used directly
309 class VIEW3D_MT_transform_base(Menu):
310     bl_label = "Transform"
311
312     # TODO: get rid of the custom text strings?
313     def draw(self, context):
314         layout = self.layout
315
316         layout.operator("transform.tosphere", text="To Sphere")
317         layout.operator("transform.shear", text="Shear")
318         layout.operator("transform.bend", text="Bend")
319         layout.operator("transform.push_pull", text="Push/Pull")
320
321         if context.mode != 'OBJECT':
322             layout.operator("transform.vertex_warp", text="Warp")
323             layout.operator("transform.vertex_random", text="Randomize")
324
325
326 # Generic transform menu - geometry types
327 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
328     def draw(self, context):
329         # base menu
330         VIEW3D_MT_transform_base.draw(self, context)
331
332         # generic...
333         layout = self.layout
334         layout.operator("transform.shrink_fatten", text="Shrink Fatten")
335
336         layout.separator()
337
338         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
339         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
340
341
342 # Object-specific extensions to Transform menu
343 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
344     def draw(self, context):
345         layout = self.layout
346
347         # base menu
348         VIEW3D_MT_transform_base.draw(self, context)
349
350         # object-specific option follow...
351         layout.separator()
352
353         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
354         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
355
356         layout.separator()
357
358         layout.operator_context = 'EXEC_REGION_WIN'
359         # XXX see alignmenu() in edit.c of b2.4x to get this working
360         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'
361
362         layout.separator()
363
364         layout.operator_context = 'EXEC_AREA'
365
366         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
367         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
368         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
369         layout.operator("object.origin_set", text="Origin to Center of Mass (Surface)").type = 'ORIGIN_CENTER_OF_MASS'
370         layout.operator("object.origin_set", text="Origin to Center of Mass (Volume)").type = 'ORIGIN_CENTER_OF_VOLUME'
371         layout.separator()
372
373         layout.operator("object.randomize_transform")
374         layout.operator("object.align")
375
376         # TODO: there is a strange context bug here.
377         """
378         layout.operator_context = 'INVOKE_REGION_WIN'
379         layout.operator("object.transform_axis_target")
380         """
381
382
383 # Armature EditMode extensions to Transform menu
384 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
385     def draw(self, context):
386         layout = self.layout
387
388         # base menu
389         VIEW3D_MT_transform_base.draw(self, context)
390
391         # armature specific extensions follow...
392         obj = context.object
393         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
394             if obj.data.draw_type == 'BBONE':
395                 layout.separator()
396
397                 layout.operator("transform.transform", text="Scale BBone").mode = 'BONE_SIZE'
398             elif obj.data.draw_type == 'ENVELOPE':
399                 layout.separator()
400
401                 layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONE_SIZE'
402                 layout.operator("transform.transform", text="Scale Radius").mode = 'BONE_ENVELOPE'
403
404         if context.edit_object and context.edit_object.type == 'ARMATURE':
405             layout.separator()
406
407             layout.operator("armature.align")
408
409
410 class VIEW3D_MT_mirror(Menu):
411     bl_label = "Mirror"
412
413     def draw(self, context):
414         layout = self.layout
415
416         layout.operator("transform.mirror", text="Interactive Mirror")
417
418         layout.separator()
419
420         layout.operator_context = 'INVOKE_REGION_WIN'
421
422         props = layout.operator("transform.mirror", text="X Global")
423         props.constraint_axis = (True, False, False)
424         props.constraint_orientation = 'GLOBAL'
425         props = layout.operator("transform.mirror", text="Y Global")
426         props.constraint_axis = (False, True, False)
427         props.constraint_orientation = 'GLOBAL'
428         props = layout.operator("transform.mirror", text="Z Global")
429         props.constraint_axis = (False, False, True)
430         props.constraint_orientation = 'GLOBAL'
431
432         if context.edit_object:
433             layout.separator()
434
435             props = layout.operator("transform.mirror", text="X Local")
436             props.constraint_axis = (True, False, False)
437             props.constraint_orientation = 'LOCAL'
438             props = layout.operator("transform.mirror", text="Y Local")
439             props.constraint_axis = (False, True, False)
440             props.constraint_orientation = 'LOCAL'
441             props = layout.operator("transform.mirror", text="Z Local")
442             props.constraint_axis = (False, False, True)
443             props.constraint_orientation = 'LOCAL'
444
445             layout.operator("object.vertex_group_mirror")
446
447
448 class VIEW3D_MT_snap(Menu):
449     bl_label = "Snap"
450
451     def draw(self, context):
452         layout = self.layout
453
454         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
455         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
456         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Offset)").use_offset = True
457         layout.operator("view3d.snap_selected_to_active", text="Selection to Active")
458
459         layout.separator()
460
461         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
462         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
463         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
464         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
465
466
467 class VIEW3D_MT_uv_map(Menu):
468     bl_label = "UV Mapping"
469
470     def draw(self, context):
471         layout = self.layout
472
473         layout.operator("uv.unwrap")
474
475         layout.operator_context = 'INVOKE_DEFAULT'
476         layout.operator("uv.smart_project")
477         layout.operator("uv.lightmap_pack")
478         layout.operator("uv.follow_active_quads")
479
480         layout.separator()
481
482         layout.operator_context = 'EXEC_REGION_WIN'
483         layout.operator("uv.cube_project")
484         layout.operator("uv.cylinder_project")
485         layout.operator("uv.sphere_project")
486
487         layout.separator()
488
489         layout.operator_context = 'INVOKE_REGION_WIN'
490         layout.operator("uv.project_from_view").scale_to_bounds = False
491         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
492
493         layout.separator()
494
495         layout.operator("uv.reset")
496
497         layout.separator()
498
499         layout.operator("mesh.uvs_rotate")
500         layout.operator("mesh.uvs_reverse")
501
502
503 class VIEW3D_MT_edit_proportional(Menu):
504     bl_label = "Proportional Editing"
505
506     def draw(self, context):
507         layout = self.layout
508
509         layout.props_enum(tool_settings, "proportional_edit")
510
511         layout.separator()
512
513         layout.label("Falloff:")
514         layout.props_enum(tool_settings, "proportional_edit_falloff")
515
516
517 # ********** View menus **********
518
519
520 class VIEW3D_MT_view(Menu):
521     bl_label = "View"
522
523     def draw(self, context):
524         layout = self.layout
525         view = context.space_data
526
527         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
528         layout.operator("view3d.properties", icon='MENU_PANEL')
529
530         layout.separator()
531
532         layout.operator("view3d.view_selected", text="Frame Selected").use_all_regions = False
533         if view.region_quadviews:
534             layout.operator("view3d.view_selected", text="Frame Selected (Quad View)").use_all_regions = True
535
536         layout.operator("view3d.view_all", text="Frame All").center = False
537         layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
538
539         layout.separator()
540
541         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
542
543         layout.separator()
544         layout.menu("VIEW3D_MT_view_viewpoint")
545         layout.menu("VIEW3D_MT_view_navigation")
546         layout.menu("VIEW3D_MT_view_align")
547
548         layout.separator()
549
550         layout.operator_context = 'INVOKE_REGION_WIN'
551         layout.menu("VIEW3D_MT_view_borders", text="View Borders")
552
553         layout.separator()
554
555         layout.operator("screen.animation_play", text="Play Animation")
556
557         layout.separator()
558
559         layout.operator("render.opengl", icon='RENDER_STILL')
560         layout.operator("render.opengl", text="OpenGL Render Animation", icon='RENDER_ANIMATION').animation = True
561
562         layout.separator()
563
564         layout.menu("INFO_MT_area")
565
566
567 class VIEW3D_MT_view_cameras(Menu):
568     bl_label = "Cameras"
569
570     def draw(self, context):
571         layout = self.layout
572
573         layout.operator("view3d.object_as_camera")
574         layout.operator("view3d.view_camera", text="Active Camera")
575
576
577 class VIEW3D_MT_view_viewpoint(Menu):
578     bl_label = "Viewpoint"
579
580     def draw(self, context):
581         layout = self.layout
582
583         layout.operator("view3d.view_camera", text="Camera")
584
585         layout.separator()
586
587         layout.operator("view3d.view_axis", text="Top").type = 'TOP'
588         layout.operator("view3d.view_axis", text="Bottom").type = 'BOTTOM'
589
590         layout.separator()
591
592         layout.operator("view3d.view_axis", text="Front").type = 'FRONT'
593         layout.operator("view3d.view_axis", text="Back").type = 'BACK'
594
595         layout.separator()
596
597         layout.operator("view3d.view_axis", text="Right").type = 'RIGHT'
598         layout.operator("view3d.view_axis", text="Left").type = 'LEFT'
599
600
601 class VIEW3D_MT_view_navigation(Menu):
602     bl_label = "Navigation"
603
604     def draw(self, context):
605         from math import pi
606         layout = self.layout
607
608         layout.operator_enum("view3d.view_orbit", "type")
609         props = layout.operator("view3d.view_orbit", "Orbit Opposite")
610         props.type = 'ORBITRIGHT'
611         props.angle = pi
612
613         layout.separator()
614
615         layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
616         layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
617
618         layout.separator()
619
620         layout.operator_enum("view3d.view_pan", "type")
621
622         layout.separator()
623
624         layout.operator("view3d.zoom", text="Zoom In").delta = 1
625         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
626         layout.operator("view3d.zoom_border", text="Zoom Border...")
627         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
628
629         layout.separator()
630
631         layout.operator("view3d.fly")
632         layout.operator("view3d.walk")
633
634
635 class VIEW3D_MT_view_align(Menu):
636     bl_label = "Align View"
637
638     def draw(self, context):
639         layout = self.layout
640
641         layout.menu("VIEW3D_MT_view_align_selected")
642
643         layout.separator()
644
645         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
646         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
647
648         layout.separator()
649
650         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
651         layout.operator("view3d.view_center_cursor")
652
653         layout.separator()
654
655         layout.operator("view3d.view_lock_to_active")
656         layout.operator("view3d.view_lock_clear")
657
658
659 class VIEW3D_MT_view_align_selected(Menu):
660     bl_label = "Align View to Active"
661
662     def draw(self, context):
663         layout = self.layout
664
665         props = layout.operator("view3d.view_axis", text="Top")
666         props.align_active = True
667         props.type = 'TOP'
668
669         props = layout.operator("view3d.view_axis", text="Bottom")
670         props.align_active = True
671         props.type = 'BOTTOM'
672
673         layout.separator()
674
675         props = layout.operator("view3d.view_axis", text="Front")
676         props.align_active = True
677         props.type = 'FRONT'
678
679         props = layout.operator("view3d.view_axis", text="Back")
680         props.align_active = True
681         props.type = 'BACK'
682
683         layout.separator()
684
685         props = layout.operator("view3d.view_axis", text="Right")
686         props.align_active = True
687         props.type = 'RIGHT'
688
689         props = layout.operator("view3d.view_axis", text="Left")
690         props.align_active = True
691         props.type = 'LEFT'
692
693
694 class VIEW3D_MT_view_borders(Menu):
695     bl_label = "View Borders"
696
697     def draw(self, context):
698         layout = self.layout
699         layout.operator("view3d.clip_border", text="Clipping Border...")
700         layout.operator("view3d.render_border", text="Render Border...")
701
702         layout.separator()
703
704         layout.operator("view3d.clear_render_border")
705
706
707 # ********** Select menus, suffix from context.mode **********
708
709 class VIEW3D_MT_select_object_more_less(Menu):
710     bl_label = "Select More/Less"
711
712     def draw(self, context):
713         layout = self.layout
714
715         layout = self.layout
716
717         layout.operator("object.select_more", text="More")
718         layout.operator("object.select_less", text="Less")
719
720         layout.separator()
721
722         props = layout.operator("object.select_hierarchy", text="Parent")
723         props.extend = False
724         props.direction = 'PARENT'
725
726         props = layout.operator("object.select_hierarchy", text="Child")
727         props.extend = False
728         props.direction = 'CHILD'
729
730         layout.separator()
731
732         props = layout.operator("object.select_hierarchy", text="Extend Parent")
733         props.extend = True
734         props.direction = 'PARENT'
735
736         props = layout.operator("object.select_hierarchy", text="Extend Child")
737         props.extend = True
738         props.direction = 'CHILD'
739
740
741 class VIEW3D_MT_select_object(Menu):
742     bl_label = "Select"
743
744     def draw(self, context):
745         layout = self.layout
746
747         layout.operator("object.select_all", text="All").action = 'SELECT'
748         layout.operator("object.select_all", text="None").action = 'DESELECT'
749         layout.operator("object.select_all", text="Invert").action = 'INVERT'
750
751         layout.separator()
752
753         layout.operator("view3d.select_border")
754         layout.operator("view3d.select_circle")
755
756         layout.separator()
757
758         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
759         layout.operator("object.select_camera", text="Select Active Camera")
760         layout.operator("object.select_mirror", text="Mirror Selection")
761         layout.operator("object.select_random", text="Select Random")
762
763         layout.separator()
764
765         layout.menu("VIEW3D_MT_select_object_more_less")
766
767         layout.separator()
768
769         layout.operator_menu_enum("object.select_grouped", "type", text="Select Grouped")
770         layout.operator_menu_enum("object.select_linked", "type", text="Select Linked")
771         layout.operator("object.select_pattern", text="Select Pattern...")
772
773
774 class VIEW3D_MT_select_pose_more_less(Menu):
775     bl_label = "Select More/Less"
776
777     def draw(self, context):
778         layout = self.layout
779
780         layout = self.layout
781
782         props = layout.operator("pose.select_hierarchy", text="Parent")
783         props.extend = False
784         props.direction = 'PARENT'
785
786         props = layout.operator("pose.select_hierarchy", text="Child")
787         props.extend = False
788         props.direction = 'CHILD'
789
790         layout.separator()
791
792         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
793         props.extend = True
794         props.direction = 'PARENT'
795
796         props = layout.operator("pose.select_hierarchy", text="Extend Child")
797         props.extend = True
798         props.direction = 'CHILD'
799
800
801 class VIEW3D_MT_select_pose(Menu):
802     bl_label = "Select"
803
804     def draw(self, context):
805         layout = self.layout
806
807         layout.operator("pose.select_all", text="All").action = 'SELECT'
808         layout.operator("pose.select_all", text="None").action = 'DESELECT'
809         layout.operator("pose.select_all", text="Invert").action = 'INVERT'
810
811         layout.separator()
812
813         layout.operator("view3d.select_border")
814         layout.operator("view3d.select_circle")
815
816         layout.separator()
817
818         layout.operator("pose.select_mirror", text="Flip Active")
819
820         layout.separator()
821
822         layout.operator("pose.select_constraint_target", text="Constraint Target")
823         layout.operator("pose.select_linked", text="Linked")
824
825         layout.separator()
826
827         layout.menu("VIEW3D_MT_select_pose_more_less")
828
829         layout.separator()
830
831         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
832         layout.operator("object.select_pattern", text="Select Pattern...")
833
834
835 class VIEW3D_MT_select_particle(Menu):
836     bl_label = "Select"
837
838     def draw(self, context):
839         layout = self.layout
840
841         layout.operator("particle.select_all", text="All").action = 'SELECT'
842         layout.operator("particle.select_all", text="None").action = 'DESELECT'
843         layout.operator("particle.select_all", text="Invert").action = 'INVERT'
844
845         layout.separator()
846
847         layout.operator("view3d.select_border")
848         layout.operator("view3d.select_circle")
849
850         layout.separator()
851
852         layout.operator("particle.select_linked")
853
854         layout.separator()
855
856         layout.operator("particle.select_more")
857         layout.operator("particle.select_less")
858
859         layout.separator()
860
861         layout.operator("particle.select_random")
862
863         layout.separator()
864
865         layout.operator("particle.select_roots", text="Roots")
866         layout.operator("particle.select_tips", text="Tips")
867
868
869 class VIEW3D_MT_edit_mesh_select_similar(Menu):
870     bl_label = "Select Similar"
871
872     def draw(self, context):
873         layout = self.layout
874
875         layout.operator_enum("mesh.select_similar", "type")
876
877         layout.separator()
878
879         layout.operator("mesh.select_similar_region", text="Face Regions")
880
881
882 class VIEW3D_MT_edit_mesh_select_by_trait(Menu):
883     bl_label = "Select All by Trait"
884
885     def draw(self, context):
886         layout = self.layout
887         tool_settings = context.tool_settings
888         if tool_settings.mesh_select_mode[2] is False:
889             layout.operator("mesh.select_non_manifold", text="Non Manifold")
890         layout.operator("mesh.select_loose", text="Loose Geometry")
891         layout.operator("mesh.select_interior_faces", text="Interior Faces")
892         layout.operator("mesh.select_face_by_sides", text="Faces by Sides")
893
894         layout.separator()
895
896         layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")
897
898
899 class VIEW3D_MT_edit_mesh_select_more_less(Menu):
900     bl_label = "Select More/Less"
901
902     def draw(self, context):
903         layout = self.layout
904
905         layout.operator("mesh.select_more", text="More")
906         layout.operator("mesh.select_less", text="Less")
907
908         layout.separator()
909
910         layout.operator("mesh.select_next_item", text="Next Active")
911         layout.operator("mesh.select_prev_item", text="Previous Active")
912
913
914 class VIEW3D_MT_edit_mesh_select_linked(Menu):
915     bl_label = "Select Linked"
916
917     def draw(self, context):
918         layout = self.layout
919
920         layout.operator("mesh.select_linked", text="Linked")
921         layout.operator("mesh.shortest_path_select", text="Shortest Path")
922         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
923
924
925 class VIEW3D_MT_edit_mesh_select_loops(Menu):
926     bl_label = "Select Loops"
927
928     def draw(self, context):
929         layout = self.layout
930
931         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
932         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
933
934         layout.separator()
935
936         layout.operator("mesh.loop_to_region")
937         layout.operator("mesh.region_to_loop")
938
939
940 class VIEW3D_MT_select_edit_mesh(Menu):
941     bl_label = "Select"
942
943     def draw(self, context):
944         layout = self.layout
945
946         # primitive
947         layout.operator("mesh.select_all", text="All").action = 'SELECT'
948         layout.operator("mesh.select_all", text="None").action = 'DESELECT'
949         layout.operator("mesh.select_all", text="Invert").action = 'INVERT'
950
951         layout.separator()
952
953         layout.operator("view3d.select_border")
954         layout.operator("view3d.select_circle")
955
956         layout.separator()
957
958         # numeric
959         layout.operator("mesh.select_random", text="Select Random")
960         layout.operator("mesh.select_nth")
961
962         layout.separator()
963
964         # geometric
965         layout.operator("mesh.edges_select_sharp", text="Select Sharp Edges")
966
967         layout.separator()
968
969         # other ...
970         layout.menu("VIEW3D_MT_edit_mesh_select_similar")
971
972         layout.separator()
973
974         layout.menu("VIEW3D_MT_edit_mesh_select_by_trait")
975
976         layout.separator()
977
978         layout.menu("VIEW3D_MT_edit_mesh_select_more_less")
979
980         layout.separator()
981
982         layout.menu("VIEW3D_MT_edit_mesh_select_loops")
983
984         layout.separator()
985
986         layout.menu("VIEW3D_MT_edit_mesh_select_linked")
987
988         layout.separator()
989
990         layout.operator("mesh.select_axis", text="Side of Active")
991         layout.operator("mesh.select_mirror", text="Mirror Selection")
992
993
994 class VIEW3D_MT_select_edit_curve(Menu):
995     bl_label = "Select"
996
997     def draw(self, context):
998         layout = self.layout
999
1000         layout.operator("curve.select_all", text="All").action = 'SELECT'
1001         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1002         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1003
1004         layout.separator()
1005
1006         layout.operator("view3d.select_border")
1007         layout.operator("view3d.select_circle")
1008
1009         layout.separator()
1010
1011         layout.operator("curve.select_random")
1012         layout.operator("curve.select_nth")
1013         layout.operator("curve.select_linked", text="Select Linked")
1014         layout.operator("curve.select_similar", text="Select Similar")
1015
1016         layout.separator()
1017
1018         layout.operator("curve.de_select_first")
1019         layout.operator("curve.de_select_last")
1020         layout.operator("curve.select_next")
1021         layout.operator("curve.select_previous")
1022
1023         layout.separator()
1024
1025         layout.operator("curve.select_more")
1026         layout.operator("curve.select_less")
1027
1028
1029 class VIEW3D_MT_select_edit_surface(Menu):
1030     bl_label = "Select"
1031
1032     def draw(self, context):
1033         layout = self.layout
1034
1035         layout.operator("curve.select_all", text="All").action = 'SELECT'
1036         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1037         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1038
1039         layout.separator()
1040
1041         layout.operator("view3d.select_border")
1042         layout.operator("view3d.select_circle")
1043
1044         layout.separator()
1045
1046         layout.operator("curve.select_random")
1047         layout.operator("curve.select_nth")
1048         layout.operator("curve.select_linked", text="Select Linked")
1049         layout.operator("curve.select_similar", text="Select Similar")
1050
1051         layout.separator()
1052
1053         layout.operator("curve.select_row")
1054
1055         layout.separator()
1056
1057         layout.operator("curve.select_more")
1058         layout.operator("curve.select_less")
1059
1060
1061 class VIEW3D_MT_select_edit_text(Menu):
1062     # intentional name mis-match
1063     # select menu for 3d-text doesn't make sense
1064     bl_label = "Edit"
1065
1066     def draw(self, context):
1067         layout = self.layout
1068
1069         layout.operator("font.text_paste", text="Paste")
1070         layout.operator("font.text_cut", text="Cut")
1071         layout.operator("font.text_copy", text="Copy")
1072
1073         layout.separator()
1074
1075         layout.operator("font.text_paste_from_file")
1076
1077         layout.separator()
1078
1079         layout.operator("font.select_all")
1080
1081
1082 class VIEW3D_MT_select_edit_metaball(Menu):
1083     bl_label = "Select"
1084
1085     def draw(self, context):
1086         layout = self.layout
1087
1088         layout.operator("mball.select_all", text="All").action = 'SELECT'
1089         layout.operator("mball.select_all", text="None").action = 'DESELECT'
1090         layout.operator("mball.select_all", text="Invert").action = 'INVERT'
1091
1092         layout.separator()
1093
1094         layout.operator("view3d.select_border")
1095         layout.operator("view3d.select_circle")
1096
1097         layout.separator()
1098
1099         layout.operator("mball.select_random_metaelems")
1100
1101         layout.separator()
1102
1103         layout.operator_menu_enum("mball.select_similar", "type", text="Similar")
1104
1105
1106 class VIEW3D_MT_select_edit_lattice(Menu):
1107     bl_label = "Select"
1108
1109     def draw(self, context):
1110         layout = self.layout
1111
1112         layout.operator("lattice.select_all", text="All").action = 'SELECT'
1113         layout.operator("lattice.select_all", text="None").action = 'DESELECT'
1114         layout.operator("lattice.select_all", text="Invert").action = 'INVERT'
1115
1116         layout.separator()
1117
1118         layout.operator("view3d.select_border")
1119         layout.operator("view3d.select_circle")
1120
1121         layout.separator()
1122
1123         layout.operator("lattice.select_mirror")
1124         layout.operator("lattice.select_random")
1125
1126         layout.separator()
1127
1128         layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")
1129
1130
1131 class VIEW3D_MT_select_edit_armature(Menu):
1132     bl_label = "Select"
1133
1134     def draw(self, context):
1135         layout = self.layout
1136
1137         layout.operator("armature.select_all", text="All").action = 'SELECT'
1138         layout.operator("armature.select_all", text="None").action = 'DESELECT'
1139         layout.operator("armature.select_all", text="Invert").action = 'INVERT'
1140
1141         layout.separator()
1142
1143         layout.operator("view3d.select_border")
1144         layout.operator("view3d.select_circle")
1145
1146         layout.separator()
1147
1148         layout.operator("armature.select_mirror", text="Mirror").extend = False
1149
1150         layout.separator()
1151
1152         layout.operator("armature.select_more", text="More")
1153         layout.operator("armature.select_less", text="Less")
1154
1155         layout.separator()
1156
1157         props = layout.operator("armature.select_hierarchy", text="Parent")
1158         props.extend = False
1159         props.direction = 'PARENT'
1160
1161         props = layout.operator("armature.select_hierarchy", text="Child")
1162         props.extend = False
1163         props.direction = 'CHILD'
1164
1165         layout.separator()
1166
1167         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
1168         props.extend = True
1169         props.direction = 'PARENT'
1170
1171         props = layout.operator("armature.select_hierarchy", text="Extend Child")
1172         props.extend = True
1173         props.direction = 'CHILD'
1174
1175         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
1176         layout.operator("object.select_pattern", text="Select Pattern...")
1177
1178
1179 class VIEW3D_MT_select_gpencil(Menu):
1180     bl_label = "Select"
1181
1182     def draw(self, context):
1183         layout = self.layout
1184
1185         layout.operator("gpencil.select_all", text="All").action = 'SELECT'
1186         layout.operator("gpencil.select_all", text="None").action = 'DESELECT'
1187         layout.operator("gpencil.select_all", text="Invert").action = 'INVERT'
1188
1189         layout.separator()
1190
1191         layout.operator("gpencil.select_border")
1192         layout.operator("gpencil.select_circle")
1193
1194         layout.separator()
1195
1196         layout.operator("gpencil.select_linked", text="Linked")
1197         layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
1198
1199         layout.separator()
1200
1201         layout.operator("gpencil.select_first")
1202         layout.operator("gpencil.select_last")
1203
1204         layout.separator()
1205
1206         layout.operator("gpencil.select_more")
1207         layout.operator("gpencil.select_less")
1208
1209
1210 class VIEW3D_MT_select_paint_mask(Menu):
1211     bl_label = "Select"
1212
1213     def draw(self, context):
1214         layout = self.layout
1215
1216         layout.operator("paint.face_select_all", text="All").action = 'SELECT'
1217         layout.operator("paint.face_select_all", text="None").action = 'DESELECT'
1218         layout.operator("paint.face_select_all", text="Invert").action = 'INVERT'
1219
1220         layout.separator()
1221
1222         layout.operator("view3d.select_border")
1223         layout.operator("view3d.select_circle")
1224
1225         layout.separator()
1226
1227         layout.operator("paint.face_select_linked", text="Linked")
1228
1229
1230 class VIEW3D_MT_select_paint_mask_vertex(Menu):
1231     bl_label = "Select"
1232
1233     def draw(self, context):
1234         layout = self.layout
1235
1236         layout.operator("paint.vert_select_all", text="All").action = 'SELECT'
1237         layout.operator("paint.vert_select_all", text="None").action = 'DESELECT'
1238         layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT'
1239
1240         layout.separator()
1241
1242         layout.operator("view3d.select_border")
1243         layout.operator("view3d.select_circle")
1244
1245         layout.separator()
1246
1247         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
1248
1249
1250 class VIEW3D_MT_angle_control(Menu):
1251     bl_label = "Angle Control"
1252
1253     @classmethod
1254     def poll(cls, context):
1255         settings = UnifiedPaintPanel.paint_settings(context)
1256         if not settings:
1257             return False
1258
1259         brush = settings.brush
1260         tex_slot = brush.texture_slot
1261
1262         return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
1263
1264     def draw(self, context):
1265         layout = self.layout
1266
1267         settings = UnifiedPaintPanel.paint_settings(context)
1268         brush = settings.brush
1269
1270         sculpt = (context.sculpt_object is not None)
1271
1272         tex_slot = brush.texture_slot
1273
1274         layout.prop(tex_slot, "use_rake", text="Rake")
1275
1276         if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
1277             if sculpt:
1278                 if brush.sculpt_capabilities.has_random_texture_angle:
1279                     layout.prop(tex_slot, "use_random", text="Random")
1280             else:
1281                 layout.prop(tex_slot, "use_random", text="Random")
1282
1283
1284 # XXX: INFO_MT_ names used to keep backwards compatibility (Add-ons etc. that hook into the menu)
1285 class INFO_MT_mesh_add(Menu):
1286     bl_idname = "INFO_MT_mesh_add"
1287     bl_label = "Mesh"
1288
1289     def draw(self, context):
1290         layout = self.layout
1291
1292         layout.operator_context = 'INVOKE_REGION_WIN'
1293
1294         layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
1295         layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
1296         layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
1297         layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
1298         layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
1299         layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
1300         layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
1301         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
1302
1303         layout.separator()
1304
1305         layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
1306         layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
1307
1308
1309 class INFO_MT_curve_add(Menu):
1310     bl_idname = "INFO_MT_curve_add"
1311     bl_label = "Curve"
1312
1313     def draw(self, context):
1314         layout = self.layout
1315
1316         layout.operator_context = 'INVOKE_REGION_WIN'
1317
1318         layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
1319         layout.operator("curve.primitive_bezier_circle_add", text="Circle", icon='CURVE_BEZCIRCLE')
1320
1321         layout.separator()
1322
1323         layout.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon='CURVE_NCURVE')
1324         layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
1325         layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
1326
1327         layout.separator()
1328
1329         layout.operator("curve.draw", icon='LINE_DATA')
1330
1331
1332 class INFO_MT_surface_add(Menu):
1333     bl_idname = "INFO_MT_surface_add"
1334     bl_label = "Surface"
1335
1336     def draw(self, context):
1337         layout = self.layout
1338
1339         layout.operator_context = 'INVOKE_REGION_WIN'
1340
1341         layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
1342         layout.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon='SURFACE_NCIRCLE')
1343         layout.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon='SURFACE_NSURFACE')
1344         layout.operator("surface.primitive_nurbs_surface_cylinder_add",
1345                         text="Nurbs Cylinder", icon='SURFACE_NCYLINDER')
1346         layout.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon='SURFACE_NSPHERE')
1347         layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS')
1348
1349
1350 class INFO_MT_metaball_add(Menu):
1351     bl_idname = "INFO_MT_metaball_add"
1352     bl_label = "Metaball"
1353
1354     def draw(self, context):
1355         layout = self.layout
1356
1357         layout.operator_context = 'INVOKE_REGION_WIN'
1358         layout.operator_enum("object.metaball_add", "type")
1359
1360
1361 class INFO_MT_edit_curve_add(Menu):
1362     bl_idname = "INFO_MT_edit_curve_add"
1363     bl_label = "Add"
1364
1365     def draw(self, context):
1366         is_surf = context.active_object.type == 'SURFACE'
1367
1368         layout = self.layout
1369         layout.operator_context = 'EXEC_REGION_WIN'
1370
1371         if is_surf:
1372             INFO_MT_surface_add.draw(self, context)
1373         else:
1374             INFO_MT_curve_add.draw(self, context)
1375
1376
1377 class INFO_MT_edit_armature_add(Menu):
1378     bl_idname = "INFO_MT_edit_armature_add"
1379     bl_label = "Armature"
1380
1381     def draw(self, context):
1382         layout = self.layout
1383
1384         layout.operator_context = 'EXEC_REGION_WIN'
1385         layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA')
1386
1387
1388 class INFO_MT_armature_add(Menu):
1389     bl_idname = "INFO_MT_armature_add"
1390     bl_label = "Armature"
1391
1392     def draw(self, context):
1393         layout = self.layout
1394
1395         layout.operator_context = 'EXEC_REGION_WIN'
1396         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
1397
1398
1399 class INFO_MT_light_add(Menu):
1400     bl_idname = "INFO_MT_light_add"
1401     bl_label = "Light"
1402
1403     def draw(self, context):
1404         layout = self.layout
1405
1406         layout.operator_context = 'INVOKE_REGION_WIN'
1407         layout.operator_enum("object.light_add", "type")
1408
1409
1410 class INFO_MT_lightprobe_add(Menu):
1411     bl_idname = "INFO_MT_lightprobe_add"
1412     bl_label = "Light Probe"
1413
1414     def draw(self, context):
1415         layout = self.layout
1416
1417         layout.operator_context = 'INVOKE_REGION_WIN'
1418         layout.operator_enum("object.lightprobe_add", "type")
1419
1420
1421 class INFO_MT_camera_add(Menu):
1422     bl_idname = "INFO_MT_camera_add"
1423     bl_label = "Camera"
1424
1425     def draw(self, context):
1426         layout = self.layout
1427         layout.operator_context = 'EXEC_REGION_WIN'
1428         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
1429
1430
1431 class INFO_MT_add(Menu):
1432     bl_label = "Add"
1433
1434     def draw(self, context):
1435         layout = self.layout
1436
1437         # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
1438
1439         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
1440         #       "align_view" to work on first call (see [#32719]).
1441         layout.operator_context = 'EXEC_REGION_WIN'
1442
1443         # layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
1444         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
1445
1446         # layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
1447         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
1448         # layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
1449         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
1450         layout.menu("INFO_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
1451         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
1452         layout.separator()
1453
1454         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
1455         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
1456         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
1457         layout.separator()
1458
1459         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
1460         layout.separator()
1461
1462         if INFO_MT_camera_add.is_extended():
1463             layout.menu("INFO_MT_camera_add", icon='OUTLINER_OB_CAMERA')
1464         else:
1465             INFO_MT_camera_add.draw(self, context)
1466
1467         layout.menu("INFO_MT_light_add", icon='OUTLINER_OB_LIGHT')
1468         layout.separator()
1469         layout.menu("INFO_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE')
1470         layout.separator()
1471
1472         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_FORCE_FIELD')
1473         layout.separator()
1474
1475         has_collections = bool(bpy.data.collections)
1476         col = layout.column()
1477         col.enabled = has_collections
1478
1479         if not has_collections or len(bpy.data.collections) > 10:
1480             col.operator_context = 'INVOKE_REGION_WIN'
1481             col.operator(
1482                 "object.collection_instance_add",
1483                 text="Collection Instance..." if has_collections else "No Collections to Instance",
1484                 icon='OUTLINER_OB_GROUP_INSTANCE',
1485             )
1486         else:
1487             col.operator_menu_enum(
1488                 "object.collection_instance_add",
1489                 "collection",
1490                 text="Collection Instance",
1491                 icon='OUTLINER_OB_GROUP_INSTANCE',
1492             )
1493
1494
1495 class VIEW3D_MT_object_relations(Menu):
1496     bl_label = "Relations"
1497
1498     def draw(self, context):
1499         layout = self.layout
1500
1501         layout.operator("object.proxy_make", text="Make Proxy...")
1502
1503         layout.operator("object.make_dupli_face")
1504
1505         layout.separator()
1506
1507         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
1508         layout.menu("VIEW3D_MT_make_single_user")
1509
1510         layout.separator()
1511
1512         layout.operator("object.data_transfer")
1513         layout.operator("object.datalayout_transfer")
1514
1515
1516 class VIEW3D_MT_object(Menu):
1517     bl_context = "objectmode"
1518     bl_label = "Object"
1519
1520     def draw(self, context):
1521         layout = self.layout
1522
1523         layout.menu("VIEW3D_MT_transform_object")
1524         layout.menu("VIEW3D_MT_mirror")
1525         layout.menu("VIEW3D_MT_object_clear")
1526         layout.menu("VIEW3D_MT_object_apply")
1527         layout.menu("VIEW3D_MT_snap")
1528
1529         layout.separator()
1530
1531         layout.operator("object.duplicate_move")
1532         layout.operator("object.duplicate_move_linked")
1533         layout.operator("object.join")
1534
1535         layout.separator()
1536
1537         layout.operator("view3d.copybuffer", text="Copy Objects")
1538         layout.operator("view3d.pastebuffer", text="Paste Objects")
1539
1540         layout.separator()
1541
1542         layout.menu("VIEW3D_MT_object_parent")
1543         layout.menu("VIEW3D_MT_object_collection")
1544         layout.menu("VIEW3D_MT_object_relations")
1545         layout.menu("VIEW3D_MT_object_constraints")
1546         layout.menu("VIEW3D_MT_object_track")
1547         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
1548
1549         layout.separator()
1550
1551         layout.operator("object.shade_smooth")
1552         layout.operator("object.shade_flat")
1553
1554         layout.separator()
1555
1556         layout.menu("VIEW3D_MT_object_animation")
1557         layout.menu("VIEW3D_MT_object_rigid_body")
1558
1559         layout.separator()
1560
1561         layout.menu("VIEW3D_MT_object_quick_effects")
1562
1563         layout.separator()
1564
1565         layout.operator_menu_enum("object.convert", "target")
1566
1567         layout.separator()
1568
1569         layout.menu("VIEW3D_MT_object_showhide")
1570
1571         layout.separator()
1572
1573         layout.operator("object.delete", text="Delete...").use_global = False
1574
1575
1576 class VIEW3D_MT_object_animation(Menu):
1577     bl_label = "Animation"
1578
1579     def draw(self, context):
1580         layout = self.layout
1581
1582         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1583         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
1584         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
1585         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1586
1587         layout.separator()
1588
1589         layout.operator("nla.bake", text="Bake Action...")
1590
1591
1592 class VIEW3D_MT_object_rigid_body(Menu):
1593     bl_label = "Rigid Body"
1594
1595     def draw(self, context):
1596         layout = self.layout
1597
1598         layout.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
1599         layout.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
1600
1601         layout.separator()
1602
1603         layout.operator("rigidbody.objects_remove", text="Remove")
1604
1605         layout.separator()
1606
1607         layout.operator("rigidbody.shape_change", text="Change Shape")
1608         layout.operator("rigidbody.mass_calculate", text="Calculate Mass")
1609         layout.operator("rigidbody.object_settings_copy", text="Copy from Active")
1610         layout.operator("object.visual_transform_apply", text="Apply Transformation")
1611         layout.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
1612
1613         layout.separator()
1614
1615         layout.operator("rigidbody.connect", text="Connect")
1616
1617
1618 class VIEW3D_MT_object_clear(Menu):
1619     bl_label = "Clear"
1620
1621     def draw(self, context):
1622         layout = self.layout
1623
1624         layout.operator("object.location_clear", text="Location").clear_delta = False
1625         layout.operator("object.rotation_clear", text="Rotation").clear_delta = False
1626         layout.operator("object.scale_clear", text="Scale").clear_delta = False
1627
1628         layout.separator()
1629
1630         layout.operator("object.origin_clear", text="Origin")
1631
1632
1633 class VIEW3D_MT_object_specials(Menu):
1634     bl_label = "Object Context Menu"
1635
1636     @classmethod
1637     def poll(cls, context):
1638         # add more special types
1639         return context.object
1640
1641     def draw(self, context):
1642         layout = self.layout
1643
1644         scene = context.scene
1645         obj = context.object
1646
1647         layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
1648         layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
1649
1650         layout.separator()
1651
1652         layout.operator("object.duplicate_move")
1653         layout.operator("object.duplicate_move_linked")
1654
1655         layout.separator()
1656
1657         layout.menu("VIEW3D_MT_snap")
1658         layout.menu("VIEW3D_MT_object_parent")
1659         layout.operator_context = 'INVOKE_REGION_WIN'
1660         layout.operator("object.move_to_collection")
1661
1662         layout.separator()
1663
1664         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1665
1666         layout.separator()
1667
1668         layout.operator("object.delete", text="Delete...").use_global = False
1669
1670         if obj.type == 'MESH':
1671
1672             layout.separator()
1673
1674             layout.operator("object.shade_smooth", text="Smooth Shading")
1675             layout.operator("object.shade_flat", text="Flat Shading")
1676
1677             layout.separator()
1678
1679             layout.operator("object.origin_set")
1680             layout.operator("object.join")
1681             layout.operator_menu_enum("object.convert", "target")
1682
1683         if obj.type == 'CAMERA':
1684             layout.operator_context = 'INVOKE_REGION_WIN'
1685
1686             if obj.data.type == 'PERSP':
1687                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1688                 props.data_path_iter = "selected_editable_objects"
1689                 props.data_path_item = "data.lens"
1690                 props.input_scale = 0.1
1691                 if obj.data.lens_unit == 'MILLIMETERS':
1692                     props.header_text = "Camera Lens Angle: %.1fmm"
1693                 else:
1694                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1695
1696             else:
1697                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1698                 props.data_path_iter = "selected_editable_objects"
1699                 props.data_path_item = "data.ortho_scale"
1700                 props.input_scale = 0.01
1701                 props.header_text = "Camera Lens Scale: %.3f"
1702
1703             if not obj.data.dof_object:
1704                 view = context.space_data
1705                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1706                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1707                 else:
1708                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1709                     props.data_path_iter = "selected_editable_objects"
1710                     props.data_path_item = "data.dof_distance"
1711                     props.input_scale = 0.02
1712                     props.header_text = "DOF Distance: %.3f"
1713                 del view
1714
1715         if obj.type in {'CURVE', 'FONT'}:
1716             layout.operator_context = 'INVOKE_REGION_WIN'
1717
1718             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1719             props.data_path_iter = "selected_editable_objects"
1720             props.data_path_item = "data.extrude"
1721             props.input_scale = 0.01
1722             props.header_text = "Extrude Size: %.3f"
1723
1724             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1725             props.data_path_iter = "selected_editable_objects"
1726             props.data_path_item = "data.offset"
1727             props.input_scale = 0.01
1728             props.header_text = "Width Size: %.3f"
1729
1730         if obj.type == 'EMPTY':
1731             layout.operator_context = 'INVOKE_REGION_WIN'
1732
1733             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
1734             props.data_path_iter = "selected_editable_objects"
1735             props.data_path_item = "empty_draw_size"
1736             props.input_scale = 0.01
1737             props.header_text = "Empty Draw Size: %.3f"
1738
1739         if obj.type == 'LIGHT':
1740             light = obj.data
1741
1742             layout.operator_context = 'INVOKE_REGION_WIN'
1743
1744             emission_node = None
1745             if light.node_tree:
1746                 for node in light.node_tree.nodes:
1747                     if getattr(node, "type", None) == 'EMISSION':
1748                         emission_node = node
1749                         break
1750
1751             if emission_node is not None:
1752                 props = layout.operator("wm.context_modal_mouse", text="Strength")
1753                 props.data_path_iter = "selected_editable_objects"
1754                 props.data_path_item = "data.node_tree" \
1755                                        ".nodes[\"" + emission_node.name + "\"]" \
1756                                        ".inputs[\"Strength\"].default_value"
1757                 props.header_text = "Light Strength: %.3f"
1758                 props.input_scale = 0.1
1759
1760             if light.type == 'AREA':
1761                 props = layout.operator("wm.context_modal_mouse", text="Size X")
1762                 props.data_path_iter = "selected_editable_objects"
1763                 props.data_path_item = "data.size"
1764                 props.header_text = "Light Size X: %.3f"
1765
1766                 if light.shape in {'RECTANGLE', 'ELLIPSE'}:
1767                     props = layout.operator("wm.context_modal_mouse", text="Size Y")
1768                     props.data_path_iter = "selected_editable_objects"
1769                     props.data_path_item = "data.size_y"
1770                     props.header_text = "Light Size Y: %.3f"
1771
1772             elif light.type in {'SPOT', 'POINT', 'SUN'}:
1773                 props = layout.operator("wm.context_modal_mouse", text="Size")
1774                 props.data_path_iter = "selected_editable_objects"
1775                 props.data_path_item = "data.shadow_soft_size"
1776                 props.header_text = "Light Size: %.3f"
1777
1778             if light.type == 'SPOT':
1779                 layout.separator()
1780                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
1781                 props.data_path_iter = "selected_editable_objects"
1782                 props.data_path_item = "data.spot_size"
1783                 props.input_scale = 0.01
1784                 props.header_text = "Spot Size: %.2f"
1785
1786                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
1787                 props.data_path_iter = "selected_editable_objects"
1788                 props.data_path_item = "data.spot_blend"
1789                 props.input_scale = -0.01
1790                 props.header_text = "Spot Blend: %.2f"
1791
1792
1793 class VIEW3D_MT_object_shading(Menu):
1794     # XXX, this menu is a place to store shading operator in object mode
1795     bl_label = "Shading"
1796
1797     def draw(self, context):
1798         layout = self.layout
1799         layout.operator("object.shade_smooth", text="Smooth")
1800         layout.operator("object.shade_flat", text="Flat")
1801
1802
1803 class VIEW3D_MT_object_apply(Menu):
1804     bl_label = "Apply"
1805
1806     def draw(self, context):
1807         layout = self.layout
1808
1809         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1810         props.location, props.rotation, props.scale = True, False, False
1811
1812         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1813         props.location, props.rotation, props.scale = False, True, False
1814
1815         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1816         props.location, props.rotation, props.scale = False, False, True
1817         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1818         props.location, props.rotation, props.scale = False, True, True
1819
1820         layout.separator()
1821
1822         layout.operator(
1823             "object.transforms_to_deltas",
1824             text="Location to Deltas",
1825             text_ctxt=i18n_contexts.default,
1826         ).mode = 'LOC'
1827         layout.operator(
1828             "object.transforms_to_deltas",
1829             text="Rotation to Deltas",
1830             text_ctxt=i18n_contexts.default,
1831         ).mode = 'ROT'
1832         layout.operator(
1833             "object.transforms_to_deltas",
1834             text="Scale to Deltas",
1835             text_ctxt=i18n_contexts.default,
1836         ).mode = 'SCALE'
1837
1838         layout.operator(
1839             "object.transforms_to_deltas",
1840             text="All Transforms to Deltas",
1841             text_ctxt=i18n_contexts.default,
1842         ).mode = 'ALL'
1843         layout.operator("object.anim_transforms_to_deltas")
1844
1845         layout.separator()
1846
1847         layout.operator(
1848             "object.visual_transform_apply",
1849             text="Visual Transform",
1850             text_ctxt=i18n_contexts.default,
1851         )
1852         layout.operator(
1853             "object.convert",
1854             text="Visual Geometry to Mesh",
1855             text_ctxt=i18n_contexts.default,
1856         ).target = 'MESH'
1857         layout.operator("object.duplicates_make_real")
1858
1859
1860 class VIEW3D_MT_object_parent(Menu):
1861     bl_label = "Parent"
1862
1863     def draw(self, context):
1864         layout = self.layout
1865
1866         layout.operator_enum("object.parent_set", "type")
1867
1868         layout.separator()
1869
1870         layout.operator_enum("object.parent_clear", "type")
1871
1872
1873 class VIEW3D_MT_object_track(Menu):
1874     bl_label = "Track"
1875
1876     def draw(self, context):
1877         layout = self.layout
1878
1879         layout.operator_enum("object.track_set", "type")
1880
1881         layout.separator()
1882
1883         layout.operator_enum("object.track_clear", "type")
1884
1885
1886 class VIEW3D_MT_object_collection(Menu):
1887     bl_label = "Collection"
1888
1889     def draw(self, context):
1890         layout = self.layout
1891
1892         layout.operator("collection.create")
1893         # layout.operator_menu_enum("collection.objects_remove", "collection")  # BUGGY
1894         layout.operator("collection.objects_remove")
1895         layout.operator("collection.objects_remove_all")
1896
1897         layout.separator()
1898
1899         layout.operator("collection.objects_add_active")
1900         layout.operator("collection.objects_remove_active")
1901
1902
1903 class VIEW3D_MT_object_constraints(Menu):
1904     bl_label = "Constraints"
1905
1906     def draw(self, context):
1907         layout = self.layout
1908
1909         layout.operator("object.constraint_add_with_targets")
1910         layout.operator("object.constraints_copy")
1911
1912         layout.separator()
1913
1914         layout.operator("object.constraints_clear")
1915
1916
1917 class VIEW3D_MT_object_quick_effects(Menu):
1918     bl_label = "Quick Effects"
1919
1920     def draw(self, context):
1921         layout = self.layout
1922
1923         layout.operator("object.quick_fur")
1924         layout.operator("object.quick_explode")
1925         layout.operator("object.quick_smoke")
1926         layout.operator("object.quick_fluid")
1927
1928
1929 class VIEW3D_MT_object_showhide(Menu):
1930     bl_label = "Show/Hide"
1931
1932     def draw(self, context):
1933         layout = self.layout
1934
1935         layout.operator("object.hide_view_clear", text="Show Hidden")
1936
1937         layout.separator()
1938
1939         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1940         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1941
1942
1943 class VIEW3D_MT_make_single_user(Menu):
1944     bl_label = "Make Single User"
1945
1946     def draw(self, context):
1947         layout = self.layout
1948
1949         props = layout.operator("object.make_single_user", text="Object")
1950         props.object = True
1951         props.obdata = props.material = props.animation = False
1952
1953         props = layout.operator("object.make_single_user", text="Object & Data")
1954         props.object = props.obdata = True
1955         props.material = props.animation = False
1956
1957         props = layout.operator("object.make_single_user", text="Object & Data & Materials")
1958         props.object = props.obdata = props.material = True
1959         props.animation = False
1960
1961         props = layout.operator("object.make_single_user", text="Materials")
1962         props.material = True
1963         props.object = props.obdata = props.animation = False
1964
1965         props = layout.operator("object.make_single_user", text="Object Animation")
1966         props.animation = True
1967         props.object = props.obdata = props.material = False
1968
1969
1970 class VIEW3D_MT_make_links(Menu):
1971     bl_label = "Make Links"
1972
1973     def draw(self, context):
1974         layout = self.layout
1975         operator_context_default = layout.operator_context
1976
1977         if len(bpy.data.scenes) > 10:
1978             layout.operator_context = 'INVOKE_REGION_WIN'
1979             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1980         else:
1981             layout.operator_context = 'EXEC_REGION_WIN'
1982             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene")
1983
1984         layout.separator()
1985
1986         layout.operator_context = operator_context_default
1987
1988         layout.operator_enum("object.make_links_data", "type")  # inline
1989
1990         layout.operator("object.join_uvs")  # stupid place to add this!
1991
1992
1993 class VIEW3D_MT_brush(Menu):
1994     bl_label = "Brush"
1995
1996     def draw(self, context):
1997         layout = self.layout
1998
1999         tool_settings = context.tool_settings
2000         settings = UnifiedPaintPanel.paint_settings(context)
2001         brush = getattr(settings, "brush", None)
2002
2003         ups = tool_settings.unified_paint_settings
2004         layout.prop(ups, "use_unified_size", text="Unified Size")
2005         layout.prop(ups, "use_unified_strength", text="Unified Strength")
2006         if context.image_paint_object or context.vertex_paint_object:
2007             layout.prop(ups, "use_unified_color", text="Unified Color")
2008         layout.separator()
2009
2010         # skip if no active brush
2011         if not brush:
2012             layout.label(text="No Brushes currently available", icon='INFO')
2013             return
2014
2015         # brush paint modes
2016         layout.menu("VIEW3D_MT_brush_paint_modes")
2017
2018         # brush tool
2019         if context.sculpt_object:
2020             layout.operator("brush.reset")
2021             layout.prop_menu_enum(brush, "sculpt_tool")
2022         elif context.image_paint_object:
2023             layout.prop_menu_enum(brush, "image_tool")
2024         elif context.vertex_paint_object or context.weight_paint_object:
2025             layout.prop_menu_enum(brush, "vertex_tool")
2026
2027         # TODO: still missing a lot of brush options here
2028
2029         # sculpt options
2030         if context.sculpt_object:
2031
2032             sculpt_tool = brush.sculpt_tool
2033
2034             layout.separator()
2035             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
2036             layout.separator()
2037
2038             if sculpt_tool != 'GRAB':
2039                 layout.prop_menu_enum(brush, "stroke_method")
2040
2041                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
2042                     layout.prop_menu_enum(brush, "direction")
2043
2044                 if sculpt_tool == 'LAYER':
2045                     layout.prop(brush, "use_persistent")
2046                     layout.operator("sculpt.set_persistent_base")
2047
2048
2049 class VIEW3D_MT_brush_paint_modes(Menu):
2050     bl_label = "Enabled Modes"
2051
2052     def draw(self, context):
2053         layout = self.layout
2054
2055         settings = UnifiedPaintPanel.paint_settings(context)
2056         brush = settings.brush
2057
2058         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
2059         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
2060         layout.prop(brush, "use_paint_weight", text="Weight Paint")
2061         layout.prop(brush, "use_paint_image", text="Texture Paint")
2062
2063
2064 class VIEW3D_MT_paint_vertex(Menu):
2065     bl_label = "Paint"
2066
2067     def draw(self, context):
2068         layout = self.layout
2069
2070         layout.operator("paint.vertex_color_set")
2071         layout.operator("paint.vertex_color_smooth")
2072         layout.operator("paint.vertex_color_dirt")
2073         layout.operator("paint.vertex_color_from_weight")
2074
2075         layout.separator()
2076
2077         layout.operator("paint.vertex_color_invert", text="Invert")
2078         layout.operator("paint.vertex_color_levels", text="Levels")
2079         layout.operator("paint.vertex_color_hsv", text="Hue Saturation Value")
2080         layout.operator("paint.vertex_color_brightness_contrast", text="Bright/Contrast")
2081
2082
2083 class VIEW3D_MT_hook(Menu):
2084     bl_label = "Hooks"
2085
2086     def draw(self, context):
2087         layout = self.layout
2088         layout.operator_context = 'EXEC_AREA'
2089         layout.operator("object.hook_add_newob")
2090         layout.operator("object.hook_add_selob").use_bone = False
2091         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
2092
2093         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
2094             layout.separator()
2095
2096             layout.operator_menu_enum("object.hook_assign", "modifier")
2097             layout.operator_menu_enum("object.hook_remove", "modifier")
2098
2099             layout.separator()
2100
2101             layout.operator_menu_enum("object.hook_select", "modifier")
2102             layout.operator_menu_enum("object.hook_reset", "modifier")
2103             layout.operator_menu_enum("object.hook_recenter", "modifier")
2104
2105
2106 class VIEW3D_MT_vertex_group(Menu):
2107     bl_label = "Vertex Groups"
2108
2109     def draw(self, context):
2110         layout = self.layout
2111
2112         layout.operator_context = 'EXEC_AREA'
2113         layout.operator("object.vertex_group_assign_new")
2114
2115         ob = context.active_object
2116         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
2117             if ob.vertex_groups.active:
2118                 layout.separator()
2119
2120                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
2121                 layout.operator(
2122                     "object.vertex_group_remove_from",
2123                     text="Remove from Active Group",
2124                 ).use_all_groups = False
2125                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
2126
2127         if ob.vertex_groups.active:
2128             layout.separator()
2129
2130             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
2131             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
2132             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
2133
2134
2135 class VIEW3D_MT_paint_weight(Menu):
2136     bl_label = "Weights"
2137
2138     @staticmethod
2139     def draw_generic(layout, is_editmode=False):
2140
2141         if not is_editmode:
2142
2143             layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
2144             layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
2145
2146             layout.separator()
2147
2148         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
2149         layout.operator("object.vertex_group_normalize", text="Normalize")
2150
2151         layout.separator()
2152
2153         layout.operator("object.vertex_group_mirror", text="Mirror")
2154         layout.operator("object.vertex_group_invert", text="Invert")
2155         layout.operator("object.vertex_group_clean", text="Clean")
2156
2157         layout.separator()
2158
2159         layout.operator("object.vertex_group_quantize", text="Quantize")
2160         layout.operator("object.vertex_group_levels", text="Levels")
2161         layout.operator("object.vertex_group_smooth", text="Smooth")
2162
2163         if not is_editmode:
2164             props = layout.operator("object.data_transfer", text="Transfer Weights")
2165             props.use_reverse_transfer = True
2166             props.data_type = 'VGROUP_WEIGHTS'
2167
2168         layout.operator("object.vertex_group_limit_total", text="Limit Total")
2169         layout.operator("object.vertex_group_fix", text="Fix Deforms")
2170
2171         if not is_editmode:
2172             layout.separator()
2173
2174             layout.operator("paint.weight_set")
2175
2176     def draw(self, context):
2177         self.draw_generic(self.layout, is_editmode=False)
2178
2179
2180 class VIEW3D_MT_sculpt(Menu):
2181     bl_label = "Sculpt"
2182
2183     def draw(self, context):
2184         layout = self.layout
2185
2186         tool_settings = context.tool_settings
2187         sculpt = tool_settings.sculpt
2188
2189         layout.prop(sculpt, "use_symmetry_x")
2190         layout.prop(sculpt, "use_symmetry_y")
2191         layout.prop(sculpt, "use_symmetry_z")
2192
2193         layout.separator()
2194
2195         layout.prop(sculpt, "lock_x")
2196         layout.prop(sculpt, "lock_y")
2197         layout.prop(sculpt, "lock_z")
2198
2199         layout.separator()
2200
2201         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
2202         layout.prop(sculpt, "show_low_resolution")
2203         layout.prop(sculpt, "show_brush")
2204         layout.prop(sculpt, "use_deform_only")
2205         layout.prop(sculpt, "show_diffuse_color")
2206         layout.prop(sculpt, "show_mask")
2207
2208
2209 class VIEW3D_MT_hide_mask(Menu):
2210     bl_label = "Hide/Mask"
2211
2212     def draw(self, context):
2213         layout = self.layout
2214
2215         props = layout.operator("paint.hide_show", text="Show All")
2216         props.action = 'SHOW'
2217         props.area = 'ALL'
2218
2219         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
2220         props.action = 'HIDE'
2221         props.area = 'INSIDE'
2222
2223         props = layout.operator("paint.hide_show", text="Show Bounding Box")
2224         props.action = 'SHOW'
2225         props.area = 'INSIDE'
2226
2227         props = layout.operator("paint.hide_show", text="Hide Masked")
2228         props.area = 'MASKED'
2229         props.action = 'HIDE'
2230
2231         layout.separator()
2232
2233         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
2234         props.mode = 'INVERT'
2235
2236         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
2237         props.mode = 'VALUE'
2238         props.value = 1
2239
2240         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
2241         props.mode = 'VALUE'
2242         props.value = 0
2243
2244         props = layout.operator("view3d.select_border", text="Box Mask")
2245         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
2246
2247
2248 class VIEW3D_MT_particle(Menu):
2249     bl_label = "Particle"
2250
2251     def draw(self, context):
2252         layout = self.layout
2253         tool_settings = context.tool_settings
2254
2255         particle_edit = tool_settings.particle_edit
2256
2257         layout.operator("particle.mirror")
2258
2259         layout.operator("particle.remove_doubles")
2260
2261         layout.separator()
2262
2263         if particle_edit.select_mode == 'POINT':
2264             layout.operator("particle.subdivide")
2265
2266         layout.operator("particle.unify_length")
2267         layout.operator("particle.rekey")
2268         layout.operator("particle.weight_set")
2269
2270         layout.separator()
2271
2272         layout.menu("VIEW3D_MT_particle_showhide")
2273
2274         layout.separator()
2275
2276         layout.operator("particle.delete")
2277
2278
2279 class VIEW3D_MT_particle_specials(Menu):
2280     bl_label = "Particle Context Menu"
2281
2282     def draw(self, context):
2283         layout = self.layout
2284         tool_settings = context.tool_settings
2285
2286         particle_edit = tool_settings.particle_edit
2287
2288         layout.operator("particle.rekey")
2289
2290         layout.separator()
2291
2292         layout.operator("particle.delete")
2293
2294         layout.separator()
2295
2296         layout.operator("particle.remove_doubles")
2297         layout.operator("particle.unify_length")
2298
2299         if particle_edit.select_mode == 'POINT':
2300             layout.operator("particle.subdivide")
2301
2302         layout.operator("particle.weight_set")
2303
2304         layout.separator()
2305
2306         layout.operator("particle.mirror")
2307
2308         if particle_edit.select_mode == 'POINT':
2309             layout.separator()
2310
2311             layout.operator("particle.select_all", text="All").action = 'SELECT'
2312             layout.operator("particle.select_all", text="None").action = 'DESELECT'
2313             layout.operator("particle.select_all", text="Invert").action = 'INVERT'
2314
2315             layout.separator()
2316
2317             layout.operator("particle.select_roots")
2318             layout.operator("particle.select_tips")
2319
2320             layout.separator()
2321
2322             layout.operator("particle.select_random")
2323
2324             layout.separator()
2325
2326             layout.operator("particle.select_more")
2327             layout.operator("particle.select_less")
2328
2329             layout.separator()
2330
2331             layout.operator("particle.select_linked")
2332
2333
2334 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
2335     _operator_name = "particle"
2336
2337
2338 class VIEW3D_MT_pose(Menu):
2339     bl_label = "Pose"
2340
2341     def draw(self, context):
2342         layout = self.layout
2343
2344         layout.menu("VIEW3D_MT_transform_armature")
2345
2346         layout.menu("VIEW3D_MT_pose_transform")
2347         layout.menu("VIEW3D_MT_pose_apply")
2348
2349         layout.menu("VIEW3D_MT_snap")
2350
2351         layout.separator()
2352
2353         layout.menu("VIEW3D_MT_object_animation")
2354
2355         layout.separator()
2356
2357         layout.menu("VIEW3D_MT_pose_slide")
2358         layout.menu("VIEW3D_MT_pose_propagate")
2359
2360         layout.separator()
2361
2362         layout.operator("pose.copy")
2363         layout.operator("pose.paste").flipped = False
2364         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
2365
2366         layout.separator()
2367
2368         layout.menu("VIEW3D_MT_pose_library")
2369         layout.menu("VIEW3D_MT_pose_motion")
2370         layout.menu("VIEW3D_MT_pose_group")
2371
2372         layout.separator()
2373
2374         layout.menu("VIEW3D_MT_object_parent")
2375         layout.menu("VIEW3D_MT_pose_ik")
2376         layout.menu("VIEW3D_MT_pose_constraints")
2377
2378         layout.separator()
2379
2380         layout.operator_context = 'EXEC_AREA'
2381         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
2382         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
2383         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
2384
2385         layout.operator("pose.flip_names")
2386
2387         layout.operator("pose.quaternions_flip")
2388
2389         layout.separator()
2390
2391         layout.operator_context = 'INVOKE_AREA'
2392         layout.operator("armature.armature_layers", text="Change Armature Layers...")
2393         layout.operator("pose.bone_layers", text="Change Bone Layers...")
2394
2395         layout.separator()
2396
2397         layout.menu("VIEW3D_MT_pose_showhide")
2398         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2399
2400
2401 class VIEW3D_MT_pose_transform(Menu):
2402     bl_label = "Clear Transform"
2403
2404     def draw(self, context):
2405         layout = self.layout
2406
2407         layout.operator("pose.transforms_clear", text="All")
2408
2409         layout.separator()
2410
2411         layout.operator("pose.loc_clear", text="Location")
2412         layout.operator("pose.rot_clear", text="Rotation")
2413         layout.operator("pose.scale_clear", text="Scale")
2414
2415         layout.separator()
2416
2417         layout.operator("pose.user_transforms_clear", text="Reset Unkeyed")
2418
2419
2420 class VIEW3D_MT_pose_slide(Menu):
2421     bl_label = "In-Betweens"
2422
2423     def draw(self, context):
2424         layout = self.layout
2425
2426         layout.operator("pose.push")
2427         layout.operator("pose.relax")
2428         layout.operator("pose.breakdown")
2429
2430
2431 class VIEW3D_MT_pose_propagate(Menu):
2432     bl_label = "Propagate"
2433
2434     def draw(self, context):
2435         layout = self.layout
2436
2437         layout.operator("pose.propagate").mode = 'WHILE_HELD'
2438
2439         layout.separator()
2440
2441         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
2442         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
2443
2444         layout.separator()
2445
2446         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
2447
2448         layout.separator()
2449
2450         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
2451
2452
2453 class VIEW3D_MT_pose_library(Menu):
2454     bl_label = "Pose Library"
2455
2456     def draw(self, context):
2457         layout = self.layout
2458
2459         layout.operator("poselib.browse_interactive", text="Browse Poses...")
2460
2461         layout.separator()
2462
2463         layout.operator("poselib.pose_add", text="Add Pose...")
2464         layout.operator("poselib.pose_rename", text="Rename Pose...")
2465         layout.operator("poselib.pose_remove", text="Remove Pose...")
2466
2467
2468 class VIEW3D_MT_pose_motion(Menu):
2469     bl_label = "Motion Paths"
2470
2471     def draw(self, context):
2472         layout = self.layout
2473
2474         layout.operator("pose.paths_calculate", text="Calculate")
2475         layout.operator("pose.paths_clear", text="Clear")
2476
2477
2478 class VIEW3D_MT_pose_group(Menu):
2479     bl_label = "Bone Groups"
2480
2481     def draw(self, context):
2482         layout = self.layout
2483
2484         pose = context.active_object.pose
2485
2486         layout.operator_context = 'EXEC_AREA'
2487         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
2488
2489         if pose.bone_groups:
2490             active_group = pose.bone_groups.active_index + 1
2491             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
2492
2493             layout.separator()
2494
2495             # layout.operator_context = 'INVOKE_AREA'
2496             layout.operator("pose.group_unassign")
2497             layout.operator("pose.group_remove")
2498
2499
2500 class VIEW3D_MT_pose_ik(Menu):
2501     bl_label = "Inverse Kinematics"
2502
2503     def draw(self, context):
2504         layout = self.layout
2505
2506         layout.operator("pose.ik_add")
2507         layout.operator("pose.ik_clear")
2508
2509
2510 class VIEW3D_MT_pose_constraints(Menu):
2511     bl_label = "Constraints"
2512
2513     def draw(self, context):
2514         layout = self.layout
2515
2516         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
2517         layout.operator("pose.constraints_copy")
2518         layout.operator("pose.constraints_clear")
2519
2520
2521 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
2522     _operator_name = "pose"
2523
2524
2525 class VIEW3D_MT_pose_apply(Menu):
2526     bl_label = "Apply"
2527
2528     def draw(self, context):
2529         layout = self.layout
2530
2531         layout.operator("pose.armature_apply")
2532         layout.operator("pose.visual_transform_apply")
2533
2534
2535 class VIEW3D_MT_pose_specials(Menu):
2536     bl_label = "Pose Context Menu"
2537
2538     def draw(self, context):
2539         layout = self.layout
2540
2541         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
2542
2543         layout.separator()
2544
2545         layout.operator("pose.copy")
2546         layout.operator("pose.paste").flipped = False
2547         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
2548
2549         layout.separator()
2550
2551         layout.operator("pose.select_constraint_target")
2552
2553         layout.separator()
2554
2555         layout.operator("pose.paths_calculate", text="Calculate")
2556         layout.operator("pose.paths_clear", text="Clear")
2557
2558         layout.separator()
2559
2560         layout.operator("pose.paths_calculate")
2561         layout.operator("pose.paths_clear")
2562
2563         layout.separator()
2564
2565         layout.operator("pose.hide").unselected = False
2566         layout.operator("pose.reveal")
2567
2568         layout.separator()
2569
2570         layout.operator("pose.user_transforms_clear")
2571
2572
2573 class BoneOptions:
2574     def draw(self, context):
2575         layout = self.layout
2576
2577         options = [
2578             "show_wire",
2579             "use_deform",
2580             "use_envelope_multiply",
2581             "use_inherit_rotation",
2582             "use_inherit_scale",
2583         ]
2584
2585         if context.mode == 'EDIT_ARMATURE':
2586             bone_props = bpy.types.EditBone.bl_rna.properties
2587             data_path_iter = "selected_bones"
2588             opt_suffix = ""
2589             options.append("lock")
2590         else:  # pose-mode
2591             bone_props = bpy.types.Bone.bl_rna.properties
2592             data_path_iter = "selected_pose_bones"
2593             opt_suffix = "bone."
2594
2595         for opt in options:
2596             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
2597                                     text_ctxt=i18n_contexts.default)
2598             props.data_path_iter = data_path_iter
2599             props.data_path_item = opt_suffix + opt
2600             props.type = self.type
2601
2602
2603 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
2604     bl_label = "Toggle Bone Options"
2605     type = 'TOGGLE'
2606
2607
2608 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
2609     bl_label = "Enable Bone Options"
2610     type = 'ENABLE'
2611
2612
2613 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
2614     bl_label = "Disable Bone Options"
2615     type = 'DISABLE'
2616
2617
2618 # ********** Edit Menus, suffix from ob.type **********
2619
2620
2621 class VIEW3D_MT_edit_mesh(Menu):
2622     bl_label = "Mesh"
2623
2624     def draw(self, context):
2625         layout = self.layout
2626         tool_settings = context.tool_settings
2627
2628         with_bullet = bpy.app.build_options.bullet
2629
2630         layout.menu("VIEW3D_MT_transform")
2631         layout.menu("VIEW3D_MT_mirror")
2632         layout.menu("VIEW3D_MT_snap")
2633
2634         layout.separator()
2635
2636         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
2637
2638         layout.separator()
2639
2640         layout.operator("mesh.duplicate_move", text="Duplicate")
2641         layout.menu("VIEW3D_MT_edit_mesh_extrude")
2642         layout.operator("mesh.split")
2643         layout.operator("mesh.bisect")
2644
2645         if with_bullet:
2646             layout.operator("mesh.convex_hull")
2647
2648         layout.separator()
2649
2650         layout.operator("mesh.symmetrize")
2651         layout.operator("mesh.symmetry_snap")
2652
2653         layout.separator()
2654
2655         layout.menu("VIEW3D_MT_edit_mesh_normals")
2656         layout.menu("VIEW3D_MT_edit_mesh_shading")
2657         layout.menu("VIEW3D_MT_edit_mesh_weights")
2658         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
2659
2660         layout.separator()
2661
2662         layout.menu("VIEW3D_MT_edit_mesh_showhide")
2663         layout.operator_menu_enum("mesh.separate", "type")
2664         layout.menu("VIEW3D_MT_edit_mesh_clean")
2665
2666         layout.separator()
2667
2668         layout.menu("VIEW3D_MT_edit_mesh_delete")
2669
2670
2671 class VIEW3D_MT_edit_mesh_specials(Menu):
2672     bl_label = "Mesh Context Menu"
2673
2674     def draw(self, context):
2675         layout = self.layout
2676
2677         select_mode = context.tool_settings.mesh_select_mode
2678
2679         layout.operator_context = 'INVOKE_REGION_WIN'
2680
2681         layout.operator("mesh.subdivide", text="Subdivide")
2682
2683         layout.separator()
2684
2685         layout.operator("mesh.duplicate_move", text="Duplicate")
2686
2687         # Vertex Select Commands
2688         if select_mode[0]:
2689             layout.separator()
2690
2691             layout.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
2692             layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2693             layout.operator("mesh.vert_connect", text="Connect Vertex Pairs")
2694
2695             layout.separator()
2696
2697             layout.operator("mesh.vertices_smooth", text="Smooth")
2698             layout.operator("mesh.vertices_smooth_laplacian", text="Smooth Laplacian")
2699
2700             layout.separator()
2701             layout.operator("mesh.merge", text="Merge Vertices...")
2702             layout.operator("mesh.remove_doubles", text="Remove Double Vertices")
2703             layout.operator("mesh.dissolve_verts")
2704             layout.operator("mesh.delete", text="Delete Vertices").type = 'VERT'
2705
2706         # Edge Select Commands
2707         if select_mode[1]:
2708             layout.separator()
2709
2710             layout.operator("mesh.bridge_edge_loops", text="Bridge Edge Loops")
2711
2712             layout.separator()
2713
2714             layout.operator("mesh.dissolve_edges")
2715             layout.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
2716
2717         # Face Select Commands
2718         if select_mode[2]:
2719             layout.separator()
2720
2721             layout.operator("mesh.faces_shade_smooth")
2722             layout.operator("mesh.faces_shade_flat")
2723
2724             layout.separator()
2725
2726             layout.operator("mesh.bridge_edge_loops", text="Bridge Faces")
2727
2728             layout.separator()
2729
2730             layout.operator("mesh.poke")
2731
2732             layout.separator()
2733
2734             props = layout.operator("mesh.quads_convert_to_tris")
2735             props.quad_method = props.ngon_method = 'BEAUTY'
2736             layout.operator("mesh.tris_convert_to_quads")
2737
2738             layout.separator()
2739
2740             layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap Faces...")
2741
2742             layout.separator()
2743
2744             layout.operator("mesh.dissolve_faces")
2745             layout.operator("mesh.delete", text="Delete Faces").type = 'FACE'
2746
2747         # General Mesh Commands
2748
2749         layout.separator()
2750
2751         layout.menu("VIEW3D_MT_snap", text="Snap...")
2752         layout.operator("transform.mirror", text="Mirror")
2753         layout.operator("mesh.symmetrize")
2754         layout.operator("mesh.symmetry_snap")
2755
2756         layout.separator()
2757
2758         layout.operator("mesh.hide", text="Hide").unselected = False
2759         layout.operator("mesh.reveal", text="Reveal")
2760
2761
2762 class VIEW3D_MT_edit_mesh_select_mode(Menu):
2763     bl_label = "Mesh Select Mode"
2764
2765     def draw(self, context):
2766         layout = self.layout
2767
2768         layout.operator_context = 'INVOKE_REGION_WIN'
2769         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
2770         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
2771         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
2772
2773
2774 class VIEW3D_MT_edit_mesh_extrude(Menu):
2775     bl_label = "Extrude"
2776
2777     _extrude_funcs = {
2778         'VERT': lambda layout:
2779             layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
2780         'EDGE': lambda layout:
2781             layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
2782         'REGION': lambda layout:
2783             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
2784         'REGION_VERT_NORMAL': lambda layout:
2785             layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
2786         'FACE': lambda layout:
2787             layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
2788     }
2789
2790     @staticmethod
2791     def extrude_options(context):
2792         tool_settings = context.tool_settings
2793         select_mode = tool_settings.mesh_select_mode
2794         mesh = context.object.data
2795
2796         menu = []
2797         if mesh.total_face_sel:
2798             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
2799         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
2800             menu += ['EDGE']
2801         if mesh.total_vert_sel and select_mode[0]:
2802             menu += ['VERT']
2803
2804         # should never get here
2805         return menu
2806
2807     def draw(self, context):
2808         layout = self.layout
2809         layout.operator_context = 'INVOKE_REGION_WIN'
2810
2811         for menu_id in self.extrude_options(context):
2812             self._extrude_funcs[menu_id](layout)
2813
2814
2815 class VIEW3D_MT_edit_mesh_vertices(Menu):
2816     bl_label = "Vertex"
2817
2818     def draw(self, context):
2819         layout = self.layout
2820         layout.operator_context = 'INVOKE_REGION_WIN'
2821
2822         layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
2823         layout.operator("mesh.bevel", text="Bevel Vertices").vertex_only = True
2824
2825         layout.separator()
2826
2827         layout.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
2828         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2829         layout.operator("mesh.vert_connect", text="Connect Vertex Pairs")
2830
2831         layout.separator()
2832
2833         props = layout.operator("mesh.rip_move", text="Rip Vertices")
2834         props.MESH_OT_rip.use_fill = False
2835         props = layout.operator("mesh.rip_move", text="Rip Vertices and Fill")
2836         props.MESH_OT_rip.use_fill = True
2837         layout.operator("mesh.rip_edge_move", text="Rip Vertices and Extend")
2838
2839         layout.separator()
2840
2841         layout.operator("transform.vert_slide", text="Slide Vertices")
2842         layout.operator("mesh.vertices_smooth", text="Smooth Vertices")
2843
2844         layout.separator()
2845
2846         layout.operator("mesh.blend_from_shape")
2847         layout.operator("mesh.shape_propagate_to_all", text="Propagate to Shapes")
2848
2849         layout.separator()
2850
2851         layout.operator("mesh.merge", text="Merge Vertices")
2852         layout.operator("mesh.remove_doubles", text="Remove Double Vertices")
2853
2854         layout.separator()
2855
2856         layout.menu("VIEW3D_MT_vertex_group")
2857         layout.menu("VIEW3D_MT_hook")
2858
2859         layout.separator()
2860
2861         layout.operator("object.vertex_parent_set")
2862
2863
2864 class VIEW3D_MT_edit_mesh_edges_data(Menu):
2865     bl_label = "Edge Data"
2866
2867     def draw(self, context):
2868         layout = self.layout
2869
2870         with_freestyle = bpy.app.build_options.freestyle
2871
2872         layout.operator_context = 'INVOKE_REGION_WIN'
2873
2874         layout.operator("transform.edge_crease")
2875         layout.operator("transform.edge_bevelweight")
2876
2877         layout.separator()
2878
2879         layout.operator("mesh.mark_seam").clear = False
2880         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
2881
2882         layout.separator()
2883
2884         layout.operator("mesh.mark_sharp")
2885         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
2886
2887         layout.operator("mesh.mark_sharp", text="Mark Sharp from Vertices").use_verts = True
2888         props = layout.operator("mesh.mark_sharp", text="Clear Sharp from Vertices")
2889         props.use_verts = True
2890         props.clear = True
2891
2892         if with_freestyle:
2893             layout.separator()
2894
2895             layout.operator("mesh.mark_freestyle_edge").clear = False
2896             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
2897
2898
2899 class VIEW3D_MT_edit_mesh_edges(Menu):
2900     bl_label = "Edge"
2901
2902     def draw(self, context):
2903         layout = self.layout
2904
2905         layout.operator_context = 'INVOKE_REGION_WIN'
2906
2907         layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
2908         layout.operator("mesh.bevel", text="Bevel Edges").vertex_only = False
2909         layout.operator("mesh.bridge_edge_loops")
2910
2911         layout.separator()
2912
2913         layout.operator("mesh.subdivide")
2914         layout.operator("mesh.subdivide_edgering")
2915         layout.operator("mesh.unsubdivide")
2916
2917         layout.separator()
2918
2919         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2920         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
2921
2922         layout.separator()
2923
2924         layout.operator("transform.edge_slide")
2925         layout.operator("mesh.edge_split")
2926
2927         layout.separator()
2928
2929         layout.menu("VIEW3D_MT_edit_mesh_edges_data")
2930
2931
2932 class VIEW3D_MT_edit_mesh_faces_data(Menu):
2933     bl_label = "Face Data"
2934
2935     def draw(self, context):
2936         layout = self.layout
2937
2938         with_freestyle = bpy.app.build_options.freestyle
2939
2940         layout.operator_context = 'INVOKE_REGION_WIN'
2941
2942         layout.operator("mesh.colors_rotate")
2943         layout.operator("mesh.colors_reverse")
2944
2945         layout.separator()
2946
2947         layout.operator("mesh.uvs_rotate")
2948         layout.operator("mesh.uvs_reverse")
2949
2950         layout.separator()
2951
2952         if with_freestyle:
2953             layout.operator("mesh.mark_freestyle_face").clear = False
2954             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
2955
2956
2957 class VIEW3D_MT_edit_mesh_faces(Menu):
2958     bl_label = "Face"
2959     bl_idname = "VIEW3D_MT_edit_mesh_faces"
2960
2961     def draw(self, context):
2962         layout = self.layout
2963
2964         with_freestyle = bpy.app.build_options.freestyle
2965
2966         layout.operator_context = 'INVOKE_REGION_WIN'
2967
2968         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
2969         layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
2970         layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
2971
2972         layout.separator()
2973
2974         layout.operator("mesh.inset")
2975         layout.operator("mesh.poke")
2976         props = layout.operator("mesh.quads_convert_to_tris")
2977         props.quad_method = props.ngon_method = 'BEAUTY'
2978         layout.operator("mesh.tris_convert_to_quads")
2979         layout.operator("mesh.solidify", text="Solidify Faces")
2980         layout.operator("mesh.wireframe")
2981
2982         layout.separator()
2983
2984         layout.operator("mesh.fill")
2985         layout.operator("mesh.fill_grid")
2986         layout.operator("mesh.beautify_fill")
2987
2988         layout.separator()
2989
2990         layout.operator("mesh.intersect")
2991         layout.operator("mesh.intersect_boolean")
2992
2993         layout.separator()
2994
2995         layout.operator("mesh.face_split_by_edges")
2996
2997         layout.separator()
2998
2999         layout.operator("mesh.faces_shade_smooth")
3000         layout.operator("mesh.faces_shade_flat")
3001
3002         layout.separator()
3003
3004         layout.menu("VIEW3D_MT_edit_mesh_faces_data")
3005
3006
3007 class VIEW3D_MT_edit_mesh_normals(Menu):
3008     bl_label = "Normals"
3009
3010     def draw(self, context):
3011         layout = self.layout
3012
3013         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
3014         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
3015
3016         layout.separator()
3017
3018         layout.operator("mesh.flip_normals")
3019         layout.operator("mesh.set_normals_from_faces", text="Set From Faces")
3020
3021         layout.operator("transform.rotate_normal", text="Rotate Normal")
3022         layout.operator("mesh.point_normals", text="Point normals to target")
3023
3024         layout.operator("mesh.merge_normals", text="Merge")
3025         layout.operator("mesh.split_normals", text="Split")
3026
3027         layout.operator("mesh.average_normals", text="Average Normals")
3028
3029         layout.label(text="Normal Vector")
3030
3031         layout.operator("mesh.normals_tools", text="Copy").mode = 'COPY'
3032         layout.operator("mesh.normals_tools", text="Paste").mode = 'PASTE'
3033
3034         layout.operator("mesh.normals_tools", text="Multiply").mode = 'MULTIPLY'
3035         layout.operator("mesh.normals_tools", text="Add").mode = 'ADD'
3036
3037         layout.operator("mesh.normals_tools", text="Reset").mode = 'RESET'
3038
3039         layout.operator("mesh.smoothen_normals", text="Smoothen")
3040
3041         layout.label(text="Face Strength")
3042         layout.operator("mesh.mod_weighted_strength", text="Face select", icon = "FACESEL").set = False
3043         layout.operator("mesh.mod_weighted_strength", text="Set Strength", icon = "ZOOMIN").set = True
3044
3045
3046 class VIEW3D_MT_edit_mesh_shading(Menu):
3047     bl_label = "Shading"
3048
3049     def draw(self, context):
3050         layout = self.layout
3051
3052         layout.operator("mesh.faces_shade_smooth", text="Smooth Faces")
3053         layout.operator("mesh.faces_shade_flat", text="Flat Faces")
3054
3055         layout.separator()
3056
3057         layout.operator("mesh.mark_sharp", text="Smooth Edges").clear = True
3058         layout.operator("mesh.mark_sharp", text="Sharp Edges")
3059
3060         layout.separator()
3061
3062         props = layout.operator("mesh.mark_sharp", text="Smooth Vertices")
3063         props.use_verts = True
3064         props.clear = True
3065
3066         layout.operator("mesh.mark_sharp", text="Sharp Vertices").use_verts = True
3067
3068
3069 class VIEW3D_MT_edit_mesh_weights(Menu):
3070     bl_label = "Weights"
3071
3072     def draw(self, context):
3073         VIEW3D_MT_paint_weight.draw_generic(self.layout, is_editmode=True)
3074
3075
3076 class VIEW3D_MT_edit_mesh_clean(Menu):
3077     bl_label = "Clean Up"
3078
3079     def draw(self, context):
3080         layout = self.layout
3081
3082         layout.operator("mesh.delete_loose")
3083
3084         layout.separator()
3085
3086         layout.operator("mesh.decimate")
3087         layout.operator("mesh.dissolve_degenerate")
3088         layout.operator("mesh.dissolve_limited")
3089         layout.operator("mesh.face_make_planar")
3090
3091         layout.separator()
3092
3093         layout.operator("mesh.vert_connect_nonplanar")
3094         layout.operator("mesh.vert_connect_concave")
3095         layout.operator("mesh.remove_doubles")
3096         layout.operator("mesh.fill_holes")
3097
3098
3099 class VIEW3D_MT_edit_mesh_delete(Menu):
3100     bl_label = "Delete"
3101
3102     def draw(self, context):
3103         layout = self.layout
3104
3105         layout.operator_enum("mesh.delete", "type")
3106
3107         layout.separator()
3108
3109         layout.operator("mesh.dissolve_verts")
3110         layout.operator("mesh.dissolve_edges")
3111         layout.operator("mesh.dissolve_faces")
3112
3113         layout.separator()
3114
3115         layout.operator("mesh.dissolve_limited")
3116
3117         layout.separator()
3118
3119         layout.operator("mesh.edge_collapse")
3120         layout.operator("mesh.delete_edgeloop", text="Edge Loops")
3121
3122
3123 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
3124     _operator_name = "mesh"
3125
3126
3127 class VIEW3D_MT_edit_gpencil_delete(Menu):
3128     bl_label = "Delete"
3129
3130     def draw(self, context):
3131         layout = self.layout
3132
3133         layout.operator_enum("gpencil.delete", "type")
3134
3135         layout.separator()
3136
3137         layout.operator("gpencil.dissolve")
3138
3139         layout.separator()
3140
3141         layout.operator("gpencil.active_frames_delete_all")
3142
3143
3144 # Edit Curve
3145 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
3146
3147
3148 def draw_curve(self, context):
3149     layout = self.layout
3150
3151     layout.menu("VIEW3D_MT_transform")
3152     layout.menu("VIEW3D_MT_mirror")
3153     layout.menu("VIEW3D_MT_snap")
3154
3155     layout.separator()
3156
3157     layout.operator("curve.extrude_move")
3158     layout.operator("curve.spin")
3159     layout.operator("curve.duplicate_move")
3160
3161     layout.separator()
3162
3163     layout.operator("curve.split")
3164     layout.operator("curve.separate")
3165     layout.operator("curve.make_segment")
3166     layout.operator("curve.cyclic_toggle")
3167
3168     layout.separator()
3169
3170     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
3171     layout.menu("VIEW3D_MT_edit_curve_segments")
3172
3173     layout.separator()
3174
3175     layout.menu("VIEW3D_MT_edit_curve_showhide")
3176     layout.menu("VIEW3D_MT_edit_curve_clean")
3177     layout.menu("VIEW3D_MT_edit_curve_delete")
3178
3179
3180 class VIEW3D_MT_edit_curve(Menu):
3181     bl_label = "Curve"
3182
3183     draw = draw_curve
3184
3185
3186 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
3187     bl_label = "Control Points"
3188
3189     def draw(self, context):
3190         layout = self.layout
3191
3192         edit_object = context.edit_object
3193
3194         if edit_object.type == 'CURVE':
3195             layout.operator("transform.tilt")
3196             layout.operator("curve.tilt_clear")
3197
3198             layout.separator()
3199
3200             layout.operator_menu_enum("curve.handle_type_set", "type")
3201             layout.operator("curve.normals_make_consistent")
3202
3203             layout.separator()
3204
3205         layout.menu("VIEW3D_MT_hook")
3206
3207         layout.separator()
3208
3209         layout.operator("object.vertex_parent_set")
3210
3211
3212 class VIEW3D_MT_edit_curve_segments(Menu):
3213     bl_label = "Segments"
3214
3215     def draw(self, context):
3216         layout = self.layout
3217
3218         layout.operator("curve.subdivide")
3219         layout.operator("curve.switch_direction")
3220
3221
3222 class VIEW3D_MT_edit_curve_clean(Menu):
3223     bl_label = "Clean Up"
3224
3225     def draw(self, context):
3226         layout = self.layout
3227
3228         layout.operator("curve.decimate")
3229
3230
3231 class VIEW3D_MT_edit_curve_specials(Menu):
3232     bl_label = "Curve Context Menu"
3233
3234     def draw(self, context):
3235         layout = self.layout
3236
3237         layout.operator("curve.subdivide")
3238         layout.operator("curve.switch_direction")
3239         layout.operator("curve.spline_weight_set")
3240         layout.operator("curve.radius_set")
3241
3242         layout.separator()
3243
3244         layout.operator("curve.smooth")
3245         layout.operator("curve.smooth_weight")
3246         layout.operator("curve.smooth_radius")
3247         layout.operator("curve.smooth_tilt")
3248
3249
3250 class VIEW3D_MT_edit_curve_delete(Menu):
3251     bl_label = "Delete"
3252
3253     def draw(self, context):
3254         layout = self.layout
3255
3256         layout.operator_enum("curve.delete", "type")
3257
3258         layout.separator()
3259
3260         layout.operator("curve.dissolve_verts")
3261
3262
3263 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
3264     _operator_name = "curve"
3265
3266
3267 class VIEW3D_MT_edit_surface(Menu):
3268     bl_label = "Surface"
3269
3270     draw = draw_curve
3271
3272
3273 class VIEW3D_MT_edit_font(Menu):
3274     bl_label = "Text"
3275
3276     def draw(self, context):
3277         layout = self.layout
3278
3279         layout.menu("VIEW3D_MT_edit_text_chars")
3280
3281         layout.separator()
3282
3283         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
3284         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
3285
3286         layout.separator()
3287
3288         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
3289         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
3290
3291
3292 class VIEW3D_MT_edit_text_chars(Menu):
3293     bl_label = "Special Characters"
3294
3295     def draw(self, context):
3296         layout = self.layout
3297
3298         layout.operator("font.text_insert", text="Copyright").text = "\u00A9"
3299         layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE"
3300
3301         layout.separator()
3302
3303         layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0"
3304         layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7"
3305         layout.operator("font.text_insert", text="Circle").text = "\u008A"
3306
3307         layout.separator()
3308
3309         layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9"
3310         layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2"
3311         layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3"
3312
3313         layout.separator()
3314
3315         layout.operator("font.text_insert", text="Double >>").text = "\u00BB"
3316         layout.operator("font.text_insert", text="Double <<").text = "\u00AB"
3317         layout.operator("font.text_insert", text="Promillage").text = "\u2030"
3318
3319         layout.separator()
3320
3321         layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4"
3322         layout.operator("font.text_insert", text="British Pound").text = "\u00A3"
3323         layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5"
3324
3325         layout.separator()
3326
3327         layout.operator("font.text_insert", text="German S").text = "\u00DF"
3328         layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF"
3329         layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1"
3330
3331
3332 class VIEW3D_MT_edit_meta(Menu):
3333     bl_label = "Metaball"
3334
3335     def draw(self, context):
3336         layout = self.layout
3337
3338         layout.menu("VIEW3D_MT_transform")
3339         layout.menu("VIEW3D_MT_mirror")
3340         layout.menu("VIEW3D_MT_snap")
3341
3342         layout.separator()
3343
3344         layout.operator("mball.duplicate_metaelems")
3345
3346         layout.separator()
3347
3348         layout.menu("VIEW3D_MT_edit_meta_showhide")
3349         layout.operator("mball.delete_metaelems", text="Delete...")
3350
3351
3352 class VIEW3D_MT_edit_meta_showhide(Menu):
3353     bl_label = "Show/Hide"
3354
3355     def draw(self, context):
3356         layout = self.layout
3357
3358         layout.operator("mball.reveal_metaelems", text="Show Hidden")
3359         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
3360         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
3361
3362
3363 class VIEW3D_MT_edit_lattice(Menu):
3364     bl_label = "Lattice"
3365
3366     def draw(self, context):
3367         layout = self.layout
3368
3369         layout.separator()
3370
3371         layout.menu("VIEW3D_MT_transform")
3372         layout.menu("VIEW3D_MT_mirror")
3373         layout.menu("VIEW3D_MT_snap")
3374         layout.operator_menu_enum("lattice.flip", "axis")
3375
3376         layout.separator()
3377
3378         layout.operator("lattice.make_regular")
3379
3380         layout.separator()
3381
3382         layout.operator("object.vertex_parent_set")
3383
3384
3385 class VIEW3D_MT_edit_armature(Menu):
3386     bl_label = "Armature"
3387
3388     def draw(self, context):
3389         layout = self.layout
3390
3391         edit_object = context.edit_object
3392         arm = edit_object.data
3393
3394         layout.menu("VIEW3D_MT_transform_armature")
3395         layout.menu("VIEW3D_MT_mirror")
3396         layout.menu("VIEW3D_MT_snap")
3397         layout.menu("VIEW3D_MT_edit_armature_roll")
3398
3399         layout.separator()
3400
3401         layout.operator("armature.extrude_move")
3402
3403         if arm.use_mirror_x:
3404             layout.operator("armature.extrude_forked")
3405
3406         layout.operator("armature.duplicate_move")
3407         layout.operator("armature.merge")
3408         layout.operator("armature.fill")
3409         layout.operator("armature.split")
3410         layout.operator("armature.separate")
3411
3412         layout.separator()
3413
3414         layout.operator("armature.subdivide", text="Subdivide")
3415         layout.operator("armature.switch_direction", text="Switch Direction")
3416
3417         layout.separator()
3418
3419         layout.operator_context = 'EXEC_AREA'
3420         layout.operator("armature.symmetrize")
3421         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
3422         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
3423         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
3424         layout.operator("armature.flip_names")
3425
3426         layout.separator()
3427
3428         layout.operator_context = 'INVOKE_DEFAULT'
3429         layout.operator("armature.armature_layers")
3430         layout.operator("armature.bone_layers")
3431
3432         layout.separator()
3433
3434         layout.menu("VIEW3D_MT_edit_armature_parent")
3435
3436         layout.separator()
3437
3438         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
3439
3440         layout.separator()
3441
3442         layout.operator("armature.delete")
3443
3444
3445 class VIEW3D_MT_armature_specials(Menu):
3446     bl_label = "Armature Context Menu"
3447
3448     def draw(self, context):
3449         layout = self.layout
3450
3451         layout.operator_context = 'INVOKE_REGION_WIN'
3452
3453         layout.operator("armature.subdivide", text="Subdivide")
3454         layout.operator("armature.switch_direction", text="Switch Direction")
3455
3456         layout.separator()
3457
3458         layout.operator_context = 'EXEC_REGION_WIN'
3459         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
3460         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
3461         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
3462         layout.operator("armature.flip_names", text="Flip Names")
3463         layout.operator("armature.symmetrize")
3464
3465
3466 class VIEW3D_MT_edit_armature_parent(Menu):
3467     bl_label = "Parent"
3468
3469     def draw(self, context):
3470         layout = self.layout
3471
3472         layout.operator("armature.parent_set", text="Make")
3473         layout.operator("armature.parent_clear", text="Clear")
3474
3475
3476 class VIEW3D_MT_edit_armature_roll(Menu):
3477     bl_label = "Bone Roll"
3478
3479     def draw(self, context):
3480         layout = self.layout
3481
3482         layout.operator_menu_enum("armature.calculate_roll", "type")
3483
3484         layout.separator()
3485
3486         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
3487         layout.operator("armature.roll_clear")
3488
3489
3490 class VIEW3D_MT_edit_armature_delete(Menu):
3491     bl_label = "Delete"
3492
3493     def draw(self, context):
3494         layout = self.layout
3495
3496         layout.operator("armature.delete", text="Delete Bones")
3497
3498         layout.separator()
3499
3500         layout.operator("armature.dissolve", text="Dissolve")
3501
3502
3503 # ********** GPencil Stroke Edit menu **********
3504
3505
3506 class VIEW3D_MT_edit_gpencil(Menu):
3507     bl_label = "GPencil"
3508
3509     def draw(self, context):
3510         tool_settings = context.tool_settings
3511
3512         layout = self.layout
3513
3514         layout.menu("VIEW3D_MT_edit_gpencil_transform")
3515         layout.operator("transform.mirror", text="Mirror")
3516         layout.menu("GPENCIL_MT_snap")
3517
3518         layout.separator()
3519
3520         layout.operator("gpencil.brush_paint", text="Sculpt Strokes").wait_for_input = True
3521         layout.prop_menu_enum(tool_settings.gpencil_sculpt, "tool", text="Sculpt Brush")
3522
3523         layout.separator()
3524
3525         layout.menu("VIEW3D_MT_object_animation")   # NOTE: provides keyingset access...
3526         layout.menu("VIEW3D_MT_edit_gpencil_interpolate")
3527
3528         layout.separator()
3529
3530         layout.operator("gpencil.duplicate_move", text="Duplicate")
3531         layout.operator("gpencil.stroke_subdivide", text="Subdivide")
3532
3533         layout.separator()
3534
3535         layout.operator_menu_enum("gpencil.stroke_join", "type", text="Join...")
3536         layout.operator("gpencil.stroke_flip", text="Flip Direction")
3537
3538         layout.separator()
3539
3540         layout.operator("gpencil.copy", text="Copy")
3541         layout.operator("gpencil.paste", text="Paste")
3542
3543         layout.separator()
3544
3545         layout.operator("gpencil.reveal")
3546         layout.operator("gpencil.hide", text="Show Active Layer Only").unselected = True
3547         layout.operator("gpencil.hide", text="Hide Active Layer").unselected = False
3548
3549         layout.separator()
3550
3551         layout.operator_menu_enum("gpencil.move_to_layer", "layer", text="Move to Layer")
3552         layout.operator("gpencil.stroke_change_color", text="Move to Color")
3553         layout.operator_menu_enum("gpencil.stroke_arrange", "direction", text="Arrange Strokes...")
3554
3555         layout.separator()
3556
3557         layout.operator_menu_enum("gpencil.convert", "type", text="Convert to Geometry...")
3558
3559         layout.separator()
3560
3561         layout.menu("VIEW3D_MT_edit_gpencil_delete")
3562
3563
3564 class VIEW3D_MT_edit_gpencil_transform(Menu):
3565     bl_label = "Transform"
3566
3567     def draw(self, context):
3568         layout = self.layout
3569
3570         layout.operator("transform.translate")
3571         layout.operator("transform.rotate")
3572         layout.operator("transform.resize", text="Scale")
3573
3574         layout.separator()
3575
3576         layout.operator("transform.bend", text="Bend")
3577         layout.operator("transform.shear", text="Shear")
3578         layout.operator("transform.tosphere", text="To Sphere")
3579         layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN'
3580
3581         layout.separator()
3582
3583         layout.operator("gpencil.reproject")
3584
3585
3586 class VIEW3D_MT_edit_gpencil_interpolate(Menu):
3587     bl_label = "Interpolate"
3588
3589     def draw(self, context):
3590         layout = self.layout
3591
3592         layout.operator("gpencil.interpolate", text="Interpolate")
3593         layout.operator("gpencil.interpolate_sequence", text="Sequence")
3594
3595
3596 class VIEW3D_MT_object_mode_pie(Menu):
3597     bl_label = "Mode"