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