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