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