d6f27a3e0bc2cf9654c69d3fcfe46e68b3f6e5aa
[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         # If nothing is selected
1737         selected_objects_len = len(context.selected_objects)
1738         if selected_objects_len == 0:
1739
1740             layout.menu("VIEW3D_MT_add", text="Add")
1741             layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
1742
1743             return
1744
1745         # If something is selected
1746         if obj.type == 'MESH':
1747
1748             layout.operator("object.shade_smooth", text="Shade Smooth")
1749             layout.operator("object.shade_flat", text="Shade Flat")
1750
1751             layout.separator()
1752
1753             layout.operator_context = 'INVOKE_REGION_WIN'
1754             layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
1755
1756             layout.operator_context = 'INVOKE_DEFAULT'
1757             # If more than one object is selected
1758             if selected_objects_len > 1:
1759                 layout.operator("object.join")
1760
1761         if obj.type == 'CAMERA':
1762             layout.operator_context = 'INVOKE_REGION_WIN'
1763
1764             if obj.data.type == 'PERSP':
1765                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1766                 props.data_path_iter = "selected_editable_objects"
1767                 props.data_path_item = "data.lens"
1768                 props.input_scale = 0.1
1769                 if obj.data.lens_unit == 'MILLIMETERS':
1770                     props.header_text = "Camera Lens Angle: %.1fmm"
1771                 else:
1772                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1773
1774             else:
1775                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1776                 props.data_path_iter = "selected_editable_objects"
1777                 props.data_path_item = "data.ortho_scale"
1778                 props.input_scale = 0.01
1779                 props.header_text = "Camera Lens Scale: %.3f"
1780
1781             if not obj.data.dof_object:
1782                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1783                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1784                 else:
1785                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1786                     props.data_path_iter = "selected_editable_objects"
1787                     props.data_path_item = "data.dof_distance"
1788                     props.input_scale = 0.02
1789                     props.header_text = "DOF Distance: %.3f"
1790
1791         if obj.type in {'CURVE', 'FONT'}:
1792             layout.operator_context = 'INVOKE_REGION_WIN'
1793
1794             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1795             props.data_path_iter = "selected_editable_objects"
1796             props.data_path_item = "data.extrude"
1797             props.input_scale = 0.01
1798             props.header_text = "Extrude Size: %.3f"
1799
1800             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1801             props.data_path_iter = "selected_editable_objects"
1802             props.data_path_item = "data.offset"
1803             props.input_scale = 0.01
1804             props.header_text = "Width Size: %.3f"
1805
1806             layout.operator("object.convert", text="Convert to Mesh").target = 'MESH'
1807
1808             layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
1809
1810         if obj.type == 'GPENCIL':
1811             layout.operator("gpencil.convert", text="Convert to Path").type = 'PATH'
1812             layout.operator("gpencil.convert", text="Convert to Bezier Curves").type = 'CURVE'
1813             layout.operator("gpencil.convert", text="Convert to Mesh").type = 'POLY'
1814
1815             layout.operator_menu_enum("object.origin_set", text="Set Origin...", property="type")
1816
1817         if obj.type == 'EMPTY':
1818             layout.operator_context = 'INVOKE_REGION_WIN'
1819
1820             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
1821             props.data_path_iter = "selected_editable_objects"
1822             props.data_path_item = "empty_display_size"
1823             props.input_scale = 0.01
1824             props.header_text = "Empty Draw Size: %.3f"
1825
1826         if obj.type == 'LIGHT':
1827             light = obj.data
1828
1829             layout.operator_context = 'INVOKE_REGION_WIN'
1830
1831             emission_node = None
1832             if light.node_tree:
1833                 for node in light.node_tree.nodes:
1834                     if getattr(node, "type", None) == 'EMISSION':
1835                         emission_node = node
1836                         break
1837
1838             if is_eevee and not emission_node:
1839                 props = layout.operator("wm.context_modal_mouse", text="Energy")
1840                 props.data_path_iter = "selected_editable_objects"
1841                 props.data_path_item = "data.energy"
1842                 props.header_text = "Light Energy: %.3f"
1843
1844             if emission_node is not None:
1845                 props = layout.operator("wm.context_modal_mouse", text="Energy")
1846                 props.data_path_iter = "selected_editable_objects"
1847                 props.data_path_item = (
1848                     "data.node_tree"
1849                     ".nodes[\"" + emission_node.name + "\"]"
1850                     ".inputs[\"Strength\"].default_value"
1851                 )
1852                 props.header_text = "Light Energy: %.3f"
1853                 props.input_scale = 0.1
1854
1855             if light.type == 'AREA':
1856                 props = layout.operator("wm.context_modal_mouse", text="Size X")
1857                 props.data_path_iter = "selected_editable_objects"
1858                 props.data_path_item = "data.size"
1859                 props.header_text = "Light Size X: %.3f"
1860
1861                 if light.shape in {'RECTANGLE', 'ELLIPSE'}:
1862                     props = layout.operator("wm.context_modal_mouse", text="Size Y")
1863                     props.data_path_iter = "selected_editable_objects"
1864                     props.data_path_item = "data.size_y"
1865                     props.header_text = "Light Size Y: %.3f"
1866
1867             elif light.type in {'SPOT', 'POINT', 'SUN'}:
1868                 props = layout.operator("wm.context_modal_mouse", text="Radius")
1869                 props.data_path_iter = "selected_editable_objects"
1870                 props.data_path_item = "data.shadow_soft_size"
1871                 props.header_text = "Light Radius: %.3f"
1872
1873             if light.type == 'SPOT':
1874                 layout.separator()
1875
1876                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
1877                 props.data_path_iter = "selected_editable_objects"
1878                 props.data_path_item = "data.spot_size"
1879                 props.input_scale = 0.01
1880                 props.header_text = "Spot Size: %.2f"
1881
1882                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
1883                 props.data_path_iter = "selected_editable_objects"
1884                 props.data_path_item = "data.spot_blend"
1885                 props.input_scale = -0.01
1886                 props.header_text = "Spot Blend: %.2f"
1887
1888         layout.separator()
1889
1890         layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
1891         layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')
1892
1893         layout.separator()
1894
1895         layout.operator("object.duplicate_move", icon='DUPLICATE')
1896         layout.operator("object.duplicate_move_linked")
1897
1898         layout.separator()
1899
1900         layout.menu("VIEW3D_MT_snap")
1901         layout.menu("VIEW3D_MT_object_parent")
1902         layout.operator_context = 'INVOKE_REGION_WIN'
1903
1904         if view and view.local_view:
1905             layout.operator("view3d.localview_remove_from")
1906         else:
1907             layout.operator("object.move_to_collection")
1908
1909         layout.separator()
1910
1911         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1912
1913         layout.separator()
1914
1915         layout.operator_context = 'EXEC_DEFAULT'
1916         layout.operator("object.delete", text="Delete").use_global = False
1917
1918
1919 class VIEW3D_MT_object_shading(Menu):
1920     # XXX, this menu is a place to store shading operator in object mode
1921     bl_label = "Shading"
1922
1923     def draw(self, context):
1924         layout = self.layout
1925         layout.operator("object.shade_smooth", text="Smooth")
1926         layout.operator("object.shade_flat", text="Flat")
1927
1928
1929 class VIEW3D_MT_object_apply(Menu):
1930     bl_label = "Apply"
1931
1932     def draw(self, context):
1933         layout = self.layout
1934
1935         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1936         props.location, props.rotation, props.scale = True, False, False
1937
1938         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1939         props.location, props.rotation, props.scale = False, True, False
1940
1941         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1942         props.location, props.rotation, props.scale = False, False, True
1943         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1944         props.location, props.rotation, props.scale = False, True, True
1945
1946         layout.separator()
1947
1948         layout.operator(
1949             "object.transforms_to_deltas",
1950             text="Location to Deltas",
1951             text_ctxt=i18n_contexts.default,
1952         ).mode = 'LOC'
1953         layout.operator(
1954             "object.transforms_to_deltas",
1955             text="Rotation to Deltas",
1956             text_ctxt=i18n_contexts.default,
1957         ).mode = 'ROT'
1958         layout.operator(
1959             "object.transforms_to_deltas",
1960             text="Scale to Deltas",
1961             text_ctxt=i18n_contexts.default,
1962         ).mode = 'SCALE'
1963
1964         layout.operator(
1965             "object.transforms_to_deltas",
1966             text="All Transforms to Deltas",
1967             text_ctxt=i18n_contexts.default,
1968         ).mode = 'ALL'
1969         layout.operator("object.anim_transforms_to_deltas")
1970
1971         layout.separator()
1972
1973         layout.operator(
1974             "object.visual_transform_apply",
1975             text="Visual Transform",
1976             text_ctxt=i18n_contexts.default,
1977         )
1978         layout.operator(
1979             "object.convert",
1980             text="Visual Geometry to Mesh",
1981             text_ctxt=i18n_contexts.default,
1982         ).target = 'MESH'
1983         layout.operator("object.duplicates_make_real")
1984
1985
1986 class VIEW3D_MT_object_parent(Menu):
1987     bl_label = "Parent"
1988
1989     def draw(self, context):
1990         layout = self.layout
1991
1992         layout.operator_enum("object.parent_set", "type")
1993
1994         layout.separator()
1995
1996         layout.operator_enum("object.parent_clear", "type")
1997
1998
1999 class VIEW3D_MT_object_track(Menu):
2000     bl_label = "Track"
2001
2002     def draw(self, context):
2003         layout = self.layout
2004
2005         layout.operator_enum("object.track_set", "type")
2006
2007         layout.separator()
2008
2009         layout.operator_enum("object.track_clear", "type")
2010
2011
2012 class VIEW3D_MT_object_collection(Menu):
2013     bl_label = "Collection"
2014
2015     def draw(self, context):
2016         layout = self.layout
2017
2018         layout.operator("collection.create")
2019         # layout.operator_menu_enum("collection.objects_remove", "collection")  # BUGGY
2020         layout.operator("collection.objects_remove")
2021         layout.operator("collection.objects_remove_all")
2022
2023         layout.separator()
2024
2025         layout.operator("collection.objects_add_active")
2026         layout.operator("collection.objects_remove_active")
2027
2028
2029 class VIEW3D_MT_object_constraints(Menu):
2030     bl_label = "Constraints"
2031
2032     def draw(self, context):
2033         layout = self.layout
2034
2035         layout.operator("object.constraint_add_with_targets")
2036         layout.operator("object.constraints_copy")
2037
2038         layout.separator()
2039
2040         layout.operator("object.constraints_clear")
2041
2042
2043 class VIEW3D_MT_object_quick_effects(Menu):
2044     bl_label = "Quick Effects"
2045
2046     def draw(self, context):
2047         layout = self.layout
2048
2049         layout.operator("object.quick_fur")
2050         layout.operator("object.quick_explode")
2051         layout.operator("object.quick_smoke")
2052         layout.operator("object.quick_fluid")
2053
2054
2055 class VIEW3D_MT_object_showhide(Menu):
2056     bl_label = "Show/Hide"
2057
2058     def draw(self, context):
2059         layout = self.layout
2060
2061         layout.operator("object.hide_view_clear", text="Show Hidden")
2062
2063         layout.separator()
2064
2065         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
2066         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
2067
2068
2069 class VIEW3D_MT_make_single_user(Menu):
2070     bl_label = "Make Single User"
2071
2072     def draw(self, context):
2073         layout = self.layout
2074
2075         props = layout.operator("object.make_single_user", text="Object")
2076         props.object = True
2077         props.obdata = props.material = props.animation = False
2078
2079         props = layout.operator("object.make_single_user", text="Object & Data")
2080         props.object = props.obdata = True
2081         props.material = props.animation = False
2082
2083         props = layout.operator("object.make_single_user", text="Object & Data & Materials")
2084         props.object = props.obdata = props.material = True
2085         props.animation = False
2086
2087         props = layout.operator("object.make_single_user", text="Materials")
2088         props.material = True
2089         props.object = props.obdata = props.animation = False
2090
2091         props = layout.operator("object.make_single_user", text="Object Animation")
2092         props.animation = True
2093         props.object = props.obdata = props.material = False
2094
2095
2096 class VIEW3D_MT_make_links(Menu):
2097     bl_label = "Make Links"
2098
2099     def draw(self, context):
2100         layout = self.layout
2101         operator_context_default = layout.operator_context
2102
2103         if len(bpy.data.scenes) > 10:
2104             layout.operator_context = 'INVOKE_REGION_WIN'
2105             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
2106         else:
2107             layout.operator_context = 'EXEC_REGION_WIN'
2108             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene")
2109
2110         layout.separator()
2111
2112         layout.operator_context = operator_context_default
2113
2114         layout.operator_enum("object.make_links_data", "type")  # inline
2115
2116         layout.operator("object.join_uvs")  # stupid place to add this!
2117
2118
2119 class VIEW3D_MT_brush(Menu):
2120     bl_label = "Brush"
2121
2122     def draw(self, context):
2123         layout = self.layout
2124
2125         tool_settings = context.tool_settings
2126         settings = UnifiedPaintPanel.paint_settings(context)
2127         brush = getattr(settings, "brush", None)
2128
2129         ups = tool_settings.unified_paint_settings
2130         layout.prop(ups, "use_unified_size", text="Unified Size")
2131         layout.prop(ups, "use_unified_strength", text="Unified Strength")
2132         if context.image_paint_object or context.vertex_paint_object:
2133             layout.prop(ups, "use_unified_color", text="Unified Color")
2134         layout.separator()
2135
2136         # skip if no active brush
2137         if not brush:
2138             layout.label(text="No Brushes currently available", icon='INFO')
2139             return
2140
2141         # brush paint modes
2142         layout.menu("VIEW3D_MT_brush_paint_modes")
2143
2144         # brush tool
2145         if context.sculpt_object:
2146             layout.operator("brush.reset")
2147             layout.prop_menu_enum(brush, "sculpt_tool")
2148         elif context.image_paint_object:
2149             layout.prop_menu_enum(brush, "image_tool")
2150         elif context.vertex_paint_object:
2151             layout.prop_menu_enum(brush, "vertex_tool")
2152         elif context.weight_paint_object:
2153             layout.prop_menu_enum(brush, "weight_tool")
2154
2155         # TODO: still missing a lot of brush options here
2156
2157         # sculpt options
2158         if context.sculpt_object:
2159
2160             sculpt_tool = brush.sculpt_tool
2161
2162             layout.separator()
2163             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
2164             layout.separator()
2165
2166             if sculpt_tool != 'GRAB':
2167                 layout.prop_menu_enum(brush, "stroke_method")
2168
2169                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
2170                     layout.prop_menu_enum(brush, "direction")
2171
2172                 if sculpt_tool == 'LAYER':
2173                     layout.prop(brush, "use_persistent")
2174                     layout.operator("sculpt.set_persistent_base")
2175
2176
2177 class VIEW3D_MT_brush_paint_modes(Menu):
2178     bl_label = "Enabled Modes"
2179
2180     def draw(self, context):
2181         layout = self.layout
2182
2183         settings = UnifiedPaintPanel.paint_settings(context)
2184         brush = settings.brush
2185
2186         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
2187         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
2188         layout.prop(brush, "use_paint_weight", text="Weight Paint")
2189         layout.prop(brush, "use_paint_image", text="Texture Paint")
2190
2191
2192 class VIEW3D_MT_paint_vertex(Menu):
2193     bl_label = "Paint"
2194
2195     def draw(self, context):
2196         layout = self.layout
2197
2198         layout.operator("paint.vertex_color_set")
2199         layout.operator("paint.vertex_color_smooth")
2200         layout.operator("paint.vertex_color_dirt")
2201         layout.operator("paint.vertex_color_from_weight")
2202
2203         layout.separator()
2204
2205         layout.operator("paint.vertex_color_invert", text="Invert")
2206         layout.operator("paint.vertex_color_levels", text="Levels")
2207         layout.operator("paint.vertex_color_hsv", text="Hue Saturation Value")
2208         layout.operator("paint.vertex_color_brightness_contrast", text="Bright/Contrast")
2209
2210
2211 class VIEW3D_MT_hook(Menu):
2212     bl_label = "Hooks"
2213
2214     def draw(self, context):
2215         layout = self.layout
2216         layout.operator_context = 'EXEC_AREA'
2217         layout.operator("object.hook_add_newob")
2218         layout.operator("object.hook_add_selob").use_bone = False
2219         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
2220
2221         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
2222             layout.separator()
2223
2224             layout.operator_menu_enum("object.hook_assign", "modifier")
2225             layout.operator_menu_enum("object.hook_remove", "modifier")
2226
2227             layout.separator()
2228
2229             layout.operator_menu_enum("object.hook_select", "modifier")
2230             layout.operator_menu_enum("object.hook_reset", "modifier")
2231             layout.operator_menu_enum("object.hook_recenter", "modifier")
2232
2233
2234 class VIEW3D_MT_vertex_group(Menu):
2235     bl_label = "Vertex Groups"
2236
2237     def draw(self, context):
2238         layout = self.layout
2239
2240         layout.operator_context = 'EXEC_AREA'
2241         layout.operator("object.vertex_group_assign_new")
2242
2243         ob = context.active_object
2244         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
2245             if ob.vertex_groups.active:
2246                 layout.separator()
2247
2248                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
2249                 layout.operator(
2250                     "object.vertex_group_remove_from",
2251                     text="Remove from Active Group",
2252                 ).use_all_groups = False
2253                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
2254
2255         if ob.vertex_groups.active:
2256             layout.separator()
2257
2258             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
2259             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
2260             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
2261
2262
2263 class VIEW3D_MT_paint_weight(Menu):
2264     bl_label = "Weights"
2265
2266     @staticmethod
2267     def draw_generic(layout, is_editmode=False):
2268
2269         if not is_editmode:
2270
2271             layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
2272             layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
2273
2274             layout.separator()
2275
2276         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
2277         layout.operator("object.vertex_group_normalize", text="Normalize")
2278
2279         layout.separator()
2280
2281         layout.operator("object.vertex_group_mirror", text="Mirror")
2282         layout.operator("object.vertex_group_invert", text="Invert")
2283         layout.operator("object.vertex_group_clean", text="Clean")
2284
2285         layout.separator()
2286
2287         layout.operator("object.vertex_group_quantize", text="Quantize")
2288         layout.operator("object.vertex_group_levels", text="Levels")
2289         layout.operator("object.vertex_group_smooth", text="Smooth")
2290
2291         if not is_editmode:
2292             props = layout.operator("object.data_transfer", text="Transfer Weights")
2293             props.use_reverse_transfer = True
2294             props.data_type = 'VGROUP_WEIGHTS'
2295
2296         layout.operator("object.vertex_group_limit_total", text="Limit Total")
2297         layout.operator("object.vertex_group_fix", text="Fix Deforms")
2298
2299         if not is_editmode:
2300             layout.separator()
2301
2302             layout.operator("paint.weight_set")
2303
2304     def draw(self, context):
2305         self.draw_generic(self.layout, is_editmode=False)
2306
2307
2308 class VIEW3D_MT_sculpt(Menu):
2309     bl_label = "Sculpt"
2310
2311     def draw(self, context):
2312         layout = self.layout
2313
2314         tool_settings = context.tool_settings
2315         sculpt = tool_settings.sculpt
2316
2317         layout.prop(sculpt, "use_symmetry_x")
2318         layout.prop(sculpt, "use_symmetry_y")
2319         layout.prop(sculpt, "use_symmetry_z")
2320
2321         layout.separator()
2322
2323         layout.prop(sculpt, "lock_x")
2324         layout.prop(sculpt, "lock_y")
2325         layout.prop(sculpt, "lock_z")
2326
2327         layout.separator()
2328
2329         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
2330         layout.prop(sculpt, "show_low_resolution")
2331         layout.prop(sculpt, "show_brush")
2332         layout.prop(sculpt, "use_deform_only")
2333         layout.prop(sculpt, "show_diffuse_color")
2334         layout.prop(sculpt, "show_mask")
2335
2336
2337 class VIEW3D_MT_hide_mask(Menu):
2338     bl_label = "Hide/Mask"
2339
2340     def draw(self, context):
2341         layout = self.layout
2342
2343         props = layout.operator("paint.hide_show", text="Show All")
2344         props.action = 'SHOW'
2345         props.area = 'ALL'
2346
2347         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
2348         props.action = 'HIDE'
2349         props.area = 'INSIDE'
2350
2351         props = layout.operator("paint.hide_show", text="Show Bounding Box")
2352         props.action = 'SHOW'
2353         props.area = 'INSIDE'
2354
2355         props = layout.operator("paint.hide_show", text="Hide Masked")
2356         props.area = 'MASKED'
2357         props.action = 'HIDE'
2358
2359         layout.separator()
2360
2361         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
2362         props.mode = 'INVERT'
2363
2364         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
2365         props.mode = 'VALUE'
2366         props.value = 1
2367
2368         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
2369         props.mode = 'VALUE'
2370         props.value = 0
2371
2372         props = layout.operator("view3d.select_box", text="Box Mask")
2373         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
2374
2375
2376 class VIEW3D_MT_particle(Menu):
2377     bl_label = "Particle"
2378
2379     def draw(self, context):
2380         layout = self.layout
2381         tool_settings = context.tool_settings
2382
2383         particle_edit = tool_settings.particle_edit
2384
2385         layout.operator("particle.mirror")
2386
2387         layout.operator("particle.remove_doubles")
2388
2389         layout.separator()
2390
2391         if particle_edit.select_mode == 'POINT':
2392             layout.operator("particle.subdivide")
2393
2394         layout.operator("particle.unify_length")
2395         layout.operator("particle.rekey")
2396         layout.operator("particle.weight_set")
2397
2398         layout.separator()
2399
2400         layout.menu("VIEW3D_MT_particle_showhide")
2401
2402         layout.separator()
2403
2404         layout.operator("particle.delete")
2405
2406
2407 class VIEW3D_MT_particle_specials(Menu):
2408     bl_label = "Particle Context Menu"
2409
2410     def draw(self, context):
2411         layout = self.layout
2412         tool_settings = context.tool_settings
2413
2414         particle_edit = tool_settings.particle_edit
2415
2416         layout.operator("particle.rekey")
2417
2418         layout.separator()
2419
2420         layout.operator("particle.delete")
2421
2422         layout.separator()
2423
2424         layout.operator("particle.remove_doubles")
2425         layout.operator("particle.unify_length")
2426
2427         if particle_edit.select_mode == 'POINT':
2428             layout.operator("particle.subdivide")
2429
2430         layout.operator("particle.weight_set")
2431
2432         layout.separator()
2433
2434         layout.operator("particle.mirror")
2435
2436         if particle_edit.select_mode == 'POINT':
2437             layout.separator()
2438
2439             layout.operator("particle.select_all", text="All").action = 'SELECT'
2440             layout.operator("particle.select_all", text="None").action = 'DESELECT'
2441             layout.operator("particle.select_all", text="Invert").action = 'INVERT'
2442
2443             layout.separator()
2444
2445             layout.operator("particle.select_roots")
2446             layout.operator("particle.select_tips")
2447
2448             layout.separator()
2449
2450             layout.operator("particle.select_random")
2451
2452             layout.separator()
2453
2454             layout.operator("particle.select_more")
2455             layout.operator("particle.select_less")
2456
2457             layout.separator()
2458
2459             layout.operator("particle.select_linked")
2460
2461
2462 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
2463     _operator_name = "particle"
2464
2465
2466 class VIEW3D_MT_pose(Menu):
2467     bl_label = "Pose"
2468
2469     def draw(self, context):
2470         layout = self.layout
2471
2472         layout.menu("VIEW3D_MT_transform_armature")
2473
2474         layout.menu("VIEW3D_MT_pose_transform")
2475         layout.menu("VIEW3D_MT_pose_apply")
2476
2477         layout.menu("VIEW3D_MT_snap")
2478
2479         layout.separator()
2480
2481         layout.menu("VIEW3D_MT_object_animation")
2482
2483         layout.separator()
2484
2485         layout.menu("VIEW3D_MT_pose_slide")
2486         layout.menu("VIEW3D_MT_pose_propagate")
2487
2488         layout.separator()
2489
2490         layout.operator("pose.copy", icon='COPYDOWN')
2491         layout.operator("pose.paste", icon='PASTEDOWN').flipped = False
2492         layout.operator("pose.paste", icon='PASTEFLIPDOWN', text="Paste Pose Flipped").flipped = True
2493
2494         layout.separator()
2495
2496         layout.menu("VIEW3D_MT_pose_library")
2497         layout.menu("VIEW3D_MT_pose_motion")
2498         layout.menu("VIEW3D_MT_pose_group")
2499
2500         layout.separator()
2501
2502         layout.menu("VIEW3D_MT_object_parent")
2503         layout.menu("VIEW3D_MT_pose_ik")
2504         layout.menu("VIEW3D_MT_pose_constraints")
2505
2506         layout.separator()
2507
2508         layout.operator_context = 'EXEC_AREA'
2509         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
2510         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
2511         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
2512
2513         layout.operator("pose.flip_names")
2514
2515         layout.operator("pose.quaternions_flip")
2516
2517         layout.separator()
2518
2519         layout.operator_context = 'INVOKE_AREA'
2520         layout.operator("armature.armature_layers", text="Change Armature Layers...")
2521         layout.operator("pose.bone_layers", text="Change Bone Layers...")
2522
2523         layout.separator()
2524
2525         layout.menu("VIEW3D_MT_pose_showhide")
2526         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2527
2528
2529 class VIEW3D_MT_pose_transform(Menu):
2530     bl_label = "Clear Transform"
2531
2532     def draw(self, context):
2533         layout = self.layout
2534
2535         layout.operator("pose.transforms_clear", text="All")
2536
2537         layout.separator()
2538
2539         layout.operator("pose.loc_clear", text="Location")
2540         layout.operator("pose.rot_clear", text="Rotation")
2541         layout.operator("pose.scale_clear", text="Scale")
2542
2543         layout.separator()
2544
2545         layout.operator("pose.user_transforms_clear", text="Reset Unkeyed")
2546
2547
2548 class VIEW3D_MT_pose_slide(Menu):
2549     bl_label = "In-Betweens"
2550
2551     def draw(self, context):
2552         layout = self.layout
2553
2554         layout.operator("pose.push")
2555         layout.operator("pose.relax")
2556         layout.operator("pose.breakdown")
2557
2558
2559 class VIEW3D_MT_pose_propagate(Menu):
2560     bl_label = "Propagate"
2561
2562     def draw(self, context):
2563         layout = self.layout
2564
2565         layout.operator("pose.propagate").mode = 'WHILE_HELD'
2566
2567         layout.separator()
2568
2569         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
2570         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
2571
2572         layout.separator()
2573
2574         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
2575
2576         layout.separator()
2577
2578         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
2579
2580
2581 class VIEW3D_MT_pose_library(Menu):
2582     bl_label = "Pose Library"
2583
2584     def draw(self, context):
2585         layout = self.layout
2586
2587         layout.operator("poselib.browse_interactive", text="Browse Poses...")
2588
2589         layout.separator()
2590
2591         layout.operator("poselib.pose_add", text="Add Pose...")
2592         layout.operator("poselib.pose_rename", text="Rename Pose...")
2593         layout.operator("poselib.pose_remove", text="Remove Pose...")
2594
2595
2596 class VIEW3D_MT_pose_motion(Menu):
2597     bl_label = "Motion Paths"
2598
2599     def draw(self, context):
2600         layout = self.layout
2601
2602         layout.operator("pose.paths_calculate", text="Calculate")
2603         layout.operator("pose.paths_clear", text="Clear")
2604
2605
2606 class VIEW3D_MT_pose_group(Menu):
2607     bl_label = "Bone Groups"
2608
2609     def draw(self, context):
2610         layout = self.layout
2611
2612         pose = context.active_object.pose
2613
2614         layout.operator_context = 'EXEC_AREA'
2615         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
2616
2617         if pose.bone_groups:
2618             active_group = pose.bone_groups.active_index + 1
2619             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
2620
2621             layout.separator()
2622
2623             # layout.operator_context = 'INVOKE_AREA'
2624             layout.operator("pose.group_unassign")
2625             layout.operator("pose.group_remove")
2626
2627
2628 class VIEW3D_MT_pose_ik(Menu):
2629     bl_label = "Inverse Kinematics"
2630
2631     def draw(self, context):
2632         layout = self.layout
2633
2634         layout.operator("pose.ik_add")
2635         layout.operator("pose.ik_clear")
2636
2637
2638 class VIEW3D_MT_pose_constraints(Menu):
2639     bl_label = "Constraints"
2640
2641     def draw(self, context):
2642         layout = self.layout
2643
2644         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
2645         layout.operator("pose.constraints_copy")
2646         layout.operator("pose.constraints_clear")
2647
2648
2649 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
2650     _operator_name = "pose"
2651
2652
2653 class VIEW3D_MT_pose_apply(Menu):
2654     bl_label = "Apply"
2655
2656     def draw(self, context):
2657         layout = self.layout
2658
2659         layout.operator("pose.armature_apply")
2660         layout.operator("pose.visual_transform_apply")
2661
2662         layout.separator()
2663
2664         props = layout.operator("object.assign_property_defaults")
2665         props.process_bones = True
2666
2667
2668 class VIEW3D_MT_pose_specials(Menu):
2669     bl_label = "Pose Context Menu"
2670
2671     def draw(self, context):
2672         layout = self.layout
2673
2674         layout.operator_context = 'INVOKE_REGION_WIN'
2675
2676         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
2677
2678         layout.separator()
2679
2680         layout.operator("pose.copy", icon='COPYDOWN')
2681         layout.operator("pose.paste", icon='PASTEDOWN').flipped = False
2682         layout.operator("pose.paste", icon='PASTEFLIPDOWN', text="Paste X-Flipped Pose").flipped = True
2683
2684         layout.separator()
2685
2686         layout.operator("pose.paths_calculate", text="Calculate")
2687         layout.operator("pose.paths_clear", text="Clear")
2688
2689         layout.separator()
2690
2691         layout.operator("pose.push")
2692         layout.operator("pose.relax")
2693         layout.operator("pose.breakdown")
2694
2695         layout.separator()
2696
2697         layout.operator("pose.paths_calculate")
2698         layout.operator("pose.paths_clear")
2699
2700         layout.separator()
2701
2702         layout.operator("pose.hide").unselected = False
2703         layout.operator("pose.reveal")
2704
2705         layout.separator()
2706
2707         layout.operator("pose.user_transforms_clear")
2708
2709
2710 class BoneOptions:
2711     def draw(self, context):
2712         layout = self.layout
2713
2714         options = [
2715             "show_wire",
2716             "use_deform",
2717             "use_envelope_multiply",
2718             "use_inherit_rotation",
2719             "use_inherit_scale",
2720         ]
2721
2722         if context.mode == 'EDIT_ARMATURE':
2723             bone_props = bpy.types.EditBone.bl_rna.properties
2724             data_path_iter = "selected_bones"
2725             opt_suffix = ""
2726             options.append("lock")
2727         else:  # pose-mode
2728             bone_props = bpy.types.Bone.bl_rna.properties
2729             data_path_iter = "selected_pose_bones"
2730             opt_suffix = "bone."
2731
2732         for opt in options:
2733             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
2734                                     text_ctxt=i18n_contexts.default)
2735             props.data_path_iter = data_path_iter
2736             props.data_path_item = opt_suffix + opt
2737             props.type = self.type
2738
2739
2740 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
2741     bl_label = "Toggle Bone Options"
2742     type = 'TOGGLE'
2743
2744
2745 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
2746     bl_label = "Enable Bone Options"
2747     type = 'ENABLE'
2748
2749
2750 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
2751     bl_label = "Disable Bone Options"
2752     type = 'DISABLE'
2753
2754
2755 # ********** Edit Menus, suffix from ob.type **********
2756
2757
2758 class VIEW3D_MT_edit_mesh(Menu):
2759     bl_label = "Mesh"
2760
2761     def draw(self, context):
2762         layout = self.layout
2763
2764         with_bullet = bpy.app.build_options.bullet
2765
2766         layout.menu("VIEW3D_MT_transform")
2767         layout.menu("VIEW3D_MT_mirror")
2768         layout.menu("VIEW3D_MT_snap")
2769
2770         layout.separator()
2771
2772         layout.operator("mesh.duplicate_move", text="Duplicate")
2773         layout.menu("VIEW3D_MT_edit_mesh_extrude")
2774         layout.operator("mesh.split")
2775         layout.operator("mesh.bisect")
2776         layout.operator("mesh.knife_project")
2777
2778         if with_bullet:
2779             layout.operator("mesh.convex_hull")
2780
2781         layout.separator()
2782
2783         layout.operator("mesh.symmetrize")
2784         layout.operator("mesh.symmetry_snap")
2785
2786         layout.separator()
2787
2788         layout.menu("VIEW3D_MT_edit_mesh_normals")
2789         layout.menu("VIEW3D_MT_edit_mesh_shading")
2790         layout.menu("VIEW3D_MT_edit_mesh_weights")
2791         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
2792
2793         layout.separator()
2794
2795         layout.menu("VIEW3D_MT_edit_mesh_showhide")
2796         layout.operator_menu_enum("mesh.separate", "type")
2797         layout.menu("VIEW3D_MT_edit_mesh_clean")
2798
2799         layout.separator()
2800
2801         layout.menu("VIEW3D_MT_edit_mesh_delete")
2802
2803
2804 class VIEW3D_MT_edit_mesh_specials(Menu):
2805     bl_label = ""
2806
2807     def draw(self, context):
2808
2809         def count_selected_items_for_objects_in_mode():
2810             selected_verts_len = 0
2811             selected_edges_len = 0
2812             selected_faces_len = 0
2813             for ob in context.objects_in_mode_unique_data:
2814                 v, e, f = ob.data.count_selected_items()
2815                 selected_verts_len += v
2816                 selected_edges_len += e
2817                 selected_faces_len += f
2818             return (selected_verts_len, selected_edges_len, selected_faces_len)
2819
2820         is_vert_mode, is_edge_mode, is_face_mode = context.tool_settings.mesh_select_mode
2821         selected_verts_len, selected_edges_len, selected_faces_len = count_selected_items_for_objects_in_mode()
2822
2823         del count_selected_items_for_objects_in_mode
2824
2825         layout = self.layout
2826
2827         layout.operator_context = 'INVOKE_REGION_WIN'
2828
2829         # If nothing is selected
2830         if not (selected_verts_len or selected_edges_len or selected_faces_len):
2831             layout.menu("VIEW3D_MT_mesh_add", text="Add")
2832
2833             return
2834
2835         # Else something is selected
2836
2837         row = layout.row()
2838
2839         if is_vert_mode:
2840             col = row.column()
2841
2842             col.label(text="Vertex Context Menu", icon='VERTEXSEL')
2843             col.separator()
2844
2845             # Additive Operators
2846             col.operator("mesh.subdivide", text="Subdivide")
2847
2848             col.separator()
2849
2850             col.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
2851             col.operator("mesh.bevel", text="Bevel Vertices").vertex_only = True
2852
2853             if selected_verts_len > 1:
2854                 col.separator()
2855                 col.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
2856                 col.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2857                 col.operator("mesh.vert_connect", text="Connect Vertex Pairs")
2858
2859             col.separator()
2860
2861             # Deform Operators
2862             col.operator("transform.push_pull", text="Push/Pull")
2863             col.operator("transform.shrink_fatten", text="Shrink/Fatten")
2864             col.operator("transform.shear", text="Shear")
2865             col.operator("transform.vert_slide", text="Slide Vertices")
2866             col.operator("transform.vertex_random", text="Randomize Vertices")
2867             col.operator("mesh.vertices_smooth", text="Smooth Vertices")
2868             col.operator("mesh.vertices_smooth_laplacian", text="Smooth Laplacian")
2869
2870             col.separator()
2871
2872             col.menu("VIEW3D_MT_snap", text="Snap Vertices...")
2873             col.operator("transform.mirror", text="Mirror Vertices")
2874
2875             col.separator()
2876
2877             # Removal Operators
2878             if selected_verts_len > 1:
2879                 col.operator("mesh.merge", text="Merge Vertices...")
2880                 col.operator("mesh.remove_doubles", text="Remove Double Vertices")
2881             col.operator("mesh.dissolve_verts")
2882             col.operator("mesh.delete", text="Delete Vertices").type = 'VERT'
2883
2884         if is_edge_mode:
2885             render = context.scene.render
2886
2887             col = row.column()
2888             col.label(text="Edge Context Menu", icon='EDGESEL')
2889             col.separator()
2890
2891             # Additive Operators
2892             col.operator("mesh.subdivide", text="Subdivide")
2893
2894             col.separator()
2895
2896             col.operator("mesh.extrude_edges_move", text="Extrude Edges"),
2897             col.operator("mesh.bevel", text="Bevel Edges").vertex_only = False
2898             if selected_edges_len >= 2:
2899                 col.operator("mesh.bridge_edge_loops")
2900
2901             col.separator()
2902
2903             col.operator("mesh.loopcut_slide")
2904             col.operator("mesh.offset_edge_loops_slide")
2905             col.operator("mesh.knife_tool")
2906             col.operator("mesh.bisect")
2907             col.operator("mesh.bridge_edge_loops", text="Bridge Edge Loops")
2908
2909             col.separator()
2910
2911             # Deform Operators
2912             col.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2913             col.operator("transform.edge_slide")
2914             col.operator("mesh.edge_split")
2915
2916             col.separator()
2917
2918             # Edge Flags
2919             col.operator("transform.edge_crease")
2920             col.operator("transform.edge_bevelweight")
2921
2922             col.separator()
2923
2924             col.operator("mesh.mark_seam").clear = False
2925             col.operator("mesh.mark_seam", text="Clear Seam").clear = True
2926
2927             col.separator()
2928
2929             col.operator("mesh.mark_sharp")
2930             col.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
2931
2932             if render.use_freestyle:
2933                 col.separator()
2934
2935                 col.operator("mesh.mark_freestyle_edge").clear = False
2936                 col.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
2937
2938             col.separator()
2939
2940             # Removal Operators
2941             col.operator("mesh.unsubdivide")
2942             col.operator("mesh.dissolve_edges")
2943             col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
2944
2945         if is_face_mode:
2946             col = row.column()
2947
2948             col.label(text="Face Context Menu", icon='FACESEL')
2949             col.separator()
2950
2951             # Additive Operators
2952             col.operator("mesh.subdivide", text="Subdivide")
2953
2954             col.separator()
2955
2956             col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
2957             col.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
2958             col.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
2959
2960             col.operator("mesh.inset"),
2961             col.operator("mesh.poke")
2962
2963             if selected_faces_len >= 2:
2964                 col.operator("mesh.bridge_edge_loops", text="Bridge Faces")
2965
2966             col.separator()
2967
2968             # Modify Operators
2969             col.menu("VIEW3D_MT_uv_map", text="UV Unwrap Faces...")
2970
2971             col.separator()
2972
2973             props = col.operator("mesh.quads_convert_to_tris")
2974             props.quad_method = props.ngon_method = 'BEAUTY'
2975             col.operator("mesh.tris_convert_to_quads")
2976
2977             col.separator()
2978
2979             col.operator("mesh.faces_shade_smooth")
2980             col.operator("mesh.faces_shade_flat")
2981
2982             col.separator()
2983
2984             # Removal Operators
2985             col.operator("mesh.unsubdivide")
2986             col.operator("mesh.dissolve_faces")
2987             col.operator("mesh.delete", text="Delete Faces").type = 'FACE'
2988
2989
2990 class VIEW3D_MT_edit_mesh_select_mode(Menu):
2991     bl_label = "Mesh Select Mode"
2992
2993     def draw(self, context):
2994         layout = self.layout
2995
2996         layout.operator_context = 'INVOKE_REGION_WIN'
2997         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
2998         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
2999         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
3000
3001
3002 class VIEW3D_MT_edit_mesh_extrude(Menu):
3003     bl_label = "Extrude"
3004
3005     _extrude_funcs = {
3006         'VERT': lambda layout:
3007             layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
3008         'EDGE': lambda layout:
3009             layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
3010         'REGION': lambda layout:
3011             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
3012         'REGION_VERT_NORMAL': lambda layout:
3013             layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
3014         'FACE': lambda layout:
3015             layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
3016     }
3017
3018     @staticmethod
3019     def extrude_options(context):
3020         tool_settings = context.tool_settings
3021         select_mode = tool_settings.mesh_select_mode
3022         mesh = context.object.data
3023
3024         menu = []
3025         if mesh.total_face_sel:
3026             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
3027         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
3028             menu += ['EDGE']
3029         if mesh.total_vert_sel and select_mode[0]:
3030             menu += ['VERT']
3031
3032         # should never get here
3033         return menu
3034
3035     def draw(self, context):
3036         layout = self.layout
3037         layout.operator_context = 'INVOKE_REGION_WIN'
3038
3039         for menu_id in self.extrude_options(context):
3040             self._extrude_funcs[menu_id](layout)
3041
3042
3043 class VIEW3D_MT_edit_mesh_vertices(Menu):
3044     bl_label = "Vertex"
3045
3046     def draw(self, context):
3047         layout = self.layout
3048         layout.operator_context = 'INVOKE_REGION_WIN'
3049
3050         layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices"),
3051         layout.operator("mesh.bevel", text="Bevel Vertices").vertex_only = True
3052
3053         layout.separator()
3054
3055         layout.operator("mesh.edge_face_add", text="New Edge/Face from Vertices")
3056         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
3057         layout.operator("mesh.vert_connect", text="Connect Vertex Pairs")
3058
3059         layout.separator()
3060
3061         props = layout.operator("mesh.rip_move", text="Rip Vertices")
3062         props.MESH_OT_rip.use_fill = False
3063         props = layout.operator("mesh.rip_move", text="Rip Vertices and Fill")
3064         props.MESH_OT_rip.use_fill = True
3065         layout.operator("mesh.rip_edge_move", text="Rip Vertices and Extend")
3066
3067         layout.separator()
3068
3069         layout.operator("transform.vert_slide", text="Slide Vertices")
3070         layout.operator("mesh.vertices_smooth", text="Smooth Vertices")
3071
3072         layout.separator()
3073
3074         layout.operator("mesh.blend_from_shape")
3075         layout.operator("mesh.shape_propagate_to_all", text="Propagate to Shapes")
3076
3077         layout.separator()
3078
3079         layout.operator("mesh.merge", text="Merge Vertices")
3080         layout.operator("mesh.remove_doubles", text="Remove Double Vertices")
3081
3082         layout.separator()
3083
3084         layout.menu("VIEW3D_MT_vertex_group")
3085         layout.menu("VIEW3D_MT_hook")
3086
3087         layout.separator()
3088
3089         layout.operator("object.vertex_parent_set")
3090
3091
3092 class VIEW3D_MT_edit_mesh_edges_data(Menu):
3093     bl_label = "Edge Data"
3094
3095     def draw(self, context):
3096         layout = self.layout
3097
3098         render = context.scene.render
3099
3100         layout.operator_context = 'INVOKE_REGION_WIN'
3101
3102         layout.operator("transform.edge_crease")
3103         layout.operator("transform.edge_bevelweight")
3104
3105         layout.separator()
3106
3107         layout.operator("mesh.mark_seam").clear = False
3108         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
3109
3110         layout.separator()
3111
3112         layout.operator("mesh.mark_sharp")
3113         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
3114
3115         layout.operator("mesh.mark_sharp", text="Mark Sharp from Vertices").use_verts = True
3116         props = layout.operator("mesh.mark_sharp", text="Clear Sharp from Vertices")
3117         props.use_verts = True
3118         props.clear = True
3119
3120         if render.use_freestyle:
3121             layout.separator()
3122
3123             layout.operator("mesh.mark_freestyle_edge").clear = False
3124             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
3125
3126
3127 class VIEW3D_MT_edit_mesh_edges(Menu):
3128     bl_label = "Edge"
3129
3130     def draw(self, context):
3131         layout = self.layout
3132
3133         with_freestyle = bpy.app.build_options.freestyle
3134
3135         layout.operator_context = 'INVOKE_REGION_WIN'
3136
3137         layout.operator("mesh.extrude_edges_move", text="Extrude Edges"),
3138         layout.operator("mesh.bevel", text="Bevel Edges").vertex_only = False
3139         layout.operator("mesh.bridge_edge_loops")
3140
3141         layout.separator()
3142
3143         layout.operator("mesh.subdivide")
3144         layout.operator("mesh.subdivide_edgering")
3145         layout.operator("mesh.unsubdivide")
3146
3147         layout.separator()
3148
3149         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
3150         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
3151
3152         layout.separator()
3153
3154         layout.operator("transform.edge_slide")
3155         layout.operator("mesh.edge_split")
3156
3157         layout.separator()
3158
3159         layout.operator("transform.edge_crease")
3160         layout.operator("transform.edge_bevelweight")
3161
3162         layout.separator()
3163
3164         layout.operator("mesh.mark_seam").clear = False
3165         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
3166
3167         layout.separator()
3168
3169         layout.operator("mesh.mark_sharp")
3170         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
3171
3172         layout.operator("mesh.mark_sharp", text="Mark Sharp from Vertices").use_verts = True
3173         props = layout.operator("mesh.mark_sharp", text="Clear Sharp from Vertices")
3174         props.use_verts = True
3175         props.clear = True
3176
3177         if with_freestyle:
3178             layout.separator()
3179
3180             layout.operator("mesh.mark_freestyle_edge").clear = False
3181             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
3182
3183
3184 class VIEW3D_MT_edit_mesh_faces_data(Menu):
3185     bl_label = "Face Data"
3186
3187     def draw(self, context):
3188         layout = self.layout
3189
3190         with_freestyle = bpy.app.build_options.freestyle
3191
3192         layout.operator_context = 'INVOKE_REGION_WIN'
3193
3194         layout.operator("mesh.colors_rotate")
3195         layout.operator("mesh.colors_reverse")
3196
3197         layout.separator()
3198
3199         layout.operator("mesh.uvs_rotate")
3200         layout.operator("mesh.uvs_reverse")
3201
3202         layout.separator()
3203
3204         if with_freestyle:
3205             layout.operator("mesh.mark_freestyle_face").clear = False
3206             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
3207
3208
3209 class VIEW3D_MT_edit_mesh_faces(Menu):
3210     bl_label = "Face"
3211     bl_idname = "VIEW3D_MT_edit_mesh_faces"
3212
3213     def draw(self, context):
3214         layout = self.layout
3215
3216         layout.operator_context = 'INVOKE_REGION_WIN'
3217
3218         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Faces"),
3219         layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Extrude Faces Along Normals"),
3220         layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces"),
3221
3222         layout.separator()
3223
3224         layout.operator("mesh.inset")
3225         layout.operator("mesh.poke")
3226         props = layout.operator("mesh.quads_convert_to_tris")
3227         props.quad_method = props.ngon_method = 'BEAUTY'
3228         layout.operator("mesh.tris_convert_to_quads")
3229         layout.operator("mesh.solidify", text="Solidify Faces")
3230         layout.operator("mesh.wireframe")
3231
3232         layout.separator()
3233
3234         layout.operator("mesh.fill")
3235         layout.operator("mesh.fill_grid")
3236         layout.operator("mesh.beautify_fill")
3237
3238         layout.separator()
3239
3240         layout.operator("mesh.intersect")
3241         layout.operator("mesh.intersect_boolean")
3242
3243         layout.separator()
3244
3245         layout.operator("mesh.face_split_by_edges")
3246
3247         layout.separator()
3248
3249         layout.operator("mesh.faces_shade_smooth")
3250         layout.operator("mesh.faces_shade_flat")
3251
3252         layout.separator()
3253
3254         layout.menu("VIEW3D_MT_edit_mesh_faces_data")
3255
3256
3257 class VIEW3D_MT_edit_mesh_normals(Menu):
3258     bl_label = "Normals"
3259
3260     def draw(self, context):
3261         layout = self.layout
3262
3263         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
3264         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
3265
3266         layout.separator()
3267
3268         layout.operator("mesh.flip_normals")
3269         layout.operator("mesh.set_normals_from_faces", text="Set From Faces")
3270
3271         layout.operator("transform.rotate_normal", text="Rotate Normal")
3272         layout.operator("mesh.point_normals", text="Point normals to target")
3273
3274         layout.operator("mesh.merge_normals", text="Merge")
3275         layout.operator("mesh.split_normals", text="Split")
3276
3277         layout.operator("mesh.average_normals", text="Average Normals")
3278
3279         layout.label(text="Normal Vector")
3280
3281         layout.operator("mesh.normals_tools", text="Copy").mode = 'COPY'
3282         layout.operator("mesh.normals_tools", text="Paste").mode = 'PASTE'
3283
3284         layout.operator("mesh.normals_tools", text="Multiply").mode = 'MULTIPLY'
3285         layout.operator("mesh.normals_tools", text="Add").mode = 'ADD'
3286
3287         layout.operator("mesh.normals_tools", text="Reset").mode = 'RESET'
3288
3289         layout.operator("mesh.smoothen_normals", text="Smoothen")
3290
3291         layout.label(text="Face Strength")
3292         layout.operator("mesh.mod_weighted_strength", text="Face Select", icon='FACESEL').set = False
3293         layout.operator("mesh.mod_weighted_strength", text="Set Strength", icon='ADD').set = True
3294
3295
3296 class VIEW3D_MT_edit_mesh_shading(Menu):
3297     bl_label = "Shading"
3298
3299     def draw(self, context):
3300         layout = self.layout
3301
3302         layout.operator("mesh.faces_shade_smooth", text="Smooth Faces")
3303         layout.operator("mesh.faces_shade_flat", text="Flat Faces")
3304
3305         layout.separator()
3306
3307         layout.operator("mesh.mark_sharp", text="Smooth Edges").clear = True
3308         layout.operator("mesh.mark_sharp", text="Sharp Edges")
3309
3310         layout.separator()
3311
3312         props = layout.operator("mesh.mark_sharp", text="Smooth Vertices")
3313         props.use_verts = True
3314         props.clear = True
3315
3316         layout.operator("mesh.mark_sharp", text="Sharp Vertices").use_verts = True
3317
3318
3319 class VIEW3D_MT_edit_mesh_weights(Menu):
3320     bl_label = "Weights"
3321
3322     def draw(self, context):
3323         VIEW3D_MT_paint_weight.draw_generic(self.layout, is_editmode=True)
3324
3325
3326 class VIEW3D_MT_edit_mesh_clean(Menu):
3327     bl_label = "Clean Up"
3328
3329     def draw(self, context):
3330         layout = self.layout
3331
3332         layout.operator("mesh.delete_loose")
3333
3334         layout.separator()
3335
3336         layout.operator("mesh.decimate")
3337         layout.operator("mesh.dissolve_degenerate")
3338         layout.operator("mesh.dissolve_limited")
3339         layout.operator("mesh.face_make_planar")
3340
3341         layout.separator()
3342
3343         layout.operator("mesh.vert_connect_nonplanar")
3344         layout.operator("mesh.vert_connect_concave")
3345         layout.operator("mesh.remove_doubles")
3346         layout.operator("mesh.fill_holes")
3347
3348
3349 class VIEW3D_MT_edit_mesh_delete(Menu):
3350     bl_label = "Delete"
3351
3352     def draw(self, context):
3353         layout = self.layout
3354
3355         layout.operator_enum("mesh.delete", "type")
3356
3357         layout.separator()
3358
3359         layout.operator("mesh.dissolve_verts")
3360         layout.operator("mesh.dissolve_edges")
3361         layout.operator("mesh.dissolve_faces")
3362
3363         layout.separator()
3364
3365         layout.operator("mesh.dissolve_limited")
3366
3367         layout.separator()
3368
3369         layout.operator("mesh.edge_collapse")
3370         layout.operator("mesh.delete_edgeloop", text="Edge Loops")
3371
3372
3373 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
3374     _operator_name = "mesh"
3375
3376
3377 class VIEW3D_MT_edit_gpencil_delete(Menu):
3378     bl_label = "Delete"
3379
3380     def draw(self, context):
3381         layout = self.layout
3382
3383         layout.operator_enum("gpencil.delete", "type")
3384
3385         layout.separator()
3386
3387         layout.operator_enum("gpencil.dissolve", "type")
3388
3389         layout.separator()
3390
3391         layout.operator("gpencil.active_frames_delete_all")
3392 # Edit Curve
3393 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
3394
3395
3396 def draw_curve(self, context):
3397     layout = self.layout
3398
3399     layout.menu("VIEW3D_MT_transform")
3400     layout.menu("VIEW3D_MT_mirror")
3401     layout.menu("VIEW3D_MT_snap")
3402
3403     layout.separator()
3404
3405     layout.operator("curve.spin")
3406     layout.operator("curve.duplicate_move")
3407
3408     layout.separator()
3409
3410     layout.operator("curve.split")
3411     layout.operator("curve.separate")
3412     layout.operator("curve.cyclic_toggle")
3413     layout.operator_menu_enum("curve.spline_type_set", "type")
3414
3415     layout.separator()
3416
3417     layout.menu("VIEW3D_MT_edit_curve_showhide")
3418     layout.menu("VIEW3D_MT_edit_curve_clean")
3419     layout.menu("VIEW3D_MT_edit_curve_delete")
3420
3421
3422 class VIEW3D_MT_edit_curve(Menu):
3423     bl_label = "Curve"
3424
3425     draw = draw_curve
3426
3427
3428 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
3429     bl_label = "Control Points"
3430
3431     def draw(self, context):
3432         layout = self.layout
3433
3434         edit_object = context.edit_object
3435
3436         if edit_object.type in {'CURVE', 'SURFACE'}:
3437             layout.operator("curve.extrude_move")
3438
3439             layout.separator()
3440
3441             layout.operator("curve.make_segment")
3442
3443             layout.separator()
3444
3445             if edit_object.type == 'CURVE':
3446                 layout.operator("transform.tilt")
3447                 layout.operator("curve.tilt_clear")
3448
3449                 layout.separator()
3450
3451                 layout.operator_menu_enum("curve.handle_type_set", "type")
3452                 layout.operator("curve.normals_make_consistent")
3453
3454                 layout.separator()
3455
3456             layout.operator("curve.smooth")
3457             if edit_object.type == 'CURVE':
3458                 layout.operator("curve.smooth_weight")
3459                 layout.operator("curve.smooth_radius")
3460                 layout.operator("curve.smooth_tilt")
3461
3462             layout.separator()
3463
3464         layout.menu("VIEW3D_MT_hook")
3465
3466         layout.separator()
3467
3468         layout.operator("object.vertex_parent_set")
3469
3470
3471 class VIEW3D_MT_edit_curve_segments(Menu):
3472     bl_label = "Segments"
3473
3474     def draw(self, context):
3475         layout = self.layout
3476
3477         layout.operator("curve.subdivide")
3478         layout.operator("curve.switch_direction")
3479
3480
3481 class VIEW3D_MT_edit_curve_clean(Menu):
3482     bl_label = "Clean Up"
3483
3484     def draw(self, context):
3485         layout = self.layout
3486
3487         layout.operator("curve.decimate")
3488
3489
3490 class VIEW3D_MT_edit_curve_specials(Menu):
3491     bl_label = "Curve Context Menu"
3492
3493     def draw(self, context):
3494         # TODO(campbell): match mesh vertex menu.
3495
3496         layout = self.layout
3497
3498         layout.operator_context = 'INVOKE_DEFAULT'
3499
3500         layout.operator("curve.subdivide")
3501         layout.operator("curve.switch_direction")
3502
3503         layout.separator()
3504
3505         layout.operator("curve.duplicate_move")
3506         layout.operator("curve.split")
3507         layout.operator("curve.cyclic_toggle")
3508         layout.operator_menu_enum("curve.spline_type_set", "type")
3509
3510         layout.separator()
3511
3512         layout.operator("curve.make_segment")
3513
3514         layout.separator()
3515
3516         layout.operator("transform.tilt")
3517         layout.operator("curve.tilt_clear")
3518
3519         layout.separator()
3520
3521         layout.operator_menu_enum("curve.handle_type_set", "type")
3522         layout.operator("curve.normals_make_consistent")
3523
3524         layout.separator()
3525
3526         layout.operator("curve.spline_weight_set")
3527         layout.operator("curve.radius_set")
3528
3529         layout.separator()
3530
3531         layout.menu("VIEW3D_MT_mirror")
3532         layout.menu("VIEW3D_MT_snap")
3533
3534         layout.separator()
3535
3536         layout.operator("curve.decimate")
3537         layout.operator("curve.delete", text="Delete Point").type = 'VERT'
3538         layout.operator("curve.delete", text="Delete Segment").type = 'SEGMENT'
3539         layout.operator("curve.dissolve_verts")
3540
3541
3542 class VIEW3D_MT_edit_curve_delete(Menu):
3543     bl_label = "Delete"
3544
3545     def draw(self, context):
3546         layout = self.layout
3547
3548         layout.operator_enum("curve.delete", "type")
3549
3550         layout.separator()
3551
3552         layout.operator("curve.dissolve_verts")
3553
3554
3555 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
3556     _operator_name = "curve"
3557
3558