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