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