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