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