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