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