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