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