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