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