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