Merge branch 'master' into blender2.8
[blender.git] / release / scripts / startup / bl_ui / space_view3d.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from .properties_grease_pencil_common import (
23     GreasePencilDataPanel,
24     GreasePencilPaletteColorPanel,
25 )
26 from .properties_paint_common import UnifiedPaintPanel
27 from bpy.app.translations import contexts as i18n_contexts
28
29
30 class VIEW3D_HT_header(Header):
31     bl_space_type = 'VIEW_3D'
32
33     def draw(self, context):
34         layout = self.layout
35
36         view = context.space_data
37         # mode_string = context.mode
38         obj = context.active_object
39         toolsettings = context.tool_settings
40
41         row = layout.row(align=True)
42         row.template_header()
43
44         VIEW3D_MT_editor_menus.draw_collapsible(context, layout)
45
46         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
47         row = layout
48         layout.template_header_3D()
49
50         if obj:
51             mode = obj.mode
52             # Particle edit
53             if mode == 'PARTICLE_EDIT':
54                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
55
56             # Occlude geometry
57             if ((view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH'))) or
58                     (mode in {'WEIGHT_PAINT', 'VERTEX_PAINT'})):
59                 row.prop(view, "use_occlude_geometry", text="")
60
61             # Proportional editing
62             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
63                 row = layout.row(align=True)
64                 row.prop(toolsettings, "proportional_edit", icon_only=True)
65                 if toolsettings.proportional_edit != 'DISABLED':
66                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
67             elif mode in {'EDIT', 'PARTICLE_EDIT'}:
68                 row = layout.row(align=True)
69                 row.prop(toolsettings, "proportional_edit", icon_only=True)
70                 if toolsettings.proportional_edit != 'DISABLED':
71                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
72             elif mode == 'OBJECT':
73                 row = layout.row(align=True)
74                 row.prop(toolsettings, "use_proportional_edit_objects", icon_only=True)
75                 if toolsettings.use_proportional_edit_objects:
76                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
77         else:
78             # Proportional editing
79             if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
80                 row = layout.row(align=True)
81                 row.prop(toolsettings, "proportional_edit", icon_only=True)
82                 if toolsettings.proportional_edit != 'DISABLED':
83                     row.prop(toolsettings, "proportional_edit_falloff", icon_only=True)
84
85         # Snap
86         show_snap = False
87         if obj is None:
88             show_snap = True
89         else:
90             if mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
91                 show_snap = True
92             else:
93                 paint_settings = UnifiedPaintPanel.paint_settings(context)
94                 if paint_settings:
95                     brush = paint_settings.brush
96                     if brush and brush.stroke_method == 'CURVE':
97                         show_snap = True
98
99         if show_snap:
100             snap_element = toolsettings.snap_element
101             row = layout.row(align=True)
102             row.prop(toolsettings, "use_snap", text="")
103             row.prop(toolsettings, "snap_element", icon_only=True)
104             if snap_element == 'INCREMENT':
105                 row.prop(toolsettings, "use_snap_grid_absolute", text="")
106             else:
107                 row.prop(toolsettings, "snap_target", text="")
108                 if obj:
109                     if mode == 'EDIT':
110                         row.prop(toolsettings, "use_snap_self", text="")
111                     if mode in {'OBJECT', 'POSE', 'EDIT'} and snap_element != 'VOLUME':
112                         row.prop(toolsettings, "use_snap_align_rotation", text="")
113
114             if snap_element == 'VOLUME':
115                 row.prop(toolsettings, "use_snap_peel_object", text="")
116             elif snap_element == 'FACE':
117                 row.prop(toolsettings, "use_snap_project", text="")
118
119         # AutoMerge editing
120         if obj:
121             if (mode == 'EDIT' and obj.type == 'MESH'):
122                 layout.prop(toolsettings, "use_mesh_automerge", text="", icon='AUTOMERGE_ON')
123
124         # OpenGL render
125         row = layout.row(align=True)
126         row.operator("render.opengl", text="", icon='RENDER_STILL')
127         row.operator("render.opengl", text="", icon='RENDER_ANIMATION').animation = True
128
129         # Pose
130         if obj and mode == 'POSE':
131             row = layout.row(align=True)
132             row.operator("pose.copy", text="", icon='COPYDOWN')
133             row.operator("pose.paste", text="", icon='PASTEDOWN').flipped = False
134             row.operator("pose.paste", text="", icon='PASTEFLIPDOWN').flipped = True
135
136         # GPencil
137         if context.gpencil_data and context.gpencil_data.use_stroke_edit_mode:
138             row = layout.row(align=True)
139             row.operator("gpencil.copy", text="", icon='COPYDOWN')
140             row.operator("gpencil.paste", text="", icon='PASTEDOWN')
141
142             # XXX: icon
143             layout.prop(context.gpencil_data, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
144
145             row = layout.row(align=True)
146             row.prop(context.tool_settings.gpencil_sculpt, "use_select_mask")
147             row.prop(context.tool_settings.gpencil_sculpt, "selection_alpha", slider=True)
148
149
150 class VIEW3D_MT_editor_menus(Menu):
151     bl_space_type = 'VIEW3D_MT_editor_menus'
152     bl_label = ""
153
154     def draw(self, context):
155         self.draw_menus(self.layout, context)
156
157     @staticmethod
158     def draw_menus(layout, context):
159         obj = context.active_object
160         mode_string = context.mode
161         edit_object = context.edit_object
162         gp_edit = context.gpencil_data and context.gpencil_data.use_stroke_edit_mode
163
164         layout.menu("VIEW3D_MT_view")
165
166         # Select Menu
167         if gp_edit:
168             layout.menu("VIEW3D_MT_select_gpencil")
169         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
170             mesh = obj.data
171             if mesh.use_paint_mask:
172                 layout.menu("VIEW3D_MT_select_paint_mask")
173             elif mesh.use_paint_mask_vertex and mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
174                 layout.menu("VIEW3D_MT_select_paint_mask_vertex")
175         elif mode_string != 'SCULPT':
176             layout.menu("VIEW3D_MT_select_%s" % mode_string.lower())
177
178         if gp_edit:
179             pass
180         elif mode_string == 'OBJECT':
181             layout.menu("INFO_MT_add", text="Add")
182         elif mode_string == 'EDIT_MESH':
183             layout.menu("INFO_MT_mesh_add", text="Add")
184         elif mode_string == 'EDIT_CURVE':
185             layout.menu("INFO_MT_curve_add", text="Add")
186         elif mode_string == 'EDIT_SURFACE':
187             layout.menu("INFO_MT_surface_add", text="Add")
188         elif mode_string == 'EDIT_METABALL':
189             layout.menu("INFO_MT_metaball_add", text="Add")
190         elif mode_string == 'EDIT_ARMATURE':
191             layout.menu("INFO_MT_edit_armature_add", text="Add")
192
193         if gp_edit:
194             layout.menu("VIEW3D_MT_edit_gpencil")
195         elif edit_object:
196             layout.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
197         elif obj:
198             if mode_string != 'PAINT_TEXTURE':
199                 layout.menu("VIEW3D_MT_%s" % mode_string.lower())
200             if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
201                 layout.menu("VIEW3D_MT_brush")
202             if mode_string == 'SCULPT':
203                 layout.menu("VIEW3D_MT_hide_mask")
204         else:
205             layout.menu("VIEW3D_MT_object")
206
207
208 # ********** Menu **********
209
210
211 # ********** Utilities **********
212
213
214 class ShowHideMenu:
215     bl_label = "Show/Hide"
216     _operator_name = ""
217
218     def draw(self, context):
219         layout = self.layout
220
221         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
222         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
223         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
224
225
226 # Standard transforms which apply to all cases
227 # NOTE: this doesn't seem to be able to be used directly
228 class VIEW3D_MT_transform_base(Menu):
229     bl_label = "Transform"
230
231     # TODO: get rid of the custom text strings?
232     def draw(self, context):
233         layout = self.layout
234
235         layout.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         layout.menu("VIEW3D_MT_object_shading")
1438
1439         layout.separator()
1440
1441         layout.menu("VIEW3D_MT_object_parent")
1442         layout.menu("VIEW3D_MT_object_group")
1443         layout.menu("VIEW3D_MT_snap")
1444
1445         layout.separator()
1446
1447         layout.operator("object.duplicate_move")
1448         layout.operator("object.duplicate_move_linked")
1449         layout.operator("object.join")
1450         layout.separator()
1451         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
1452         layout.menu("VIEW3D_MT_object_relations")
1453         layout.menu("VIEW3D_MT_object_constraints")
1454         layout.menu("VIEW3D_MT_object_track")
1455
1456         layout.separator()
1457
1458         layout.menu("VIEW3D_MT_object_animation")
1459         layout.menu("VIEW3D_MT_object_rigid_body")
1460
1461         layout.separator()
1462
1463         layout.menu("VIEW3D_MT_object_quick_effects")
1464
1465         layout.separator()
1466
1467         layout.operator_menu_enum("object.convert", "target")
1468
1469
1470 class VIEW3D_MT_object_animation(Menu):
1471     bl_label = "Animation"
1472
1473     def draw(self, context):
1474         layout = self.layout
1475
1476         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1477         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
1478         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
1479         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1480
1481         layout.separator()
1482
1483         layout.operator("nla.bake", text="Bake Action...")
1484
1485
1486 class VIEW3D_MT_object_rigid_body(Menu):
1487     bl_label = "Rigid Body"
1488
1489     def draw(self, context):
1490         layout = self.layout
1491
1492         layout.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
1493         layout.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
1494
1495         layout.separator()
1496
1497         layout.operator("rigidbody.objects_remove", text="Remove")
1498
1499         layout.separator()
1500
1501         layout.operator("rigidbody.shape_change", text="Change Shape")
1502         layout.operator("rigidbody.mass_calculate", text="Calculate Mass")
1503         layout.operator("rigidbody.object_settings_copy", text="Copy from Active")
1504         layout.operator("object.visual_transform_apply", text="Apply Transformation")
1505         layout.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
1506
1507         layout.separator()
1508
1509         layout.operator("rigidbody.connect", text="Connect")
1510
1511
1512 class VIEW3D_MT_object_clear(Menu):
1513     bl_label = "Clear"
1514
1515     def draw(self, context):
1516         layout = self.layout
1517
1518         layout.operator("object.location_clear", text="Location").clear_delta = False
1519         layout.operator("object.rotation_clear", text="Rotation").clear_delta = False
1520         layout.operator("object.scale_clear", text="Scale").clear_delta = False
1521
1522         layout.separator()
1523
1524         layout.operator("object.origin_clear", text="Origin")
1525
1526
1527 class VIEW3D_MT_object_specials(Menu):
1528     bl_label = "Specials"
1529
1530     @classmethod
1531     def poll(cls, context):
1532         # add more special types
1533         return context.object
1534
1535     def draw(self, context):
1536         layout = self.layout
1537
1538         scene = context.scene
1539         obj = context.object
1540
1541         if obj.type == 'CAMERA':
1542             layout.operator_context = 'INVOKE_REGION_WIN'
1543
1544             if obj.data.type == 'PERSP':
1545                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
1546                 props.data_path_iter = "selected_editable_objects"
1547                 props.data_path_item = "data.lens"
1548                 props.input_scale = 0.1
1549                 if obj.data.lens_unit == 'MILLIMETERS':
1550                     props.header_text = "Camera Lens Angle: %.1fmm"
1551                 else:
1552                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
1553
1554             else:
1555                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
1556                 props.data_path_iter = "selected_editable_objects"
1557                 props.data_path_item = "data.ortho_scale"
1558                 props.input_scale = 0.01
1559                 props.header_text = "Camera Lens Scale: %.3f"
1560
1561             if not obj.data.dof_object:
1562                 view = context.space_data
1563                 if view and view.camera == obj and view.region_3d.view_perspective == 'CAMERA':
1564                     props = layout.operator("ui.eyedropper_depth", text="DOF Distance (Pick)")
1565                 else:
1566                     props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
1567                     props.data_path_iter = "selected_editable_objects"
1568                     props.data_path_item = "data.dof_distance"
1569                     props.input_scale = 0.02
1570                     props.header_text = "DOF Distance: %.3f"
1571                 del view
1572
1573         if obj.type in {'CURVE', 'FONT'}:
1574             layout.operator_context = 'INVOKE_REGION_WIN'
1575
1576             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
1577             props.data_path_iter = "selected_editable_objects"
1578             props.data_path_item = "data.extrude"
1579             props.input_scale = 0.01
1580             props.header_text = "Extrude Size: %.3f"
1581
1582             props = layout.operator("wm.context_modal_mouse", text="Width Size")
1583             props.data_path_iter = "selected_editable_objects"
1584             props.data_path_item = "data.offset"
1585             props.input_scale = 0.01
1586             props.header_text = "Width Size: %.3f"
1587
1588         if obj.type == 'EMPTY':
1589             layout.operator_context = 'INVOKE_REGION_WIN'
1590
1591             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
1592             props.data_path_iter = "selected_editable_objects"
1593             props.data_path_item = "empty_draw_size"
1594             props.input_scale = 0.01
1595             props.header_text = "Empty Draw Size: %.3f"
1596
1597         if obj.type == 'LAMP':
1598             lamp = obj.data
1599
1600             layout.operator_context = 'INVOKE_REGION_WIN'
1601
1602             emission_node = None
1603             if lamp.node_tree:
1604                 for node in lamp.node_tree.nodes:
1605                     if getattr(node, "type", None) == 'EMISSION':
1606                         emission_node = node
1607                         break
1608
1609             if emission_node is not None:
1610                 props = layout.operator("wm.context_modal_mouse", text="Strength")
1611                 props.data_path_iter = "selected_editable_objects"
1612                 props.data_path_item = "data.node_tree" \
1613                                        ".nodes[\"" + emission_node.name + "\"]" \
1614                                        ".inputs[\"Strength\"].default_value"
1615                 props.header_text = "Lamp Strength: %.3f"
1616                 props.input_scale = 0.1
1617
1618             if lamp.type == 'AREA':
1619                 props = layout.operator("wm.context_modal_mouse", text="Size X")
1620                 props.data_path_iter = "selected_editable_objects"
1621                 props.data_path_item = "data.size"
1622                 props.header_text = "Lamp Size X: %.3f"
1623
1624                 if lamp.shape == 'RECTANGLE':
1625                     props = layout.operator("wm.context_modal_mouse", text="Size Y")
1626                     props.data_path_iter = "selected_editable_objects"
1627                     props.data_path_item = "data.size_y"
1628                     props.header_text = "Lamp Size Y: %.3f"
1629
1630             elif lamp.type in {'SPOT', 'POINT', 'SUN'}:
1631                 props = layout.operator("wm.context_modal_mouse", text="Size")
1632                 props.data_path_iter = "selected_editable_objects"
1633                 props.data_path_item = "data.shadow_soft_size"
1634                 props.header_text = "Lamp Size: %.3f"
1635
1636             if lamp.type == 'SPOT':
1637                 layout.separator()
1638                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
1639                 props.data_path_iter = "selected_editable_objects"
1640                 props.data_path_item = "data.spot_size"
1641                 props.input_scale = 0.01
1642                 props.header_text = "Spot Size: %.2f"
1643
1644                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
1645                 props.data_path_iter = "selected_editable_objects"
1646                 props.data_path_item = "data.spot_blend"
1647                 props.input_scale = -0.01
1648                 props.header_text = "Spot Blend: %.2f"
1649
1650         layout.separator()
1651
1652         props = layout.operator("object.isolate_type_render")
1653         props = layout.operator("object.hide_render_clear_all")
1654
1655
1656 class VIEW3D_MT_object_shading(Menu):
1657     # XXX, this menu is a place to store shading operator in object mode
1658     bl_label = "Shading"
1659
1660     def draw(self, context):
1661         layout = self.layout
1662         layout.operator("object.shade_smooth", text="Smooth")
1663         layout.operator("object.shade_flat", text="Flat")
1664
1665
1666 class VIEW3D_MT_object_apply(Menu):
1667     bl_label = "Apply"
1668
1669     def draw(self, context):
1670         layout = self.layout
1671
1672         props = layout.operator("object.transform_apply", text="Location", text_ctxt=i18n_contexts.default)
1673         props.location, props.rotation, props.scale = True, False, False
1674
1675         props = layout.operator("object.transform_apply", text="Rotation", text_ctxt=i18n_contexts.default)
1676         props.location, props.rotation, props.scale = False, True, False
1677
1678         props = layout.operator("object.transform_apply", text="Scale", text_ctxt=i18n_contexts.default)
1679         props.location, props.rotation, props.scale = False, False, True
1680         props = layout.operator("object.transform_apply", text="Rotation & Scale", text_ctxt=i18n_contexts.default)
1681         props.location, props.rotation, props.scale = False, True, True
1682
1683         layout.separator()
1684
1685         layout.operator(
1686             "object.transforms_to_deltas",
1687             text="Location to Deltas",
1688             text_ctxt=i18n_contexts.default,
1689         ).mode = 'LOC'
1690         layout.operator(
1691             "object.transforms_to_deltas",
1692             text="Rotation to Deltas",
1693             text_ctxt=i18n_contexts.default,
1694         ).mode = 'ROT'
1695         layout.operator(
1696             "object.transforms_to_deltas",
1697             text="Scale to Deltas",
1698             text_ctxt=i18n_contexts.default,
1699         ).mode = 'SCALE'
1700
1701         layout.operator(
1702             "object.transforms_to_deltas",
1703             text="All Transforms to Deltas",
1704             text_ctxt=i18n_contexts.default,
1705         ).mode = 'ALL'
1706         layout.operator("object.anim_transforms_to_deltas")
1707
1708         layout.separator()
1709
1710         layout.operator(
1711             "object.visual_transform_apply",
1712             text="Visual Transform",
1713             text_ctxt=i18n_contexts.default,
1714         )
1715         layout.operator(
1716             "object.convert",
1717             text="Visual Geometry to Mesh",
1718             text_ctxt=i18n_contexts.default,
1719         ).target = 'MESH'
1720         layout.operator("object.duplicates_make_real")
1721
1722
1723 class VIEW3D_MT_object_parent(Menu):
1724     bl_label = "Parent"
1725
1726     def draw(self, context):
1727         layout = self.layout
1728
1729         layout.operator_enum("object.parent_set", "type")
1730
1731         layout.separator()
1732
1733         layout.operator_enum("object.parent_clear", "type")
1734
1735
1736 class VIEW3D_MT_object_track(Menu):
1737     bl_label = "Track"
1738
1739     def draw(self, context):
1740         layout = self.layout
1741
1742         layout.operator_enum("object.track_set", "type")
1743
1744         layout.separator()
1745
1746         layout.operator_enum("object.track_clear", "type")
1747
1748
1749 class VIEW3D_MT_object_group(Menu):
1750     bl_label = "Group"
1751
1752     def draw(self, context):
1753         layout = self.layout
1754
1755         layout.operator("group.create")
1756         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
1757         layout.operator("group.objects_remove")
1758         layout.operator("group.objects_remove_all")
1759
1760         layout.separator()
1761
1762         layout.operator("group.objects_add_active")
1763         layout.operator("group.objects_remove_active")
1764
1765
1766 class VIEW3D_MT_object_constraints(Menu):
1767     bl_label = "Constraints"
1768
1769     def draw(self, context):
1770         layout = self.layout
1771
1772         layout.operator("object.constraint_add_with_targets")
1773         layout.operator("object.constraints_copy")
1774
1775         layout.separator()
1776
1777         layout.operator("object.constraints_clear")
1778
1779
1780 class VIEW3D_MT_object_quick_effects(Menu):
1781     bl_label = "Quick Effects"
1782
1783     def draw(self, context):
1784         layout = self.layout
1785
1786         layout.operator("object.quick_fur")
1787         layout.operator("object.quick_explode")
1788         layout.operator("object.quick_smoke")
1789         layout.operator("object.quick_fluid")
1790
1791
1792 class VIEW3D_MT_make_single_user(Menu):
1793     bl_label = "Make Single User"
1794
1795     def draw(self, context):
1796         layout = self.layout
1797
1798         props = layout.operator("object.make_single_user", text="Object")
1799         props.object = True
1800         props.obdata = props.material = props.texture = props.animation = False
1801
1802         props = layout.operator("object.make_single_user", text="Object & Data")
1803         props.object = props.obdata = True
1804         props.material = props.texture = props.animation = False
1805
1806         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1807         props.object = props.obdata = props.material = props.texture = True
1808         props.animation = False
1809
1810         props = layout.operator("object.make_single_user", text="Materials+Tex")
1811         props.material = props.texture = True
1812         props.object = props.obdata = props.animation = False
1813
1814         props = layout.operator("object.make_single_user", text="Object Animation")
1815         props.animation = True
1816         props.object = props.obdata = props.material = props.texture = False
1817
1818
1819 class VIEW3D_MT_make_links(Menu):
1820     bl_label = "Make Links"
1821
1822     def draw(self, context):
1823         layout = self.layout
1824         operator_context_default = layout.operator_context
1825
1826         if len(bpy.data.scenes) > 10:
1827             layout.operator_context = 'INVOKE_REGION_WIN'
1828             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1829         else:
1830             layout.operator_context = 'EXEC_REGION_WIN'
1831             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene")
1832
1833         layout.separator()
1834
1835         layout.operator_context = operator_context_default
1836
1837         layout.operator_enum("object.make_links_data", "type")  # inline
1838
1839         layout.operator("object.join_uvs")  # stupid place to add this!
1840
1841
1842 class VIEW3D_MT_brush(Menu):
1843     bl_label = "Brush"
1844
1845     def draw(self, context):
1846         layout = self.layout
1847
1848         settings = UnifiedPaintPanel.paint_settings(context)
1849         brush = getattr(settings, "brush", None)
1850
1851         ups = context.tool_settings.unified_paint_settings
1852         layout.prop(ups, "use_unified_size", text="Unified Size")
1853         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1854         if context.image_paint_object or context.vertex_paint_object:
1855             layout.prop(ups, "use_unified_color", text="Unified Color")
1856         layout.separator()
1857
1858         # skip if no active brush
1859         if not brush:
1860             layout.label(text="No Brushes currently available", icon='INFO')
1861             return
1862
1863         # brush paint modes
1864         layout.menu("VIEW3D_MT_brush_paint_modes")
1865
1866         # brush tool
1867         if context.sculpt_object:
1868             layout.operator("brush.reset")
1869             layout.prop_menu_enum(brush, "sculpt_tool")
1870         elif context.image_paint_object:
1871             layout.prop_menu_enum(brush, "image_tool")
1872         elif context.vertex_paint_object or context.weight_paint_object:
1873             layout.prop_menu_enum(brush, "vertex_tool")
1874
1875         # TODO: still missing a lot of brush options here
1876
1877         # sculpt options
1878         if context.sculpt_object:
1879
1880             sculpt_tool = brush.sculpt_tool
1881
1882             layout.separator()
1883             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1884             layout.separator()
1885
1886             if sculpt_tool != 'GRAB':
1887                 layout.prop_menu_enum(brush, "stroke_method")
1888
1889                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1890                     layout.prop_menu_enum(brush, "direction")
1891
1892                 if sculpt_tool == 'LAYER':
1893                     layout.prop(brush, "use_persistent")
1894                     layout.operator("sculpt.set_persistent_base")
1895
1896
1897 class VIEW3D_MT_brush_paint_modes(Menu):
1898     bl_label = "Enabled Modes"
1899
1900     def draw(self, context):
1901         layout = self.layout
1902
1903         settings = UnifiedPaintPanel.paint_settings(context)
1904         brush = settings.brush
1905
1906         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1907         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1908         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1909         layout.prop(brush, "use_paint_image", text="Texture Paint")
1910
1911
1912 class VIEW3D_MT_paint_vertex(Menu):
1913     bl_label = "Paint"
1914
1915     def draw(self, context):
1916         layout = self.layout
1917
1918         layout.menu("VIEW3D_MT_undo_redo")
1919
1920         layout.separator()
1921
1922         layout.operator("paint.vertex_color_set")
1923         layout.operator("paint.vertex_color_smooth")
1924         layout.operator("paint.vertex_color_dirt")
1925         layout.operator("paint.vertex_color_from_weight")
1926
1927         layout.separator()
1928
1929         layout.operator("paint.vertex_color_invert", text="Invert")
1930         layout.operator("paint.vertex_color_levels", text="Levels")
1931         layout.operator("paint.vertex_color_hsv", text="Hue Saturation Value")
1932         layout.operator("paint.vertex_color_brightness_contrast", text="Bright/Contrast")
1933
1934
1935 class VIEW3D_MT_hook(Menu):
1936     bl_label = "Hooks"
1937
1938     def draw(self, context):
1939         layout = self.layout
1940         layout.operator_context = 'EXEC_AREA'
1941         layout.operator("object.hook_add_newob")
1942         layout.operator("object.hook_add_selob").use_bone = False
1943         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1944
1945         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1946             layout.separator()
1947
1948             layout.operator_menu_enum("object.hook_assign", "modifier")
1949             layout.operator_menu_enum("object.hook_remove", "modifier")
1950
1951             layout.separator()
1952
1953             layout.operator_menu_enum("object.hook_select", "modifier")
1954             layout.operator_menu_enum("object.hook_reset", "modifier")
1955             layout.operator_menu_enum("object.hook_recenter", "modifier")
1956
1957
1958 class VIEW3D_MT_vertex_group(Menu):
1959     bl_label = "Vertex Groups"
1960
1961     def draw(self, context):
1962         layout = self.layout
1963
1964         layout.operator_context = 'EXEC_AREA'
1965         layout.operator("object.vertex_group_assign_new")
1966
1967         ob = context.active_object
1968         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1969             if ob.vertex_groups.active:
1970                 layout.separator()
1971
1972                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1973                 layout.operator(
1974                     "object.vertex_group_remove_from",
1975                     text="Remove from Active Group",
1976                 ).use_all_groups = False
1977                 layout.operator("object.vertex_group_remove_from", text="Remove from All").use_all_groups = True
1978
1979         if ob.vertex_groups.active:
1980             layout.separator()
1981
1982             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1983             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1984             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1985
1986
1987 class VIEW3D_MT_paint_weight(Menu):
1988     bl_label = "Weights"
1989
1990     @staticmethod
1991     def draw_generic(layout, is_editmode=False):
1992
1993         if not is_editmode:
1994             layout.menu("VIEW3D_MT_undo_redo")
1995
1996             layout.separator()
1997
1998             layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1999             layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
2000
2001             layout.separator()
2002
2003         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
2004         layout.operator("object.vertex_group_normalize", text="Normalize")
2005
2006         layout.separator()
2007
2008         layout.operator("object.vertex_group_mirror", text="Mirror")
2009         layout.operator("object.vertex_group_invert", text="Invert")
2010         layout.operator("object.vertex_group_clean", text="Clean")
2011
2012         layout.separator()
2013
2014         layout.operator("object.vertex_group_quantize", text="Quantize")
2015         layout.operator("object.vertex_group_levels", text="Levels")
2016         layout.operator("object.vertex_group_smooth", text="Smooth")
2017
2018         if not is_editmode:
2019             props = layout.operator("object.data_transfer", text="Transfer Weights")
2020             props.use_reverse_transfer = True
2021             props.data_type = 'VGROUP_WEIGHTS'
2022
2023         layout.operator("object.vertex_group_limit_total", text="Limit Total")
2024         layout.operator("object.vertex_group_fix", text="Fix Deforms")
2025
2026
2027         if not is_editmode:
2028             layout.separator()
2029
2030             layout.operator("paint.weight_set")
2031
2032     def draw(self, context):
2033         self.draw_generic(self.layout, is_editmode=False);
2034
2035
2036 class VIEW3D_MT_sculpt(Menu):
2037     bl_label = "Sculpt"
2038
2039     def draw(self, context):
2040         layout = self.layout
2041
2042         toolsettings = context.tool_settings
2043         sculpt = toolsettings.sculpt
2044
2045         layout.menu("VIEW3D_MT_undo_redo")
2046
2047         layout.separator()
2048
2049         layout.prop(sculpt, "use_symmetry_x")
2050         layout.prop(sculpt, "use_symmetry_y")
2051         layout.prop(sculpt, "use_symmetry_z")
2052
2053         layout.separator()
2054
2055         layout.prop(sculpt, "lock_x")
2056         layout.prop(sculpt, "lock_y")
2057         layout.prop(sculpt, "lock_z")
2058
2059         layout.separator()
2060
2061         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
2062         layout.prop(sculpt, "show_low_resolution")
2063         layout.prop(sculpt, "show_brush")
2064         layout.prop(sculpt, "use_deform_only")
2065         layout.prop(sculpt, "show_diffuse_color")
2066         layout.prop(sculpt, "show_mask")
2067
2068
2069 class VIEW3D_MT_hide_mask(Menu):
2070     bl_label = "Hide/Mask"
2071
2072     def draw(self, context):
2073         layout = self.layout
2074
2075         props = layout.operator("paint.hide_show", text="Show All")
2076         props.action = 'SHOW'
2077         props.area = 'ALL'
2078
2079         props = layout.operator("paint.hide_show", text="Hide Bounding Box")
2080         props.action = 'HIDE'
2081         props.area = 'INSIDE'
2082
2083         props = layout.operator("paint.hide_show", text="Show Bounding Box")
2084         props.action = 'SHOW'
2085         props.area = 'INSIDE'
2086
2087         props = layout.operator("paint.hide_show", text="Hide Masked")
2088         props.area = 'MASKED'
2089         props.action = 'HIDE'
2090
2091         layout.separator()
2092
2093         props = layout.operator("paint.mask_flood_fill", text="Invert Mask")
2094         props.mode = 'INVERT'
2095
2096         props = layout.operator("paint.mask_flood_fill", text="Fill Mask")
2097         props.mode = 'VALUE'
2098         props.value = 1
2099
2100         props = layout.operator("paint.mask_flood_fill", text="Clear Mask")
2101         props.mode = 'VALUE'
2102         props.value = 0
2103
2104         props = layout.operator("view3d.select_border", text="Box Mask")
2105         props = layout.operator("paint.mask_lasso_gesture", text="Lasso Mask")
2106
2107
2108 class VIEW3D_MT_particle(Menu):
2109     bl_label = "Particle"
2110
2111     def draw(self, context):
2112         layout = self.layout
2113
2114         particle_edit = context.tool_settings.particle_edit
2115
2116         layout.menu("VIEW3D_MT_undo_redo")
2117
2118         layout.separator()
2119
2120         layout.operator("particle.delete")
2121
2122         layout.separator()
2123
2124         layout.operator("particle.mirror")
2125
2126         layout.operator("particle.remove_doubles")
2127
2128         layout.separator()
2129
2130         if particle_edit.select_mode == 'POINT':
2131             layout.operator("particle.subdivide")
2132
2133         layout.operator("particle.unify_length")
2134         layout.operator("particle.rekey")
2135         layout.operator("particle.weight_set")
2136
2137         layout.separator()
2138
2139         layout.menu("VIEW3D_MT_particle_showhide")
2140
2141
2142 class VIEW3D_MT_particle_specials(Menu):
2143     bl_label = "Specials"
2144
2145     def draw(self, context):
2146         layout = self.layout
2147
2148         particle_edit = context.tool_settings.particle_edit
2149
2150         layout.operator("particle.rekey")
2151
2152         layout.separator()
2153
2154         layout.operator("particle.delete")
2155
2156         layout.separator()
2157
2158         layout.operator("particle.remove_doubles")
2159         layout.operator("particle.unify_length")
2160
2161         if particle_edit.select_mode == 'POINT':
2162             layout.operator("particle.subdivide")
2163
2164         layout.operator("particle.weight_set")
2165
2166         layout.separator()
2167
2168         layout.operator("particle.mirror")
2169
2170         if particle_edit.select_mode == 'POINT':
2171             layout.separator()
2172             layout.operator("particle.select_roots")
2173             layout.operator("particle.select_tips")
2174
2175             layout.separator()
2176
2177             layout.operator("particle.select_random")
2178
2179             layout.separator()
2180
2181             layout.operator("particle.select_more")
2182             layout.operator("particle.select_less")
2183
2184             layout.separator()
2185
2186             layout.operator("particle.select_all").action = 'TOGGLE'
2187             layout.operator("particle.select_linked")
2188             layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
2189
2190
2191 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
2192     _operator_name = "particle"
2193
2194
2195 class VIEW3D_MT_pose(Menu):
2196     bl_label = "Pose"
2197
2198     def draw(self, context):
2199         layout = self.layout
2200
2201         layout.menu("VIEW3D_MT_undo_redo")
2202
2203         layout.separator()
2204
2205         layout.menu("VIEW3D_MT_transform_armature")
2206
2207         layout.menu("VIEW3D_MT_pose_transform")
2208         layout.menu("VIEW3D_MT_pose_apply")
2209
2210         layout.menu("VIEW3D_MT_snap")
2211
2212         layout.separator()
2213
2214         layout.menu("VIEW3D_MT_object_animation")
2215
2216         layout.separator()
2217
2218         layout.menu("VIEW3D_MT_pose_slide")
2219         layout.menu("VIEW3D_MT_pose_propagate")
2220
2221         layout.separator()
2222
2223         layout.operator("pose.copy")
2224         layout.operator("pose.paste").flipped = False
2225         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
2226
2227         layout.separator()
2228
2229         layout.menu("VIEW3D_MT_pose_library")
2230         layout.menu("VIEW3D_MT_pose_motion")
2231         layout.menu("VIEW3D_MT_pose_group")
2232
2233         layout.separator()
2234
2235         layout.menu("VIEW3D_MT_object_parent")
2236         layout.menu("VIEW3D_MT_pose_ik")
2237         layout.menu("VIEW3D_MT_pose_constraints")
2238
2239         layout.separator()
2240
2241         layout.operator_context = 'EXEC_AREA'
2242         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
2243         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
2244         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
2245
2246         layout.operator("pose.flip_names")
2247
2248         layout.operator("pose.quaternions_flip")
2249
2250         layout.separator()
2251
2252         layout.operator_context = 'INVOKE_AREA'
2253         layout.operator("armature.armature_layers", text="Change Armature Layers...")
2254         layout.operator("pose.bone_layers", text="Change Bone Layers...")
2255
2256         layout.separator()
2257
2258         layout.menu("VIEW3D_MT_pose_showhide")
2259         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2260
2261
2262 class VIEW3D_MT_pose_transform(Menu):
2263     bl_label = "Clear Transform"
2264
2265     def draw(self, context):
2266         layout = self.layout
2267
2268         layout.operator("pose.transforms_clear", text="All")
2269
2270         layout.separator()
2271
2272         layout.operator("pose.loc_clear", text="Location")
2273         layout.operator("pose.rot_clear", text="Rotation")
2274         layout.operator("pose.scale_clear", text="Scale")
2275
2276         layout.separator()
2277
2278         layout.operator("pose.user_transforms_clear", text="Reset Unkeyed")
2279
2280
2281 class VIEW3D_MT_pose_slide(Menu):
2282     bl_label = "In-Betweens"
2283
2284     def draw(self, context):
2285         layout = self.layout
2286
2287         layout.operator("pose.push")
2288         layout.operator("pose.relax")
2289         layout.operator("pose.breakdown")
2290
2291
2292 class VIEW3D_MT_pose_propagate(Menu):
2293     bl_label = "Propagate"
2294
2295     def draw(self, context):
2296         layout = self.layout
2297
2298         layout.operator("pose.propagate").mode = 'WHILE_HELD'
2299
2300         layout.separator()
2301
2302         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
2303         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
2304
2305         layout.separator()
2306
2307         layout.operator("pose.propagate", text="On Selected Keyframes").mode = 'SELECTED_KEYS'
2308
2309         layout.separator()
2310
2311         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
2312
2313
2314 class VIEW3D_MT_pose_library(Menu):
2315     bl_label = "Pose Library"
2316
2317     def draw(self, context):
2318         layout = self.layout
2319
2320         layout.operator("poselib.browse_interactive", text="Browse Poses...")
2321
2322         layout.separator()
2323
2324         layout.operator("poselib.pose_add", text="Add Pose...")
2325         layout.operator("poselib.pose_rename", text="Rename Pose...")
2326         layout.operator("poselib.pose_remove", text="Remove Pose...")
2327
2328
2329 class VIEW3D_MT_pose_motion(Menu):
2330     bl_label = "Motion Paths"
2331
2332     def draw(self, context):
2333         layout = self.layout
2334
2335         layout.operator("pose.paths_calculate", text="Calculate")
2336         layout.operator("pose.paths_clear", text="Clear")
2337
2338
2339 class VIEW3D_MT_pose_group(Menu):
2340     bl_label = "Bone Groups"
2341
2342     def draw(self, context):
2343         layout = self.layout
2344
2345         pose = context.active_object.pose
2346
2347         layout.operator_context = 'EXEC_AREA'
2348         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
2349
2350         if pose.bone_groups:
2351             active_group = pose.bone_groups.active_index + 1
2352             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
2353
2354             layout.separator()
2355
2356             # layout.operator_context = 'INVOKE_AREA'
2357             layout.operator("pose.group_unassign")
2358             layout.operator("pose.group_remove")
2359
2360
2361 class VIEW3D_MT_pose_ik(Menu):
2362     bl_label = "Inverse Kinematics"
2363
2364     def draw(self, context):
2365         layout = self.layout
2366
2367         layout.operator("pose.ik_add")
2368         layout.operator("pose.ik_clear")
2369
2370
2371 class VIEW3D_MT_pose_constraints(Menu):
2372     bl_label = "Constraints"
2373
2374     def draw(self, context):
2375         layout = self.layout
2376
2377         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
2378         layout.operator("pose.constraints_copy")
2379         layout.operator("pose.constraints_clear")
2380
2381
2382 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
2383     _operator_name = "pose"
2384
2385
2386 class VIEW3D_MT_pose_apply(Menu):
2387     bl_label = "Apply"
2388
2389     def draw(self, context):
2390         layout = self.layout
2391
2392         layout.operator("pose.armature_apply")
2393         layout.operator("pose.visual_transform_apply")
2394
2395
2396 class VIEW3D_MT_pose_specials(Menu):
2397     bl_label = "Specials"
2398
2399     def draw(self, context):
2400         layout = self.layout
2401
2402         layout.operator("paint.weight_from_bones", text="Assign Automatic from Bones").type = 'AUTOMATIC'
2403         layout.operator("paint.weight_from_bones", text="Assign from Bone Envelopes").type = 'ENVELOPES'
2404
2405         layout.separator()
2406
2407         layout.operator("pose.select_constraint_target")
2408         layout.operator("pose.flip_names")
2409
2410         layout.separator()
2411
2412         layout.operator("pose.paths_calculate")
2413         layout.operator("pose.paths_clear")
2414         layout.operator("pose.user_transforms_clear")
2415         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
2416         layout.operator("pose.relax")
2417
2418         layout.separator()
2419
2420         layout.operator_menu_enum("pose.autoside_names", "axis")
2421
2422
2423 class BoneOptions:
2424     def draw(self, context):
2425         layout = self.layout
2426
2427         options = [
2428             "show_wire",
2429             "use_deform",
2430             "use_envelope_multiply",
2431             "use_inherit_rotation",
2432             "use_inherit_scale",
2433         ]
2434
2435         if context.mode == 'EDIT_ARMATURE':
2436             bone_props = bpy.types.EditBone.bl_rna.properties
2437             data_path_iter = "selected_bones"
2438             opt_suffix = ""
2439             options.append("lock")
2440         else:  # pose-mode
2441             bone_props = bpy.types.Bone.bl_rna.properties
2442             data_path_iter = "selected_pose_bones"
2443             opt_suffix = "bone."
2444
2445         for opt in options:
2446             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name,
2447                                     text_ctxt=i18n_contexts.default)
2448             props.data_path_iter = data_path_iter
2449             props.data_path_item = opt_suffix + opt
2450             props.type = self.type
2451
2452
2453 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
2454     bl_label = "Toggle Bone Options"
2455     type = 'TOGGLE'
2456
2457
2458 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
2459     bl_label = "Enable Bone Options"
2460     type = 'ENABLE'
2461
2462
2463 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
2464     bl_label = "Disable Bone Options"
2465     type = 'DISABLE'
2466
2467
2468 # ********** Edit Menus, suffix from ob.type **********
2469
2470
2471 class VIEW3D_MT_edit_mesh(Menu):
2472     bl_label = "Mesh"
2473
2474     def draw(self, context):
2475         layout = self.layout
2476
2477         toolsettings = context.tool_settings
2478
2479         layout.menu("VIEW3D_MT_undo_redo")
2480
2481         layout.separator()
2482
2483         layout.menu("VIEW3D_MT_edit_mesh_delete")
2484
2485         layout.separator()
2486
2487         layout.menu("VIEW3D_MT_transform")
2488         layout.menu("VIEW3D_MT_mirror")
2489         layout.menu("VIEW3D_MT_snap")
2490
2491         layout.separator()
2492
2493         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
2494
2495         layout.separator()
2496
2497         layout.operator("mesh.duplicate_move")
2498         layout.menu("VIEW3D_MT_edit_mesh_extrude")
2499
2500         layout.separator()
2501
2502         layout.menu("VIEW3D_MT_edit_mesh_vertices")
2503         layout.menu("VIEW3D_MT_edit_mesh_edges")
2504         layout.menu("VIEW3D_MT_edit_mesh_faces")
2505
2506         layout.separator()
2507
2508         layout.menu("VIEW3D_MT_edit_mesh_normals")
2509         layout.menu("VIEW3D_MT_edit_mesh_shading")
2510         layout.menu("VIEW3D_MT_edit_mesh_weights")
2511         layout.menu("VIEW3D_MT_edit_mesh_clean")
2512
2513         layout.separator()
2514
2515         layout.operator("mesh.symmetrize")
2516         layout.operator("mesh.symmetry_snap")
2517         layout.operator("mesh.bisect")
2518         layout.operator_menu_enum("mesh.sort_elements", "type", text="Sort Elements...")
2519
2520         layout.separator()
2521
2522         layout.prop(toolsettings, "use_mesh_automerge")
2523         layout.menu("VIEW3D_MT_edit_proportional")
2524
2525         layout.separator()
2526
2527         layout.menu("VIEW3D_MT_edit_mesh_showhide")
2528
2529
2530 class VIEW3D_MT_edit_mesh_specials(Menu):
2531     bl_label = "Specials"
2532
2533     def draw(self, context):
2534         layout = self.layout
2535
2536         layout.operator_context = 'INVOKE_REGION_WIN'
2537
2538         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
2539         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
2540
2541         layout.separator()
2542
2543         layout.operator("mesh.merge", text="Merge...")
2544         layout.operator("mesh.remove_doubles")
2545
2546         layout.separator()
2547
2548         layout.operator("mesh.hide", text="Hide").unselected = False
2549         layout.operator("mesh.reveal", text="Reveal")
2550         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
2551
2552         layout.separator()
2553
2554         layout.operator("mesh.flip_normals")
2555         layout.operator("mesh.vertices_smooth", text="Smooth")
2556         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
2557
2558         layout.separator()
2559
2560         layout.operator("mesh.inset")
2561         layout.operator("mesh.bevel", text="Bevel")
2562         layout.operator("mesh.bridge_edge_loops")
2563
2564         layout.separator()
2565
2566         layout.operator("mesh.faces_shade_smooth")
2567         layout.operator("mesh.faces_shade_flat")
2568
2569         layout.separator()
2570
2571         layout.operator("mesh.blend_from_shape")
2572         layout.operator("mesh.shape_propagate_to_all")
2573         layout.operator("mesh.shortest_path_select")
2574         layout.operator("mesh.sort_elements")
2575         layout.operator("mesh.symmetrize")
2576         layout.operator("mesh.symmetry_snap")
2577
2578
2579 class VIEW3D_MT_edit_mesh_select_mode(Menu):
2580     bl_label = "Mesh Select Mode"
2581
2582     def draw(self, context):
2583         layout = self.layout
2584
2585         layout.operator_context = 'INVOKE_REGION_WIN'
2586         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
2587         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
2588         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
2589
2590
2591 class VIEW3D_MT_edit_mesh_extrude(Menu):
2592     bl_label = "Extrude"
2593
2594     _extrude_funcs = {
2595         'VERT': lambda layout:
2596             layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
2597         'EDGE': lambda layout:
2598             layout.operator("mesh.extrude_edges_move", text="Edges Only"),
2599         'FACE': lambda layout:
2600             layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
2601         'REGION': lambda layout:
2602             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
2603         'REGION_VERT_NORMAL': lambda layout:
2604             layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten", text="Region (Vertex Normals)"),
2605     }
2606
2607     @staticmethod
2608     def extrude_options(context):
2609         mesh = context.object.data
2610         select_mode = context.tool_settings.mesh_select_mode
2611
2612         menu = []
2613         if mesh.total_face_sel:
2614             menu += ['REGION', 'REGION_VERT_NORMAL', 'FACE']
2615         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
2616             menu += ['EDGE']
2617         if mesh.total_vert_sel and select_mode[0]:
2618             menu += ['VERT']
2619
2620         # should never get here
2621         return menu
2622
2623     def draw(self, context):
2624         layout = self.layout
2625         layout.operator_context = 'INVOKE_REGION_WIN'
2626
2627         for menu_id in self.extrude_options(context):
2628             self._extrude_funcs[menu_id](layout)
2629
2630
2631 class VIEW3D_MT_edit_mesh_vertices(Menu):
2632     bl_label = "Vertices"
2633
2634     def draw(self, context):
2635         layout = self.layout
2636         layout.operator_context = 'INVOKE_REGION_WIN'
2637
2638         with_bullet = bpy.app.build_options.bullet
2639
2640         layout.operator("mesh.merge")
2641         layout.operator("mesh.remove_doubles")
2642         layout.operator("mesh.rip_move")
2643         layout.operator("mesh.rip_move_fill")
2644         layout.operator("mesh.rip_edge_move")
2645         layout.operator("mesh.split")
2646         layout.operator_menu_enum("mesh.separate", "type")
2647         layout.operator("mesh.vert_connect_path", text="Connect Vertex Path")
2648         layout.operator("mesh.vert_connect", text="Connect Vertices")
2649         layout.operator("transform.vert_slide", text="Slide")
2650
2651         layout.separator()
2652
2653         layout.operator("mesh.mark_sharp", text="Mark Sharp Edges").use_verts = True
2654         props = layout.operator("mesh.mark_sharp", text="Clear Sharp Edges")
2655         props.use_verts = True
2656         props.clear = True
2657
2658         layout.separator()
2659
2660         layout.operator("mesh.bevel").vertex_only = True
2661         if with_bullet:
2662             layout.operator("mesh.convex_hull")
2663         layout.operator("mesh.vertices_smooth")
2664
2665         layout.operator("mesh.blend_from_shape")
2666
2667         layout.operator("object.vertex_group_smooth")
2668         layout.operator("mesh.shape_propagate_to_all")
2669
2670         layout.separator()
2671
2672         layout.menu("VIEW3D_MT_vertex_group")
2673         layout.menu("VIEW3D_MT_hook")
2674
2675         layout.separator()
2676
2677         layout.operator("object.vertex_parent_set")
2678
2679
2680 class VIEW3D_MT_edit_mesh_edges_data(Menu):
2681     bl_label = "Edge Data"
2682
2683     def draw(self, context):
2684         layout = self.layout
2685
2686         with_freestyle = bpy.app.build_options.freestyle
2687
2688         layout.operator_context = 'INVOKE_REGION_WIN'
2689
2690         layout.operator("transform.edge_crease")
2691         layout.operator("transform.edge_bevelweight")
2692
2693         layout.separator()
2694
2695         layout.operator("mesh.mark_seam").clear = False
2696         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
2697
2698         layout.separator()
2699
2700         layout.operator("mesh.mark_sharp")
2701         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
2702
2703         layout.separator()
2704
2705         if with_freestyle:
2706             layout.operator("mesh.mark_freestyle_edge").clear = False
2707             layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
2708             layout.separator()
2709
2710
2711 class VIEW3D_MT_edit_mesh_edges(Menu):
2712     bl_label = "Edges"
2713
2714     def draw(self, context):
2715         layout = self.layout
2716
2717         layout.operator_context = 'INVOKE_REGION_WIN'
2718
2719         layout.operator("mesh.edge_face_add")
2720         layout.operator("mesh.subdivide")
2721         layout.operator("mesh.subdivide_edgering")
2722         layout.operator("mesh.unsubdivide")
2723
2724         layout.separator()
2725
2726         layout.menu("VIEW3D_MT_edit_mesh_edges_data")
2727
2728         layout.separator()
2729
2730         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2731         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
2732
2733         layout.separator()
2734
2735         layout.operator("mesh.bevel").vertex_only = False
2736         layout.operator("mesh.edge_split")
2737         layout.operator("mesh.bridge_edge_loops")
2738
2739         layout.separator()
2740
2741         layout.operator("transform.edge_slide")
2742         layout.operator("mesh.loop_multi_select", text="Edge Loops").ring = False
2743         layout.operator("mesh.loop_multi_select", text="Edge Rings").ring = True
2744         layout.operator("mesh.loop_to_region")
2745         layout.operator("mesh.region_to_loop")
2746
2747
2748 class VIEW3D_MT_edit_mesh_faces(Menu):
2749     bl_label = "Faces"
2750     bl_idname = "VIEW3D_MT_edit_mesh_faces"
2751
2752     def draw(self, context):
2753         layout = self.layout
2754
2755         with_freestyle = bpy.app.build_options.freestyle
2756
2757         layout.operator_context = 'INVOKE_REGION_WIN'
2758
2759         layout.operator("mesh.flip_normals")
2760         layout.operator("mesh.edge_face_add")
2761         layout.operator("mesh.fill")
2762         layout.operator("mesh.fill_grid")
2763         layout.operator("mesh.beautify_fill")
2764         layout.operator("mesh.inset")
2765         layout.operator("mesh.bevel").vertex_only = False
2766         layout.operator("mesh.solidify")
2767         layout.operator("mesh.intersect")
2768         layout.operator("mesh.intersect_boolean")
2769         layout.operator("mesh.wireframe")
2770
2771         layout.separator()
2772
2773         if with_freestyle:
2774             layout.operator("mesh.mark_freestyle_face").clear = False
2775             layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
2776             layout.separator()
2777
2778         layout.operator("mesh.poke")
2779         props = layout.operator("mesh.quads_convert_to_tris")
2780         props.quad_method = props.ngon_method = 'BEAUTY'
2781         layout.operator("mesh.tris_convert_to_quads")
2782         layout.operator("mesh.face_split_by_edges")
2783
2784         layout.separator()
2785
2786         layout.operator("mesh.faces_shade_smooth")
2787         layout.operator("mesh.faces_shade_flat")
2788
2789         layout.operator("mesh.normals_make_consistent", text="Recalculate Normals").inside = False
2790
2791         layout.separator()
2792
2793         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
2794
2795         layout.separator()
2796
2797         layout.operator("mesh.uvs_rotate")
2798         layout.operator("mesh.uvs_reverse")
2799         layout.operator("mesh.colors_rotate")
2800         layout.operator("mesh.colors_reverse")
2801
2802
2803 class VIEW3D_MT_edit_mesh_normals(Menu):
2804     bl_label = "Normals"
2805
2806     def draw(self, context):
2807         layout = self.layout
2808
2809         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
2810         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
2811
2812         layout.separator()
2813
2814         layout.operator("mesh.flip_normals")
2815         layout.operator("mesh.set_normals_from_faces", text="Set From Faces")
2816
2817
2818 class VIEW3D_MT_edit_mesh_shading(Menu):
2819     bl_label = "Shading"
2820
2821     def draw(self, context):
2822         layout = self.layout
2823
2824         layout.label(text="Faces:")
2825         layout.operator("mesh.faces_shade_smooth", text="Smooth")
2826         layout.operator("mesh.faces_shade_flat", text="Flat")
2827         layout.label(text="Edges:")
2828         layout.operator("mesh.mark_sharp", text="Smooth").clear = True
2829         layout.operator("mesh.mark_sharp", text="Sharp")
2830         layout.label(text="Vertices:")
2831         props = layout.operator("mesh.mark_sharp", text="Smooth")
2832         props.use_verts = True
2833         props.clear = True
2834         layout.operator("mesh.mark_sharp", text="Sharp").use_verts = True
2835
2836
2837 class VIEW3D_MT_edit_mesh_weights(Menu):
2838     bl_label = "Weights"
2839
2840     def draw(self, context):
2841         VIEW3D_MT_paint_weight.draw_generic(self.layout, is_editmode=True)
2842
2843
2844 class VIEW3D_MT_edit_mesh_clean(Menu):
2845     bl_label = "Clean Up"
2846
2847     def draw(self, context):
2848         layout = self.layout
2849
2850         layout.operator("mesh.delete_loose")
2851
2852         layout.separator()
2853
2854         layout.operator("mesh.decimate")
2855         layout.operator("mesh.dissolve_degenerate")
2856         layout.operator("mesh.dissolve_limited")
2857         layout.operator("mesh.face_make_planar")
2858
2859         layout.separator()
2860
2861         layout.operator("mesh.vert_connect_nonplanar")
2862         layout.operator("mesh.vert_connect_concave")
2863         layout.operator("mesh.remove_doubles")
2864         layout.operator("mesh.fill_holes")
2865
2866
2867 class VIEW3D_MT_edit_mesh_delete(Menu):
2868     bl_label = "Delete"
2869
2870     def draw(self, context):
2871         layout = self.layout
2872
2873         layout.operator_enum("mesh.delete", "type")
2874
2875         layout.separator()
2876
2877         layout.operator("mesh.dissolve_verts")
2878         layout.operator("mesh.dissolve_edges")
2879         layout.operator("mesh.dissolve_faces")
2880
2881         layout.separator()
2882
2883         layout.operator("mesh.dissolve_limited")
2884
2885         layout.separator()
2886
2887         layout.operator("mesh.edge_collapse")
2888         layout.operator("mesh.delete_edgeloop", text="Edge Loops")
2889
2890
2891 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
2892     _operator_name = "mesh"
2893
2894
2895 class VIEW3D_MT_edit_gpencil_delete(Menu):
2896     bl_label = "Delete"
2897
2898     def draw(self, context):
2899         layout = self.layout
2900
2901         layout.operator_enum("gpencil.delete", "type")
2902
2903         layout.separator()
2904
2905         layout.operator("gpencil.dissolve")
2906
2907         layout.separator()
2908
2909         layout.operator("gpencil.active_frames_delete_all")
2910
2911
2912 # Edit Curve
2913 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
2914
2915
2916 def draw_curve(self, context):
2917     layout = self.layout
2918
2919     layout.menu("VIEW3D_MT_undo_redo")
2920
2921     layout.separator()
2922
2923     layout.menu("VIEW3D_MT_edit_curve_delete")
2924
2925     layout.separator()
2926
2927     layout.menu("VIEW3D_MT_transform")
2928     layout.menu("VIEW3D_MT_mirror")
2929     layout.menu("VIEW3D_MT_snap")
2930
2931     layout.separator()
2932
2933     layout.operator("curve.extrude_move")
2934     layout.operator("curve.spin")
2935     layout.operator("curve.duplicate_move")
2936
2937     layout.separator()
2938
2939     layout.operator("curve.split")
2940     layout.operator("curve.separate")
2941     layout.operator("curve.make_segment")
2942     layout.operator("curve.cyclic_toggle")
2943
2944     layout.separator()
2945
2946     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
2947     layout.menu("VIEW3D_MT_edit_curve_segments")
2948
2949     layout.separator()
2950
2951     layout.menu("VIEW3D_MT_edit_curve_clean")
2952
2953     layout.separator()
2954
2955     layout.menu("VIEW3D_MT_edit_proportional")
2956
2957     layout.separator()
2958
2959     layout.menu("VIEW3D_MT_edit_curve_showhide")
2960
2961
2962 class VIEW3D_MT_edit_curve(Menu):
2963     bl_label = "Curve"
2964
2965     draw = draw_curve
2966
2967
2968 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2969     bl_label = "Control Points"
2970
2971     def draw(self, context):
2972         layout = self.layout
2973
2974         edit_object = context.edit_object
2975
2976         if edit_object.type == 'CURVE':
2977             layout.operator("transform.tilt")
2978             layout.operator("curve.tilt_clear")
2979
2980             layout.separator()
2981
2982             layout.operator_menu_enum("curve.handle_type_set", "type")
2983             layout.operator("curve.normals_make_consistent")
2984
2985             layout.separator()
2986
2987         layout.menu("VIEW3D_MT_hook")
2988
2989         layout.separator()
2990
2991         layout.operator("object.vertex_parent_set")
2992
2993
2994 class VIEW3D_MT_edit_curve_segments(Menu):
2995     bl_label = "Segments"
2996
2997     def draw(self, context):
2998         layout = self.layout
2999
3000         layout.operator("curve.subdivide")
3001         layout.operator("curve.switch_direction")
3002
3003 class VIEW3D_MT_edit_curve_clean(Menu):
3004     bl_label = "Clean Up"
3005
3006     def draw(self, context):
3007         layout = self.layout
3008
3009         layout.operator("curve.decimate")
3010
3011
3012 class VIEW3D_MT_edit_curve_specials(Menu):
3013     bl_label = "Specials"
3014
3015     def draw(self, context):
3016         layout = self.layout
3017
3018         layout.operator("curve.subdivide")
3019         layout.operator("curve.switch_direction")
3020         layout.operator("curve.spline_weight_set")
3021         layout.operator("curve.radius_set")
3022
3023         layout.separator()
3024
3025         layout.operator("curve.smooth")
3026         layout.operator("curve.smooth_weight")
3027         layout.operator("curve.smooth_radius")
3028         layout.operator("curve.smooth_tilt")
3029
3030
3031 class VIEW3D_MT_edit_curve_delete(Menu):
3032     bl_label = "Delete"
3033
3034     def draw(self, context):
3035         layout = self.layout
3036
3037         layout.operator_enum("curve.delete", "type")
3038
3039         layout.separator()
3040
3041         layout.operator("curve.dissolve_verts")
3042
3043
3044 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
3045     _operator_name = "curve"
3046
3047
3048 class VIEW3D_MT_edit_surface(Menu):
3049     bl_label = "Surface"
3050
3051     draw = draw_curve
3052
3053
3054 class VIEW3D_MT_edit_font(Menu):
3055     bl_label = "Text"
3056
3057     def draw(self, context):
3058         layout = self.layout
3059
3060         # Break convention of having undo menu here,
3061         # instead place in "Edit" menu, matching the text menu.
3062
3063         layout.menu("VIEW3D_MT_edit_text_chars")
3064
3065         layout.separator()
3066
3067         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
3068         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
3069
3070         layout.separator()
3071
3072         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
3073         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
3074
3075
3076 class VIEW3D_MT_edit_text_chars(Menu):
3077     bl_label = "Special Characters"
3078
3079     def draw(self, context):
3080         layout = self.layout
3081
3082         layout.operator("font.text_insert", text="Copyright").text = "\u00A9"
3083         layout.operator("font.text_insert", text="Registered Trademark").text = "\u00AE"
3084
3085         layout.separator()
3086
3087         layout.operator("font.text_insert", text="Degree Sign").text = "\u00B0"
3088         layout.operator("font.text_insert", text="Multiplication Sign").text = "\u00D7"
3089         layout.operator("font.text_insert", text="Circle").text = "\u008A"
3090
3091         layout.separator()
3092
3093         layout.operator("font.text_insert", text="Superscript 1").text = "\u00B9"
3094         layout.operator("font.text_insert", text="Superscript 2").text = "\u00B2"
3095         layout.operator("font.text_insert", text="Superscript 3").text = "\u00B3"
3096
3097         layout.separator()
3098
3099         layout.operator("font.text_insert", text="Double >>").text = "\u00BB"
3100         layout.operator("font.text_insert", text="Double <<").text = "\u00AB"
3101         layout.operator("font.text_insert", text="Promillage").text = "\u2030"
3102
3103         layout.separator()
3104
3105         layout.operator("font.text_insert", text="Dutch Florin").text = "\u00A4"
3106         layout.operator("font.text_insert", text="British Pound").text = "\u00A3"
3107         layout.operator("font.text_insert", text="Japanese Yen").text = "\u00A5"
3108
3109         layout.separator()
3110
3111         layout.operator("font.text_insert", text="German S").text = "\u00DF"
3112         layout.operator("font.text_insert", text="Spanish Question Mark").text = "\u00BF"
3113         layout.operator("font.text_insert", text="Spanish Exclamation Mark").text = "\u00A1"
3114
3115
3116 class VIEW3D_MT_edit_meta(Menu):
3117     bl_label = "Metaball"
3118
3119     def draw(self, context):
3120         layout = self.layout
3121
3122         layout.menu("VIEW3D_MT_undo_redo")
3123
3124         layout.separator()
3125
3126         layout.operator("mball.delete_metaelems", text="Delete...")
3127
3128         layout.separator()
3129
3130         layout.menu("VIEW3D_MT_transform")
3131         layout.menu("VIEW3D_MT_mirror")
3132         layout.menu("VIEW3D_MT_snap")
3133
3134         layout.separator()
3135
3136         layout.operator("mball.duplicate_metaelems")
3137
3138         layout.separator()
3139
3140         layout.menu("VIEW3D_MT_edit_proportional")
3141
3142         layout.separator()
3143
3144         layout.menu("VIEW3D_MT_edit_meta_showhide")
3145
3146
3147 class VIEW3D_MT_edit_meta_showhide(Menu):
3148     bl_label = "Show/Hide"
3149
3150     def draw(self, context):
3151         layout = self.layout
3152
3153         layout.operator("mball.reveal_metaelems", text="Show Hidden")
3154         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
3155         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
3156
3157
3158 class VIEW3D_MT_edit_lattice(Menu):
3159     bl_label = "Lattice"
3160
3161     def draw(self, context):
3162         layout = self.layout
3163
3164         layout.menu("VIEW3D_MT_undo_redo")
3165
3166         layout.separator()
3167
3168         layout.menu("VIEW3D_MT_transform")
3169         layout.menu("VIEW3D_MT_mirror")
3170         layout.menu("VIEW3D_MT_snap")
3171         layout.operator_menu_enum("lattice.flip", "axis")
3172
3173         layout.separator()
3174
3175         layout.operator("lattice.make_regular")
3176
3177         layout.separator()
3178
3179         layout.operator("object.vertex_parent_set")
3180
3181         layout.separator()
3182
3183         layout.menu("VIEW3D_MT_edit_proportional")
3184
3185
3186 class VIEW3D_MT_edit_armature(Menu):
3187     bl_label = "Armature"
3188
3189     def draw(self, context):
3190         layout = self.layout
3191
3192         edit_object = context.edit_object
3193         arm = edit_object.data
3194
3195         layout.menu("VIEW3D_MT_undo_redo")
3196
3197         layout.separator()
3198
3199         layout.operator("armature.delete")
3200
3201         layout.separator()
3202
3203         layout.menu("VIEW3D_MT_transform_armature")
3204         layout.menu("VIEW3D_MT_mirror")
3205         layout.menu("VIEW3D_MT_snap")
3206         layout.menu("VIEW3D_MT_edit_armature_roll")
3207
3208         layout.separator()
3209
3210         layout.operator("armature.extrude_move")
3211
3212         if arm.use_mirror_x:
3213             layout.operator("armature.extrude_forked")
3214
3215         layout.operator("armature.duplicate_move")
3216         layout.operator("armature.merge")
3217         layout.operator("armature.fill")
3218         layout.operator("armature.split")
3219         layout.operator("armature.separate")
3220
3221         layout.separator()
3222
3223         layout.operator("armature.subdivide", text="Subdivide")
3224         layout.operator("armature.switch_direction", text="Switch Direction")
3225
3226         layout.separator()
3227
3228         layout.operator_context = 'EXEC_AREA'
3229         layout.operator("armature.symmetrize")
3230         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
3231         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
3232         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
3233         layout.operator("armature.flip_names")
3234
3235         layout.separator()
3236
3237         layout.operator_context = 'INVOKE_DEFAULT'
3238         layout.operator("armature.armature_layers")
3239         layout.operator("armature.bone_layers")
3240
3241         layout.separator()
3242
3243         layout.menu("VIEW3D_MT_edit_armature_parent")
3244
3245         layout.separator()
3246
3247         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
3248
3249
3250 class VIEW3D_MT_armature_specials(Menu):
3251     bl_label = "Specials"
3252
3253     def draw(self, context):
3254         layout = self.layout
3255
3256         layout.operator_context = 'INVOKE_REGION_WIN'
3257
3258         layout.operator("armature.subdivide", text="Subdivide")
3259         layout.operator("armature.switch_direction", text="Switch Direction")
3260
3261         layout.separator()
3262
3263         layout.operator_context = 'EXEC_REGION_WIN'
3264         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
3265         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
3266         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
3267         layout.operator("armature.flip_names", text="Flip Names")
3268         layout.operator("armature.symmetrize")
3269
3270
3271 class VIEW3D_MT_edit_armature_parent(Menu):
3272     bl_label = "Parent"
3273
3274     def draw(self, context):
3275         layout = self.layout
3276
3277         layout.operator("armature.parent_set", text="Make")
3278         layout.operator("armature.parent_clear", text="Clear")
3279
3280
3281 class VIEW3D_MT_edit_armature_roll(Menu):
3282     bl_label = "Bone Roll"
3283
3284     def draw(self, context):
3285         layout = self.layout
3286
3287         layout.operator_menu_enum("armature.calculate_roll", "type")
3288
3289         layout.separator()
3290
3291         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
3292         layout.operator("armature.roll_clear")
3293
3294
3295 class VIEW3D_MT_edit_armature_delete(Menu):
3296     bl_label = "Delete"
3297
3298     def draw(self, context):
3299         layout = self.layout
3300
3301         layout.operator("armature.delete", text="Delete Bones")
3302
3303         layout.separator()
3304
3305         layout.operator("armature.dissolve", text="Dissolve")
3306
3307
3308 # ********** GPencil Stroke Edit menu **********
3309
3310
3311 class VIEW3D_MT_edit_gpencil(Menu):
3312     bl_label = "GPencil"
3313
3314     def draw(self, context):
3315         toolsettings = context.tool_settings
3316
3317         layout = self.layout
3318
3319         layout.menu("VIEW3D_MT_undo_redo")
3320
3321         layout.separator()
3322
3323         layout.menu("VIEW3D_MT_edit_gpencil_delete")
3324
3325         layout.separator()
3326
3327         layout.menu("VIEW3D_MT_edit_gpencil_transform")
3328         layout.operator("transform.mirror", text="Mirror")
3329         layout.menu("GPENCIL_MT_snap")
3330
3331         layout.separator()
3332
3333         layout.operator("gpencil.brush_paint", text="Sculpt Strokes").wait_for_input = True
3334         layout.prop_menu_enum(toolsettings.gpencil_sculpt, "tool", text="Sculpt Brush")
3335
3336         layout.separator()
3337
3338         layout.menu("VIEW3D_MT_object_animation")   # NOTE: provides keyingset access...
3339         layout.menu("VIEW3D_MT_edit_gpencil_interpolate")
3340
3341         layout.separator()
3342
3343         layout.operator("gpencil.duplicate_move", text="Duplicate")
3344         layout.operator("gpencil.stroke_subdivide", text="Subdivide")
3345
3346         layout.separator()
3347
3348         layout.operator_menu_enum("gpencil.stroke_join", "type", text="Join...")
3349         layout.operator("gpencil.stroke_flip", text="Flip Direction")
3350
3351         layout.separator()
3352
3353         layout.operator("gpencil.copy", text="Copy")
3354         layout.operator("gpencil.paste", text="Paste")
3355
3356         layout.separator()
3357
3358         layout.menu("VIEW3D_MT_edit_proportional")
3359
3360         layout.separator()
3361
3362         layout.operator("gpencil.reveal")
3363         layout.operator("gpencil.hide", text="Show Active Layer Only").unselected = True
3364         layout.operator("gpencil.hide", text="Hide Active Layer").unselected = False
3365
3366         layout.separator()
3367
3368         layout.operator_menu_enum("gpencil.move_to_layer", "layer", text="Move to Layer")
3369         layout.operator("gpencil.stroke_change_color", text="Move to Color")
3370         layout.operator_menu_enum("gpencil.stroke_arrange", "direction", text="Arrange Strokes...")
3371
3372         layout.separator()
3373
3374         layout.operator_menu_enum("gpencil.convert", "type", text="Convert to Geometry...")
3375
3376
3377 class VIEW3D_MT_edit_gpencil_transform(Menu):
3378     bl_label = "Transform"
3379
3380     def draw(self, context):
3381         layout = self.layout
3382
3383         layout.operator("transform.translate")
3384         layout.operator("transform.rotate")
3385         layout.operator("transform.resize", text="Scale")
3386
3387         layout.separator()
3388
3389         layout.operator("transform.bend", text="Bend")
3390         layout.operator("transform.shear", text="Shear")
3391         layout.operator("transform.tosphere", text="To Sphere")
3392         layout.operator("transform.transform", text="Shrink Fatten").mode = 'GPENCIL_SHRINKFATTEN'
3393
3394         layout.separator()
3395
3396         layout.operator("gpencil.reproject")
3397
3398
3399 class VIEW3D_MT_edit_gpencil_interpolate(Menu):
3400     bl_label = "Interpolate"
3401
3402     def draw(self, context):
3403         layout = self.layout
3404
3405         layout.operator("gpencil.interpolate", text="Interpolate")
3406         layout.operator("gpencil.interpolate_sequence", text="Sequence")
3407
3408
3409 # ********** Panel **********
3410
3411
3412 class VIEW3D_PT_grease_pencil(GreasePencilDataPanel, Panel):
3413     bl_space_type = 'VIEW_3D'
3414     bl_region_type = 'UI'
3415
3416     # NOTE: this is just a wrapper around the generic GP Panel
3417
3418
3419 class VIEW3D_PT_grease_pencil_palettecolor(GreasePencilPaletteColorPanel, Panel):
3420     bl_space_type = 'VIEW_3D'
3421     bl_region_type = 'UI'
3422
3423     # NOTE: this is just a wrapper around the generic GP Panel
3424
3425
3426 class VIEW3D_PT_view3d_properties(Panel):
3427     bl_space_type = 'VIEW_3D'
3428     bl_region_type = 'UI'
3429     bl_label = "View"
3430
3431     @classmethod
3432     def poll(cls, context):
3433         view = context.space_data
3434         return (view)
3435
3436     def draw(self, context):
3437         layout = self.layout
3438
3439         view = context.space_data
3440
3441         col = layout.column()
3442         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
3443         col.prop(view, "lens")
3444         col.label(text="Lock to Object:")
3445         col.prop(view, "lock_object", text="")
3446         lock_object = view.lock_object
3447         if lock_object:
3448             if lock_object.type == 'ARMATURE':
3449                 col.prop_search(view, "lock_bone", lock_object.data,
3450                                 "edit_bones" if lock_object.mode == 'EDIT'
3451                                 else "bones",
3452                                 text="")
3453         else:
3454             col.prop(view, "lock_cursor", text="Lock to Cursor")
3455
3456         col = layout.column()
3457         col.prop(view, "lock_camera")
3458
3459         col = layout.column(align=True)
3460         col.label(text="Clip:")
3461         col.prop(view, "clip_start", text="Start")
3462         col.prop(view, "clip_end", text="End")
3463
3464         subcol = col.column(align=True)
3465         subcol.enabled = not view.lock_camera_and_layers
3466         subcol.label(text="Local Camera:")
3467         subcol.prop(view, "camera", text="")
3468
3469         col = layout.column(align=True)
3470         col.prop(view, "use_render_border")
3471         col.active = view.region_3d.view_perspective != 'CAMERA'
3472
3473
3474 class VIEW3D_PT_view3d_cursor(Panel):
3475     bl_space_type = 'VIEW_3D'
3476     bl_region_type = 'UI'
3477     bl_label = "3D Cursor"
3478
3479     @classmethod
3480     def poll(cls, context):
3481         view = context.space_data
3482         return (view is not None)
3483
3484     def draw(self, context):
3485         layout = self.layout
3486
3487         view = context.space_data
3488         layout.column().prop(view, "cursor_location", text="Location")
3489
3490
3491 class VIEW3D_PT_view3d_name(Panel):
3492     bl_space_type = 'VIEW_3D'
3493     bl_region_type = 'UI'
3494     bl_label = "Item"
3495
3496     @classmethod
3497     def poll(cls, context):
3498         return (context.space_data and context.active_object)
3499
3500     def draw(self, context):
3501         layout = self.layout
3502
3503         ob = context.active_object
3504         row = layout.row()
3505         row.label(text="", icon='OBJECT_DATA')
3506         row.prop(ob, "name", text="")
3507
3508         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
3509             bone = context.active_bone
3510             if bone:
3511                 row = layout.row()
3512                 row.label(text="", icon='BONE_DATA')
3513                 row.prop(bone, "name", text="")
3514
3515
3516 class VIEW3D_PT_view3d_display(Panel):
3517     bl_space_type = 'VIEW_3D'
3518     bl_region_type = 'UI'
3519     bl_label = "Display"
3520     bl_options = {'DEFAULT_CLOSED'}
3521
3522     @classmethod
3523     def poll(cls, context):
3524         view = context.space_data
3525         return (view)
3526
3527     def draw(self, context):
3528         layout = self.layout
3529
3530         view = context.space_data
3531         scene = context.scene
3532
3533         col = layout.column()
3534         col.prop(view, "show_only_render")
3535         col.prop(view, "show_world")
3536
3537         if view.viewport_shade == "SOLID":
3538             col.prop(view, "show_random_object_colors")
3539             col.prop(view, "show_object_overlap")
3540
3541         if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
3542             col.prop(view, "show_mode_shade_override")
3543
3544         col = layout.column()
3545         display_all = not view.show_only_render
3546         col.active = display_all
3547         col.prop(view, "show_outline_selected")
3548         col.prop(view, "show_all_objects_origin")
3549         col.prop(view, "show_relationship_lines")
3550         col.prop(view, "show_face_orientation_overlay")
3551
3552         col = layout.column()
3553         col.active = display_all
3554         split = col.split(percentage=0.55)
3555         split.prop(view, "show_floor", text="Grid Floor")
3556
3557         row = split.row(align=True)
3558         row.prop(view, "show_axis_x", text="X", toggle=True)
3559         row.prop(view, "show_axis_y", text="Y", toggle=True)
3560         row.prop(view, "show_axis_z", text="Z", toggle=True)
3561
3562         sub = col.column(align=True)
3563         sub.active = bool(view.show_floor or view.region_quadviews or not view.region_3d.is_perspective)
3564         subsub = sub.column(align=True)
3565         subsub.active = view.show_floor
3566         subsub.prop(view, "grid_lines", text="Lines")
3567         sub.prop(view, "grid_scale", text="Scale")
3568         subsub = sub.column(align=True)
3569         subsub.active = scene.unit_settings.system == 'NONE'
3570         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
3571
3572         layout.separator()
3573
3574         layout.operator("screen.region_quadview", text="Toggle Quad View")
3575
3576         if view.region_quadviews:
3577             region = view.region_quadviews[2]
3578             col = layout.column()
3579             col.prop(region, "lock_rotation")
3580             row = col.row()
3581             row.enabled = region.lock_rotation
3582             row.prop(region, "show_sync_view")
3583             row = col.row()
3584             row.enabled = region.lock_rotation and region.show_sync_view
3585             row.prop(region, "use_box_clip")
3586
3587
3588 class VIEW3D_PT_view3d_stereo(Panel):
3589     bl_space_type = 'VIEW_3D'
3590     bl_region_type = 'UI'
3591     bl_label = "Stereoscopy"
3592     bl_options = {'DEFAULT_CLOSED'}
3593
3594     @classmethod
3595     def poll(cls, context):
3596         scene = context.scene
3597
3598         multiview = scene.render.use_multiview
3599         return context.space_data and multiview
3600
3601     def draw(self, context):
3602         layout = self.layout
3603         view = context.space_data
3604
3605         basic_stereo = context.scene.render.views_format == 'STEREO_3D'
3606
3607         col = layout.column()
3608         col.row().prop(view, "stereo_3d_camera", expand=True)
3609
3610         col.label(text="Display:")
3611        &nb