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