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