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