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