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