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