updated ndof popup menu (part 2 of 2)
[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
22
23 class VIEW3D_HT_header(bpy.types.Header):
24     bl_space_type = 'VIEW_3D'
25
26     def draw(self, context):
27         layout = self.layout
28
29         view = context.space_data
30         mode_string = context.mode
31         edit_object = context.edit_object
32         obj = context.active_object
33         toolsettings = context.tool_settings
34
35         row = layout.row(align=True)
36         row.template_header()
37
38         # Menus
39         if context.area.show_menus:
40             sub = row.row(align=True)
41
42             sub.menu("VIEW3D_MT_view")
43
44             # Select Menu
45             if mode_string not in {'EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
46                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
47
48             if edit_object:
49                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
50             elif obj:
51                 if mode_string not in {'PAINT_TEXTURE'}:
52                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
53             else:
54                 sub.menu("VIEW3D_MT_object")
55
56         row = layout.row()
57         row.template_header_3D()
58
59         # do in C for now since these buttons cant be both toggle AND exclusive.
60         '''
61         if obj and obj.mode == 'EDIT' and obj.type == 'MESH':
62             row_sub = row.row(align=True)
63             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=0, icon='VERTEXSEL')
64             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=1, icon='EDGESEL')
65             row_sub.prop(toolsettings, "mesh_select_mode", text="", index=2, icon='FACESEL')
66         '''
67
68         if obj:
69             # Particle edit
70             if obj.mode == 'PARTICLE_EDIT':
71                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True, toggle=True)
72
73             # Occlude geometry
74             if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
75                 row.prop(view, "use_occlude_geometry", text="")
76
77             # Proportional editing
78             if obj.mode in {'EDIT', 'PARTICLE_EDIT'}:
79                 row = layout.row(align=True)
80                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
81                 if toolsettings.proportional_edit != 'DISABLED':
82                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
83             elif obj.mode == 'OBJECT':
84                 row = layout.row(align=True)
85                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
86                 if toolsettings.use_proportional_edit_objects:
87                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
88
89         # Snap
90         row = layout.row(align=True)
91         row.prop(toolsettings, "use_snap", text="")
92         row.prop(toolsettings, "snap_element", text="", icon_only=True)
93         if toolsettings.snap_element != 'INCREMENT':
94             row.prop(toolsettings, "snap_target", text="")
95             if obj and obj.mode == 'OBJECT':
96                 row.prop(toolsettings, "use_snap_align_rotation", text="")
97         if toolsettings.snap_element == 'VOLUME':
98             row.prop(toolsettings, "use_snap_peel_object", text="")
99         elif toolsettings.snap_element == 'FACE':
100             row.prop(toolsettings, "use_snap_project", text="")
101             if toolsettings.use_snap_project and obj.mode == 'EDIT':
102                 row.prop(toolsettings, "use_snap_project_self", text="")
103
104         # OpenGL render
105         row = layout.row(align=True)
106         row.operator("render.opengl", text="", icon='RENDER_STILL')
107         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
108         props.animation = True
109
110         # Pose
111         if obj and obj.mode == 'POSE':
112             row = layout.row(align=True)
113             row.operator("pose.copy", text="", icon='COPYDOWN')
114             row.operator("pose.paste", text="", icon='PASTEDOWN')
115             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
116             props.flipped = 1
117
118
119 # ********** Menu **********
120
121 # ********** Utilities **********
122
123
124 class ShowHideMenu():
125     bl_label = "Show/Hide"
126     _operator_name = ""
127
128     def draw(self, context):
129         layout = self.layout
130
131         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
132         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
133         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
134
135
136 class VIEW3D_MT_transform(bpy.types.Menu):
137     bl_label = "Transform"
138
139     # TODO: get rid of the custom text strings?
140     def draw(self, context):
141         layout = self.layout
142
143         layout.operator("transform.translate", text="Grab/Move")
144         # TODO: sub-menu for grab per axis
145         layout.operator("transform.rotate", text="Rotate")
146         # TODO: sub-menu for rot per axis
147         layout.operator("transform.resize", text="Scale")
148         # TODO: sub-menu for scale per axis
149
150         layout.separator()
151
152         layout.operator("transform.tosphere", text="To Sphere")
153         layout.operator("transform.shear", text="Shear")
154         layout.operator("transform.warp", text="Warp")
155         layout.operator("transform.push_pull", text="Push/Pull")
156
157         layout.separator()
158
159         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
160         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
161
162         layout.separator()
163
164         obj = context.object
165         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}:
166             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
167
168         if context.edit_object and context.edit_object.type == 'ARMATURE':
169             layout.operator("armature.align")
170         else:
171             layout.operator_context = 'EXEC_REGION_WIN'
172             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
173
174         layout.separator()
175
176         layout.operator_context = 'EXEC_AREA'
177
178         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
179         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
180         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
181
182         layout.separator()
183
184         layout.operator("object.randomize_transform")
185         layout.operator("object.align")
186
187
188 class VIEW3D_MT_mirror(bpy.types.Menu):
189     bl_label = "Mirror"
190
191     def draw(self, context):
192         layout = self.layout
193
194         layout.operator("transform.mirror", text="Interactive Mirror")
195
196         layout.separator()
197
198         layout.operator_context = 'INVOKE_REGION_WIN'
199
200         props = layout.operator("transform.mirror", text="X Global")
201         props.constraint_axis = (True, False, False)
202         props.constraint_orientation = 'GLOBAL'
203         props = layout.operator("transform.mirror", text="Y Global")
204         props.constraint_axis = (False, True, False)
205         props.constraint_orientation = 'GLOBAL'
206         props = layout.operator("transform.mirror", text="Z Global")
207         props.constraint_axis = (False, False, True)
208         props.constraint_orientation = 'GLOBAL'
209
210         if context.edit_object:
211             layout.separator()
212
213             props = layout.operator("transform.mirror", text="X Local")
214             props.constraint_axis = (True, False, False)
215             props.constraint_orientation = 'LOCAL'
216             props = layout.operator("transform.mirror", text="Y Local")
217             props.constraint_axis = (False, True, False)
218             props.constraint_orientation = 'LOCAL'
219             props = layout.operator("transform.mirror", text="Z Local")
220             props.constraint_axis = (False, False, True)
221             props.constraint_orientation = 'LOCAL'
222
223             layout.operator("object.vertex_group_mirror")
224
225
226 class VIEW3D_MT_snap(bpy.types.Menu):
227     bl_label = "Snap"
228
229     def draw(self, context):
230         layout = self.layout
231
232         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
233         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
234
235         layout.separator()
236
237         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
238         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
239         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
240         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
241
242
243 class VIEW3D_MT_uv_map(bpy.types.Menu):
244     bl_label = "UV Mapping"
245
246     def draw(self, context):
247         layout = self.layout
248
249         layout.operator("uv.unwrap")
250
251         layout.operator_context = 'INVOKE_DEFAULT'
252         layout.operator("uv.smart_project")
253         layout.operator("uv.lightmap_pack")
254         layout.operator("uv.follow_active_quads")
255
256         layout.separator()
257
258         layout.operator_context = 'EXEC_DEFAULT'
259         layout.operator("uv.cube_project")
260         layout.operator("uv.cylinder_project")
261         layout.operator("uv.sphere_project")
262
263         layout.separator()
264
265         layout.operator("uv.project_from_view")
266         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
267
268         layout.separator()
269
270         layout.operator("uv.reset")
271
272
273 # ********** View menus **********
274
275
276 class VIEW3D_MT_view(bpy.types.Menu):
277     bl_label = "View"
278
279     def draw(self, context):
280         layout = self.layout
281
282         layout.operator("view3d.properties", icon='MENU_PANEL')
283         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
284
285         layout.separator()
286
287         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
288         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
289         layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
290         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
291         layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
292         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
293         layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
294
295         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
296
297         layout.separator()
298
299         layout.operator("view3d.view_persportho")
300
301         layout.separator()
302
303         layout.menu("VIEW3D_MT_view_navigation")
304         layout.menu("VIEW3D_MT_view_align")
305
306         layout.separator()
307
308         layout.operator_context = 'INVOKE_REGION_WIN'
309
310         layout.operator("view3d.clip_border", text="Clipping Border...")
311         layout.operator("view3d.zoom_border", text="Zoom Border...")
312
313         layout.separator()
314
315         layout.operator("view3d.layers", text="Show All Layers").nr = 0
316
317         layout.separator()
318
319         layout.operator("view3d.localview", text="View Global/Local")
320         layout.operator("view3d.view_selected")
321         layout.operator("view3d.view_all")
322
323         layout.separator()
324
325         layout.operator("screen.animation_play", text="Playback Animation")
326
327         layout.separator()
328
329         layout.operator("screen.area_dupli")
330         layout.operator("screen.region_quadview")
331         layout.operator("screen.screen_full_area")
332
333
334 class VIEW3D_MT_view_navigation(bpy.types.Menu):
335     bl_label = "Navigation"
336
337     def draw(self, context):
338         layout = self.layout
339
340         layout.operator_enum("view3d.view_orbit", "type")
341
342         layout.separator()
343
344         layout.operator_enum("view3d.view_pan", "type")
345
346         layout.separator()
347
348         layout.operator("view3d.zoom", text="Zoom In").delta = 1
349         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
350         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
351
352         layout.separator()
353
354         layout.operator("view3d.fly")
355
356
357 class VIEW3D_MT_ndof_settings(bpy.types.Menu):
358     bl_label = "3D Mouse Settings"
359
360     def draw(self, context):
361         layout = self.layout
362         input_prefs = context.user_preferences.inputs
363
364         layout.separator()
365         layout.prop(input_prefs, "ndof_sensitivity")
366
367         if context.space_data.type == 'VIEW_3D':
368             layout.separator()
369             layout.prop(input_prefs, "ndof_show_guide")
370
371             layout.separator()
372             layout.label(text="orbit options")
373             layout.prop(input_prefs, "ndof_orbit_invert_axes")
374
375             layout.separator()
376             layout.label(text="fly options")
377             layout.prop(input_prefs, "ndof_fly_helicopter", icon='NDOF_FLY')
378             layout.prop(input_prefs, "ndof_lock_horizon", icon='NDOF_DOM')
379
380
381 class VIEW3D_MT_view_align(bpy.types.Menu):
382     bl_label = "Align View"
383
384     def draw(self, context):
385         layout = self.layout
386
387         layout.menu("VIEW3D_MT_view_align_selected")
388
389         layout.separator()
390
391         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
392         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
393         layout.operator("view3d.view_selected")
394         layout.operator("view3d.view_center_cursor")
395
396
397 class VIEW3D_MT_view_align_selected(bpy.types.Menu):
398     bl_label = "Align View to Selected"
399
400     def draw(self, context):
401         layout = self.layout
402
403         props = layout.operator("view3d.viewnumpad", text="Top")
404         props.align_active = True
405         props.type = 'TOP'
406         props = layout.operator("view3d.viewnumpad", text="Bottom")
407         props.align_active = True
408         props.type = 'BOTTOM'
409         props = layout.operator("view3d.viewnumpad", text="Front")
410         props.align_active = True
411         props.type = 'FRONT'
412         props = layout.operator("view3d.viewnumpad", text="Back")
413         props.align_active = True
414         props.type = 'BACK'
415         props = layout.operator("view3d.viewnumpad", text="Right")
416         props.align_active = True
417         props.type = 'RIGHT'
418         props = layout.operator("view3d.viewnumpad", text="Left")
419         props.align_active = True
420         props.type = 'LEFT'
421
422
423 class VIEW3D_MT_view_cameras(bpy.types.Menu):
424     bl_label = "Cameras"
425
426     def draw(self, context):
427         layout = self.layout
428
429         layout.operator("view3d.object_as_camera")
430         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
431
432 # ********** Select menus, suffix from context.mode **********
433
434
435 class VIEW3D_MT_select_object(bpy.types.Menu):
436     bl_label = "Select"
437
438     def draw(self, context):
439         layout = self.layout
440
441         layout.operator("view3d.select_border")
442         layout.operator("view3d.select_circle")
443
444         layout.separator()
445
446         layout.operator("object.select_all", text="Select/Deselect All")
447         layout.operator("object.select_inverse", text="Inverse")
448         layout.operator("object.select_random", text="Random")
449         layout.operator("object.select_mirror", text="Mirror")
450         layout.operator("object.select_by_layer", text="Select All by Layer")
451         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
452         layout.operator("object.select_camera", text="Select Camera")
453
454         layout.separator()
455
456         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
457         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
458         layout.operator("object.select_pattern", text="Select Pattern...")
459
460
461 class VIEW3D_MT_select_pose(bpy.types.Menu):
462     bl_label = "Select"
463
464     def draw(self, context):
465         layout = self.layout
466
467         layout.operator("view3d.select_border")
468
469         layout.separator()
470
471         layout.operator("pose.select_all", text="Select/Deselect All")
472         layout.operator("pose.select_inverse", text="Inverse")
473         layout.operator("pose.select_flip_active", text="Flip Active")
474         layout.operator("pose.select_constraint_target", text="Constraint Target")
475         layout.operator("pose.select_linked", text="Linked")
476
477         layout.separator()
478
479         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
480         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
481
482         layout.separator()
483
484         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
485         props.extend = True
486         props.direction = 'PARENT'
487
488         props = layout.operator("pose.select_hierarchy", text="Extend Child")
489         props.extend = True
490         props.direction = 'CHILD'
491
492         layout.separator()
493
494         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
495         layout.operator("object.select_pattern", text="Select Pattern...")
496
497
498 class VIEW3D_MT_select_particle(bpy.types.Menu):
499     bl_label = "Select"
500
501     def draw(self, context):
502         layout = self.layout
503
504         layout.operator("view3d.select_border")
505
506         layout.separator()
507
508         layout.operator("particle.select_all", text="Select/Deselect All")
509         layout.operator("particle.select_linked")
510         layout.operator("particle.select_inverse")
511
512         layout.separator()
513
514         layout.operator("particle.select_more")
515         layout.operator("particle.select_less")
516
517         layout.separator()
518
519         layout.operator("particle.select_roots", text="Roots")
520         layout.operator("particle.select_tips", text="Tips")
521
522
523 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
524     bl_label = "Select"
525
526     def draw(self, context):
527         layout = self.layout
528
529         layout.operator("view3d.select_border")
530         layout.operator("view3d.select_circle")
531
532         layout.separator()
533
534         layout.operator("mesh.select_all", text="Select/Deselect All")
535         layout.operator("mesh.select_inverse", text="Inverse")
536
537         layout.separator()
538
539         layout.operator("mesh.select_random", text="Random")
540         layout.operator("mesh.select_nth", text="Every N Number of Verts")
541         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
542         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
543         layout.operator("mesh.faces_select_interior", text="Interior Faces")
544         layout.operator("mesh.select_axis", text="Side of Active")
545
546         layout.separator()
547
548         layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
549         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
550         if context.scene.tool_settings.mesh_select_mode[2] == False:
551                 layout.operator("mesh.select_non_manifold", text="Non Manifold")
552         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
553         layout.operator("mesh.select_similar", text="Similar")
554
555         layout.separator()
556
557         layout.operator("mesh.select_less", text="Less")
558         layout.operator("mesh.select_more", text="More")
559
560         layout.separator()
561
562         layout.operator("mesh.select_mirror", text="Mirror")
563
564         layout.operator("mesh.select_linked", text="Linked")
565         layout.operator("mesh.select_vertex_path", text="Vertex Path")
566         layout.operator("mesh.loop_multi_select", text="Edge Loop")
567         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
568
569         layout.separator()
570
571         layout.operator("mesh.loop_to_region")
572         layout.operator("mesh.region_to_loop")
573
574
575 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
576     bl_label = "Select"
577
578     def draw(self, context):
579         layout = self.layout
580
581         layout.operator("view3d.select_border")
582         layout.operator("view3d.select_circle")
583
584         layout.separator()
585
586         layout.operator("curve.select_all", text="Select/Deselect All")
587         layout.operator("curve.select_inverse")
588         layout.operator("curve.select_random")
589         layout.operator("curve.select_nth", text="Every Nth Number of Points")
590
591         layout.separator()
592
593         layout.operator("curve.de_select_first")
594         layout.operator("curve.de_select_last")
595         layout.operator("curve.select_next")
596         layout.operator("curve.select_previous")
597
598         layout.separator()
599
600         layout.operator("curve.select_more")
601         layout.operator("curve.select_less")
602
603
604 class VIEW3D_MT_select_edit_surface(bpy.types.Menu):
605     bl_label = "Select"
606
607     def draw(self, context):
608         layout = self.layout
609
610         layout.operator("view3d.select_border")
611         layout.operator("view3d.select_circle")
612
613         layout.separator()
614
615         layout.operator("curve.select_all", text="Select/Deselect All")
616         layout.operator("curve.select_inverse")
617         layout.operator("curve.select_random")
618         layout.operator("curve.select_nth", text="Every Nth Number of Points")
619
620         layout.separator()
621
622         layout.operator("curve.select_row")
623
624         layout.separator()
625
626         layout.operator("curve.select_more")
627         layout.operator("curve.select_less")
628
629
630 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
631     bl_label = "Select"
632
633     def draw(self, context):
634         layout = self.layout
635
636         layout.operator("view3d.select_border")
637
638         layout.separator()
639
640         layout.operator("mball.select_all").action = 'TOGGLE'
641         layout.operator("mball.select_inverse_metaelems")
642
643         layout.separator()
644
645         layout.operator("mball.select_random_metaelems")
646
647
648 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
649     bl_label = "Select"
650
651     def draw(self, context):
652         layout = self.layout
653
654         layout.operator("view3d.select_border")
655
656         layout.separator()
657
658         layout.operator("lattice.select_all", text="Select/Deselect All")
659
660
661 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
662     bl_label = "Select"
663
664     def draw(self, context):
665         layout = self.layout
666
667         layout.operator("view3d.select_border")
668
669         layout.separator()
670
671         layout.operator("armature.select_all", text="Select/Deselect All")
672         layout.operator("armature.select_inverse", text="Inverse")
673
674         layout.separator()
675
676         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
677         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
678
679         layout.separator()
680
681         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
682         props.extend = True
683         props.direction = 'PARENT'
684
685         props = layout.operator("armature.select_hierarchy", text="Extend Child")
686         props.extend = True
687         props.direction = 'CHILD'
688
689         layout.operator("object.select_pattern", text="Select Pattern...")
690
691
692 class VIEW3D_MT_select_face(bpy.types.Menu):  # XXX no matching enum
693     bl_label = "Select"
694
695     def draw(self, context):
696         # layout = self.layout
697
698         # TODO
699         # see view3d_select_faceselmenu
700         pass
701
702 # ********** Object menu **********
703
704
705 class VIEW3D_MT_object(bpy.types.Menu):
706     bl_context = "objectmode"
707     bl_label = "Object"
708
709     def draw(self, context):
710         layout = self.layout
711
712         layout.operator("ed.undo")
713         layout.operator("ed.redo")
714         layout.operator("ed.undo_history")
715
716         layout.separator()
717
718         layout.menu("VIEW3D_MT_transform")
719         layout.menu("VIEW3D_MT_mirror")
720         layout.menu("VIEW3D_MT_object_clear")
721         layout.menu("VIEW3D_MT_object_apply")
722         layout.menu("VIEW3D_MT_snap")
723
724         layout.separator()
725
726         layout.menu("VIEW3D_MT_object_animation")
727
728         layout.separator()
729
730         layout.operator("object.duplicate_move")
731         layout.operator("object.duplicate_move_linked")
732         layout.operator("object.delete", text="Delete...")
733         layout.operator("object.proxy_make", text="Make Proxy...")
734         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
735         layout.operator("object.make_dupli_face")
736         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
737         layout.menu("VIEW3D_MT_make_single_user")
738
739         layout.separator()
740
741         layout.menu("VIEW3D_MT_object_parent")
742         layout.menu("VIEW3D_MT_object_track")
743         layout.menu("VIEW3D_MT_object_group")
744         layout.menu("VIEW3D_MT_object_constraints")
745
746         layout.separator()
747
748         layout.menu("VIEW3D_MT_object_game")
749
750         layout.separator()
751
752         layout.operator("object.join_uvs")
753         layout.operator("object.join")
754
755         layout.separator()
756
757         layout.operator("object.move_to_layer", text="Move to Layer...")
758         layout.menu("VIEW3D_MT_object_showhide")
759
760         layout.operator_menu_enum("object.convert", "target")
761
762
763 class VIEW3D_MT_object_animation(bpy.types.Menu):
764     bl_label = "Animation"
765
766     def draw(self, context):
767         layout = self.layout
768
769         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
770         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
771         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
772
773
774 class VIEW3D_MT_object_clear(bpy.types.Menu):
775     bl_label = "Clear"
776
777     def draw(self, context):
778         layout = self.layout
779
780         layout.operator("object.location_clear", text="Location")
781         layout.operator("object.rotation_clear", text="Rotation")
782         layout.operator("object.scale_clear", text="Scale")
783         layout.operator("object.origin_clear", text="Origin")
784
785
786 class VIEW3D_MT_object_specials(bpy.types.Menu):
787     bl_label = "Specials"
788
789     @classmethod
790     def poll(cls, context):
791         # add more special types
792         return context.object
793
794     def draw(self, context):
795         layout = self.layout
796
797         obj = context.object
798         if obj.type == 'CAMERA':
799             layout.operator_context = 'INVOKE_REGION_WIN'
800
801             if obj.data.type == 'PERSP':
802                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
803                 props.data_path_iter = "selected_editable_objects"
804                 props.data_path_item = "data.lens"
805                 props.input_scale = 0.1
806             else:
807                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
808                 props.data_path_iter = "selected_editable_objects"
809                 props.data_path_item = "data.ortho_scale"
810                 props.input_scale = 0.01
811
812             if not obj.data.dof_object:
813                 #layout.label(text="Test Has DOF obj");
814                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
815                 props.data_path_iter = "selected_editable_objects"
816                 props.data_path_item = "data.dof_distance"
817                 props.input_scale = 0.02
818
819         if obj.type in {'CURVE', 'FONT'}:
820             layout.operator_context = 'INVOKE_REGION_WIN'
821
822             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
823             props.data_path_iter = "selected_editable_objects"
824             props.data_path_item = "data.extrude"
825             props.input_scale = 0.01
826
827             props = layout.operator("wm.context_modal_mouse", text="Width Size")
828             props.data_path_iter = "selected_editable_objects"
829             props.data_path_item = "data.offset"
830             props.input_scale = 0.01
831
832         if obj.type == 'EMPTY':
833             layout.operator_context = 'INVOKE_REGION_WIN'
834
835             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
836             props.data_path_iter = "selected_editable_objects"
837             props.data_path_item = "empty_draw_size"
838             props.input_scale = 0.01
839
840         if obj.type == 'LAMP':
841             layout.operator_context = 'INVOKE_REGION_WIN'
842
843             props = layout.operator("wm.context_modal_mouse", text="Energy")
844             props.data_path_iter = "selected_editable_objects"
845             props.data_path_item = "data.energy"
846
847             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
848                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
849                 props.data_path_iter = "selected_editable_objects"
850                 props.data_path_item = "data.distance"
851                 props.input_scale = 0.1
852
853             if obj.data.type == 'SPOT':
854                 layout.separator()
855                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
856                 props.data_path_iter = "selected_editable_objects"
857                 props.data_path_item = "data.spot_size"
858                 props.input_scale = 0.01
859
860                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
861                 props.data_path_iter = "selected_editable_objects"
862                 props.data_path_item = "data.spot_blend"
863                 props.input_scale = -0.01
864
865                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
866                 props.data_path_iter = "selected_editable_objects"
867                 props.data_path_item = "data.shadow_buffer_clip_start"
868                 props.input_scale = 0.05
869
870                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
871                 props.data_path_iter = "selected_editable_objects"
872                 props.data_path_item = "data.shadow_buffer_clip_end"
873                 props.input_scale = 0.05
874
875         layout.separator()
876
877         props = layout.operator("object.isolate_type_render")
878         props = layout.operator("object.hide_render_clear_all")
879
880
881 class VIEW3D_MT_object_apply(bpy.types.Menu):
882     bl_label = "Apply"
883
884     def draw(self, context):
885         layout = self.layout
886
887         layout.operator("object.transform_apply", text="Location").location = True
888         layout.operator("object.transform_apply", text="Rotation").rotation = True
889         layout.operator("object.transform_apply", text="Scale").scale = True
890         props = layout.operator("object.transform_apply", text="Rotation & Scale")
891         props.scale = True
892         props.rotation = True
893
894         layout.separator()
895
896         layout.operator("object.visual_transform_apply", text="Visual Transform")
897         layout.operator("object.duplicates_make_real")
898
899
900 class VIEW3D_MT_object_parent(bpy.types.Menu):
901     bl_label = "Parent"
902
903     def draw(self, context):
904         layout = self.layout
905
906         layout.operator("object.parent_set", text="Set")
907         layout.operator("object.parent_clear", text="Clear")
908
909
910 class VIEW3D_MT_object_track(bpy.types.Menu):
911     bl_label = "Track"
912
913     def draw(self, context):
914         layout = self.layout
915
916         layout.operator("object.track_set", text="Set")
917         layout.operator("object.track_clear", text="Clear")
918
919
920 class VIEW3D_MT_object_group(bpy.types.Menu):
921     bl_label = "Group"
922
923     def draw(self, context):
924         layout = self.layout
925
926         layout.operator("group.create")
927         layout.operator("group.objects_remove")
928
929         layout.separator()
930
931         layout.operator("group.objects_add_active")
932         layout.operator("group.objects_remove_active")
933
934
935 class VIEW3D_MT_object_constraints(bpy.types.Menu):
936     bl_label = "Constraints"
937
938     def draw(self, context):
939         layout = self.layout
940
941         layout.operator("object.constraint_add_with_targets")
942         layout.operator("object.constraints_copy")
943         layout.operator("object.constraints_clear")
944
945
946 class VIEW3D_MT_object_showhide(bpy.types.Menu):
947     bl_label = "Show/Hide"
948
949     def draw(self, context):
950         layout = self.layout
951
952         layout.operator("object.hide_view_clear", text="Show Hidden")
953         layout.operator("object.hide_view_set", text="Hide Selected")
954         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
955
956
957 class VIEW3D_MT_make_single_user(bpy.types.Menu):
958     bl_label = "Make Single User"
959
960     def draw(self, context):
961         layout = self.layout
962
963         props = layout.operator("object.make_single_user", text="Object")
964         props.object = True
965
966         props = layout.operator("object.make_single_user", text="Object & Data")
967         props.object = props.obdata = True
968
969         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
970         props.object = props.obdata = props.material = props.texture = True
971
972         props = layout.operator("object.make_single_user", text="Materials+Tex")
973         props.material = props.texture = True
974
975         props = layout.operator("object.make_single_user", text="Object Animation")
976         props.animation = True
977
978
979 class VIEW3D_MT_make_links(bpy.types.Menu):
980     bl_label = "Make Links"
981
982     def draw(self, context):
983         layout = self.layout
984
985         if(len(bpy.data.scenes) > 10):
986             layout.operator_context = 'INVOKE_DEFAULT'
987             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
988             layout.operator("object.make_links_scene", text="Markers to Scene...", icon='OUTLINER_OB_EMPTY')
989         else:
990             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
991             layout.operator_menu_enum("marker.make_links_scene", "scene", text="Markers to Scene...")
992
993         layout.operator_enum("object.make_links_data", "type")  # inline
994
995
996 class VIEW3D_MT_object_game(bpy.types.Menu):
997     bl_label = "Game"
998
999     def draw(self, context):
1000         layout = self.layout
1001
1002         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1003
1004         layout.separator()
1005
1006         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1007         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1008         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1009
1010         layout.separator()
1011
1012         layout.operator("object.game_property_clear")
1013
1014
1015 # ********** Vertex paint menu **********
1016
1017
1018 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
1019     bl_label = "Paint"
1020
1021     def draw(self, context):
1022         layout = self.layout
1023
1024         layout.operator("ed.undo")
1025         layout.operator("ed.redo")
1026
1027         layout.separator()
1028
1029         layout.operator("paint.vertex_color_set")
1030         layout.operator("paint.vertex_color_dirt")
1031
1032
1033 class VIEW3D_MT_hook(bpy.types.Menu):
1034     bl_label = "Hooks"
1035
1036     def draw(self, context):
1037         layout = self.layout
1038         layout.operator_context = 'EXEC_AREA'
1039         layout.operator("object.hook_add_newob")
1040         layout.operator("object.hook_add_selob")
1041
1042         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1043             layout.separator()
1044             layout.operator_menu_enum("object.hook_assign", "modifier")
1045             layout.operator_menu_enum("object.hook_remove", "modifier")
1046             layout.separator()
1047             layout.operator_menu_enum("object.hook_select", "modifier")
1048             layout.operator_menu_enum("object.hook_reset", "modifier")
1049             layout.operator_menu_enum("object.hook_recenter", "modifier")
1050
1051
1052 class VIEW3D_MT_vertex_group(bpy.types.Menu):
1053     bl_label = "Vertex Groups"
1054
1055     def draw(self, context):
1056         layout = self.layout
1057         layout.operator_context = 'EXEC_AREA'
1058         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1059
1060         ob = context.active_object
1061         if ob.mode == 'EDIT':
1062             if ob.vertex_groups.active:
1063                 layout.separator()
1064                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1065                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
1066                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1067                 layout.separator()
1068
1069         if ob.vertex_groups.active:
1070             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1071             layout.operator("object.vertex_group_remove", text="Remove Active Group")
1072             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1073
1074 # ********** Weight paint menu **********
1075
1076
1077 class VIEW3D_MT_paint_weight(bpy.types.Menu):
1078     bl_label = "Weights"
1079
1080     def draw(self, context):
1081         layout = self.layout
1082
1083         layout.operator("ed.undo")
1084         layout.operator("ed.redo")
1085         layout.operator("ed.undo_history")
1086
1087         layout.separator()
1088
1089         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1090         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1091
1092         layout.separator()
1093
1094         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1095         layout.operator("object.vertex_group_normalize", text="Normalize")
1096         layout.operator("object.vertex_group_invert", text="Invert")
1097         layout.operator("object.vertex_group_clean", text="Clean")
1098         layout.operator("object.vertex_group_levels", text="Levels")
1099
1100         layout.separator()
1101
1102         layout.operator("paint.weight_set")
1103
1104 # ********** Sculpt menu **********
1105
1106
1107 class VIEW3D_MT_sculpt(bpy.types.Menu):
1108     bl_label = "Sculpt"
1109
1110     def draw(self, context):
1111         layout = self.layout
1112
1113         tool_settings = context.tool_settings
1114         sculpt = tool_settings.sculpt
1115         brush = tool_settings.sculpt.brush
1116
1117         layout.operator("ed.undo")
1118         layout.operator("ed.redo")
1119
1120         layout.separator()
1121
1122         layout.prop(sculpt, "use_symmetry_x")
1123         layout.prop(sculpt, "use_symmetry_y")
1124         layout.prop(sculpt, "use_symmetry_z")
1125         layout.separator()
1126         layout.prop(sculpt, "lock_x")
1127         layout.prop(sculpt, "lock_y")
1128         layout.prop(sculpt, "lock_z")
1129         layout.separator()
1130         layout.operator_menu_enum("brush.curve_preset", "shape")
1131         layout.separator()
1132
1133         if brush is not None:  # unlikely but can happen
1134             sculpt_tool = brush.sculpt_tool
1135
1136             if sculpt_tool != 'GRAB':
1137                 layout.prop_menu_enum(brush, "stroke_method")
1138
1139                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1140                     layout.prop_menu_enum(brush, "direction")
1141
1142                 if sculpt_tool == 'LAYER':
1143                     layout.prop(brush, "use_persistent")
1144                     layout.operator("sculpt.set_persistent_base")
1145
1146         layout.separator()
1147         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1148         layout.prop(sculpt, "show_brush")
1149
1150         # TODO, make availabel from paint menu!
1151         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Unify Size")
1152         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Unify Strength")
1153
1154 # ********** Particle menu **********
1155
1156
1157 class VIEW3D_MT_particle(bpy.types.Menu):
1158     bl_label = "Particle"
1159
1160     def draw(self, context):
1161         layout = self.layout
1162
1163         particle_edit = context.tool_settings.particle_edit
1164
1165         layout.operator("ed.undo")
1166         layout.operator("ed.redo")
1167         layout.operator("ed.undo_history")
1168
1169         layout.separator()
1170
1171         layout.operator("particle.mirror")
1172
1173         layout.separator()
1174
1175         layout.operator("particle.remove_doubles")
1176         layout.operator("particle.delete")
1177
1178         if particle_edit.select_mode == 'POINT':
1179             layout.operator("particle.subdivide")
1180
1181         layout.operator("particle.rekey")
1182         layout.operator("particle.weight_set")
1183
1184         layout.separator()
1185
1186         layout.menu("VIEW3D_MT_particle_showhide")
1187
1188
1189 class VIEW3D_MT_particle_specials(bpy.types.Menu):
1190     bl_label = "Specials"
1191
1192     def draw(self, context):
1193         layout = self.layout
1194         particle_edit = context.tool_settings.particle_edit
1195
1196         layout.operator("particle.rekey")
1197
1198         layout.separator()
1199         if particle_edit.select_mode == 'POINT':
1200             layout.operator("particle.subdivide")
1201             layout.operator("particle.select_roots")
1202             layout.operator("particle.select_tips")
1203
1204         layout.operator("particle.remove_doubles")
1205
1206
1207 class VIEW3D_MT_particle_showhide(ShowHideMenu, bpy.types.Menu):
1208     _operator_name = "particle"
1209
1210 # ********** Pose Menu **********
1211
1212
1213 class VIEW3D_MT_pose(bpy.types.Menu):
1214     bl_label = "Pose"
1215
1216     def draw(self, context):
1217         layout = self.layout
1218
1219         layout.operator("ed.undo")
1220         layout.operator("ed.redo")
1221         layout.operator("ed.undo_history")
1222
1223         layout.separator()
1224
1225         layout.menu("VIEW3D_MT_transform")
1226
1227         layout.menu("VIEW3D_MT_pose_transform")
1228         layout.menu("VIEW3D_MT_pose_apply")
1229
1230         layout.menu("VIEW3D_MT_snap")
1231
1232         layout.separator()
1233
1234         layout.menu("VIEW3D_MT_object_animation")
1235
1236         layout.separator()
1237
1238         layout.menu("VIEW3D_MT_pose_slide")
1239         layout.menu("VIEW3D_MT_pose_propagate")
1240
1241         layout.separator()
1242
1243         layout.operator("pose.copy")
1244         layout.operator("pose.paste")
1245         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1246
1247         layout.separator()
1248
1249         layout.menu("VIEW3D_MT_pose_library")
1250         layout.menu("VIEW3D_MT_pose_motion")
1251         layout.menu("VIEW3D_MT_pose_group")
1252
1253         layout.separator()
1254
1255         layout.menu("VIEW3D_MT_object_parent")
1256         layout.menu("VIEW3D_MT_pose_ik")
1257         layout.menu("VIEW3D_MT_pose_constraints")
1258
1259         layout.separator()
1260
1261         layout.operator_context = 'EXEC_AREA'
1262         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1263         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1264         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1265
1266         layout.operator("pose.flip_names")
1267
1268         layout.operator("pose.quaternions_flip")
1269
1270         layout.separator()
1271
1272         layout.operator_context = 'INVOKE_AREA'
1273         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1274         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1275
1276         layout.separator()
1277
1278         layout.menu("VIEW3D_MT_pose_showhide")
1279         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1280
1281
1282 class VIEW3D_MT_pose_transform(bpy.types.Menu):
1283     bl_label = "Clear Transform"
1284
1285     def draw(self, context):
1286         layout = self.layout
1287
1288         layout.operator("pose.transforms_clear", text="All")
1289
1290         layout.operator("pose.loc_clear", text="Location")
1291         layout.operator("pose.rot_clear", text="Rotation")
1292         layout.operator("pose.scale_clear", text="Scale")
1293
1294         layout.label(text="Origin")
1295
1296
1297 class VIEW3D_MT_pose_slide(bpy.types.Menu):
1298     bl_label = "In-Betweens"
1299
1300     def draw(self, context):
1301         layout = self.layout
1302
1303         layout.operator("pose.push")
1304         layout.operator("pose.relax")
1305         layout.operator("pose.breakdown")
1306
1307
1308 class VIEW3D_MT_pose_propagate(bpy.types.Menu):
1309     bl_label = "Propagate"
1310
1311     def draw(self, context):
1312         layout = self.layout
1313
1314         layout.operator("pose.propagate")
1315
1316         layout.separator()
1317
1318         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1319         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1320
1321         layout.separator()
1322
1323         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1324
1325
1326 class VIEW3D_MT_pose_library(bpy.types.Menu):
1327     bl_label = "Pose Library"
1328
1329     def draw(self, context):
1330         layout = self.layout
1331
1332         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1333
1334         layout.separator()
1335
1336         layout.operator("poselib.pose_add", text="Add Pose...")
1337         layout.operator("poselib.pose_rename", text="Rename Pose...")
1338         layout.operator("poselib.pose_remove", text="Remove Pose...")
1339
1340
1341 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1342     bl_label = "Motion Paths"
1343
1344     def draw(self, context):
1345         layout = self.layout
1346
1347         layout.operator("pose.paths_calculate", text="Calculate")
1348         layout.operator("pose.paths_clear", text="Clear")
1349
1350
1351 class VIEW3D_MT_pose_group(bpy.types.Menu):
1352     bl_label = "Bone Groups"
1353
1354     def draw(self, context):
1355         layout = self.layout
1356         layout.operator("pose.group_add")
1357         layout.operator("pose.group_remove")
1358
1359         layout.separator()
1360
1361         layout.operator("pose.group_assign")
1362         layout.operator("pose.group_unassign")
1363
1364
1365 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1366     bl_label = "Inverse Kinematics"
1367
1368     def draw(self, context):
1369         layout = self.layout
1370
1371         layout.operator("pose.ik_add")
1372         layout.operator("pose.ik_clear")
1373
1374
1375 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1376     bl_label = "Constraints"
1377
1378     def draw(self, context):
1379         layout = self.layout
1380
1381         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1382         layout.operator("pose.constraints_copy")
1383         layout.operator("pose.constraints_clear")
1384
1385
1386 class VIEW3D_MT_pose_showhide(ShowHideMenu, bpy.types.Menu):
1387     _operator_name = "pose"
1388
1389
1390 class VIEW3D_MT_pose_apply(bpy.types.Menu):
1391     bl_label = "Apply"
1392
1393     def draw(self, context):
1394         layout = self.layout
1395
1396         layout.operator("pose.armature_apply")
1397         layout.operator("pose.visual_transform_apply")
1398
1399
1400 class BoneOptions:
1401     def draw(self, context):
1402         layout = self.layout
1403
1404         options = [
1405             "show_wire",
1406             "use_deform",
1407             "use_envelope_multiply",
1408             "use_inherit_rotation",
1409             "use_inherit_scale",
1410         ]
1411
1412         if context.mode == 'EDIT_ARMATURE':
1413             bone_props = bpy.types.EditBone.bl_rna.properties
1414             data_path_iter = "selected_bones"
1415             opt_suffix = ""
1416             options.append("lock")
1417         else:  # posemode
1418             bone_props = bpy.types.Bone.bl_rna.properties
1419             data_path_iter = "selected_pose_bones"
1420             opt_suffix = "bone."
1421
1422         for opt in options:
1423             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1424             props.data_path_iter = data_path_iter
1425             props.data_path_item = opt_suffix + opt
1426             props.type = self.type
1427
1428
1429 class VIEW3D_MT_bone_options_toggle(bpy.types.Menu, BoneOptions):
1430     bl_label = "Toggle Bone Options"
1431     type = 'TOGGLE'
1432
1433
1434 class VIEW3D_MT_bone_options_enable(bpy.types.Menu, BoneOptions):
1435     bl_label = "Enable Bone Options"
1436     type = 'ENABLE'
1437
1438
1439 class VIEW3D_MT_bone_options_disable(bpy.types.Menu, BoneOptions):
1440     bl_label = "Disable Bone Options"
1441     type = 'DISABLE'
1442
1443 # ********** Edit Menus, suffix from ob.type **********
1444
1445
1446 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1447     bl_label = "Mesh"
1448
1449     def draw(self, context):
1450         layout = self.layout
1451
1452         settings = context.tool_settings
1453
1454         layout.operator("ed.undo")
1455         layout.operator("ed.redo")
1456         layout.operator("ed.undo_history")
1457
1458         layout.separator()
1459
1460         layout.menu("VIEW3D_MT_transform")
1461         layout.menu("VIEW3D_MT_mirror")
1462         layout.menu("VIEW3D_MT_snap")
1463
1464         layout.separator()
1465
1466         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1467
1468         layout.separator()
1469
1470         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1471         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1472         layout.operator("mesh.duplicate_move")
1473         layout.operator("mesh.delete", text="Delete...")
1474
1475         layout.separator()
1476
1477         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1478         layout.menu("VIEW3D_MT_edit_mesh_edges")
1479         layout.menu("VIEW3D_MT_edit_mesh_faces")
1480         layout.menu("VIEW3D_MT_edit_mesh_normals")
1481
1482         layout.separator()
1483
1484         layout.prop(settings, "use_mesh_automerge")
1485         layout.prop_menu_enum(settings, "proportional_edit")
1486         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1487
1488         layout.separator()
1489
1490         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1491
1492
1493 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1494     bl_label = "Specials"
1495
1496     def draw(self, context):
1497         layout = self.layout
1498
1499         layout.operator_context = 'INVOKE_REGION_WIN'
1500
1501         layout.operator("mesh.subdivide", text="Subdivide")
1502         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1503         layout.operator("mesh.merge", text="Merge...")
1504         layout.operator("mesh.remove_doubles")
1505         layout.operator("mesh.hide", text="Hide")
1506         layout.operator("mesh.reveal", text="Reveal")
1507         layout.operator("mesh.select_inverse")
1508         layout.operator("mesh.flip_normals")
1509         layout.operator("mesh.vertices_smooth", text="Smooth")
1510         # layout.operator("mesh.bevel", text="Bevel")
1511         layout.operator("mesh.faces_shade_smooth")
1512         layout.operator("mesh.faces_shade_flat")
1513         layout.operator("mesh.blend_from_shape")
1514         layout.operator("mesh.shape_propagate_to_all")
1515         layout.operator("mesh.select_vertex_path")
1516
1517
1518 class VIEW3D_MT_edit_mesh_select_mode(bpy.types.Menu):
1519     bl_label = "Mesh Select Mode"
1520
1521     def draw(self, context):
1522         layout = self.layout
1523
1524         layout.operator_context = 'INVOKE_REGION_WIN'
1525
1526         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1527         prop.value = "(True, False, False)"
1528         prop.data_path = "tool_settings.mesh_select_mode"
1529
1530         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1531         prop.value = "(False, True, False)"
1532         prop.data_path = "tool_settings.mesh_select_mode"
1533
1534         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1535         prop.value = "(False, False, True)"
1536         prop.data_path = "tool_settings.mesh_select_mode"
1537
1538
1539 class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu):
1540     bl_label = "Extrude"
1541
1542     _extrude_funcs = { \
1543         "VERT": lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1544         "EDGE": lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1545         "FACE": lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1546         "REGION": lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1547     }
1548
1549     @staticmethod
1550     def extrude_options(context):
1551         mesh = context.object.data
1552         select_mode = context.tool_settings.mesh_select_mode
1553
1554         menu = []
1555         if mesh.total_face_sel:
1556             menu += ["REGION", "FACE"]
1557         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1558             menu += ["EDGE"]
1559         if mesh.total_vert_sel and select_mode[0]:
1560             menu += ["VERT"]
1561
1562         # should never get here
1563         return menu
1564
1565     def draw(self, context):
1566         layout = self.layout
1567         layout.operator_context = 'INVOKE_REGION_WIN'
1568
1569         for menu_id in self.extrude_options(context):
1570             self._extrude_funcs[menu_id](layout)
1571
1572
1573 class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator):
1574     "Extrude individual elements and move"
1575     bl_label = "Extrude Individual and Move"
1576     bl_idname = "view3d.edit_mesh_extrude_individual_move"
1577
1578     def execute(self, context):
1579         mesh = context.object.data
1580         select_mode = context.tool_settings.mesh_select_mode
1581
1582         totface = mesh.total_face_sel
1583         totedge = mesh.total_edge_sel
1584         # totvert = mesh.total_vert_sel
1585
1586         if select_mode[2] and totface == 1:
1587             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (False, False, True)})
1588         elif select_mode[2] and totface > 1:
1589             bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
1590         elif select_mode[1] and totedge >= 1:
1591             bpy.ops.mesh.extrude_edges_move('INVOKE_REGION_WIN')
1592         else:
1593             bpy.ops.mesh.extrude_vertices_move('INVOKE_REGION_WIN')
1594
1595         # ignore return from operators above because they are 'RUNNING_MODAL', and cause this one not to be freed. [#24671]
1596         return {'FINISHED'}
1597
1598     def invoke(self, context, event):
1599         return self.execute(context)
1600
1601
1602 class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator):
1603     "Extrude and move along normals"
1604     bl_label = "Extrude and Move on Normals"
1605     bl_idname = "view3d.edit_mesh_extrude_move_normal"
1606
1607     def execute(self, context):
1608         mesh = context.object.data
1609
1610         totface = mesh.total_face_sel
1611         totedge = mesh.total_edge_sel
1612         # totvert = mesh.total_vert_sel
1613
1614         if totface >= 1:
1615             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (False, False, True)})
1616         elif totedge == 1:
1617             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": 'NORMAL', "constraint_axis": (True, True, False)})
1618         else:
1619             bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')
1620
1621         # ignore return from operators above because they are 'RUNNING_MODAL', and cause this one not to be freed. [#24671]
1622         return {'FINISHED'}
1623
1624     def invoke(self, context, event):
1625         return self.execute(context)
1626
1627
1628 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1629     bl_label = "Vertices"
1630
1631     def draw(self, context):
1632         layout = self.layout
1633         layout.operator_context = 'INVOKE_REGION_WIN'
1634
1635         layout.operator("mesh.merge")
1636         layout.operator("mesh.rip_move")
1637         layout.operator("mesh.split")
1638         layout.operator("mesh.separate")
1639
1640         layout.separator()
1641
1642         layout.operator("mesh.vertices_smooth")
1643         layout.operator("mesh.remove_doubles")
1644         layout.operator("mesh.vertices_sort")
1645         layout.operator("mesh.vertices_randomize")
1646
1647         layout.operator("mesh.select_vertex_path")
1648
1649         layout.operator("mesh.blend_from_shape")
1650
1651         layout.operator("object.vertex_group_blend")
1652         layout.operator("mesh.shape_propagate_to_all")
1653
1654         layout.separator()
1655
1656         layout.menu("VIEW3D_MT_vertex_group")
1657         layout.menu("VIEW3D_MT_hook")
1658
1659
1660 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1661     bl_label = "Edges"
1662
1663     def draw(self, context):
1664         layout = self.layout
1665         layout.operator_context = 'INVOKE_REGION_WIN'
1666
1667         layout.operator("mesh.edge_face_add")
1668         layout.operator("mesh.subdivide")
1669
1670         layout.separator()
1671
1672         layout.operator("mesh.mark_seam")
1673         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1674
1675         layout.separator()
1676
1677         layout.operator("mesh.mark_sharp")
1678         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1679
1680         layout.separator()
1681
1682         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1683         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1684
1685         layout.separator()
1686
1687         layout.operator("TRANSFORM_OT_edge_slide")
1688         layout.operator("TRANSFORM_OT_edge_crease")
1689         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1690
1691         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1692         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1693
1694         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1695
1696         layout.operator("mesh.loop_to_region")
1697         layout.operator("mesh.region_to_loop")
1698
1699
1700 class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
1701     bl_label = "Faces"
1702     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1703
1704     def draw(self, context):
1705         layout = self.layout
1706         layout.operator_context = 'INVOKE_REGION_WIN'
1707
1708         layout.operator("mesh.flip_normals")
1709         # layout.operator("mesh.bevel")
1710         # layout.operator("mesh.bevel")
1711         layout.operator("mesh.edge_face_add")
1712         layout.operator("mesh.fill")
1713         layout.operator("mesh.beautify_fill")
1714         layout.operator("mesh.solidify")
1715         layout.operator("mesh.sort_faces")
1716
1717         layout.separator()
1718
1719         layout.operator("mesh.fgon_make")
1720         layout.operator("mesh.fgon_clear")
1721
1722         layout.separator()
1723
1724         layout.operator("mesh.quads_convert_to_tris")
1725         layout.operator("mesh.tris_convert_to_quads")
1726         layout.operator("mesh.edge_flip")
1727
1728         layout.separator()
1729
1730         layout.operator("mesh.faces_shade_smooth")
1731         layout.operator("mesh.faces_shade_flat")
1732
1733         layout.separator()
1734
1735         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1736         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1737
1738         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1739
1740         layout.separator()
1741
1742         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1743         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1744         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1745         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1746
1747
1748 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1749     bl_label = "Normals"
1750
1751     def draw(self, context):
1752         layout = self.layout
1753
1754         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1755         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1756
1757         layout.separator()
1758
1759         layout.operator("mesh.flip_normals")
1760
1761
1762 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, bpy.types.Menu):
1763     _operator_name = "mesh"
1764
1765 # Edit Curve
1766 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1767
1768
1769 def draw_curve(self, context):
1770     layout = self.layout
1771
1772     settings = context.tool_settings
1773
1774     layout.menu("VIEW3D_MT_transform")
1775     layout.menu("VIEW3D_MT_mirror")
1776     layout.menu("VIEW3D_MT_snap")
1777
1778     layout.separator()
1779
1780     layout.operator("curve.extrude")
1781     layout.operator("curve.duplicate")
1782     layout.operator("curve.separate")
1783     layout.operator("curve.make_segment")
1784     layout.operator("curve.cyclic_toggle")
1785     layout.operator("curve.delete", text="Delete...")
1786
1787     layout.separator()
1788
1789     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1790     layout.menu("VIEW3D_MT_edit_curve_segments")
1791
1792     layout.separator()
1793
1794     layout.prop_menu_enum(settings, "proportional_edit")
1795     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1796
1797     layout.separator()
1798
1799     layout.menu("VIEW3D_MT_edit_curve_showhide")
1800
1801
1802 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1803     bl_label = "Curve"
1804
1805     draw = draw_curve
1806
1807
1808 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1809     bl_label = "Control Points"
1810
1811     def draw(self, context):
1812         layout = self.layout
1813
1814         edit_object = context.edit_object
1815
1816         if edit_object.type == 'CURVE':
1817             layout.operator("transform.transform", text="Tilt").mode = 'TILT'
1818             layout.operator("curve.tilt_clear")
1819             layout.operator("curve.separate")
1820
1821             layout.separator()
1822
1823             layout.operator_menu_enum("curve.handle_type_set", "type")
1824
1825             layout.separator()
1826
1827             layout.menu("VIEW3D_MT_hook")
1828
1829
1830 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1831     bl_label = "Segments"
1832
1833     def draw(self, context):
1834         layout = self.layout
1835
1836         layout.operator("curve.subdivide")
1837         layout.operator("curve.switch_direction")
1838
1839
1840 class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
1841     bl_label = "Specials"
1842
1843     def draw(self, context):
1844         layout = self.layout
1845
1846         layout.operator("curve.subdivide")
1847         layout.operator("curve.switch_direction")
1848         layout.operator("curve.spline_weight_set")
1849         layout.operator("curve.radius_set")
1850         layout.operator("curve.smooth")
1851         layout.operator("curve.smooth_radius")
1852
1853
1854 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, bpy.types.Menu):
1855     _operator_name = "curve"
1856
1857
1858 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1859     bl_label = "Surface"
1860
1861     draw = draw_curve
1862
1863
1864 class VIEW3D_MT_edit_font(bpy.types.Menu):
1865     bl_label = "Text"
1866
1867     def draw(self, context):
1868         layout = self.layout
1869
1870         layout.operator("font.file_paste")
1871
1872         layout.separator()
1873
1874         layout.menu("VIEW3D_MT_edit_text_chars")
1875
1876         layout.separator()
1877
1878         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1879         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1880         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1881         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1882
1883
1884 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1885     bl_label = "Special Characters"
1886
1887     def draw(self, context):
1888         layout = self.layout
1889
1890         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1891         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1892
1893         layout.separator()
1894
1895         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1896         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1897         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1898         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1899         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1900         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1901         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1902         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1903         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1904
1905         layout.separator()
1906
1907         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1908         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1909         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1910
1911         layout.separator()
1912
1913         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1914         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1915         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1916
1917
1918 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1919     bl_label = "Metaball"
1920
1921     def draw(self, context):
1922         layout = self.layout
1923
1924         settings = context.tool_settings
1925
1926         layout.operator("ed.undo")
1927         layout.operator("ed.redo")
1928         layout.operator("ed.undo_history")
1929
1930         layout.separator()
1931
1932         layout.menu("VIEW3D_MT_transform")
1933         layout.menu("VIEW3D_MT_mirror")
1934         layout.menu("VIEW3D_MT_snap")
1935
1936         layout.separator()
1937
1938         layout.operator("mball.delete_metaelems", text="Delete...")
1939         layout.operator("mball.duplicate_metaelems")
1940
1941         layout.separator()
1942
1943         layout.prop_menu_enum(settings, "proportional_edit")
1944         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1945
1946         layout.separator()
1947
1948         layout.menu("VIEW3D_MT_edit_meta_showhide")
1949
1950
1951 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1952     bl_label = "Show/Hide"
1953
1954     def draw(self, context):
1955         layout = self.layout
1956
1957         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1958         layout.operator("mball.hide_metaelems", text="Hide Selected")
1959         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1960
1961
1962 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1963     bl_label = "Lattice"
1964
1965     def draw(self, context):
1966         layout = self.layout
1967
1968         settings = context.tool_settings
1969
1970         layout.menu("VIEW3D_MT_transform")
1971         layout.menu("VIEW3D_MT_mirror")
1972         layout.menu("VIEW3D_MT_snap")
1973
1974         layout.separator()
1975
1976         layout.operator("lattice.make_regular")
1977
1978         layout.separator()
1979
1980         layout.prop_menu_enum(settings, "proportional_edit")
1981         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1982
1983
1984 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1985     bl_label = "Armature"
1986
1987     def draw(self, context):
1988         layout = self.layout
1989
1990         edit_object = context.edit_object
1991         arm = edit_object.data
1992
1993         layout.menu("VIEW3D_MT_transform")
1994         layout.menu("VIEW3D_MT_mirror")
1995         layout.menu("VIEW3D_MT_snap")
1996         layout.menu("VIEW3D_MT_edit_armature_roll")
1997
1998         layout.separator()
1999
2000         layout.operator("armature.extrude_move")
2001
2002         if arm.use_mirror_x:
2003             layout.operator("armature.extrude_forked")
2004
2005         layout.operator("armature.duplicate_move")
2006         layout.operator("armature.merge")
2007         layout.operator("armature.fill")
2008         layout.operator("armature.delete")
2009         layout.operator("armature.separate")
2010
2011         layout.separator()
2012
2013         layout.operator("armature.subdivide", text="Subdivide")
2014         layout.operator("armature.switch_direction", text="Switch Direction")
2015
2016         layout.separator()
2017
2018         layout.operator_context = 'EXEC_AREA'
2019         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2020         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2021         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2022         layout.operator("armature.flip_names")
2023
2024         layout.separator()
2025
2026         layout.operator_context = 'INVOKE_DEFAULT'
2027         layout.operator("armature.armature_layers")
2028         layout.operator("armature.bone_layers")
2029
2030         layout.separator()
2031
2032         layout.menu("VIEW3D_MT_edit_armature_parent")
2033
2034         layout.separator()
2035
2036         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2037
2038
2039 class VIEW3D_MT_armature_specials(bpy.types.Menu):
2040     bl_label = "Specials"
2041
2042     def draw(self, context):
2043         layout = self.layout
2044
2045         layout.operator_context = 'INVOKE_REGION_WIN'
2046
2047         layout.operator("armature.subdivide", text="Subdivide")
2048         layout.operator("armature.switch_direction", text="Switch Direction")
2049
2050         layout.separator()
2051
2052         layout.operator_context = 'EXEC_REGION_WIN'
2053         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2054         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2055         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2056         layout.operator("armature.flip_names", text="Flip Names")
2057
2058
2059 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
2060     bl_label = "Parent"
2061
2062     def draw(self, context):
2063         layout = self.layout
2064
2065         layout.operator("armature.parent_set", text="Make")
2066         layout.operator("armature.parent_clear", text="Clear")
2067
2068
2069 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
2070     bl_label = "Bone Roll"
2071
2072     def draw(self, context):
2073         layout = self.layout
2074
2075         layout.operator_menu_enum("armature.calculate_roll", "type")
2076
2077         layout.separator()
2078
2079         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2080
2081 # ********** Panel **********
2082
2083
2084 class VIEW3D_PT_view3d_properties(bpy.types.Panel):
2085     bl_space_type = 'VIEW_3D'
2086     bl_region_type = 'UI'
2087     bl_label = "View"
2088
2089     @classmethod
2090     def poll(cls, context):
2091         view = context.space_data
2092         return (view)
2093
2094     def draw(self, context):
2095         layout = self.layout
2096
2097         view = context.space_data
2098
2099         col = layout.column()
2100         col.active = view.region_3d.view_perspective != 'CAMERA'
2101         col.prop(view, "lens")
2102         col.label(text="Lock to Object:")
2103         col.prop(view, "lock_object", text="")
2104         if view.lock_object and view.lock_object.type == 'ARMATURE':
2105             col.prop_search(view, "lock_bone", view.lock_object.data, "bones", text="")
2106         elif not view.lock_object:
2107             col.prop(view, "lock_cursor", text="Lock to Cursor")
2108
2109         col = layout.column()
2110         col.prop(view, "lock_camera")
2111
2112         col = layout.column(align=True)
2113         col.label(text="Clip:")
2114         col.prop(view, "clip_start", text="Start")
2115         col.prop(view, "clip_end", text="End")
2116
2117         subcol = col.column()
2118         subcol.enabled = not view.lock_camera_and_layers
2119         subcol.label(text="Local Camera:")
2120         subcol.prop(view, "camera", text="")
2121
2122         layout.column().prop(view, "cursor_location")
2123
2124
2125 class VIEW3D_PT_view3d_name(bpy.types.Panel):
2126     bl_space_type = 'VIEW_3D'
2127     bl_region_type = 'UI'
2128     bl_label = "Item"
2129
2130     @classmethod
2131     def poll(cls, context):
2132         return (context.space_data and context.active_object)
2133
2134     def draw(self, context):
2135         layout = self.layout
2136
2137         ob = context.active_object
2138         row = layout.row()
2139         row.label(text="", icon='OBJECT_DATA')
2140         row.prop(ob, "name", text="")
2141
2142         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2143             bone = context.active_bone
2144             if bone:
2145                 row = layout.row()
2146                 row.label(text="", icon='BONE_DATA')
2147                 row.prop(bone, "name", text="")
2148
2149
2150 class VIEW3D_PT_view3d_display(bpy.types.Panel):
2151     bl_space_type = 'VIEW_3D'
2152     bl_region_type = 'UI'
2153     bl_label = "Display"
2154     bl_options = {'DEFAULT_CLOSED'}
2155
2156     @classmethod
2157     def poll(cls, context):
2158         view = context.space_data
2159         return (view)
2160
2161     def draw(self, context):
2162         layout = self.layout
2163
2164         view = context.space_data
2165         scene = context.scene
2166         gs = scene.game_settings
2167         ob = context.object
2168
2169         col = layout.column()
2170         col.prop(view, "show_only_render")
2171
2172         col = layout.column()
2173         display_all = not view.show_only_render
2174         col.active = display_all
2175         col.prop(view, "show_outline_selected")
2176         col.prop(view, "show_all_objects_origin")
2177         col.prop(view, "show_relationship_lines")
2178         if ob and ob.type == 'MESH':
2179             mesh = ob.data
2180             col.prop(mesh, "show_all_edges")
2181
2182         col = layout.column()
2183         col.active = display_all
2184         split = col.split(percentage=0.55)
2185         split.prop(view, "show_floor", text="Grid Floor")
2186
2187         row = split.row(align=True)
2188         row.prop(view, "show_axis_x", text="X", toggle=True)
2189         row.prop(view, "show_axis_y", text="Y", toggle=True)
2190         row.prop(view, "show_axis_z", text="Z", toggle=True)
2191
2192         sub = col.column(align=True)
2193         sub.active = (display_all and view.show_floor)
2194         sub.prop(view, "grid_lines", text="Lines")
2195         sub.prop(view, "grid_scale", text="Scale")
2196         subsub = sub.column(align=True)
2197         subsub.active = scene.unit_settings.system == 'NONE'
2198         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2199
2200         col = layout.column()
2201         col.label(text="Shading:")
2202         col.prop(gs, "material_mode", text="")
2203         col.prop(view, "show_textured_solid")
2204
2205         layout.separator()
2206
2207         region = view.region_quadview
2208
2209         layout.operator("screen.region_quadview", text="Toggle Quad View")
2210
2211         if region:
2212             col = layout.column()
2213             col.prop(region, "lock_rotation")
2214             row = col.row()
2215             row.enabled = region.lock_rotation
2216             row.prop(region, "show_sync_view")
2217             row = col.row()
2218             row.enabled = region.lock_rotation and region.show_sync_view
2219             row.prop(region, "use_box_clip")
2220
2221
2222 class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel):
2223     bl_space_type = 'VIEW_3D'
2224     bl_region_type = 'UI'
2225     bl_label = "Mesh Display"
2226
2227     @classmethod
2228     def poll(cls, context):
2229         # The active object check is needed because of localmode
2230         return (context.active_object and (context.mode == 'EDIT_MESH'))
2231
2232     def draw(self, context):
2233         layout = self.layout
2234
2235         mesh = context.active_object.data
2236
2237         col = layout.column()
2238         col.label(text="Overlays:")
2239         col.prop(mesh, "show_edges", text="Edges")
2240         col.prop(mesh, "show_faces", text="Faces")
2241         col.prop(mesh, "show_edge_crease", text="Creases")
2242         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2243         col.prop(mesh, "show_edge_seams", text="Seams")
2244         col.prop(mesh, "show_edge_sharp", text="Sharp")
2245
2246         col.separator()
2247         col.label(text="Normals:")
2248         col.prop(mesh, "show_normal_face", text="Face")
2249         col.prop(mesh, "show_normal_vertex", text="Vertex")
2250         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2251
2252         col.separator()
2253         col.label(text="Numerics:")
2254         col.prop(mesh, "show_extra_edge_length")
2255         col.prop(mesh, "show_extra_face_angle")
2256         col.prop(mesh, "show_extra_face_area")
2257
2258
2259 class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel):
2260     bl_space_type = 'VIEW_3D'
2261     bl_region_type = 'UI'
2262     bl_label = "Curve Display"
2263
2264     @classmethod
2265     def poll(cls, context):
2266         editmesh = context.mode == 'EDIT_CURVE'
2267         return (editmesh)
2268
2269     def draw(self, context):
2270         layout = self.layout
2271
2272         curve = context.active_object.data
2273
2274         col = layout.column()
2275         col.label(text="Overlays:")
2276         col.prop(curve, "show_handles", text="Handles")
2277         col.prop(curve, "show_normal_face", text="Normals")
2278         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2279
2280
2281 class VIEW3D_PT_background_image(bpy.types.Panel):
2282     bl_space_type = 'VIEW_3D'
2283     bl_region_type = 'UI'
2284     bl_label = "Background Images"
2285     bl_options = {'DEFAULT_CLOSED'}
2286
2287     @classmethod
2288     def poll(cls, context):
2289         view = context.space_data
2290         # bg = context.space_data.background_image
2291         return (view)
2292
2293     def draw_header(self, context):
2294         layout = self.layout
2295         view = context.space_data
2296
2297         layout.prop(view, "show_background_images", text="")
2298
2299     def draw(self, context):
2300         layout = self.layout
2301
2302         view = context.space_data
2303
2304         col = layout.column()
2305         col.operator("view3d.background_image_add", text="Add Image")
2306
2307         for i, bg in enumerate(view.background_images):
2308             layout.active = view.show_background_images
2309             box = layout.box()
2310             row = box.row(align=True)
2311             row.prop(bg, "show_expanded", text="", emboss=False)
2312             if bg.image:
2313                 row.prop(bg.image, "name", text="", emboss=False)
2314             else:
2315                 row.label(text="Not Set")
2316             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2317
2318             box.prop(bg, "view_axis", text="Axis")
2319
2320             if bg.show_expanded:
2321                 row = box.row()
2322                 row.template_ID(bg, "image", open="image.open")
2323                 if (bg.image):
2324                     box.template_image(bg, "image", bg.image_user, compact=True)
2325
2326                     box.prop(bg, "opacity", slider=True)
2327                     if bg.view_axis != 'CAMERA':
2328                         box.prop(bg, "size")
2329                         row = box.row(align=True)
2330                         row.prop(bg, "offset_x", text="X")
2331                         row.prop(bg, "offset_y", text="Y")
2332
2333
2334 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
2335     bl_space_type = 'VIEW_3D'
2336     bl_region_type = 'UI'
2337     bl_label = "Transform Orientations"
2338     bl_options = {'DEFAULT_CLOSED'}
2339
2340     @classmethod
2341     def poll(cls, context):
2342         view = context.space_data
2343         return (view)
2344
2345     def draw(self, context):
2346         layout = self.layout
2347
2348         view = context.space_data
2349
2350         col = layout.column()
2351
2352         col.prop(view, "transform_orientation")
2353         col.operator("transform.create_orientation", text="Create")
2354
2355         orientation = view.current_orientation
2356
2357         if orientation:
2358             col.prop(orientation, "name")
2359             col.operator("transform.delete_orientation", text="Delete")
2360
2361
2362 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
2363     bl_space_type = 'VIEW_3D'
2364     bl_region_type = 'UI'
2365     bl_label = "Skeleton Sketching"
2366     bl_options = {'DEFAULT_CLOSED'}
2367
2368     @classmethod
2369     def poll(cls, context):
2370         scene = context.space_data
2371         ob = context.active_object
2372         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2373
2374     def draw_header(self, context):
2375         layout = self.layout
2376         toolsettings = context.scene.tool_settings
2377
2378         layout.prop(toolsettings, "use_bone_sketching", text="")
2379
2380     def draw(self, context):
2381         layout = self.layout
2382         toolsettings = context.scene.tool_settings
2383
2384         col = layout.column()
2385
2386         col.prop(toolsettings, "use_etch_quick")
2387         col.prop(toolsettings, "use_etch_overdraw")
2388
2389         col.prop(toolsettings, "etch_convert_mode")
2390
2391         if toolsettings.etch_convert_mode == 'LENGTH':
2392             col.prop(toolsettings, "etch_length_limit")
2393         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2394             col.prop(toolsettings, "etch_adaptive_limit")
2395         elif toolsettings.etch_convert_mode == 'FIXED':
2396             col.prop(toolsettings, "etch_subdivision_number")
2397         elif toolsettings.etch_convert_mode == 'RETARGET':
2398             col.prop(toolsettings, "etch_template")
2399             col.prop(toolsettings, "etch_roll_mode")
2400             col.prop(toolsettings, "use_etch_autoname")
2401             col.prop(toolsettings, "etch_number")
2402             col.prop(toolsettings, "etch_side")
2403
2404         col.operator("sketch.convert", text="Convert")
2405
2406
2407 class VIEW3D_PT_context_properties(bpy.types.Panel):
2408     bl_space_type = 'VIEW_3D'
2409     bl_region_type = 'UI'
2410     bl_label = "Properties"
2411     bl_options = {'DEFAULT_CLOSED'}
2412
2413     def _active_context_member(context):
2414         obj = context.object
2415         if obj:
2416             mode = obj.mode
2417             if mode == 'POSE':
2418                 return "active_pose_bone"
2419             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2420                 return "active_bone"
2421             else:
2422                 return "object"
2423
2424         return ""
2425
2426     @classmethod
2427     def poll(cls, context):
2428         member = cls._active_context_member(context)
2429         if member:
2430             context_member = getattr(context, member)
2431             return context_member and context_member.keys()
2432
2433         return False
2434
2435     def draw(self, context):
2436         import rna_prop_ui
2437         member = VIEW3D_PT_context_properties._active_context_member(context)
2438
2439         if member:
2440             # Draw with no edit button
2441             rna_prop_ui.draw(self.layout, context, member, object, False)
2442
2443
2444 def register():
2445     bpy.utils.register_module(__name__)
2446
2447
2448 def unregister():
2449     bpy.utils.unregister_module(__name__)
2450
2451 if __name__ == "__main__":
2452     register()
2453
2454 if __name__ == "__main__":  # only for live edit.
2455     bpy.utils.register_module(__name__)