f8bde3f8297549fc8cf22892bea2f39bd4587a93
[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_space_type = 'VIEW3D_MT_editor_menus'
300     bl_label = ""
301
302     def draw(self, context):
303         layout = self.layout
304         obj = context.active_object
305         mode_string = context.mode
306         edit_object = context.edit_object
307         gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}
308
309         layout.menu("VIEW3D_MT_view")
310
311         # Select Menu
312         if gp_edit:
313             if mode_string not in {'PAINT_GPENCIL', 'WEIGHT_GPENCIL'}:
314                 layout.menu("VIEW3D_MT_select_gpencil")
315         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
316             mesh = obj.data
317             if mesh.use_paint_mask:
318                 layout.menu("VIEW3D_MT_select_paint_mask")
319             elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
320                 layout.menu("VIEW3D_MT_select_paint_mask_vertex")
321         elif mode_string != 'SCULPT':
322             layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
323
324         if gp_edit:
325             pass
326         elif mode_string == 'OBJECT':
327             layout.menu("VIEW3D_MT_add", text="Add")
328         elif mode_string == 'EDIT_MESH':
329             layout.menu("VIEW3D_MT_mesh_add", text="Add")
330         elif mode_string == 'EDIT_CURVE':
331             layout.menu("VIEW3D_MT_curve_add", text="Add")
332         elif mode_string == 'EDIT_SURFACE':
333             layout.menu("VIEW3D_MT_surface_add", text="Add")
334         elif mode_string == 'EDIT_METABALL':
335             layout.menu("VIEW3D_MT_metaball_add", text="Add")
336         elif mode_string == 'EDIT_ARMATURE':
337             layout.menu("TOPBAR_MT_edit_armature_add", text="Add")
338
339         if gp_edit:
340             if obj and obj.mode == 'PAINT_GPENCIL':
341                 layout.menu("VIEW3D_MT_paint_gpencil")
342             elif obj and obj.mode == 'EDIT_GPENCIL':
343                 layout.menu("VIEW3D_MT_edit_gpencil")
344             elif obj and obj.mode == 'WEIGHT_GPENCIL':
345                 layout.menu("VIEW3D_MT_weight_gpencil")
346
347         elif edit_object:
348             layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
349
350             if mode_string == 'EDIT_MESH':
351                 layout.menu("VIEW3D_MT_edit_mesh_vertices")
352                 layout.menu("VIEW3D_MT_edit_mesh_edges")
353                 layout.menu("VIEW3D_MT_edit_mesh_faces")
354                 layout.menu("VIEW3D_MT_uv_map", text="UV")
355             elif mode_string in {'EDIT_CURVE', 'EDIT_SURFACE'}:
356                 layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
357                 layout.menu("VIEW3D_MT_edit_curve_segments")
358
359         elif obj:
360             if mode_string != 'PAINT_TEXTURE':
361                 layout.menu("VIEW3D_MT_%s" % mode_string.lower())
362             if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
363                 layout.menu("VIEW3D_MT_brush")
364             if mode_string == 'SCULPT':
365                 layout.menu("VIEW3D_MT_hide_mask")
366         else:
367             layout.menu("VIEW3D_MT_object")
368
369
370 # ********** Menu **********
371
372
373 # ********** Utilities **********
374
375
376 class ShowHideMenu:
377     bl_label = "Show/Hide"
378     _operator_name = ""
379
380     def draw(self, context):
381         layout = self.layout
382
383         layout.operator("%s.reveal" % self._operator_name)
384         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
385         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
386
387
388 # Standard transforms which apply to all cases
389 # NOTE: this doesn't seem to be able to be used directly
390 class VIEW3D_MT_transform_base(Menu):
391     bl_label = "Transform"
392     bl_category = "View"
393
394     # TODO: get rid of the custom text strings?
395     def draw(self, context):
396         layout = self.layout
397
398         layout.operator("transform.translate")
399         layout.operator("transform.rotate")
400         layout.operator("transform.resize", text="Scale")
401
402         layout.separator()
403
404         layout.operator("transform.tosphere", text="To Sphere")
405         layout.operator("transform.shear", text="Shear")
406         layout.operator("transform.bend", text="Bend")
407         layout.operator("transform.push_pull", text="Push/Pull")
408
409         if context.mode != 'OBJECT':
410             layout.operator("transform.vertex_warp", text="Warp")
411             layout.operator("transform.vertex_random", text="Randomize")
412
413
414 # Generic transform menu - geometry types
415 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
416     def draw(self, context):
417         # base menu
418         VIEW3D_MT_transform_base.draw(self, context)
419
420         # generic...
421         layout = self.layout
422         if context.mode == 'EDIT_MESH':
423             layout.operator("transform.shrink_fatten", text="Shrink Fatten")
424         elif context.mode == 'EDIT_CURVE':
425             layout.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN'
426
427         layout.separator()
428
429         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
430         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
431
432
433 # Object-specific extensions to Transform menu
434 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
435     def draw(self, context):
436         layout = self.layout
437
438         # base menu
439         VIEW3D_MT_transform_base.draw(self, context)
440
441         # object-specific option follow...
442         layout.separator()
443
444         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
445         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
446
447         layout.separator()
448
449         layout.operator_context = 'EXEC_REGION_WIN'
450         # XXX see alignmenu() in edit.c of b2.4x to get this working
451         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'
452
453         layout.separator()
454
455         layout.operator("object.randomize_transform")
456         layout.operator("object.align")
457
458         # TODO: there is a strange context bug here.
459         """
460         layout.operator_context = 'INVOKE_REGION_WIN'
461         layout.operator("object.transform_axis_target")
462         """
463
464
465 # Armature EditMode extensions to Transform menu
466 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
467     def draw(self, context):
468         layout = self.layout
469
470         # base menu
471         VIEW3D_MT_transform_base.draw(self, context)
472
473         # armature specific extensions follow...
474         obj = context.object
475         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'}:
476             if obj.data.display_type == 'BBONE':
477                 layout.separator()
478
479                 layout.operator("transform.transform", text="Scale BBone").mode = 'BONE_SIZE'
480             elif obj.data.display_type == 'ENVELOPE':
481                 layout.separator()
482
483                 layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONE_SIZE'
484                 layout.operator("transform.transform", text="Scale Radius").mode = 'BONE_ENVELOPE'
485
486         if context.edit_object and context.edit_object.type == 'ARMATURE':
487             layout.separator()
488
489             layout.operator("armature.align")
490
491
492 class VIEW3D_MT_mirror(Menu):
493     bl_label = "Mirror"
494
495     def draw(self, context):
496         layout = self.layout
497
498         layout.operator("transform.mirror", text="Interactive Mirror")
499
500         layout.separator()
501
502         layout.operator_context = 'EXEC_REGION_WIN'
503
504         for (space_name, space_id) in (("Global", 'GLOBAL'), ("Local", 'LOCAL')):
505             for axis_index, axis_name in enumerate("XYZ"):
506                 props = layout.operator("transform.mirror", text=f"{axis_name!s} {space_name!s}")
507                 props.constraint_axis[axis_index] = True
508                 props.orient_type = 'GLOBAL'
509
510             if space_id == 'GLOBAL':
511                 layout.separator()
512
513
514 class VIEW3D_MT_snap(Menu):
515     bl_label = "Snap"
516
517     def draw(self, context):
518         layout = self.layout
519
520         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
521         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor").use_offset = False
522         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor (Keep Offset)").use_offset = True
523         layout.operator("view3d.snap_selected_to_active", text="Selection to Active")
524
525         layout.separator()
526
527         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
528         layout.operator("view3d.snap_cursor_to_center", text="Cursor to World Origin")
529         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
530         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
531
532
533 class VIEW3D_MT_uv_map(Menu):
534     bl_label = "UV Mapping"
535
536     def draw(self, context):
537         layout = self.layout
538
539         layout.operator("uv.unwrap")
540
541         layout.operator_context = 'INVOKE_DEFAULT'
542         layout.operator("uv.smart_project")
543         layout.operator("uv.lightmap_pack")
544         layout.operator("uv.follow_active_quads")
545
546         layout.separator()
547
548         layout.operator_context = 'EXEC_REGION_WIN'
549         layout.operator("uv.cube_project")
550         layout.operator("uv.cylinder_project")
551         layout.operator("uv.sphere_project")
552
553         layout.separator()
554
555         layout.operator_context = 'INVOKE_REGION_WIN'
556         layout.operator("uv.project_from_view").scale_to_bounds = False
557         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
558
559         layout.separator()
560
561         layout.operator("mesh.mark_seam").clear = False
562         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
563
564         layout.separator()
565
566         layout.operator("uv.reset")
567
568
569 # ********** View menus **********
570
571
572 class VIEW3D_MT_view(Menu):
573     bl_label = "View"
574
575     def draw(self, context):
576         layout = self.layout
577         view = context.space_data
578
579         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
580         layout.operator("view3d.properties", icon='MENU_PANEL')
581
582         layout.separator()
583
584         layout.operator("view3d.view_selected", text="Frame Selected").use_all_regions = False
585         if view.region_quadviews:
586             layout.operator("view3d.view_selected", text="Frame Selected (Quad View)").use_all_regions = True
587
588         layout.operator("view3d.view_all", text="Frame All").center = False
589         layout.operator("view3d.view_persportho", text="Perspective/Orthographic")
590         layout.menu("VIEW3D_MT_view_local")
591
592         layout.separator()
593
594         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
595
596         layout.separator()
597         layout.menu("VIEW3D_MT_view_viewpoint")
598         layout.menu("VIEW3D_MT_view_navigation")
599         layout.menu("VIEW3D_MT_view_align")
600
601         layout.separator()
602
603         layout.operator_context = 'INVOKE_REGION_WIN'
604         layout.menu("VIEW3D_MT_view_regions", text="View Regions")
605
606         layout.separator()
607
608         layout.operator("screen.animation_play", text="Play Animation")
609
610         layout.separator()
611
612         layout.operator("render.opengl", text="Viewport Render Image", icon='RENDER_STILL')
613         layout.operator("render.opengl", text="Viewport Render Animation", icon='RENDER_ANIMATION').animation = True
614
615         layout.separator()
616
617         layout.menu("INFO_MT_area")
618
619
620 class VIEW3D_MT_view_local(Menu):
621     bl_label = "Local View"
622
623     def draw(self, context):
624         layout = self.layout
625
626         layout.operator("view3d.localview", text="Toggle Local View")
627         layout.operator("view3d.localview_remove_from")
628
629
630 class VIEW3D_MT_view_cameras(Menu):
631     bl_label = "Cameras"
632
633     def draw(self, context):
634         layout = self.layout
635
636         layout.operator("view3d.object_as_camera")
637         layout.operator("view3d.view_camera", text="Active Camera")
638
639
640 class VIEW3D_MT_view_viewpoint(Menu):
641     bl_label = "Viewpoint"
642
643     def draw(self, context):
644         layout = self.layout
645
646         layout.operator("view3d.view_camera", text="Camera")
647
648         layout.separator()
649
650         layout.operator("view3d.view_axis", text="Top").type = 'TOP'
651         layout.operator("view3d.view_axis", text="Bottom").type = 'BOTTOM'
652
653         layout.separator()
654
655         layout.operator("view3d.view_axis", text="Front").type = 'FRONT'
656         layout.operator("view3d.view_axis", text="Back").type = 'BACK'
657
658         layout.separator()
659
660         layout.operator("view3d.view_axis", text="Right").type = 'RIGHT'
661         layout.operator("view3d.view_axis", text="Left").type = 'LEFT'
662
663
664 class VIEW3D_MT_view_navigation(Menu):
665     bl_label = "Navigation"
666
667     def draw(self, context):
668         from math import pi
669         layout = self.layout
670
671         layout.operator_enum("view3d.view_orbit", "type")
672         props = layout.operator("view3d.view_orbit", text="Orbit Opposite")
673         props.type = 'ORBITRIGHT'
674         props.angle = pi
675
676         layout.separator()
677
678         layout.operator("view3d.view_roll", text="Roll Left").type = 'LEFT'
679         layout.operator("view3d.view_roll", text="Roll Right").type = 'RIGHT'
680
681         layout.separator()
682
683         layout.operator_enum("view3d.view_pan", "type")
684
685         layout.separator()
686
687         layout.operator("view3d.zoom", text="Zoom In").delta = 1
688         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
689         layout.operator("view3d.zoom_border", text="Zoom Border...")
690         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
691
692         layout.separator()
693
694         layout.operator("view3d.fly")
695         layout.operator("view3d.walk")
696
697
698 class VIEW3D_MT_view_align(Menu):
699     bl_label = "Align View"
700
701     def draw(self, context):
702         layout = self.layout
703
704         layout.menu("VIEW3D_MT_view_align_selected")
705
706         layout.separator()
707
708         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
709         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
710
711         layout.separator()
712
713         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
714         layout.operator("view3d.view_center_cursor")
715
716         layout.separator()
717
718         layout.operator("view3d.view_lock_to_active")
719         layout.operator("view3d.view_lock_clear")
720
721
722 class VIEW3D_MT_view_align_selected(Menu):
723     bl_label = "Align View to Active"
724
725     def draw(self, context):
726         layout = self.layout
727
728         props = layout.operator("view3d.view_axis", text="Top")
729         props.align_active = True
730         props.type = 'TOP'
731
732         props = layout.operator("view3d.view_axis", text="Bottom")
733         props.align_active = True
734         props.type = 'BOTTOM'
735
736         layout.separator()
737
738         props = layout.operator("view3d.view_axis", text="Front")
739         props.align_active = True
740         props.type = 'FRONT'
741
742         props = layout.operator("view3d.view_axis", text="Back")
743         props.align_active = True
744         props.type = 'BACK'
745
746         layout.separator()
747
748         props = layout.operator("view3d.view_axis", text="Right")
749         props.align_active = True
750         props.type = 'RIGHT'
751
752         props = layout.operator("view3d.view_axis", text="Left")
753         props.align_active = True
754         props.type = 'LEFT'
755
756
757 class VIEW3D_MT_view_regions(Menu):
758     bl_label = "View Regions"
759
760     def draw(self, context):
761         layout = self.layout
762         layout.operator("view3d.clip_border", text="Clipping Region...")
763         layout.operator("view3d.render_border", text="Render Region...")
764
765         layout.separator()
766
767         layout.operator("view3d.clear_render_border")
768
769
770 # ********** Select menus, suffix from context.mode **********
771
772 class VIEW3D_MT_select_object_more_less(Menu):
773     bl_label = "Select More/Less"
774
775     def draw(self, context):
776         layout = self.layout
777
778         layout = self.layout
779
780         layout.operator("object.select_more", text="More")
781         layout.operator("object.select_less", text="Less")
782
783         layout.separator()
784
785         props = layout.operator("object.select_hierarchy", text="Parent")
786         props.extend = False
787         props.direction = 'PARENT'
788
789         props = layout.operator("object.select_hierarchy", text="Child")
790         props.extend = False
791         props.direction = 'CHILD'
792
793         layout.separator()
794
795         props = layout.operator("object.select_hierarchy", text="Extend Parent")
796         props.extend = True
797         props.direction = 'PARENT'
798
799         props = layout.operator("object.select_hierarchy", text="Extend Child")
800         props.extend = True
801         props.direction = 'CHILD'
802
803
804 class VIEW3D_MT_select_object(Menu):
805     bl_label = "Select"
806
807     def draw(self, context):
808         layout = self.layout
809
810         layout.operator("object.select_all", text="All").action = 'SELECT'
811         layout.operator("object.select_all", text="None").action = 'DESELECT'
812         layout.operator("object.select_all", text="Invert").action = 'INVERT'
813
814         layout.separator()
815
816         layout.operator("view3d.select_box")
817         layout.operator("view3d.select_circle")
818
819         layout.separator()
820
821         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
822         layout.operator("object.select_camera", text="Select Active Camera")
823         layout.operator("object.select_mirror", text="Mirror Selection")
824         layout.operator("object.select_random", text="Select Random")
825
826         layout.separator()
827
828         layout.menu("VIEW3D_MT_select_object_more_less")
829
830         layout.separator()
831
832         layout.operator_menu_enum("object.select_grouped", "type", text="Select Grouped")
833         layout.operator_menu_enum("object.select_linked", "type", text="Select Linked")
834         layout.operator("object.select_pattern", text="Select Pattern...")
835
836
837 class VIEW3D_MT_select_pose_more_less(Menu):
838     bl_label = "Select More/Less"
839
840     def draw(self, context):
841         layout = self.layout
842
843         layout = self.layout
844
845         props = layout.operator("pose.select_hierarchy", text="Parent")
846         props.extend = False
847         props.direction = 'PARENT'
848
849         props = layout.operator("pose.select_hierarchy", text="Child")
850         props.extend = False
851         props.direction = 'CHILD'
852
853         layout.separator()
854
855         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
856         props.extend = True
857         props.direction = 'PARENT'
858
859         props = layout.operator("pose.select_hierarchy", text="Extend Child")
860         props.extend = True
861         props.direction = 'CHILD'
862
863
864 class VIEW3D_MT_select_pose(Menu):
865     bl_label = "Select"
866
867     def draw(self, context):
868         layout = self.layout
869
870         layout.operator("pose.select_all", text="All").action = 'SELECT'
871         layout.operator("pose.select_all", text="None").action = 'DESELECT'
872         layout.operator("pose.select_all", text="Invert").action = 'INVERT'
873
874         layout.separator()
875
876         layout.operator("view3d.select_box")
877         layout.operator("view3d.select_circle")
878
879         layout.separator()
880
881         layout.operator("pose.select_mirror", text="Flip Active")
882
883         layout.separator()
884
885         layout.operator("pose.select_constraint_target", text="Constraint Target")
886         layout.operator("pose.select_linked", text="Linked")
887
888         layout.separator()
889
890         layout.menu("VIEW3D_MT_select_pose_more_less")
891
892         layout.separator()
893
894         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
895         layout.operator("object.select_pattern", text="Select Pattern...")
896
897
898 class VIEW3D_MT_select_particle(Menu):
899     bl_label = "Select"
900
901     def draw(self, context):
902         layout = self.layout
903
904         layout.operator("particle.select_all", text="All").action = 'SELECT'
905         layout.operator("particle.select_all", text="None").action = 'DESELECT'
906         layout.operator("particle.select_all", text="Invert").action = 'INVERT'
907
908         layout.separator()
909
910         layout.operator("view3d.select_box")
911         layout.operator("view3d.select_circle")
912
913         layout.separator()
914
915         layout.operator("particle.select_linked")
916
917         layout.separator()
918
919         layout.operator("particle.select_more")
920         layout.operator("particle.select_less")
921
922         layout.separator()
923
924         layout.operator("particle.select_random")
925
926         layout.separator()
927
928         layout.operator("particle.select_roots", text="Roots")
929         layout.operator("particle.select_tips", text="Tips")
930
931
932 class VIEW3D_MT_edit_mesh_select_similar(Menu):
933     bl_label = "Select Similar"
934
935     def draw(self, context):
936         layout = self.layout
937
938         layout.operator_enum("mesh.select_similar", "type")
939
940         layout.separator()
941
942         layout.operator("mesh.select_similar_region", text="Face Regions")
943
944
945 class VIEW3D_MT_edit_mesh_select_by_trait(Menu):
946     bl_label = "Select All by Trait"
947
948     def draw(self, context):
949         layout = self.layout
950         tool_settings = context.tool_settings
951         if tool_settings.mesh_select_mode[2] is False:
952             layout.operator("mesh.select_non_manifold", text="Non Manifold")
953         layout.operator("mesh.select_loose", text="Loose Geometry")
954         layout.operator("mesh.select_interior_faces", text="Interior Faces")
955         layout.operator("mesh.select_face_by_sides", text="Faces by Sides")
956
957         layout.separator()
958
959         layout.operator("mesh.select_ungrouped", text="Ungrouped Verts")
960
961
962 class VIEW3D_MT_edit_mesh_select_more_less(Menu):
963     bl_label = "Select More/Less"
964
965     def draw(self, context):
966         layout = self.layout
967
968         layout.operator("mesh.select_more", text="More")
969         layout.operator("mesh.select_less", text="Less")
970
971         layout.separator()
972
973         layout.operator("mesh.select_next_item", text="Next Active")
974         layout.operator("mesh.select_prev_item", text="Previous Active")
975
976
977 class VIEW3D_MT_edit_mesh_select_linked(Menu):
978     bl_label = "Select Linked"
979
980     def draw(self, context):
981         layout = self.layout
982
983         layout.operator("mesh.select_linked", text="Linked")
984         layout.operator("mesh.shortest_path_select", text="Shortest Path")
985         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
986
987
988 class VIEW3D_MT_edit_mesh_select_loops(Menu):
989     bl_label = "Select Loops"
990
991     def draw(self, context):
992         layout = self.layout
993
994         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
995         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
996
997         layout.separator()
998
999         layout.operator("mesh.loop_to_region")
1000         layout.operator("mesh.region_to_loop")
1001
1002
1003 class VIEW3D_MT_select_edit_mesh(Menu):
1004     bl_label = "Select"
1005
1006     def draw(self, context):
1007         layout = self.layout
1008
1009         # primitive
1010         layout.operator("mesh.select_all", text="All").action = 'SELECT'
1011         layout.operator("mesh.select_all", text="None").action = 'DESELECT'
1012         layout.operator("mesh.select_all", text="Invert").action = 'INVERT'
1013
1014         layout.separator()
1015
1016         layout.operator("view3d.select_box")
1017         layout.operator("view3d.select_circle")
1018
1019         layout.separator()
1020
1021         # numeric
1022         layout.operator("mesh.select_random", text="Select Random")
1023         layout.operator("mesh.select_nth")
1024
1025         layout.separator()
1026
1027         # geometric
1028         layout.operator("mesh.edges_select_sharp", text="Select Sharp Edges")
1029
1030         layout.separator()
1031
1032         # other ...
1033         layout.menu("VIEW3D_MT_edit_mesh_select_similar")
1034
1035         layout.separator()
1036
1037         layout.menu("VIEW3D_MT_edit_mesh_select_by_trait")
1038
1039         layout.separator()
1040
1041         layout.menu("VIEW3D_MT_edit_mesh_select_more_less")
1042
1043         layout.separator()
1044
1045         layout.menu("VIEW3D_MT_edit_mesh_select_loops")
1046
1047         layout.separator()
1048
1049         layout.menu("VIEW3D_MT_edit_mesh_select_linked")
1050
1051         layout.separator()
1052
1053         layout.operator("mesh.select_axis", text="Side of Active")
1054         layout.operator("mesh.select_mirror", text="Mirror Selection")
1055
1056
1057 class VIEW3D_MT_select_edit_curve(Menu):
1058     bl_label = "Select"
1059
1060     def draw(self, context):
1061         layout = self.layout
1062
1063         layout.operator("curve.select_all", text="All").action = 'SELECT'
1064         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1065         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1066
1067         layout.separator()
1068
1069         layout.operator("view3d.select_box")
1070         layout.operator("view3d.select_circle")
1071
1072         layout.separator()
1073
1074         layout.operator("curve.select_random")
1075         layout.operator("curve.select_nth")
1076         layout.operator("curve.select_linked", text="Select Linked")
1077         layout.operator("curve.select_similar", text="Select Similar")
1078
1079         layout.separator()
1080
1081         layout.operator("curve.de_select_first")
1082         layout.operator("curve.de_select_last")
1083         layout.operator("curve.select_next")
1084         layout.operator("curve.select_previous")
1085
1086         layout.separator()
1087
1088         layout.operator("curve.select_more")
1089         layout.operator("curve.select_less")
1090
1091
1092 class VIEW3D_MT_select_edit_surface(Menu):
1093     bl_label = "Select"
1094
1095     def draw(self, context):
1096         layout = self.layout
1097
1098         layout.operator("curve.select_all", text="All").action = 'SELECT'
1099         layout.operator("curve.select_all", text="None").action = 'DESELECT'
1100         layout.operator("curve.select_all", text="Invert").action = 'INVERT'
1101
1102         layout.separator()
1103
1104         layout.operator("view3d.select_box")
1105         layout.operator("view3d.select_circle")
1106
1107         layout.separator()
1108
1109         layout.operator("curve.select_random")
1110         layout.operator("curve.select_nth")
1111         layout.operator("curve.select_linked", text="Select Linked")
1112         layout.operator("curve.select_similar", text="Select Similar")
1113
1114         layout.separator()
1115
1116         layout.operator("curve.select_row")
1117
1118         layout.separator()
1119
1120         layout.operator("curve.select_more")
1121         layout.operator("curve.select_less")
1122
1123
1124 class VIEW3D_MT_edit_text_context_menu(Menu):
1125     bl_label = "Text Context Menu"
1126
1127     def draw(self, context):
1128         layout = self.layout
1129
1130         layout = self.layout
1131
1132         layout.operator_context = 'INVOKE_DEFAULT'
1133
1134         layout.operator("font.text_cut", text="Cut")
1135         layout.operator("font.text_copy", text="Copy", icon='COPYDOWN')
1136         layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN')
1137
1138         layout.separator()
1139
1140         layout.operator("font.select_all")
1141
1142         layout.separator()
1143
1144         layout.menu("VIEW3D_MT_edit_font")
1145
1146
1147 class VIEW3D_MT_select_edit_text(Menu):
1148     # intentional name mismatch
1149     # select menu for 3d-text doesn't make sense
1150     bl_label = "Edit"
1151
1152     def draw(self, context):
1153         layout = self.layout
1154
1155         layout.operator("font.text_cut", text="Cut")
1156         layout.operator("font.text_copy", text="Copy", icon='COPYDOWN')
1157         layout.operator("font.text_paste", text="Paste", icon='PASTEDOWN')
1158
1159         layout.separator()
1160
1161         layout.operator("font.text_paste_from_file")
1162
1163         layout.separator()
1164
1165         layout.operator("font.select_all")
1166
1167         layout.menu("VIEW3D_MT_edit_font")
1168
1169
1170 class VIEW3D_MT_select_edit_metaball(Menu):
1171     bl_label = "Select"
1172
1173     def draw(self, context):
1174         layout = self.layout
1175
1176         layout.operator("mball.select_all", text="All").action = 'SELECT'
1177         layout.operator("mball.select_all", text="None").action = 'DESELECT'
1178         layout.operator("mball.select_all", text="Invert").action = 'INVERT'
1179
1180         layout.separator()
1181
1182         layout.operator("view3d.select_box")
1183         layout.operator("view3d.select_circle")
1184
1185         layout.separator()
1186
1187         layout.operator("mball.select_random_metaelems")
1188
1189         layout.separator()
1190
1191         layout.operator_menu_enum("mball.select_similar", "type", text="Similar")
1192
1193
1194 class VIEW3D_MT_edit_lattice_context_menu(Menu):
1195     bl_label = "Lattice Context Menu"
1196
1197     def draw(self, context):
1198         layout = self.layout
1199
1200         layout = self.layout
1201
1202         layout.menu("VIEW3D_MT_mirror")
1203         layout.operator_menu_enum("lattice.flip", "axis")
1204         layout.menu("VIEW3D_MT_snap")
1205
1206         layout.separator()
1207
1208         layout.operator("lattice.make_regular")
1209
1210
1211 class VIEW3D_MT_select_edit_lattice(Menu):
1212     bl_label = "Select"
1213
1214     def draw(self, context):
1215         layout = self.layout
1216
1217         layout.operator("lattice.select_all", text="All").action = 'SELECT'
1218         layout.operator("lattice.select_all", text="None").action = 'DESELECT'
1219         layout.operator("lattice.select_all", text="Invert").action = 'INVERT'
1220
1221         layout.separator()
1222
1223         layout.operator("view3d.select_box")
1224         layout.operator("view3d.select_circle")
1225
1226         layout.separator()
1227
1228         layout.operator("lattice.select_mirror")
1229         layout.operator("lattice.select_random")
1230
1231         layout.separator()
1232
1233         layout.operator("lattice.select_more")
1234         layout.operator("lattice.select_less")
1235
1236         layout.separator()
1237
1238         layout.operator("lattice.select_ungrouped", text="Ungrouped Verts")
1239
1240
1241 class VIEW3D_MT_select_edit_armature(Menu):
1242     bl_label = "Select"
1243
1244     def draw(self, context):
1245         layout = self.layout
1246
1247         layout.operator("armature.select_all", text="All").action = 'SELECT'
1248         layout.operator("armature.select_all", text="None").action = 'DESELECT'
1249         layout.operator("armature.select_all", text="Invert").action = 'INVERT'
1250
1251         layout.separator()
1252
1253         layout.operator("view3d.select_box")
1254         layout.operator("view3d.select_circle")
1255
1256         layout.separator()
1257
1258         layout.operator("armature.select_mirror", text="Mirror").extend = False
1259
1260         layout.separator()
1261
1262         layout.operator("armature.select_more", text="More")
1263         layout.operator("armature.select_less", text="Less")
1264
1265         layout.separator()
1266
1267         props = layout.operator("armature.select_hierarchy", text="Parent")
1268         props.extend = False
1269         props.direction = 'PARENT'
1270
1271         props = layout.operator("armature.select_hierarchy", text="Child")
1272         props.extend = False
1273         props.direction = 'CHILD'
1274
1275         layout.separator()
1276
1277         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
1278         props.extend = True
1279         props.direction = 'PARENT'
1280
1281         props = layout.operator("armature.select_hierarchy", text="Extend Child")
1282         props.extend = True
1283         props.direction = 'CHILD'
1284
1285         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
1286         layout.operator("object.select_pattern", text="Select Pattern...")
1287
1288
1289 class VIEW3D_MT_select_gpencil(Menu):
1290     bl_label = "Select"
1291
1292     def draw(self, context):
1293         layout = self.layout
1294
1295         layout.operator("gpencil.select_all", text="All").action = 'SELECT'
1296         layout.operator("gpencil.select_all", text="None").action = 'DESELECT'
1297         layout.operator("gpencil.select_all", text="Invert").action = 'INVERT'
1298
1299         layout.separator()
1300
1301         layout.operator("gpencil.select_box")
1302         layout.operator("gpencil.select_circle")
1303
1304         layout.separator()
1305
1306         layout.operator("gpencil.select_linked", text="Linked")
1307         layout.operator("gpencil.select_alternate")
1308         layout.operator_menu_enum("gpencil.select_grouped", "type", text="Grouped")
1309
1310         layout.separator()
1311
1312         layout.operator("gpencil.select_first")
1313         layout.operator("gpencil.select_last")
1314
1315         layout.separator()
1316
1317         layout.operator("gpencil.select_more")
1318         layout.operator("gpencil.select_less")
1319
1320
1321 class VIEW3D_MT_select_paint_mask(Menu):
1322     bl_label = "Select"
1323
1324     def draw(self, context):
1325         layout = self.layout
1326
1327         layout.operator("paint.face_select_all", text="All").action = 'SELECT'
1328         layout.operator("paint.face_select_all", text="None").action = 'DESELECT'
1329         layout.operator("paint.face_select_all", text="Invert").action = 'INVERT'
1330
1331         layout.separator()
1332
1333         layout.operator("view3d.select_box")
1334         layout.operator("view3d.select_circle")
1335
1336         layout.separator()
1337
1338         layout.operator("paint.face_select_linked", text="Linked")
1339
1340
1341 class VIEW3D_MT_select_paint_mask_vertex(Menu):
1342     bl_label = "Select"
1343
1344     def draw(self, context):
1345         layout = self.layout
1346
1347         layout.operator("paint.vert_select_all", text="All").action = 'SELECT'
1348         layout.operator("paint.vert_select_all", text="None").action = 'DESELECT'
1349         layout.operator("paint.vert_select_all", text="Invert").action = 'INVERT'
1350
1351         layout.separator()
1352
1353         layout.operator("view3d.select_box")
1354         layout.operator("view3d.select_circle")
1355
1356         layout.separator()
1357
1358         layout.operator("paint.vert_select_ungrouped", text="Ungrouped Verts")
1359
1360
1361 class VIEW3D_MT_angle_control(Menu):
1362     bl_label = "Angle Control"
1363
1364     @classmethod
1365     def poll(cls, context):
1366         settings = UnifiedPaintPanel.paint_settings(context)
1367         if not settings:
1368             return False
1369
1370         brush = settings.brush
1371         tex_slot = brush.texture_slot
1372
1373         return tex_slot.has_texture_angle and tex_slot.has_texture_angle_source
1374
1375     def draw(self, context):
1376         layout = self.layout
1377
1378         settings = UnifiedPaintPanel.paint_settings(context)
1379         brush = settings.brush
1380
1381         sculpt = (context.sculpt_object is not None)
1382
1383         tex_slot = brush.texture_slot
1384
1385         layout.prop(tex_slot, "use_rake", text="Rake")
1386
1387         if brush.brush_capabilities.has_random_texture_angle and tex_slot.has_random_texture_angle:
1388             if sculpt:
1389                 if brush.sculpt_capabilities.has_random_texture_angle:
1390                     layout.prop(tex_slot, "use_random", text="Random")
1391             else:
1392                 layout.prop(tex_slot, "use_random", text="Random")
1393
1394
1395 class VIEW3D_MT_mesh_add(Menu):
1396     bl_idname = "VIEW3D_MT_mesh_add"
1397     bl_label = "Mesh"
1398
1399     def draw(self, context):
1400         layout = self.layout
1401
1402         layout.operator_context = 'INVOKE_REGION_WIN'
1403
1404         layout.operator("mesh.primitive_plane_add", text="Plane", icon='MESH_PLANE')
1405         layout.operator("mesh.primitive_cube_add", text="Cube", icon='MESH_CUBE')
1406         layout.operator("mesh.primitive_circle_add", text="Circle", icon='MESH_CIRCLE')
1407         layout.operator("mesh.primitive_uv_sphere_add", text="UV Sphere", icon='MESH_UVSPHERE')
1408         layout.operator("mesh.primitive_ico_sphere_add", text="Ico Sphere", icon='MESH_ICOSPHERE')
1409         layout.operator("mesh.primitive_cylinder_add", text="Cylinder", icon='MESH_CYLINDER')
1410         layout.operator("mesh.primitive_cone_add", text="Cone", icon='MESH_CONE')
1411         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
1412
1413         layout.separator()
1414
1415         layout.operator("mesh.primitive_grid_add", text="Grid", icon='MESH_GRID')
1416         layout.operator("mesh.primitive_monkey_add", text="Monkey", icon='MESH_MONKEY')
1417
1418
1419 class VIEW3D_MT_curve_add(Menu):
1420     bl_idname = "VIEW3D_MT_curve_add"
1421     bl_label = "Curve"
1422
1423     def draw(self, context):
1424         layout = self.layout
1425
1426         layout.operator_context = 'INVOKE_REGION_WIN'
1427
1428         layout.operator("curve.primitive_bezier_curve_add", text="Bezier", icon='CURVE_BEZCURVE')
1429         layout.operator("curve.primitive_bezier_circle_add", text="Circle", icon='CURVE_BEZCIRCLE')
1430
1431         layout.separator()
1432
1433         layout.operator("curve.primitive_nurbs_curve_add", text="Nurbs Curve", icon='CURVE_NCURVE')
1434         layout.operator("curve.primitive_nurbs_circle_add", text="Nurbs Circle", icon='CURVE_NCIRCLE')
1435         layout.operator("curve.primitive_nurbs_path_add", text="Path", icon='CURVE_PATH')
1436
1437
1438 class VIEW3D_MT_surface_add(Menu):
1439     bl_idname = "VIEW3D_MT_surface_add"
1440     bl_label = "Surface"
1441
1442     def draw(self, context):
1443         layout = self.layout
1444
1445         layout.operator_context = 'INVOKE_REGION_WIN'
1446
1447         layout.operator("surface.primitive_nurbs_surface_curve_add", text="Nurbs Curve", icon='SURFACE_NCURVE')
1448         layout.operator("surface.primitive_nurbs_surface_circle_add", text="Nurbs Circle", icon='SURFACE_NCIRCLE')
1449         layout.operator("surface.primitive_nurbs_surface_surface_add", text="Nurbs Surface", icon='SURFACE_NSURFACE')
1450         layout.operator("surface.primitive_nurbs_surface_cylinder_add",
1451                         text="Nurbs Cylinder", icon='SURFACE_NCYLINDER')
1452         layout.operator("surface.primitive_nurbs_surface_sphere_add", text="Nurbs Sphere", icon='SURFACE_NSPHERE')
1453         layout.operator("surface.primitive_nurbs_surface_torus_add", text="Nurbs Torus", icon='SURFACE_NTORUS')
1454
1455
1456 class VIEW3D_MT_edit_metaball_context_menu(Menu):
1457     bl_label = "Metaball Context Menu"
1458
1459     def draw(self, context):
1460         layout = self.layout
1461
1462         layout.operator_context = 'INVOKE_REGION_WIN'
1463
1464         # Add
1465         layout.operator("mball.duplicate_move")
1466
1467         layout.separator()
1468
1469         # Modify
1470         layout.menu("VIEW3D_MT_mirror")
1471         layout.menu("VIEW3D_MT_snap")
1472
1473         layout.separator()
1474
1475         # Remove
1476         layout.operator_context = 'EXEC_DEFAULT'
1477         layout.operator("mball.delete_metaelems", text="Delete")
1478
1479
1480 class VIEW3D_MT_metaball_add(Menu):
1481     bl_idname = "VIEW3D_MT_metaball_add"
1482     bl_label = "Metaball"
1483
1484     def draw(self, context):
1485         layout = self.layout
1486
1487         layout.operator_context = 'INVOKE_REGION_WIN'
1488         layout.operator_enum("object.metaball_add", "type")
1489
1490
1491 class TOPBAR_MT_edit_curve_add(Menu):
1492     bl_idname = "TOPBAR_MT_edit_curve_add"
1493     bl_label = "Add"
1494
1495     def draw(self, context):
1496         is_surf = context.active_object.type == 'SURFACE'
1497
1498         layout = self.layout
1499         layout.operator_context = 'EXEC_REGION_WIN'
1500
1501         if is_surf:
1502             VIEW3D_MT_surface_add.draw(self, context)
1503         else:
1504             VIEW3D_MT_curve_add.draw(self, context)
1505
1506
1507 class TOPBAR_MT_edit_armature_add(Menu):
1508     bl_idname = "TOPBAR_MT_edit_armature_add"
1509     bl_label = "Armature"
1510
1511     def draw(self, context):
1512         layout = self.layout
1513
1514         layout.operator_context = 'EXEC_REGION_WIN'
1515         layout.operator("armature.bone_primitive_add", text="Single Bone", icon='BONE_DATA')
1516
1517
1518 class VIEW3D_MT_armature_add(Menu):
1519     bl_idname = "VIEW3D_MT_armature_add"
1520     bl_label = "Armature"
1521
1522     def draw(self, context):
1523         layout = self.layout
1524
1525         layout.operator_context = 'EXEC_REGION_WIN'
1526         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
1527
1528
1529 class VIEW3D_MT_light_add(Menu):
1530     bl_idname = "VIEW3D_MT_light_add"
1531     bl_label = "Light"
1532
1533     def draw(self, context):
1534         layout = self.layout
1535
1536         layout.operator_context = 'INVOKE_REGION_WIN'
1537         layout.operator_enum("object.light_add", "type")
1538
1539
1540 class VIEW3D_MT_lightprobe_add(Menu):
1541     bl_idname = "VIEW3D_MT_lightprobe_add"
1542     bl_label = "Light Probe"
1543
1544     def draw(self, context):
1545         layout = self.layout
1546
1547         layout.operator_context = 'INVOKE_REGION_WIN'
1548         layout.operator_enum("object.lightprobe_add", "type")
1549
1550
1551 class VIEW3D_MT_camera_add(Menu):
1552     bl_idname = "VIEW3D_MT_camera_add"
1553     bl_label = "Camera"
1554
1555     def draw(self, context):
1556         layout = self.layout
1557         layout.operator_context = 'EXEC_REGION_WIN'
1558         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
1559
1560
1561 class VIEW3D_MT_add(Menu):
1562     bl_label = "Add"
1563
1564     def draw(self, context):
1565         layout = self.layout
1566
1567         # note, don't use 'EXEC_SCREEN' or operators won't get the 'v3d' context.
1568
1569         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
1570         #       "align_view" to work on first call (see [#32719]).
1571         layout.operator_context = 'EXEC_REGION_WIN'
1572
1573         # layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
1574         layout.menu("VIEW3D_MT_mesh_add", icon='OUTLINER_OB_MESH')
1575
1576         # layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
1577         layout.menu("VIEW3D_MT_curve_add", icon='OUTLINER_OB_CURVE')
1578         # layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
1579         layout.menu("VIEW3D_MT_surface_add", icon='OUTLINER_OB_SURFACE')
1580         layout.menu("VIEW3D_MT_metaball_add", text="Metaball", icon='OUTLINER_OB_META')
1581         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
1582         layout.operator_menu_enum("object.gpencil_add", "type", text="Grease Pencil", icon='OUTLINER_OB_GREASEPENCIL')
1583
1584         layout.separator()
1585
1586         if VIEW3D_MT_armature_add.is_extended():
1587             layout.menu("VIEW3D_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
1588         else:
1589             layout.operator("object.armature_add", text="Armature", icon='OUTLINER_OB_ARMATURE')
1590
1591         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
1592
1593         layout.separator()
1594
1595         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
1596         layout.menu("VIEW3D_MT_image_add", text="Image", icon='OUTLINER_OB_IMAGE')
1597
1598         layout.separator()
1599
1600         layout.menu("VIEW3D_MT_light_add", icon='OUTLINER_OB_LIGHT')
1601         layout.menu("VIEW3D_MT_lightprobe_add", icon='OUTLINER_OB_LIGHTPROBE')
1602
1603         layout.separator()
1604
1605         if VIEW3D_MT_camera_add.is_extended():
1606             layout.menu("VIEW3D_MT_camera_add", icon='OUTLINER_OB_CAMERA')
1607         else:
1608             VIEW3D_MT_camera_add.draw(self, context)
1609
1610         layout.separator()
1611
1612         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
1613
1614         layout.separator()
1615
1616         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_FORCE_FIELD')
1617
1618         layout.separator()
1619
1620         has_collections = bool(bpy.data.collections)
1621         col = layout.column()
1622         col.enabled = has_collections
1623
1624         if not has_collections or len(bpy.data.collections) > 10:
1625             col.operator_context = 'INVOKE_REGION_WIN'
1626             col.operator(
1627                 "object.collection_instance_add",
1628                 text="Collection Instance..." if has_collections else "No Collections to Instance",
1629                 icon='OUTLINER_OB_GROUP_INSTANCE',
1630             )
1631         else:
1632             col.operator_menu_enum(
1633                 "object.collection_instance_add",
1634                 "collection",
1635                 text="Collection Instance",
1636                 icon='OUTLINER_OB_GROUP_INSTANCE',
1637             )
1638
1639
1640 class VIEW3D_MT_image_add(Menu):
1641     bl_label = "Add Image"
1642
1643     def draw(self, context):
1644         layout = self.layout
1645         layout.operator("object.load_reference_image", text="Reference", icon='IMAGE_REFERENCE')
1646         layout.operator("object.load_background_image", text="Background", icon='IMAGE_BACKGROUND')
1647
1648
1649 class VIEW3D_MT_object_relations(Menu):
1650     bl_label = "Relations"
1651
1652     def draw(self, context):
1653         layout = self.layout
1654
1655         layout.operator("object.proxy_make", text="Make Proxy...")
1656
1657         layout.operator("object.make_dupli_face")
1658
1659         layout.separator()
1660
1661         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
1662         layout.menu("VIEW3D_MT_make_single_user")
1663
1664         layout.separator()
1665
1666         layout.operator("object.data_transfer")
1667         layout.operator("object.datalayout_transfer")
1668
1669
1670 class VIEW3D_MT_object(Menu):
1671     bl_context = "objectmode"
1672     bl_label = "Object"
1673
1674     def draw(self, context):
1675         layout = self.layout
1676
1677         layout.menu("VIEW3D_MT_transform_object")
1678         layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
1679         layout.menu("VIEW3D_MT_mirror")
1680         layout.menu("VIEW3D_MT_object_clear")
1681         layout.menu("VIEW3D_MT_object_apply")
1682         layout.menu("VIEW3D_MT_snap")
1683
1684         layout.separator()
1685
1686         layout.operator("object.duplicate_move")
1687         layout.operator("object.duplicate_move_linked")
1688         layout.operator("object.join")
1689
1690         layout.separator()
1691
1692         layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
1693         layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
1694
1695         layout.separator()
1696
1697         layout.menu("VIEW3D_MT_object_parent")
1698         layout.menu("VIEW3D_MT_object_collection")
1699         layout.menu("VIEW3D_MT_object_relations")
1700         layout.menu("VIEW3D_MT_object_constraints")
1701         layout.menu("VIEW3D_MT_object_track")
1702         layout.menu("VIEW3D_MT_make_links", text="Make Links")
1703
1704         layout.separator()
1705
1706         layout.operator("object.shade_smooth")
1707         layout.operator("object.shade_flat")
1708
1709         layout.separator()
1710
1711         layout.menu("VIEW3D_MT_object_animation")
1712         layout.menu("VIEW3D_MT_object_rigid_body")
1713
1714         layout.separator()
1715
1716         layout.menu("VIEW3D_MT_object_quick_effects")
1717
1718         layout.separator()
1719
1720         ob = context.active_object
1721         if ob and ob.type == 'GPENCIL' and context.gpencil_data:
1722             layout.operator_menu_enum("gpencil.convert", "type", text="Convert to")
1723         else:
1724             layout.operator_menu_enum("object.convert", "target")
1725
1726         layout.separator()
1727
1728         layout.menu("VIEW3D_MT_object_showhide")
1729
1730         layout.separator()
1731
1732         layout.operator_context = 'EXEC_DEFAULT'
1733         layout.operator("object.delete", text="Delete").use_global = False
1734         layout.operator("object.delete", text="Delete Global").use_global = True
1735
1736
1737 class VIEW3D_MT_object_animation(Menu):
1738     bl_label = "Animation"
1739
1740     def draw(self, context):
1741         layout = self.layout
1742
1743         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1744         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
1745         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
1746         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1747
1748         layout.separator()
1749
1750         layout.operator("nla.bake", text="Bake Action...")
1751
1752
1753 class VIEW3D_MT_object_rigid_body(Menu):
1754     bl_label = "Rigid Body"
1755
1756     def draw(self, context):
1757         layout = self.layout
1758
1759         layout.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
1760         layout.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
1761
1762         layout.separator()
1763
1764         layout.operator("rigidbody.objects_remove", text="Remove")
1765
1766         layout.separator()
1767
1768         layout.operator("rigidbody.shape_change", text="Change Shape")
1769         layout.operator("rigidbody.mass_calculate", text="Calculate Mass")
1770         layout.operator("rigidbody.object_settings_copy", text="Copy from Active")
1771         layout.operator("object.visual_transform_apply", text="Apply Transformation")
1772         layout.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
1773
1774         layout.separator()
1775
1776         layout.operator("rigidbody.connect", text="Connect")
1777
1778
1779 class VIEW3D_MT_object_clear(Menu):
1780     bl_label = "Clear"
1781
1782     def draw(self, context):
1783         layout = self.layout
1784
1785         layout.operator("object.location_clear", text="Location").clear_delta = False
1786         layout.operator("object.rotation_clear", text="Rotation").clear_delta = False
1787         layout.operator("object.scale_clear", text="Scale").clear_delta = False
1788
1789         layout.separator()
1790
1791         layout.operator("object.origin_clear", text="Origin")
1792
1793
1794 class VIEW3D_MT_object_context_menu(Menu):
1795     bl_label = "Object Context Menu"
1796
1797     def draw(self, context):
1798
1799         layout = self.layout
1800         view = context.space_data
1801
1802         obj = context.object
1803         is_eevee = context.scene.render.engine == 'BLENDER_EEVEE'
1804
1805         selected_objects_len = len(context.selected_objects)
1806
1807         # If nothing is selected
1808         # (disabled for now until it can be made more useful).
1809         '''
1810         if selected_objects_len == 0:
1811
1812             layout.menu("VIEW3D_MT_add", text="Add")
1813             layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
1814
1815             return
1816         '''
1817
1818         # If something is selected
1819         if obj is not None and obj.type in {'MESH', 'CURVE', 'SURFACE'}:
1820             layout.operator("object.shade_smooth", text="Shade Smooth")
1821             layout.operator("object.shade_flat", text="Shade Flat")
1822
1823             layout.separator()
1824
1825         if obj is None:
1826             pass
1827         elif obj.type == 'MESH':
1828             layout.operator_context = 'INVOKE_REGION_WIN'
1829             layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
1830
1831             layout.operator_context = 'INVOKE_DEFAULT'
1832             # If more than one object is selected
1833             if selected_objects_len > 1:
1834                 layout.operator("object.join")
1835
1836             layout.separator()
1837
1838         elif obj.type == 'CAMERA':
1839             layout.operator_context = 'INVOKE_REGION_WIN'
1840
1841             if obj.data.type == 'PERSP':
1842                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1843                 props.data_path_iter = "selected_editable_objects"
1844                 props.data_path_item = "data.lens"
1845                 props.input_scale = 0.1
1846                 if obj.data.lens_unit == 'MILLIMETERS':
1847                     props.header_text = "Camera Lens Angle: %.1fmm"
1848                 else:
1849                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1850
1851             else:
1852                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1853                 props.data_path_iter = "selected_editable_objects"
1854                 props.data_path_item = "data.ortho_scale"
1855                 props.input_scale = 0.01
1856                 props.header_text = "Camera Lens Scale: %.3f"
1857
1858             if not obj.data.dof_object:
1859                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1860                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1861                 else:
1862                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1863                     props.data_path_iter = "selected_editable_objects"
1864                     props.data_path_item = "data.dof_distance"
1865                     props.input_scale = 0.02
1866                     props.header_text = "DOF Distance: %.3f"
1867
1868             layout.separator()
1869
1870         elif obj.type in {'CURVE', 'FONT'}:
1871             layout.operator_context = 'INVOKE_REGION_WIN'
1872
1873             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1874             props.data_path_iter = "selected_editable_objects"
1875             props.data_path_item = "data.extrude"
1876             props.input_scale = 0.01
1877             props.header_text = "Extrude Size: %.3f"
1878
1879             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1880             props.data_path_iter = "selected_editable_objects"
1881             props.data_path_item = "data.offset"
1882             props.input_scale = 0.01
1883             props.header_text = "Width Size: %.3f"
1884
1885             layout.operator("object.convert", text="Convert to Mesh").target = 'MESH'
1886
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'}: