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