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