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