Added Toggle Full Screen and Duplicate Area to the menus of all the main spaces in...
[blender-staging.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 import dynamic_menu
22
23
24 class VIEW3D_HT_header(bpy.types.Header):
25     bl_space_type = 'VIEW_3D'
26
27     def draw(self, context):
28         layout = self.layout
29
30         view = context.space_data
31         mode_string = context.mode
32         edit_object = context.edit_object
33         obj = context.active_object
34         toolsettings = context.scene.tool_settings
35         
36         row = layout.row()
37         row.template_header()
38         
39         sub = row.row(align=True)
40         
41         # Menus
42         if context.area.show_menus:
43             
44             sub.menu("VIEW3D_MT_view")
45
46             # Select Menu
47             if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'):
48                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
49
50             if edit_object:
51                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
52             elif obj:
53                 if mode_string not in ('PAINT_WEIGHT'):
54                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
55             else:
56                 sub.menu("VIEW3D_MT_object")
57
58         row.template_header_3D()
59
60         # Particle edit
61         if obj and obj.mode == 'PARTICLE_EDIT':
62             row.prop(toolsettings.particle_edit, "selection_mode", text="", expand=True, toggle=True)
63
64         # Occlude geometry
65         if obj and view.viewport_shading in ('SOLID', 'SHADED', 'TEXTURED') and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
66             row.prop(view, "occlude_geometry", text="")
67
68         # Proportional editing
69         if obj and obj.mode in ('OBJECT', 'EDIT'):
70             row = layout.row(align=True)
71             row.prop(toolsettings, "proportional_editing", text="", icon_only=True)
72             if toolsettings.proportional_editing != 'DISABLED':
73                 row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True)
74
75         # Snap
76         row = layout.row(align=True)
77         row.prop(toolsettings, "snap", text="")
78         row.prop(toolsettings, "snap_element", text="", icon_only=True)
79         if toolsettings.snap_element != 'INCREMENT':
80             row.prop(toolsettings, "snap_target", text="")
81             if obj and obj.mode == 'OBJECT':
82                 row.prop(toolsettings, "snap_align_rotation", text="")
83         if toolsettings.snap_element == 'VOLUME':
84             row.prop(toolsettings, "snap_peel_object", text="")
85         elif toolsettings.snap_element == 'FACE':
86             row.prop(toolsettings, "snap_project", text="")
87
88         # OpenGL render
89         row = layout.row(align=True)
90         row.operator("screen.opengl_render", text="", icon='ICON_RENDER_STILL')
91         props = row.operator("screen.opengl_render", text="", icon='ICON_RENDER_ANIMATION')
92         props.animation = True
93
94         # Pose
95         if obj and obj.mode == 'POSE':
96             row = layout.row(align=True)
97             row.operator("pose.copy", text="", icon='ICON_COPYDOWN')
98             row.operator("pose.paste", text="", icon='ICON_PASTEDOWN')
99             props = row.operator("pose.paste", text="", icon='ICON_PASTEFLIPDOWN')
100             props.flipped = 1
101
102
103 # ********** Menu **********
104
105 # ********** Utilities **********
106
107
108 class VIEW3D_MT_showhide(bpy.types.Menu):
109     bl_label = "Show/Hide"
110     _operator_name = ""
111
112     def draw(self, context):
113         layout = self.layout
114
115         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
116         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
117         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
118
119
120 class VIEW3D_MT_transform(bpy.types.Menu):
121     bl_label = "Transform"
122
123     # TODO: get rid of the custom text strings?
124     def draw(self, context):
125         layout = self.layout
126
127         layout.operator("tfm.translate", text="Grab/Move")
128         # TODO: sub-menu for grab per axis
129         layout.operator("tfm.rotate", text="Rotate")
130         # TODO: sub-menu for rot per axis
131         layout.operator("tfm.resize", text="Scale")
132         # TODO: sub-menu for scale per axis
133
134         layout.separator()
135
136         layout.operator("tfm.tosphere", text="To Sphere")
137         layout.operator("tfm.shear", text="Shear")
138         layout.operator("tfm.warp", text="Warp")
139         layout.operator("tfm.transform", text="Push/Pull").mode = 'PUSHPULL'
140         if context.edit_object and context.edit_object.type == 'ARMATURE':
141             layout.operator("armature.align")
142         else:
143             layout.operator_context = 'EXEC_REGION_WIN'
144             layout.operator("tfm.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working
145
146         layout.separator()
147
148         layout.operator_context = 'EXEC_AREA'
149
150         layout.operator("object.center_set", text="Object Data to Origin").type = 'CENTER'
151         layout.operator("object.center_set", text="Origin to Object Data").type = 'CENTER_NEW'
152         layout.operator("object.center_set", text="Origin to 3D Cursor").type = 'CENTER_CURSOR'
153
154
155 class VIEW3D_MT_mirror(bpy.types.Menu):
156     bl_label = "Mirror"
157
158     def draw(self, context):
159         layout = self.layout
160
161         layout.operator("tfm.mirror", text="Interactive Mirror")
162
163         layout.separator()
164
165         layout.operator_context = 'INVOKE_REGION_WIN'
166
167         props = layout.operator("tfm.mirror", text="X Global")
168         props.constraint_axis = (True, False, False)
169         props.constraint_orientation = 'GLOBAL'
170         props = layout.operator("tfm.mirror", text="Y Global")
171         props.constraint_axis = (False, True, False)
172         props.constraint_orientation = 'GLOBAL'
173         props = layout.operator("tfm.mirror", text="Z Global")
174         props.constraint_axis = (False, False, True)
175         props.constraint_orientation = 'GLOBAL'
176
177         if context.edit_object:
178             layout.separator()
179
180             props = layout.operator("tfm.mirror", text="X Local")
181             props.constraint_axis = (True, False, False)
182             props.constraint_orientation = 'LOCAL'
183             props = layout.operator("tfm.mirror", text="Y Local")
184             props.constraint_axis = (False, True, False)
185             props.constraint_orientation = 'LOCAL'
186             props = layout.operator("tfm.mirror", text="Z Local")
187             props.constraint_axis = (False, False, True)
188             props.constraint_orientation = 'LOCAL'
189
190
191 class VIEW3D_MT_snap(bpy.types.Menu):
192     bl_label = "Snap"
193
194     def draw(self, context):
195         layout = self.layout
196
197         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
198         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
199         layout.operator("view3d.snap_selected_to_center", text="Selection to Origin")
200
201         layout.separator()
202
203         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
204         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
205         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
206
207
208 class VIEW3D_MT_uv_map(dynamic_menu.DynMenu):
209     bl_label = "UV Mapping"
210
211     def draw(self, context):
212         layout = self.layout
213
214         layout.operator("uv.unwrap")
215         layout.operator("uv.cube_project")
216         layout.operator("uv.cylinder_project")
217         layout.operator("uv.sphere_project")
218         layout.operator("uv.project_from_view")
219
220         layout.separator()
221
222         layout.operator("uv.reset")
223
224 # ********** View menus **********
225
226
227 class VIEW3D_MT_view(bpy.types.Menu):
228     bl_label = "View"
229
230     def draw(self, context):
231         layout = self.layout
232
233         layout.operator("view3d.properties", icon='ICON_MENU_PANEL')
234         layout.operator("view3d.toolbar", icon='ICON_MENU_PANEL')
235
236         layout.separator()
237
238         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
239         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
240         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
241         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
242
243         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
244
245         layout.separator()
246
247         layout.operator("view3d.view_persportho")
248
249         layout.separator()
250
251         layout.menu("VIEW3D_MT_view_navigation")
252         layout.menu("VIEW3D_MT_view_align")
253
254         layout.separator()
255
256         layout.operator_context = 'INVOKE_REGION_WIN'
257
258         layout.operator("view3d.clip_border", text="Clipping Border...")
259         layout.operator("view3d.zoom_border", text="Zoom Border...")
260
261         layout.separator()
262
263         layout.operator("view3d.layers", text="Show All Layers").nr = 0
264
265         layout.separator()
266
267         layout.operator("view3d.localview", text="View Global/Local")
268         layout.operator("view3d.view_center")
269         layout.operator("view3d.view_all")
270
271         layout.separator()
272         
273         layout.operator("screen.animation_play", text="Playback Animation")
274         
275         layout.separator()
276         
277         layout.operator("screen.area_dupli")
278         layout.operator("screen.region_foursplit")
279         layout.operator("screen.screen_full_area")
280
281         
282
283         
284
285
286 class VIEW3D_MT_view_navigation(bpy.types.Menu):
287     bl_label = "Navigation"
288
289     def draw(self, context):
290         layout = self.layout
291
292         layout.operator_enums("view3d.view_orbit", "type")
293
294         layout.separator()
295
296         layout.operator_enums("view3d.view_pan", "type")
297
298         layout.separator()
299
300         layout.operator("view3d.zoom", text="Zoom In").delta = 1.0
301         layout.operator("view3d.zoom", text="Zoom Out").delta = -1.0
302
303         layout.separator()
304
305         layout.operator("view3d.fly")
306
307
308 class VIEW3D_MT_view_align(bpy.types.Menu):
309     bl_label = "Align View"
310
311     def draw(self, context):
312         layout = self.layout
313
314         layout.menu("VIEW3D_MT_view_align_selected")
315
316         layout.separator()
317
318         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
319         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
320         layout.operator("view3d.view_center")
321         layout.operator("view3d.view_center_cursor")
322
323
324 class VIEW3D_MT_view_align_selected(bpy.types.Menu):
325     bl_label = "Align View to Selected"
326
327     def draw(self, context):
328         layout = self.layout
329
330         props = layout.operator("view3d.viewnumpad", text="Top")
331         props.align_active = True
332         props.type = 'TOP'
333         props = layout.operator("view3d.viewnumpad", text="Bottom")
334         props.align_active = True
335         props.type = 'BOTTOM'
336         props = layout.operator("view3d.viewnumpad", text="Front")
337         props.align_active = True
338         props.type = 'FRONT'
339         props = layout.operator("view3d.viewnumpad", text="Back")
340         props.align_active = True
341         props.type = 'BACK'
342         props = layout.operator("view3d.viewnumpad", text="Right")
343         props.align_active = True
344         props.type = 'RIGHT'
345         props = layout.operator("view3d.viewnumpad", text="Left")
346         props.align_active = True
347         props.type = 'LEFT'
348
349
350 class VIEW3D_MT_view_cameras(bpy.types.Menu):
351     bl_label = "Cameras"
352
353     def draw(self, context):
354         layout = self.layout
355
356         layout.operator("view3d.object_as_camera")
357         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
358
359 # ********** Select menus, suffix from context.mode **********
360
361
362 class VIEW3D_MT_select_object(bpy.types.Menu):
363     bl_label = "Select"
364
365     def draw(self, context):
366         layout = self.layout
367
368         layout.operator("view3d.select_border")
369         layout.operator("view3d.select_circle")
370
371         layout.separator()
372
373         layout.operator("object.select_all", text="Select/Deselect All")
374         layout.operator("object.select_inverse", text="Inverse")
375         layout.operator("object.select_random", text="Random")
376         layout.operator("object.select_mirror", text="Mirror")
377         layout.operator("object.select_by_layer", text="Select All by Layer")
378         layout.operator_menu_enum("object.select_by_type", "type", "", text="Select All by Type...")
379
380         layout.separator()
381
382         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
383         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
384         layout.operator("object.select_pattern", text="Select Pattern...")
385
386
387 class VIEW3D_MT_select_pose(bpy.types.Menu):
388     bl_label = "Select"
389
390     def draw(self, context):
391         layout = self.layout
392
393         layout.operator("view3d.select_border")
394
395         layout.separator()
396
397         layout.operator("pose.select_all", text="Select/Deselect All")
398         layout.operator("pose.select_inverse", text="Inverse")
399         layout.operator("pose.select_constraint_target", text="Constraint Target")
400         layout.operator("pose.select_linked", text="Linked")
401
402         layout.separator()
403
404         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
405         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
406
407         layout.separator()
408
409         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
410         props.extend = True
411         props.direction = 'PARENT'
412
413         props = layout.operator("pose.select_hierarchy", text="Extend Child")
414         props.extend = True
415         props.direction = 'CHILD'
416         
417         layout.operator("object.select_pattern", text="Select Pattern...")
418
419
420 class VIEW3D_MT_select_particle(bpy.types.Menu):
421     bl_label = "Select"
422
423     def draw(self, context):
424         layout = self.layout
425
426         layout.operator("view3d.select_border")
427
428         layout.separator()
429
430         layout.operator("particle.select_all", text="Select/Deselect All")
431         layout.operator("particle.select_linked")
432         layout.operator("particle.select_inverse")
433
434         layout.separator()
435
436         layout.operator("particle.select_more")
437         layout.operator("particle.select_less")
438
439         layout.separator()
440
441         layout.operator("particle.select_first", text="Roots")
442         layout.operator("particle.select_last", text="Tips")
443
444
445 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
446     bl_label = "Select"
447
448     def draw(self, context):
449         layout = self.layout
450
451         layout.operator("view3d.select_border")
452         layout.operator("view3d.select_circle")
453
454         layout.separator()
455
456         layout.operator("mesh.select_all", text="Select/Deselect All")
457         layout.operator("mesh.select_inverse", text="Inverse")
458
459         layout.separator()
460
461         layout.operator("mesh.select_random", text="Random...")
462         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
463         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
464         layout.operator("mesh.faces_select_interior", text="Interior Faces")
465         layout.operator("mesh.select_axis", text="Side of Active")
466
467         layout.separator()
468
469         layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
470         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
471         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
472         layout.operator("mesh.select_similar", text="Similar...")
473
474         layout.separator()
475
476         layout.operator("mesh.select_less", text="Less")
477         layout.operator("mesh.select_more", text="More")
478
479         layout.separator()
480
481         layout.operator("mesh.select_mirror", text="Mirror")
482
483         layout.operator("mesh.select_linked", text="Linked")
484         layout.operator("mesh.select_vertex_path", text="Vertex Path")
485         layout.operator("mesh.loop_multi_select", text="Edge Loop")
486         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
487
488         layout.separator()
489
490         layout.operator("mesh.loop_to_region")
491         layout.operator("mesh.region_to_loop")
492
493
494 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
495     bl_label = "Select"
496
497     def draw(self, context):
498         layout = self.layout
499
500         layout.operator("view3d.select_border")
501         layout.operator("view3d.select_circle")
502
503         layout.separator()
504
505         layout.operator("curve.select_all", text="Select/Deselect All")
506         layout.operator("curve.select_inverse")
507         layout.operator("curve.select_random")
508         layout.operator("curve.select_every_nth")
509
510         layout.separator()
511
512         layout.operator("curve.de_select_first")
513         layout.operator("curve.de_select_last")
514         layout.operator("curve.select_next")
515         layout.operator("curve.select_previous")
516
517         layout.separator()
518
519         layout.operator("curve.select_more")
520         layout.operator("curve.select_less")
521
522
523 class VIEW3D_MT_select_edit_surface(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("curve.select_all", text="Select/Deselect All")
535         layout.operator("curve.select_inverse")
536         layout.operator("curve.select_random")
537         layout.operator("curve.select_every_nth")
538
539         layout.separator()
540
541         layout.operator("curve.select_row")
542
543         layout.separator()
544
545         layout.operator("curve.select_more")
546         layout.operator("curve.select_less")
547
548
549 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
550     bl_label = "Select"
551
552     def draw(self, context):
553         layout = self.layout
554
555         layout.operator("view3d.select_border")
556
557         layout.separator()
558
559         layout.operator("mball.select_deselect_all_metaelems")
560         layout.operator("mball.select_inverse_metaelems")
561
562         layout.separator()
563
564         layout.operator("mball.select_random_metaelems")
565
566
567 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
568     bl_label = "Select"
569
570     def draw(self, context):
571         layout = self.layout
572
573         layout.operator("view3d.select_border")
574
575         layout.separator()
576
577         layout.operator("lattice.select_all", text="Select/Deselect All")
578
579
580 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
581     bl_label = "Select"
582
583     def draw(self, context):
584         layout = self.layout
585
586         layout.operator("view3d.select_border")
587
588
589         layout.separator()
590
591         layout.operator("armature.select_all", text="Select/Deselect All")
592         layout.operator("armature.select_inverse", text="Inverse")
593
594         layout.separator()
595
596         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
597         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
598
599         layout.separator()
600
601         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
602         props.extend = True
603         props.direction = 'PARENT'
604
605         props = layout.operator("armature.select_hierarchy", text="Extend Child")
606         props.extend = True
607         props.direction = 'CHILD'
608         
609         layout.operator("object.select_pattern", text="Select Pattern...")
610
611
612 class VIEW3D_MT_select_face(bpy.types.Menu):# XXX no matching enum
613     bl_label = "Select"
614
615     def draw(self, context):
616         layout = self.layout
617
618         # TODO
619         # see view3d_select_faceselmenu
620
621 # ********** Object menu **********
622
623
624 class VIEW3D_MT_object(bpy.types.Menu):
625     bl_context = "objectmode"
626     bl_label = "Object"
627
628     def draw(self, context):
629         layout = self.layout
630
631         layout.menu("VIEW3D_MT_transform")
632         layout.menu("VIEW3D_MT_mirror")
633         layout.menu("VIEW3D_MT_object_clear")
634         layout.menu("VIEW3D_MT_object_apply")
635         layout.menu("VIEW3D_MT_snap")
636
637         layout.separator()
638
639         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
640         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
641
642         layout.separator()
643
644         layout.operator("object.duplicate_move")
645         layout.operator("object.duplicate", text="Duplicate Linked").linked = True
646         layout.operator("object.delete", text="Delete...")
647         layout.operator("object.proxy_make", text="Make Proxy...")
648         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
649         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
650         layout.menu("VIEW3D_MT_make_single_user")
651
652         layout.separator()
653
654         layout.menu("VIEW3D_MT_object_parent")
655         layout.menu("VIEW3D_MT_object_track")
656         layout.menu("VIEW3D_MT_object_group")
657         layout.menu("VIEW3D_MT_object_constraints")
658
659         layout.separator()
660
661         layout.operator("object.join_shapes")
662         layout.operator("object.join")
663
664         layout.separator()
665
666         layout.operator("object.move_to_layer", text="Move to Layer...")
667         layout.menu("VIEW3D_MT_object_showhide")
668
669         layout.operator_menu_enum("object.convert", "target")
670
671
672 class VIEW3D_MT_object_clear(bpy.types.Menu):
673     bl_label = "Clear"
674
675     def draw(self, context):
676         layout = self.layout
677
678         layout.operator("object.location_clear", text="Location")
679         layout.operator("object.rotation_clear", text="Rotation")
680         layout.operator("object.scale_clear", text="Scale")
681         layout.operator("object.origin_clear", text="Origin")
682
683
684 class VIEW3D_MT_object_apply(bpy.types.Menu):
685     bl_label = "Apply"
686
687     def draw(self, context):
688         layout = self.layout
689
690         layout.operator("object.location_apply", text="Location")
691         layout.operator("object.rotation_apply", text="Rotation")
692         layout.operator("object.scale_apply", text="Scale")
693         layout.separator()
694         layout.operator("object.visual_transform_apply", text="Visual Transform")
695         layout.operator("object.duplicates_make_real")
696
697
698 class VIEW3D_MT_object_parent(bpy.types.Menu):
699     bl_label = "Parent"
700
701     def draw(self, context):
702         layout = self.layout
703
704         layout.operator("object.parent_set", text="Set")
705         layout.operator("object.parent_clear", text="Clear")
706
707
708 class VIEW3D_MT_object_track(bpy.types.Menu):
709     bl_label = "Track"
710
711     def draw(self, context):
712         layout = self.layout
713
714         layout.operator("object.track_set", text="Set")
715         layout.operator("object.track_clear", text="Clear")
716
717
718 class VIEW3D_MT_object_group(bpy.types.Menu):
719     bl_label = "Group"
720
721     def draw(self, context):
722         layout = self.layout
723
724         layout.operator("group.create")
725         layout.operator("group.objects_remove")
726
727         layout.separator()
728
729         layout.operator("group.objects_add_active")
730         layout.operator("group.objects_remove_active")
731
732
733 class VIEW3D_MT_object_constraints(bpy.types.Menu):
734     bl_label = "Constraints"
735
736     def draw(self, context):
737         layout = self.layout
738
739         layout.operator("object.constraint_add_with_targets")
740         layout.operator("object.constraints_clear")
741
742
743 class VIEW3D_MT_object_showhide(bpy.types.Menu):
744     bl_label = "Show/Hide"
745
746     def draw(self, context):
747         layout = self.layout
748
749         layout.operator("object.restrictview_clear", text="Show Hidden")
750         layout.operator("object.restrictview_set", text="Hide Selected")
751         layout.operator("object.restrictview_set", text="Hide Unselected").unselected = True
752
753
754 class VIEW3D_MT_make_single_user(bpy.types.Menu):
755     bl_label = "Make Single User"
756
757     def draw(self, context):
758         layout = self.layout
759
760         props = layout.operator("object.make_single_user", text="Object")
761         props.object = True
762
763         props = layout.operator("object.make_single_user", text="Object & ObData")
764         props.object = props.obdata = True
765
766         props = layout.operator("object.make_single_user", text="Object & ObData & Materials+Tex")
767         props.object = props.obdata = props.material = props.texture = True
768
769         props = layout.operator("object.make_single_user", text="Materials+Tex")
770         props.material = props.texture = True
771
772         props = layout.operator("object.make_single_user", text="Animation")
773         props.animation = True
774
775
776 class VIEW3D_MT_make_links(bpy.types.Menu):
777     bl_label = "Make Links"
778
779     def draw(self, context):
780         layout = self.layout
781
782         layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...")
783
784         layout.operator_enums("object.make_links_data", property="type") # inline
785
786
787 # ********** Vertex paint menu **********
788
789
790 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
791     bl_label = "Paint"
792
793     def draw(self, context):
794         layout = self.layout
795
796         layout.operator("paint.vertex_color_set")
797         layout.operator("paint.vertex_color_set", text="Set Selected Vertex Colors").selected = True
798
799
800 class VIEW3D_MT_hook(bpy.types.Menu):
801     bl_label = "Hooks"
802
803     def draw(self, context):
804         layout = self.layout
805         layout.operator_context = 'EXEC_AREA'
806         layout.operator("object.hook_add_newob")
807         layout.operator("object.hook_add_selob")
808
809         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
810             layout.separator()
811             layout.operator_menu_enum("object.hook_assign", "modifier")
812             layout.operator_menu_enum("object.hook_remove", "modifier")
813             layout.separator()
814             layout.operator_menu_enum("object.hook_select", "modifier")
815             layout.operator_menu_enum("object.hook_reset", "modifier")
816             layout.operator_menu_enum("object.hook_recenter", "modifier")
817
818
819 class VIEW3D_MT_vertex_group(bpy.types.Menu):
820     bl_label = "Vertex Groups"
821
822     def draw(self, context):
823         layout = self.layout
824         layout.operator_context = 'EXEC_AREA'
825         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
826
827         ob = context.active_object
828         if ob.mode == 'EDIT':
829             if ob.vertex_groups and ob.active_vertex_group:
830                 layout.separator()
831                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
832                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
833                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
834                 layout.separator()
835
836         if ob.vertex_groups and ob.active_vertex_group:
837             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
838             layout.operator("object.vertex_group_remove", text="Remove Active Group")
839             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
840
841
842 # ********** Sculpt menu **********
843
844
845 class VIEW3D_MT_sculpt(bpy.types.Menu):
846     bl_label = "Sculpt"
847
848     def draw(self, context):
849         layout = self.layout
850
851         sculpt = context.tool_settings.sculpt
852         brush = context.tool_settings.sculpt.brush
853
854         layout.prop(sculpt, "symmetry_x")
855         layout.prop(sculpt, "symmetry_y")
856         layout.prop(sculpt, "symmetry_z")
857         layout.separator()
858         layout.prop(sculpt, "lock_x")
859         layout.prop(sculpt, "lock_y")
860         layout.prop(sculpt, "lock_z")
861         layout.separator()
862         layout.operator_menu_enum("brush.curve_preset", property="shape")
863         layout.separator()
864
865         sculpt_tool = brush.sculpt_tool
866
867         if sculpt_tool != 'GRAB':
868             layout.prop(brush, "use_airbrush")
869
870             if sculpt_tool != 'LAYER':
871                 layout.prop(brush, "use_anchor")
872
873             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
874                 layout.prop(brush, "flip_direction")
875
876             if sculpt_tool == 'LAYER':
877                 layout.prop(brush, "use_persistent")
878                 layout.operator("sculpt.set_persistent_base")
879
880 # ********** Particle menu **********
881
882
883 class VIEW3D_MT_particle(bpy.types.Menu):
884     bl_label = "Particle"
885
886     def draw(self, context):
887         layout = self.layout
888
889         particle_edit = context.tool_settings.particle_edit
890
891         layout.operator("particle.mirror")
892
893         layout.separator()
894
895         layout.operator("particle.remove_doubles")
896         layout.operator("particle.delete")
897
898         if particle_edit.selection_mode == 'POINT':
899             layout.operator("particle.subdivide")
900
901         layout.operator("particle.rekey")
902
903         layout.separator()
904
905         layout.menu("VIEW3D_MT_particle_showhide")
906
907
908 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
909     _operator_name = "particle"
910
911 # ********** Pose Menu **********
912
913
914 class VIEW3D_MT_pose(bpy.types.Menu):
915     bl_label = "Pose"
916
917     def draw(self, context):
918         layout = self.layout
919
920         arm = context.active_object.data
921
922         layout.menu("VIEW3D_MT_transform")
923         layout.menu("VIEW3D_MT_snap")
924         if arm.drawtype in ('BBONE', 'ENVELOPE'):
925             layout.operator("tfm.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
926
927         layout.menu("VIEW3D_MT_pose_transform")
928
929         layout.separator()
930
931         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
932         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
933
934         layout.separator()
935
936         layout.operator("pose.apply")
937         layout.operator("pose.relax")
938
939         layout.separator()
940
941         layout.operator("pose.copy")
942         layout.operator("pose.paste")
943         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
944
945         layout.separator()
946
947         layout.menu("VIEW3D_MT_pose_pose")
948         layout.menu("VIEW3D_MT_pose_motion")
949         layout.menu("VIEW3D_MT_pose_group")
950
951         layout.separator()
952
953         layout.menu("VIEW3D_MT_pose_ik")
954         layout.menu("VIEW3D_MT_pose_constraints")
955
956         layout.separator()
957
958         layout.operator_context = 'EXEC_AREA'
959         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
960         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
961         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
962
963         layout.operator("pose.flip_names")
964
965         layout.separator()
966
967         layout.operator_context = 'INVOKE_AREA'
968         layout.operator("pose.armature_layers", text="Change Armature Layers...")
969         layout.operator("pose.bone_layers", text="Change Bone Layers...")
970
971         layout.separator()
972
973         layout.menu("VIEW3D_MT_pose_showhide")
974         layout.operator_menu_enum("pose.flags_set", 'mode', text="Bone Settings")
975
976
977 class VIEW3D_MT_pose_transform(bpy.types.Menu):
978     bl_label = "Clear Transform"
979
980     def draw(self, context):
981         layout = self.layout
982
983         layout.label(text="User Transform")
984
985         layout.operator("pose.loc_clear", text="Location")
986         layout.operator("pose.rot_clear", text="Rotation")
987         layout.operator("pose.scale_clear", text="Scale")
988
989         layout.label(text="Origin")
990
991
992 class VIEW3D_MT_pose_pose(bpy.types.Menu):
993     bl_label = "Pose Library"
994
995     def draw(self, context):
996         layout = self.layout
997
998         layout.operator("poselib.browse_interactive", text="Browse Poses...")
999
1000         layout.separator()
1001
1002         layout.operator("poselib.pose_add", text="Add Pose...")
1003         layout.operator("poselib.pose_rename", text="Rename Pose...")
1004         layout.operator("poselib.pose_remove", text="Remove Pose...")
1005
1006
1007 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1008     bl_label = "Motion Paths"
1009
1010     def draw(self, context):
1011         layout = self.layout
1012
1013         layout.operator("pose.paths_calculate", text="Calculate")
1014         layout.operator("pose.paths_clear", text="Clear")
1015
1016
1017 class VIEW3D_MT_pose_group(bpy.types.Menu):
1018     bl_label = "Bone Groups"
1019
1020     def draw(self, context):
1021         layout = self.layout
1022         layout.operator("pose.group_add")
1023         layout.operator("pose.group_remove")
1024
1025         layout.separator()
1026
1027         layout.operator("pose.group_assign")
1028         layout.operator("pose.group_unassign")
1029
1030
1031 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1032     bl_label = "Inverse Kinematics"
1033
1034     def draw(self, context):
1035         layout = self.layout
1036
1037         layout.operator("pose.ik_add")
1038         layout.operator("pose.ik_clear")
1039
1040
1041 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1042     bl_label = "Constraints"
1043
1044     def draw(self, context):
1045         layout = self.layout
1046
1047         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1048         layout.operator("pose.constraints_clear")
1049
1050
1051 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
1052     _operator_name = "pose"
1053
1054 # ********** Edit Menus, suffix from ob.type **********
1055
1056
1057 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1058     bl_label = "Mesh"
1059
1060     def draw(self, context):
1061         layout = self.layout
1062
1063         settings = context.tool_settings
1064
1065         layout.operator("ed.undo")
1066         layout.operator("ed.redo")
1067
1068         layout.separator()
1069
1070         layout.menu("VIEW3D_MT_transform")
1071         layout.menu("VIEW3D_MT_mirror")
1072         layout.menu("VIEW3D_MT_snap")
1073
1074         layout.separator()
1075
1076         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1077
1078         layout.separator()
1079
1080         layout.operator("mesh.extrude_move")
1081         layout.operator("mesh.duplicate_move")
1082         layout.operator("mesh.delete", text="Delete...")
1083
1084         layout.separator()
1085
1086         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1087         layout.menu("VIEW3D_MT_edit_mesh_edges")
1088         layout.menu("VIEW3D_MT_edit_mesh_faces")
1089         layout.menu("VIEW3D_MT_edit_mesh_normals")
1090
1091         layout.separator()
1092
1093         layout.prop(settings, "automerge_editing")
1094         layout.prop_menu_enum(settings, "proportional_editing")
1095         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1096
1097         layout.separator()
1098
1099         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1100
1101
1102 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1103     bl_label = "Specials"
1104
1105     def draw(self, context):
1106         layout = self.layout
1107
1108         layout.operator_context = 'INVOKE_REGION_WIN'
1109
1110         layout.operator("mesh.subdivide", text="Subdivide")
1111         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1112         layout.operator("mesh.merge", text="Merge...")
1113         layout.operator("mesh.remove_doubles")
1114         layout.operator("mesh.hide", text="Hide")
1115         layout.operator("mesh.reveal", text="Reveal")
1116         layout.operator("mesh.select_inverse")
1117         layout.operator("mesh.flip_normals")
1118         layout.operator("mesh.vertices_smooth", text="Smooth")
1119         # layout.operator("mesh.bevel", text="Bevel")
1120         layout.operator("mesh.faces_shade_smooth")
1121         layout.operator("mesh.faces_shade_flat")
1122         layout.operator("mesh.blend_from_shape")
1123         layout.operator("mesh.shape_propagate_to_all")
1124         layout.operator("mesh.select_vertex_path")
1125
1126
1127 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1128     bl_label = "Vertices"
1129
1130     def draw(self, context):
1131         layout = self.layout
1132         layout.operator_context = 'INVOKE_REGION_WIN'
1133
1134         layout.operator("mesh.merge")
1135         layout.operator("mesh.rip")
1136         layout.operator("mesh.split")
1137         layout.operator("mesh.separate")
1138
1139         layout.separator()
1140
1141         layout.operator("mesh.vertices_smooth")
1142         layout.operator("mesh.remove_doubles")
1143
1144         layout.operator("mesh.select_vertex_path")
1145
1146         layout.operator("mesh.blend_from_shape")
1147
1148         layout.operator("object.vertex_group_blend")
1149         layout.operator("mesh.shape_propagate_to_all")
1150
1151         layout.separator()
1152
1153         layout.menu("VIEW3D_MT_vertex_group")
1154         layout.menu("VIEW3D_MT_hook")
1155
1156
1157 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1158     bl_label = "Edges"
1159
1160     def draw(self, context):
1161         layout = self.layout
1162         layout.operator_context = 'INVOKE_REGION_WIN'
1163
1164         layout.operator("mesh.edge_face_add")
1165         layout.operator("mesh.subdivide")
1166
1167         layout.separator()
1168
1169         layout.operator("mesh.mark_seam")
1170         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1171
1172         layout.separator()
1173
1174         layout.operator("mesh.mark_sharp")
1175         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1176
1177         layout.separator()
1178
1179         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1180         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1181
1182         layout.separator()
1183
1184         layout.operator("TFM_OT_edge_slide", text="Edge Slide")
1185         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1186
1187         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1188         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1189
1190         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1191
1192         layout.operator("mesh.loop_to_region")
1193         layout.operator("mesh.region_to_loop")
1194
1195
1196 class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu):
1197     bl_label = "Faces"
1198     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1199
1200     def draw(self, context):
1201         layout = self.layout
1202         layout.operator_context = 'INVOKE_REGION_WIN'
1203
1204         # layout.operator("mesh.bevel")
1205         # layout.operator("mesh.bevel")
1206         layout.operator("mesh.edge_face_add")
1207         layout.operator("mesh.fill")
1208         layout.operator("mesh.beauty_fill")
1209
1210         layout.separator()
1211
1212         layout.operator("mesh.quads_convert_to_tris")
1213         layout.operator("mesh.tris_convert_to_quads")
1214         layout.operator("mesh.edge_flip")
1215
1216         layout.separator()
1217
1218         layout.operator("mesh.faces_shade_smooth")
1219         layout.operator("mesh.faces_shade_flat")
1220
1221         layout.separator()
1222
1223         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1224         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1225
1226         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1227
1228         layout.separator()
1229
1230         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1231         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1232         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1233         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1234
1235
1236 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1237     bl_label = "Normals"
1238
1239     def draw(self, context):
1240         layout = self.layout
1241
1242         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1243         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1244
1245         layout.separator()
1246
1247         layout.operator("mesh.flip_normals")
1248
1249
1250 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1251     _operator_name = "mesh"
1252
1253 # Edit Curve
1254 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1255
1256
1257 def draw_curve(self, context):
1258     layout = self.layout
1259
1260     settings = context.tool_settings
1261
1262     layout.menu("VIEW3D_MT_transform")
1263     layout.menu("VIEW3D_MT_mirror")
1264     layout.menu("VIEW3D_MT_snap")
1265
1266     layout.separator()
1267
1268     layout.operator("curve.extrude")
1269     layout.operator("curve.duplicate")
1270     layout.operator("curve.separate")
1271     layout.operator("curve.make_segment")
1272     layout.operator("curve.cyclic_toggle")
1273     layout.operator("curve.delete", text="Delete...")
1274
1275     layout.separator()
1276
1277     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1278     layout.menu("VIEW3D_MT_edit_curve_segments")
1279
1280     layout.separator()
1281
1282     layout.prop_menu_enum(settings, "proportional_editing")
1283     layout.prop_menu_enum(settings, "proportional_editing_falloff")
1284
1285     layout.separator()
1286
1287     layout.menu("VIEW3D_MT_edit_curve_showhide")
1288
1289
1290 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1291     bl_label = "Curve"
1292
1293     draw = draw_curve
1294
1295
1296 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1297     bl_label = "Control Points"
1298
1299     def draw(self, context):
1300         layout = self.layout
1301
1302         edit_object = context.edit_object
1303
1304         if edit_object.type == 'CURVE':
1305             layout.operator("tfm.transform").mode = 'TILT'
1306             layout.operator("curve.tilt_clear")
1307             layout.operator("curve.separate")
1308
1309             layout.separator()
1310
1311             layout.operator_menu_enum("curve.handle_type_set", "type")
1312
1313             layout.separator()
1314
1315             layout.menu("VIEW3D_MT_hook")
1316
1317
1318 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1319     bl_label = "Segments"
1320
1321     def draw(self, context):
1322         layout = self.layout
1323
1324         layout.operator("curve.subdivide")
1325         layout.operator("curve.switch_direction")
1326
1327
1328 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1329     _operator_name = "curve"
1330
1331
1332 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1333     bl_label = "Surface"
1334
1335     draw = draw_curve
1336
1337
1338 class VIEW3D_MT_edit_text(bpy.types.Menu):
1339     bl_label = "Text"
1340
1341     def draw(self, context):
1342         layout = self.layout
1343
1344         layout.operator("font.file_paste")
1345
1346         layout.separator()
1347
1348         layout.menu("VIEW3D_MT_edit_text_chars")
1349
1350
1351 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1352     bl_label = "Special Characters"
1353
1354     def draw(self, context):
1355         layout = self.layout
1356
1357         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1358         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1359
1360         layout.separator()
1361
1362         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1363         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1364         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1365         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1366         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1367         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1368         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1369         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1370         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1371
1372         layout.separator()
1373
1374         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1375         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1376         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1377
1378         layout.separator()
1379
1380         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1381         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1382         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1383
1384
1385 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1386     bl_label = "Metaball"
1387
1388     def draw(self, context):
1389         layout = self.layout
1390
1391         settings = context.tool_settings
1392
1393         layout.operator("ed.undo")
1394         layout.operator("ed.redo")
1395
1396         layout.separator()
1397
1398         layout.menu("VIEW3D_MT_transform")
1399         layout.menu("VIEW3D_MT_mirror")
1400         layout.menu("VIEW3D_MT_snap")
1401
1402         layout.separator()
1403
1404         layout.operator("mball.delete_metaelems", text="Delete...")
1405         layout.operator("mball.duplicate_metaelems")
1406
1407         layout.separator()
1408
1409         layout.prop_menu_enum(settings, "proportional_editing")
1410         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1411
1412         layout.separator()
1413
1414         layout.menu("VIEW3D_MT_edit_meta_showhide")
1415
1416
1417 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1418     bl_label = "Show/Hide"
1419
1420     def draw(self, context):
1421         layout = self.layout
1422
1423         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1424         layout.operator("mball.hide_metaelems", text="Hide Selected")
1425         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1426
1427
1428 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1429     bl_label = "Lattice"
1430
1431     def draw(self, context):
1432         layout = self.layout
1433
1434         settings = context.tool_settings
1435
1436         layout.menu("VIEW3D_MT_transform")
1437         layout.menu("VIEW3D_MT_mirror")
1438         layout.menu("VIEW3D_MT_snap")
1439
1440         layout.separator()
1441
1442         layout.operator("lattice.make_regular")
1443
1444         layout.separator()
1445
1446         layout.prop_menu_enum(settings, "proportional_editing")
1447         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1448
1449
1450 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1451     bl_label = "Armature"
1452
1453     def draw(self, context):
1454         layout = self.layout
1455
1456         edit_object = context.edit_object
1457         arm = edit_object.data
1458
1459         layout.menu("VIEW3D_MT_transform")
1460         layout.menu("VIEW3D_MT_mirror")
1461         layout.menu("VIEW3D_MT_snap")
1462         layout.menu("VIEW3D_MT_edit_armature_roll")
1463
1464         if arm.drawtype == 'ENVELOPE':
1465             layout.operator("tfm.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1466         else:
1467             layout.operator("tfm.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
1468
1469         layout.separator()
1470
1471         layout.operator("armature.extrude_move")
1472
1473         if arm.x_axis_mirror:
1474             layout.operator("armature.extrude_forked")
1475
1476         layout.operator("armature.duplicate_move")
1477         layout.operator("armature.merge")
1478         layout.operator("armature.fill")
1479         layout.operator("armature.delete")
1480         layout.operator("armature.separate")
1481
1482         layout.separator()
1483
1484         layout.operator("armature.subdivide_multi", text="Subdivide")
1485         layout.operator("armature.switch_direction", text="Switch Direction")
1486
1487         layout.separator()
1488
1489         layout.operator_context = 'EXEC_AREA'
1490         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1491         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1492         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1493         layout.operator("armature.flip_names")
1494
1495         layout.separator()
1496
1497         layout.operator_context = 'INVOKE_DEFAULT'
1498         layout.operator("armature.armature_layers")
1499         layout.operator("armature.bone_layers")
1500
1501         layout.separator()
1502
1503         layout.menu("VIEW3D_MT_edit_armature_parent")
1504
1505         layout.separator()
1506
1507         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1508
1509
1510 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1511     bl_label = "Specials"
1512
1513     def draw(self, context):
1514         layout = self.layout
1515
1516         layout.operator_context = 'INVOKE_REGION_WIN'
1517
1518         layout.operator("armature.subdivide_multi", text="Subdivide")
1519         layout.operator("armature.switch_direction", text="Switch Direction")
1520
1521         layout.separator()
1522
1523         layout.operator_context = 'EXEC_REGION_WIN'
1524         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1525         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1526         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1527         layout.operator("armature.flip_names", text="Flip Names")
1528
1529
1530 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1531     bl_label = "Parent"
1532
1533     def draw(self, context):
1534         layout = self.layout
1535
1536         layout.operator("armature.parent_set", text="Make")
1537         layout.operator("armature.parent_clear", text="Clear")
1538
1539
1540 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1541     bl_label = "Bone Roll"
1542
1543     def draw(self, context):
1544         layout = self.layout
1545
1546         layout.operator("armature.calculate_roll", text="Clear Roll (Z-Axis Up)").type = 'GLOBALUP'
1547         layout.operator("armature.calculate_roll", text="Roll to Cursor").type = 'CURSOR'
1548
1549         layout.separator()
1550
1551         layout.operator("tfm.transform", text="Set Roll").mode = 'BONE_ROLL'
1552
1553 # ********** Panel **********
1554
1555
1556 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1557     bl_space_type = 'VIEW_3D'
1558     bl_region_type = 'UI'
1559     bl_label = "View"
1560
1561     def poll(self, context):
1562         view = context.space_data
1563         return (view)
1564
1565     def draw(self, context):
1566         layout = self.layout
1567
1568         view = context.space_data
1569         scene = context.scene
1570
1571         col = layout.column()
1572         col.label(text="Camera:")
1573         col.prop(view, "camera", text="")
1574         col.prop(view, "lens")
1575         col.label(text="Lock to Object:")
1576         col.prop(view, "lock_object", text="")
1577         if view.lock_object and view.lock_object.type == 'ARMATURE':
1578             col.prop_object(view, "lock_bone", view.lock_object.data, "bones", text="")
1579
1580         col = layout.column(align=True)
1581         col.label(text="Clip:")
1582         col.prop(view, "clip_start", text="Start")
1583         col.prop(view, "clip_end", text="End")
1584
1585         layout.column().prop(scene, "cursor_location", text="3D Cursor:")
1586
1587
1588 class VIEW3D_PT_3dview_name(bpy.types.Panel):
1589     bl_space_type = 'VIEW_3D'
1590     bl_region_type = 'UI'
1591     bl_label = "Item"
1592
1593     def poll(self, context):
1594         return (context.space_data and context.active_object)
1595
1596     def draw(self, context):
1597         layout = self.layout
1598
1599         ob = context.active_object
1600         row = layout.row()
1601         row.label(text="", icon='ICON_OBJECT_DATA')
1602         row.prop(ob, "name", text="")
1603
1604         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1605             bone = context.active_bone
1606             if bone:
1607                 row = layout.row()
1608                 row.label(text="", icon='ICON_BONE_DATA')
1609                 row.prop(bone, "name", text="")
1610
1611
1612 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1613     bl_space_type = 'VIEW_3D'
1614     bl_region_type = 'UI'
1615     bl_label = "Display"
1616     bl_default_closed = True
1617
1618     def poll(self, context):
1619         view = context.space_data
1620         return (view)
1621
1622     def draw(self, context):
1623         layout = self.layout
1624
1625         view = context.space_data
1626         gs = context.scene.game_data
1627         ob = context.object
1628
1629         col = layout.column()
1630         col.prop(view, "display_x_axis", text="X Axis")
1631         col.prop(view, "display_y_axis", text="Y Axis")
1632         col.prop(view, "display_z_axis", text="Z Axis")
1633         col.prop(view, "outline_selected")
1634         col.prop(view, "all_object_origins")
1635         col.prop(view, "relationship_lines")
1636         if ob and ob.type == 'MESH':
1637             mesh = ob.data
1638             col.prop(mesh, "all_edges")
1639
1640         col = layout.column()
1641         col.prop(view, "display_floor", text="Grid Floor")
1642         sub = col.column(align=True)
1643         sub.active = view.display_floor
1644         sub.prop(view, "grid_lines", text="Lines")
1645         sub.prop(view, "grid_spacing", text="Spacing")
1646         sub.prop(view, "grid_subdivisions", text="Subdivisions")
1647
1648         col = layout.column()
1649         col.label(text="Shading:")
1650         col.prop(gs, "material_mode", text="")
1651         col.prop(view, "textured_solid")
1652
1653 # XXX - the Quad View options don't work yet
1654 #               layout.separator()
1655 #
1656 #               layout.operator("screen.region_foursplit", text="Toggle Quad View")
1657 #               col = layout.column()
1658 #               col.prop(view, "lock_rotation")
1659 #               col.prop(view, "box_preview")
1660 #               col.prop(view, "box_clip")
1661
1662
1663 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1664     bl_space_type = 'VIEW_3D'
1665     bl_region_type = 'UI'
1666     bl_label = "Mesh Display"
1667
1668     def poll(self, context):
1669         # The active object check is needed because of localmode
1670         return (context.active_object and (context.mode == 'EDIT_MESH'))
1671
1672     def draw(self, context):
1673         layout = self.layout
1674
1675         mesh = context.active_object.data
1676
1677         col = layout.column()
1678         col.label(text="Overlays:")
1679         col.prop(mesh, "draw_edges", text="Edges")
1680         col.prop(mesh, "draw_faces", text="Faces")
1681         col.prop(mesh, "draw_creases", text="Creases")
1682         col.prop(mesh, "draw_bevel_weights", text="Bevel Weights")
1683         col.prop(mesh, "draw_seams", text="Seams")
1684         col.prop(mesh, "draw_sharp", text="Sharp")
1685
1686         col.separator()
1687         col.label(text="Normals:")
1688         col.prop(mesh, "draw_normals", text="Face")
1689         col.prop(mesh, "draw_vertex_normals", text="Vertex")
1690         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1691
1692         col.separator()
1693         col.label(text="Numerics:")
1694         col.prop(mesh, "draw_edge_lenght")
1695         col.prop(mesh, "draw_edge_angle")
1696         col.prop(mesh, "draw_face_area")
1697
1698
1699 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1700     bl_space_type = 'VIEW_3D'
1701     bl_region_type = 'UI'
1702     bl_label = "Curve Display"
1703
1704     def poll(self, context):
1705         editmesh = context.mode == 'EDIT_CURVE'
1706         return (editmesh)
1707
1708     def draw(self, context):
1709         layout = self.layout
1710
1711         curve = context.active_object.data
1712
1713         col = layout.column()
1714         col.label(text="Overlays:")
1715         col.prop(curve, "draw_handles", text="Handles")
1716         col.prop(curve, "draw_normals", text="Normals")
1717         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1718
1719
1720 class VIEW3D_PT_background_image(bpy.types.Panel):
1721     bl_space_type = 'VIEW_3D'
1722     bl_region_type = 'UI'
1723     bl_label = "Background Image"
1724     bl_default_closed = True
1725
1726     def poll(self, context):
1727         view = context.space_data
1728         # bg = context.space_data.background_image
1729         return (view)
1730
1731     def draw_header(self, context):
1732         layout = self.layout
1733         view = context.space_data
1734
1735         layout.prop(view, "display_background_image", text="")
1736
1737     def draw(self, context):
1738         layout = self.layout
1739
1740         view = context.space_data
1741         bg = view.background_image
1742
1743         if bg:
1744             layout.active = view.display_background_image
1745
1746             col = layout.column()
1747             col.template_ID(bg, "image", open="image.open")
1748             col.prop(bg, "size")
1749             col.prop(bg, "transparency", slider=True)
1750
1751
1752             col = layout.column(align=True)
1753             col.label(text="Offset:")
1754             col.prop(bg, "offset_x", text="X")
1755             col.prop(bg, "offset_y", text="Y")
1756
1757
1758 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1759     bl_space_type = 'VIEW_3D'
1760     bl_region_type = 'UI'
1761     bl_label = "Transform Orientations"
1762     bl_default_closed = True
1763
1764     def poll(self, context):
1765         view = context.space_data
1766         return (view)
1767
1768     def draw(self, context):
1769         layout = self.layout
1770
1771         view = context.space_data
1772
1773         col = layout.column()
1774
1775         col.prop(view, "transform_orientation")
1776         col.operator("tfm.create_orientation", text="Create")
1777
1778         orientation = view.current_orientation
1779
1780         if orientation:
1781             col.prop(orientation, "name")
1782             col.operator("tfm.delete_orientation", text="Delete")
1783
1784
1785 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1786     bl_space_type = 'VIEW_3D'
1787     bl_region_type = 'UI'
1788     bl_label = "Skeleton Sketching"
1789     bl_default_closed = True
1790
1791     def poll(self, context):
1792         scene = context.space_data
1793         ob = context.active_object
1794         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1795
1796     def draw_header(self, context):
1797         layout = self.layout
1798         toolsettings = context.scene.tool_settings
1799
1800         layout.prop(toolsettings, "bone_sketching", text="")
1801
1802     def draw(self, context):
1803         layout = self.layout
1804         toolsettings = context.scene.tool_settings
1805
1806         col = layout.column()
1807
1808         col.prop(toolsettings, "etch_quick")
1809         col.prop(toolsettings, "etch_overdraw")
1810
1811         col.prop(toolsettings, "etch_convert_mode")
1812
1813         if toolsettings.etch_convert_mode == 'LENGTH':
1814             col.prop(toolsettings, "etch_length_limit")
1815         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
1816             col.prop(toolsettings, "etch_adaptive_limit")
1817         elif toolsettings.etch_convert_mode == 'FIXED':
1818             col.prop(toolsettings, "etch_subdivision_number")
1819         elif toolsettings.etch_convert_mode == 'RETARGET':
1820             col.prop(toolsettings, "etch_template")
1821             col.prop(toolsettings, "etch_roll_mode")
1822             col.prop(toolsettings, "etch_autoname")
1823             col.prop(toolsettings, "etch_number")
1824             col.prop(toolsettings, "etch_side")
1825
1826
1827 class VIEW3D_PT_context_properties(bpy.types.Panel):
1828     bl_space_type = 'VIEW_3D'
1829     bl_region_type = 'UI'
1830     bl_label = "Properties"
1831     bl_default_closed = True
1832
1833     def _active_context_member(self, context):
1834         obj = context.object
1835         if obj:
1836             mode = obj.mode
1837             if mode == 'POSE':
1838                 return "active_pose_bone"
1839             elif mode == 'EDIT' and obj.type == 'ARMATURE':
1840                 return "active_bone"
1841             else:
1842                 return "object"
1843
1844         return ""
1845
1846     def poll(self, context):
1847         member = self._active_context_member(context)
1848         if member:
1849             context_member = getattr(context, member)
1850             return context_member and context_member.keys()
1851
1852         return False
1853
1854     def draw(self, context):
1855         import rna_prop_ui
1856         # reload(rna_prop_ui)
1857         member = self._active_context_member(context)
1858
1859         if member:
1860             # Draw with no edit button
1861             rna_prop_ui.draw(self.layout, context, member, False)
1862
1863
1864 bpy.types.register(VIEW3D_HT_header) # Header
1865
1866 bpy.types.register(VIEW3D_MT_view) #View Menus
1867 bpy.types.register(VIEW3D_MT_view_navigation)
1868 bpy.types.register(VIEW3D_MT_view_align)
1869 bpy.types.register(VIEW3D_MT_view_align_selected)
1870 bpy.types.register(VIEW3D_MT_view_cameras)
1871
1872 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1873 bpy.types.register(VIEW3D_MT_select_pose)
1874 bpy.types.register(VIEW3D_MT_select_particle)
1875 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1876 bpy.types.register(VIEW3D_MT_select_edit_curve)
1877 bpy.types.register(VIEW3D_MT_select_edit_surface)
1878 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1879 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1880 bpy.types.register(VIEW3D_MT_select_edit_armature)
1881 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1882
1883 bpy.types.register(VIEW3D_MT_transform) # Object/Edit Menus
1884 bpy.types.register(VIEW3D_MT_mirror) # Object/Edit Menus
1885 bpy.types.register(VIEW3D_MT_snap) # Object/Edit Menus
1886 bpy.types.register(VIEW3D_MT_uv_map) # Edit Menus
1887
1888 bpy.types.register(VIEW3D_MT_object) # Object Menu
1889 bpy.types.register(VIEW3D_MT_object_apply)
1890 bpy.types.register(VIEW3D_MT_object_clear)
1891 bpy.types.register(VIEW3D_MT_object_parent)
1892 bpy.types.register(VIEW3D_MT_object_track)
1893 bpy.types.register(VIEW3D_MT_object_group)
1894 bpy.types.register(VIEW3D_MT_object_constraints)
1895 bpy.types.register(VIEW3D_MT_object_showhide)
1896 bpy.types.register(VIEW3D_MT_make_single_user)
1897 bpy.types.register(VIEW3D_MT_make_links)
1898
1899 bpy.types.register(VIEW3D_MT_hook)
1900 bpy.types.register(VIEW3D_MT_vertex_group)
1901
1902 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1903
1904 bpy.types.register(VIEW3D_MT_paint_vertex)
1905
1906 bpy.types.register(VIEW3D_MT_particle) # Particle Menu
1907 bpy.types.register(VIEW3D_MT_particle_showhide)
1908
1909 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1910 bpy.types.register(VIEW3D_MT_pose_transform)
1911 bpy.types.register(VIEW3D_MT_pose_pose)
1912 bpy.types.register(VIEW3D_MT_pose_motion)
1913 bpy.types.register(VIEW3D_MT_pose_group)
1914 bpy.types.register(VIEW3D_MT_pose_ik)
1915 bpy.types.register(VIEW3D_MT_pose_constraints)
1916 bpy.types.register(VIEW3D_MT_pose_showhide)
1917
1918 bpy.types.register(VIEW3D_MT_edit_mesh)
1919 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1920 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1921 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1922 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1923 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1924 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1925
1926 bpy.types.register(VIEW3D_MT_edit_curve)
1927 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1928 bpy.types.register(VIEW3D_MT_edit_curve_segments)
1929 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
1930
1931 bpy.types.register(VIEW3D_MT_edit_surface)
1932
1933 bpy.types.register(VIEW3D_MT_edit_text)
1934 bpy.types.register(VIEW3D_MT_edit_text_chars)
1935
1936 bpy.types.register(VIEW3D_MT_edit_meta)
1937 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
1938
1939 bpy.types.register(VIEW3D_MT_edit_lattice)
1940
1941 bpy.types.register(VIEW3D_MT_edit_armature)
1942 bpy.types.register(VIEW3D_MT_edit_armature_parent)
1943 bpy.types.register(VIEW3D_MT_edit_armature_roll)
1944
1945 bpy.types.register(VIEW3D_MT_armature_specials) # Only as a menu for keybindings
1946
1947  # Panels
1948 bpy.types.register(VIEW3D_PT_3dview_properties)
1949 bpy.types.register(VIEW3D_PT_3dview_display)
1950 bpy.types.register(VIEW3D_PT_3dview_name)
1951 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
1952 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
1953 bpy.types.register(VIEW3D_PT_background_image)
1954 bpy.types.register(VIEW3D_PT_transform_orientations)
1955 bpy.types.register(VIEW3D_PT_etch_a_ton)
1956
1957 bpy.types.register(VIEW3D_PT_context_properties)