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