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