Missing Transform Menus + Buggy Object Operators:
[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.items_enumO("object.hook_add", "type")
750         # layout.itemS()
751         # Other operators still need porting
752
753
754 # ********** Sculpt menu **********
755
756
757 class VIEW3D_MT_sculpt(bpy.types.Menu):
758     bl_label = "Sculpt"
759
760     def draw(self, context):
761         layout = self.layout
762
763         sculpt = context.tool_settings.sculpt
764         brush = context.tool_settings.sculpt.brush
765
766         layout.itemR(sculpt, "symmetry_x")
767         layout.itemR(sculpt, "symmetry_y")
768         layout.itemR(sculpt, "symmetry_z")
769         layout.itemS()
770         layout.itemR(sculpt, "lock_x")
771         layout.itemR(sculpt, "lock_y")
772         layout.itemR(sculpt, "lock_z")
773         layout.itemS()
774         layout.item_menu_enumO("brush.curve_preset", property="shape")
775         layout.itemS()
776
777         sculpt_tool = brush.sculpt_tool
778
779         if sculpt_tool != 'GRAB':
780             layout.itemR(brush, "use_airbrush")
781
782             if sculpt_tool != 'LAYER':
783                 layout.itemR(brush, "use_anchor")
784
785             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
786                 layout.itemR(brush, "flip_direction")
787
788             if sculpt_tool == 'LAYER':
789                 layout.itemR(brush, "use_persistent")
790                 layout.itemO("sculpt.set_persistent_base")
791
792 # ********** Particle menu **********
793
794
795 class VIEW3D_MT_particle(bpy.types.Menu):
796     bl_label = "Particle"
797
798     def draw(self, context):
799         layout = self.layout
800
801         particle_edit = context.tool_settings.particle_edit
802
803         layout.itemO("particle.mirror")
804
805         layout.itemS()
806
807         layout.itemO("particle.remove_doubles")
808         layout.itemO("particle.delete")
809
810         if particle_edit.selection_mode == 'POINT':
811             layout.itemO("particle.subdivide")
812
813         layout.itemO("particle.rekey")
814
815         layout.itemS()
816
817         layout.itemM("VIEW3D_MT_particle_showhide")
818
819
820 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
821     _operator_name = "particle"
822
823 # ********** Pose Menu **********
824
825
826 class VIEW3D_MT_pose(bpy.types.Menu):
827     bl_label = "Pose"
828
829     def draw(self, context):
830         layout = self.layout
831
832         arm = context.active_object.data
833         
834         layout.itemM("VIEW3D_MT_transform")
835         layout.itemM("VIEW3D_MT_snap")
836         if arm.drawtype in ('BBONE', 'ENVELOPE'):
837             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
838
839         layout.itemM("VIEW3D_MT_pose_transform")
840
841         layout.itemS()
842
843         layout.itemO("anim.insert_keyframe_menu", text="Insert Keyframe...")
844         layout.itemO("anim.delete_keyframe_v3d", text="Delete Keyframe...")
845
846         layout.itemS()
847
848         layout.itemO("pose.apply")
849         layout.itemO("pose.relax")
850
851         layout.itemS()
852
853         layout.itemO("pose.copy")
854         layout.itemO("pose.paste")
855         layout.item_booleanO("pose.paste", "flipped", True, text="Paste X-Flipped Pose")
856
857         layout.itemS()
858
859         layout.itemM("VIEW3D_MT_pose_pose")
860         layout.itemM("VIEW3D_MT_pose_motion")
861         layout.itemM("VIEW3D_MT_pose_group")
862
863         layout.itemS()
864
865         layout.itemM("VIEW3D_MT_pose_ik")
866         layout.itemM("VIEW3D_MT_pose_constraints")
867
868         layout.itemS()
869
870         layout.operator_context = 'EXEC_AREA'
871         layout.item_enumO("pose.autoside_names", "axis", 'XAXIS', text="AutoName Left/Right")
872         layout.item_enumO("pose.autoside_names", "axis", 'YAXIS', text="AutoName Front/Back")
873         layout.item_enumO("pose.autoside_names", "axis", 'ZAXIS', text="AutoName Top/Bottom")
874
875         layout.itemO("pose.flip_names")
876
877         layout.itemS()
878
879         layout.operator_context = 'INVOKE_AREA'
880         layout.itemO("pose.armature_layers", text="Change Armature Layers...")
881         layout.itemO("pose.bone_layers", text="Change Bone Layers...")
882
883         layout.itemS()
884
885         layout.itemM("VIEW3D_MT_pose_showhide")
886         layout.item_menu_enumO("pose.flags_set", 'mode', text="Bone Settings")
887
888
889 class VIEW3D_MT_pose_transform(bpy.types.Menu):
890     bl_label = "Clear Transform"
891
892     def draw(self, context):
893         layout = self.layout
894
895         layout.itemL(text="User Transform")
896
897         layout.itemO("pose.loc_clear", text="Location")
898         layout.itemO("pose.rot_clear", text="Rotation")
899         layout.itemO("pose.scale_clear", text="Scale")
900
901         layout.itemL(text="Origin")
902
903
904 class VIEW3D_MT_pose_pose(bpy.types.Menu):
905     bl_label = "Pose Library"
906
907     def draw(self, context):
908         layout = self.layout
909
910         layout.itemO("poselib.browse_interactive", text="Browse Poses...")
911
912         layout.itemS()
913
914         layout.itemO("poselib.pose_add", text="Add Pose...")
915         layout.itemO("poselib.pose_rename", text="Rename Pose...")
916         layout.itemO("poselib.pose_remove", text="Remove Pose...")
917
918
919 class VIEW3D_MT_pose_motion(bpy.types.Menu):
920     bl_label = "Motion Paths"
921
922     def draw(self, context):
923         layout = self.layout
924
925         layout.itemO("pose.paths_calculate", text="Calculate")
926         layout.itemO("pose.paths_clear", text="Clear")
927
928
929 class VIEW3D_MT_pose_group(bpy.types.Menu):
930     bl_label = "Bone Groups"
931
932     def draw(self, context):
933         layout = self.layout
934         layout.itemO("pose.group_add")
935         layout.itemO("pose.group_remove")
936
937         layout.itemS()
938
939         layout.itemO("pose.group_assign")
940         layout.itemO("pose.group_unassign")
941
942
943 class VIEW3D_MT_pose_ik(bpy.types.Menu):
944     bl_label = "Inverse Kinematics"
945
946     def draw(self, context):
947         layout = self.layout
948
949         layout.itemO("pose.ik_add")
950         layout.itemO("pose.ik_clear")
951
952
953 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
954     bl_label = "Constraints"
955
956     def draw(self, context):
957         layout = self.layout
958
959         layout.itemO("pose.constraint_add_with_targets", text="Add (With Targets)...")
960         layout.itemO("pose.constraints_clear")
961
962
963 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
964     _operator_name = "pose"
965
966 # ********** Edit Menus, suffix from ob.type **********
967
968
969 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
970     bl_label = "Mesh"
971
972     def draw(self, context):
973         layout = self.layout
974
975         settings = context.tool_settings
976
977         layout.itemO("ed.undo")
978         layout.itemO("ed.redo")
979
980         layout.itemS()
981
982         layout.itemM("VIEW3D_MT_transform")
983         layout.itemM("VIEW3D_MT_mirror")
984         layout.itemM("VIEW3D_MT_snap")
985
986         layout.itemS()
987
988         layout.itemM("VIEW3D_MT_uv_map", text="UV Unwrap...")
989
990         layout.itemS()
991
992         layout.itemO("mesh.extrude_move")
993         layout.itemO("mesh.duplicate_move")
994         layout.itemO("mesh.delete", text="Delete...")
995
996         layout.itemS()
997
998         layout.itemM("VIEW3D_MT_edit_mesh_vertices")
999         layout.itemM("VIEW3D_MT_edit_mesh_edges")
1000         layout.itemM("VIEW3D_MT_edit_mesh_faces")
1001         layout.itemM("VIEW3D_MT_edit_mesh_normals")
1002
1003         layout.itemS()
1004
1005         layout.itemR(settings, "automerge_editing")
1006         layout.item_menu_enumR(settings, "proportional_editing")
1007         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1008
1009         layout.itemS()
1010
1011         layout.itemM("VIEW3D_MT_edit_mesh_showhide")
1012
1013
1014 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1015     bl_label = "Specials"
1016
1017     def draw(self, context):
1018         layout = self.layout
1019
1020         layout.operator_context = 'INVOKE_REGION_WIN'
1021
1022         layout.itemO("mesh.subdivide", text="Subdivide")
1023         layout.item_floatO("mesh.subdivide", "smoothness", 1.0, text="Subdivide Smooth")
1024         layout.itemO("mesh.merge", text="Merge...")
1025         layout.itemO("mesh.remove_doubles")
1026         layout.itemO("mesh.hide", text="Hide")
1027         layout.itemO("mesh.reveal", text="Reveal")
1028         layout.itemO("mesh.select_inverse")
1029         layout.itemO("mesh.flip_normals")
1030         layout.itemO("mesh.vertices_smooth", text="Smooth")
1031         # layout.itemO("mesh.bevel", text="Bevel")
1032         layout.itemO("mesh.faces_shade_smooth")
1033         layout.itemO("mesh.faces_shade_flat")
1034         layout.itemO("mesh.blend_from_shape")
1035         layout.itemO("mesh.shape_propagate_to_all")
1036         layout.itemO("mesh.select_vertex_path")
1037
1038
1039 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1040     bl_label = "Vertices"
1041
1042     def draw(self, context):
1043         layout = self.layout
1044         layout.operator_context = 'INVOKE_REGION_WIN'
1045
1046         layout.itemO("mesh.merge")
1047         layout.itemO("mesh.rip")
1048         layout.itemO("mesh.split")
1049         layout.itemO("mesh.separate")
1050
1051         layout.itemS()
1052
1053         layout.itemO("mesh.vertices_smooth")
1054         layout.itemO("mesh.remove_doubles")
1055
1056         layout.itemO("mesh.select_vertex_path")
1057
1058         layout.itemO("mesh.blend_from_shape")
1059
1060         layout.itemO("object.vertex_group_blend")
1061         layout.itemO("mesh.shape_propagate_to_all")
1062
1063         layout.itemS()
1064
1065         layout.itemM("VIEW3D_MT_hook")
1066
1067
1068 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1069     bl_label = "Edges"
1070
1071     def draw(self, context):
1072         layout = self.layout
1073         layout.operator_context = 'INVOKE_REGION_WIN'
1074
1075         layout.itemO("mesh.edge_face_add")
1076         layout.itemO("mesh.subdivide")
1077
1078         layout.itemS()
1079
1080         layout.itemO("mesh.mark_seam")
1081         layout.item_booleanO("mesh.mark_seam", "clear", True, text="Clear Seam")
1082
1083         layout.itemS()
1084
1085         layout.itemO("mesh.mark_sharp")
1086         layout.item_booleanO("mesh.mark_sharp", "clear", True, text="Clear Sharp")
1087
1088         layout.itemS()
1089
1090         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
1091         layout.item_enumO("mesh.edge_rotate", "direction", 'CCW', text="Rotate Edge CCW")
1092
1093         layout.itemS()
1094
1095         layout.itemO("TFM_OT_edge_slide", text="Edge Slide")
1096         layout.itemO("mesh.loop_multi_select", text="Edge Loop")
1097
1098         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1099         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1100
1101         layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
1102
1103         layout.itemO("mesh.loop_to_region")
1104         layout.itemO("mesh.region_to_loop")
1105
1106
1107 class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu):
1108     bl_label = "Faces"
1109     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1110
1111     def draw(self, context):
1112         layout = self.layout
1113         layout.operator_context = 'INVOKE_REGION_WIN'
1114
1115         # layout.itemO("mesh.bevel")
1116         # layout.itemO("mesh.bevel")
1117         layout.itemO("mesh.edge_face_add")
1118         layout.itemO("mesh.fill")
1119         layout.itemO("mesh.beauty_fill")
1120
1121         layout.itemS()
1122
1123         layout.itemO("mesh.quads_convert_to_tris")
1124         layout.itemO("mesh.tris_convert_to_quads")
1125         layout.itemO("mesh.edge_flip")
1126
1127         layout.itemS()
1128
1129         layout.itemO("mesh.faces_shade_smooth")
1130         layout.itemO("mesh.faces_shade_flat")
1131
1132         layout.itemS()
1133
1134         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1135         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1136
1137         layout.item_enumO("mesh.edge_rotate", "direction", 'CW', text="Rotate Edge CW")
1138
1139         layout.itemS()
1140
1141         layout.item_menu_enumO("mesh.uvs_rotate", "direction")
1142         layout.item_menu_enumO("mesh.uvs_mirror", "axis")
1143         layout.item_menu_enumO("mesh.colors_rotate", "direction")
1144         layout.item_menu_enumO("mesh.colors_mirror", "axis")
1145
1146
1147 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1148     bl_label = "Normals"
1149
1150     def draw(self, context):
1151         layout = self.layout
1152
1153         layout.itemO("mesh.normals_make_consistent", text="Recalculate Outside")
1154         layout.item_booleanO("mesh.normals_make_consistent", "inside", True, text="Recalculate Inside")
1155
1156         layout.itemS()
1157
1158         layout.itemO("mesh.flip_normals")
1159
1160
1161 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1162     _operator_name = "mesh"
1163
1164 # Edit Curve
1165 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1166
1167
1168 def draw_curve(self, context):
1169     layout = self.layout
1170
1171     settings = context.tool_settings
1172     
1173     layout.itemM("VIEW3D_MT_transform")
1174     layout.itemM("VIEW3D_MT_mirror")
1175     layout.itemM("VIEW3D_MT_snap")
1176
1177     layout.itemS()
1178
1179     layout.itemO("curve.extrude")
1180     layout.itemO("curve.duplicate")
1181     layout.itemO("curve.separate")
1182     layout.itemO("curve.make_segment")
1183     layout.itemO("curve.cyclic_toggle")
1184     layout.itemO("curve.delete", text="Delete...")
1185
1186     layout.itemS()
1187
1188     layout.itemM("VIEW3D_MT_edit_curve_ctrlpoints")
1189     layout.itemM("VIEW3D_MT_edit_curve_segments")
1190
1191     layout.itemS()
1192
1193     layout.item_menu_enumR(settings, "proportional_editing")
1194     layout.item_menu_enumR(settings, "proportional_editing_falloff")
1195
1196     layout.itemS()
1197
1198     layout.itemM("VIEW3D_MT_edit_curve_showhide")
1199
1200
1201 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1202     bl_label = "Curve"
1203
1204     draw = draw_curve
1205
1206
1207 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1208     bl_label = "Control Points"
1209
1210     def draw(self, context):
1211         layout = self.layout
1212
1213         edit_object = context.edit_object
1214
1215         if edit_object.type == 'CURVE':
1216             layout.item_enumO("tfm.transform", "mode", 'TILT')
1217             layout.itemO("curve.tilt_clear")
1218             layout.itemO("curve.separate")
1219
1220             layout.itemS()
1221
1222             layout.item_menu_enumO("curve.handle_type_set", "type")
1223
1224             layout.itemS()
1225
1226             layout.itemM("VIEW3D_MT_hook")
1227
1228
1229 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1230     bl_label = "Segments"
1231
1232     def draw(self, context):
1233         layout = self.layout
1234
1235         layout.itemO("curve.subdivide")
1236         layout.itemO("curve.switch_direction")
1237
1238
1239 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1240     _operator_name = "curve"
1241
1242
1243 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1244     bl_label = "Surface"
1245
1246     draw = draw_curve
1247
1248
1249 class VIEW3D_MT_edit_text(bpy.types.Menu):
1250     bl_label = "Text"
1251
1252     def draw(self, context):
1253         layout = self.layout
1254
1255         layout.itemO("font.file_paste")
1256
1257         layout.itemS()
1258
1259         layout.itemM("VIEW3D_MT_edit_text_chars")
1260
1261
1262 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1263     bl_label = "Special Characters"
1264
1265     def draw(self, context):
1266         layout = self.layout
1267
1268         layout.item_stringO("font.text_insert", "text", b'\xC2\xA9'.decode(), text="Copyright|Alt C")
1269         layout.item_stringO("font.text_insert", "text", b'\xC2\xAE'.decode(), text="Registered Trademark|Alt R")
1270
1271         layout.itemS()
1272
1273         layout.item_stringO("font.text_insert", "text", b'\xC2\xB0'.decode(), text="Degree Sign|Alt G")
1274         layout.item_stringO("font.text_insert", "text", b'\xC3\x97'.decode(), text="Multiplication Sign|Alt x")
1275         layout.item_stringO("font.text_insert", "text", b'\xC2\x8A'.decode(), text="Circle|Alt .")
1276         layout.item_stringO("font.text_insert", "text", b'\xC2\xB9'.decode(), text="Superscript 1|Alt 1")
1277         layout.item_stringO("font.text_insert", "text", b'\xC2\xB2'.decode(), text="Superscript 2|Alt 2")
1278         layout.item_stringO("font.text_insert", "text", b'\xC2\xB3'.decode(), text="Superscript 3|Alt 3")
1279         layout.item_stringO("font.text_insert", "text", b'\xC2\xBB'.decode(), text="Double >>|Alt >")
1280         layout.item_stringO("font.text_insert", "text", b'\xC2\xAB'.decode(), text="Double <<|Alt <")
1281         layout.item_stringO("font.text_insert", "text", b'\xE2\x80\xB0'.decode(), text="Promillage|Alt %")
1282
1283         layout.itemS()
1284
1285         layout.item_stringO("font.text_insert", "text", b'\xC2\xA4'.decode(), text="Dutch Florin|Alt F")
1286         layout.item_stringO("font.text_insert", "text", b'\xC2\xA3'.decode(), text="British Pound|Alt L")
1287         layout.item_stringO("font.text_insert", "text", b'\xC2\xA5'.decode(), text="Japanese Yen|Alt Y")
1288
1289         layout.itemS()
1290
1291         layout.item_stringO("font.text_insert", "text", b'\xC3\x9F'.decode(), text="German S|Alt S")
1292         layout.item_stringO("font.text_insert", "text", b'\xC2\xBF'.decode(), text="Spanish Question Mark|Alt ?")
1293         layout.item_stringO("font.text_insert", "text", b'\xC2\xA1'.decode(), text="Spanish Exclamation Mark|Alt !")
1294
1295
1296 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1297     bl_label = "Metaball"
1298
1299     def draw(self, context):
1300         layout = self.layout
1301
1302         settings = context.tool_settings
1303
1304         layout.itemO("ed.undo")
1305         layout.itemO("ed.redo")
1306
1307         layout.itemS()
1308         
1309         layout.itemM("VIEW3D_MT_transform")
1310         layout.itemM("VIEW3D_MT_mirror")
1311         layout.itemM("VIEW3D_MT_snap")
1312
1313         layout.itemS()
1314
1315         layout.itemO("mball.delete_metaelems", text="Delete...")
1316         layout.itemO("mball.duplicate_metaelems")
1317
1318         layout.itemS()
1319
1320         layout.item_menu_enumR(settings, "proportional_editing")
1321         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1322
1323         layout.itemS()
1324
1325         layout.itemM("VIEW3D_MT_edit_meta_showhide")
1326
1327
1328 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1329     bl_label = "Show/Hide"
1330
1331     def draw(self, context):
1332         layout = self.layout
1333
1334         layout.itemO("mball.reveal_metaelems", text="Show Hidden")
1335         layout.itemO("mball.hide_metaelems", text="Hide Selected")
1336         layout.item_booleanO("mball.hide_metaelems", "unselected", True, text="Hide Unselected")
1337
1338
1339 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1340     bl_label = "Lattice"
1341
1342     def draw(self, context):
1343         layout = self.layout
1344
1345         settings = context.tool_settings
1346         
1347         layout.itemM("VIEW3D_MT_transform")
1348         layout.itemM("VIEW3D_MT_mirror")
1349         layout.itemM("VIEW3D_MT_snap")
1350
1351         layout.itemS()
1352
1353         layout.itemO("lattice.make_regular")
1354
1355         layout.itemS()
1356
1357         layout.item_menu_enumR(settings, "proportional_editing")
1358         layout.item_menu_enumR(settings, "proportional_editing_falloff")
1359
1360
1361 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1362     bl_label = "Armature"
1363
1364     def draw(self, context):
1365         layout = self.layout
1366
1367         edit_object = context.edit_object
1368         arm = edit_object.data
1369         
1370         layout.itemM("VIEW3D_MT_transform")
1371         layout.itemM("VIEW3D_MT_mirror")
1372         layout.itemM("VIEW3D_MT_snap")
1373         layout.itemM("VIEW3D_MT_edit_armature_roll")
1374
1375         if arm.drawtype == 'ENVELOPE':
1376             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale Envelope Distance")
1377         else:
1378             layout.item_enumO("tfm.transform", "mode", 'BONESIZE', text="Scale B-Bone Width")
1379
1380         layout.itemS()
1381
1382         layout.itemO("armature.extrude_move")
1383
1384         if arm.x_axis_mirror:
1385             layout.itemO("armature.extrude_forked")
1386
1387         layout.itemO("armature.duplicate_move")
1388         layout.itemO("armature.merge")
1389         layout.itemO("armature.fill")
1390         layout.itemO("armature.delete")
1391         layout.itemO("armature.separate")
1392
1393         layout.itemS()
1394
1395         layout.itemO("armature.subdivide_multi", text="Subdivide")
1396         layout.itemO("armature.switch_direction", text="Switch Direction")
1397
1398         layout.itemS()
1399
1400         layout.operator_context = 'EXEC_AREA'
1401         layout.item_enumO("armature.autoside_names", "type", 'XAXIS', text="AutoName Left/Right")
1402         layout.item_enumO("armature.autoside_names", "type", 'YAXIS', text="AutoName Front/Back")
1403         layout.item_enumO("armature.autoside_names", "type", 'ZAXIS', text="AutoName Top/Bottom")
1404         layout.itemO("armature.flip_names")
1405
1406         layout.itemS()
1407
1408         layout.operator_context = 'INVOKE_DEFAULT'
1409         layout.itemO("armature.armature_layers")
1410         layout.itemO("armature.bone_layers")
1411
1412         layout.itemS()
1413
1414         layout.itemM("VIEW3D_MT_edit_armature_parent")
1415
1416         layout.itemS()
1417
1418         layout.item_menu_enumO("armature.flags_set", "mode", text="Bone Settings")
1419
1420
1421 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1422     bl_label = "Specials"
1423
1424     def draw(self, context):
1425         layout = self.layout
1426
1427         layout.operator_context = 'INVOKE_REGION_WIN'
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_REGION_WIN'
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", text="Flip Names")
1439
1440
1441 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1442     bl_label = "Parent"
1443
1444     def draw(self, context):
1445         layout = self.layout
1446
1447         layout.itemO("armature.parent_set", text="Make")
1448         layout.itemO("armature.parent_clear", text="Clear")
1449
1450
1451 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1452     bl_label = "Bone Roll"
1453
1454     def draw(self, context):
1455         layout = self.layout
1456
1457         layout.item_enumO("armature.calculate_roll", "type", 'GLOBALUP', text="Clear Roll (Z-Axis Up)")
1458         layout.item_enumO("armature.calculate_roll", "type", 'CURSOR', text="Roll to Cursor")
1459
1460         layout.itemS()
1461
1462         layout.item_enumO("tfm.transform", "mode", 'BONE_ROLL', text="Set Roll")
1463
1464 # ********** Panel **********
1465
1466
1467 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1468     bl_space_type = 'VIEW_3D'
1469     bl_region_type = 'UI'
1470     bl_label = "View"
1471
1472     def poll(self, context):
1473         view = context.space_data
1474         return (view)
1475
1476     def draw(self, context):
1477         layout = self.layout
1478
1479         view = context.space_data
1480         scene = context.scene
1481
1482         col = layout.column()
1483         col.itemL(text="Camera:")
1484         col.itemR(view, "camera", text="")
1485         col.itemR(view, "lens")
1486
1487         col = layout.column(align=True)
1488         col.itemL(text="Clip:")
1489         col.itemR(view, "clip_start", text="Start")
1490         col.itemR(view, "clip_end", text="End")
1491
1492         col = layout.column(align=True)
1493         col.itemL(text="Grid:")
1494         col.itemR(view, "grid_lines", text="Lines")
1495         col.itemR(view, "grid_spacing", text="Spacing")
1496         col.itemR(view, "grid_subdivisions", text="Subdivisions")
1497
1498         layout.column().itemR(scene, "cursor_location", text="3D Cursor:")
1499
1500
1501 class VIEW3D_PT_3dview_name(bpy.types.Panel):
1502     bl_space_type = 'VIEW_3D'
1503     bl_region_type = 'UI'
1504     bl_label = "Item"
1505
1506     def poll(self, context):
1507         return (context.space_data and context.active_object)
1508
1509     def draw(self, context):
1510         layout = self.layout
1511
1512         ob = context.active_object
1513         row = layout.row()
1514         row.itemL(text="", icon='ICON_OBJECT_DATA')
1515         row.itemR(ob, "name", text="")
1516
1517         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1518             bone = context.active_bone
1519             if bone:
1520                 row = layout.row()
1521                 row.itemL(text="", icon='ICON_BONE_DATA')
1522                 row.itemR(bone, "name", text="")
1523
1524
1525 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1526     bl_space_type = 'VIEW_3D'
1527     bl_region_type = 'UI'
1528     bl_label = "Display"
1529     bl_default_closed = True
1530
1531     def poll(self, context):
1532         view = context.space_data
1533         return (view)
1534
1535     def draw(self, context):
1536         layout = self.layout
1537
1538         view = context.space_data
1539         gs = context.scene.game_data
1540         ob = context.object
1541
1542         col = layout.column()
1543         col.itemR(view, "display_floor", text="Grid Floor")
1544         col.itemR(view, "display_x_axis", text="X Axis")
1545         col.itemR(view, "display_y_axis", text="Y Axis")
1546         col.itemR(view, "display_z_axis", text="Z Axis")
1547         col.itemR(view, "outline_selected")
1548         col.itemR(view, "all_object_centers")
1549         col.itemR(view, "relationship_lines")
1550         if ob and ob.type == 'MESH':
1551             mesh = ob.data
1552             col.itemR(mesh, "all_edges")
1553
1554         col = layout.column()
1555         col.itemL(text="Shading:")
1556         col.itemR(gs, "material_mode", text="")
1557         col.itemR(view, "textured_solid")
1558
1559 # XXX - the Quad View options don't work yet
1560 #               layout.itemS()
1561 #
1562 #               layout.itemO("screen.region_foursplit", text="Toggle Quad View")
1563 #               col = layout.column()
1564 #               col.itemR(view, "lock_rotation")
1565 #               col.itemR(view, "box_preview")
1566 #               col.itemR(view, "box_clip")
1567
1568
1569 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1570     bl_space_type = 'VIEW_3D'
1571     bl_region_type = 'UI'
1572     bl_label = "Mesh Display"
1573
1574     def poll(self, context):
1575         # The active object check is needed because of localmode
1576         return (context.active_object and (context.mode == 'EDIT_MESH'))
1577
1578     def draw(self, context):
1579         layout = self.layout
1580
1581         mesh = context.active_object.data
1582
1583         col = layout.column()
1584         col.itemL(text="Overlays:")
1585         col.itemR(mesh, "draw_edges", text="Edges")
1586         col.itemR(mesh, "draw_faces", text="Faces")
1587         col.itemR(mesh, "draw_creases", text="Creases")
1588         col.itemR(mesh, "draw_bevel_weights", text="Bevel Weights")
1589         col.itemR(mesh, "draw_seams", text="Seams")
1590         col.itemR(mesh, "draw_sharp", text="Sharp")
1591
1592         col.itemS()
1593         col.itemL(text="Normals:")
1594         col.itemR(mesh, "draw_normals", text="Face")
1595         col.itemR(mesh, "draw_vertex_normals", text="Vertex")
1596         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1597
1598         col.itemS()
1599         col.itemL(text="Numerics:")
1600         col.itemR(mesh, "draw_edge_lenght")
1601         col.itemR(mesh, "draw_edge_angle")
1602         col.itemR(mesh, "draw_face_area")
1603
1604
1605 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1606     bl_space_type = 'VIEW_3D'
1607     bl_region_type = 'UI'
1608     bl_label = "Curve Display"
1609
1610     def poll(self, context):
1611         editmesh = context.mode == 'EDIT_CURVE'
1612         return (editmesh)
1613
1614     def draw(self, context):
1615         layout = self.layout
1616
1617         curve = context.active_object.data
1618
1619         col = layout.column()
1620         col.itemL(text="Overlays:")
1621         col.itemR(curve, "draw_handles", text="Handles")
1622         col.itemR(curve, "draw_normals", text="Normals")
1623         col.itemR(context.scene.tool_settings, "normal_size", text="Normal Size")
1624
1625
1626 class VIEW3D_PT_background_image(bpy.types.Panel):
1627     bl_space_type = 'VIEW_3D'
1628     bl_region_type = 'UI'
1629     bl_label = "Background Image"
1630     bl_default_closed = True
1631
1632     def poll(self, context):
1633         view = context.space_data
1634         # bg = context.space_data.background_image
1635         return (view)
1636
1637     def draw_header(self, context):
1638         layout = self.layout
1639         view = context.space_data
1640
1641         layout.itemR(view, "display_background_image", text="")
1642
1643     def draw(self, context):
1644         layout = self.layout
1645
1646         view = context.space_data
1647         bg = view.background_image
1648
1649         if bg:
1650             layout.active = view.display_background_image
1651
1652             col = layout.column()
1653             col.itemR(bg, "image", text="")
1654             #col.itemR(bg, "image_user")
1655             col.itemR(bg, "size")
1656             col.itemR(bg, "transparency", slider=True)
1657
1658
1659             col = layout.column(align=True)
1660             col.itemL(text="Offset:")
1661             col.itemR(bg, "offset_x", text="X")
1662             col.itemR(bg, "offset_y", text="Y")
1663
1664
1665 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1666     bl_space_type = 'VIEW_3D'
1667     bl_region_type = 'UI'
1668     bl_label = "Transform Orientations"
1669     bl_default_closed = True
1670
1671     def poll(self, context):
1672         view = context.space_data
1673         return (view)
1674
1675     def draw(self, context):
1676         layout = self.layout
1677
1678         view = context.space_data
1679
1680         col = layout.column()
1681
1682         col.itemR(view, "transform_orientation")
1683         col.itemO("tfm.create_orientation", text="Create")
1684
1685         orientation = view.current_orientation
1686
1687         if orientation:
1688             col.itemR(orientation, "name")
1689             col.itemO("tfm.delete_orientation", text="Delete")
1690
1691
1692 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1693     bl_space_type = 'VIEW_3D'
1694     bl_region_type = 'UI'
1695     bl_label = "Skeleton Sketching"
1696     bl_default_closed = True
1697
1698     def poll(self, context):
1699         scene = context.space_data
1700         ob = context.active_object
1701         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1702
1703     def draw_header(self, context):
1704         layout = self.layout
1705         toolsettings = context.scene.tool_settings
1706
1707         layout.itemR(toolsettings, "bone_sketching", text="")
1708
1709     def draw(self, context):
1710         layout = self.layout
1711         toolsettings = context.scene.tool_settings
1712
1713         col = layout.column()
1714
1715         col.itemR(toolsettings, "etch_quick")
1716         col.itemR(toolsettings, "etch_overdraw")
1717
1718         col.itemR(toolsettings, "etch_convert_mode")
1719
1720         if toolsettings.etch_convert_mode == 'LENGTH':
1721             col.itemR(toolsettings, "etch_length_limit")
1722         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
1723             col.itemR(toolsettings, "etch_adaptive_limit")
1724         elif toolsettings.etch_convert_mode == 'FIXED':
1725             col.itemR(toolsettings, "etch_subdivision_number")
1726         elif toolsettings.etch_convert_mode == 'RETARGET':
1727             col.itemR(toolsettings, "etch_template")
1728             col.itemR(toolsettings, "etch_roll_mode")
1729             col.itemR(toolsettings, "etch_autoname")
1730             col.itemR(toolsettings, "etch_number")
1731             col.itemR(toolsettings, "etch_side")
1732
1733
1734 class VIEW3D_PT_context_properties(bpy.types.Panel):
1735     bl_space_type = 'VIEW_3D'
1736     bl_region_type = 'UI'
1737     bl_label = "Properties"
1738     bl_default_closed = True
1739
1740     def draw(self, context):
1741         import rna_prop_ui
1742         # reload(rna_prop_ui)
1743         obj = context.object
1744         if obj:
1745             mode = obj.mode
1746             if mode == 'POSE':
1747                 item = "active_pchan"
1748             elif mode == 'EDIT' and obj.type == 'ARMATURE':
1749                 item = "active_bone"
1750             else:
1751                 item = "object"
1752
1753             # Draw with no edit button
1754             rna_prop_ui.draw(self.layout, context, item, False)
1755
1756
1757 # Operators
1758 from bpy.props import *
1759
1760
1761 class OBJECT_OT_select_pattern(bpy.types.Operator):
1762     '''Select object matching a naming pattern.'''
1763     bl_idname = "object.select_pattern"
1764     bl_label = "Select Pattern"
1765     bl_register = True
1766     bl_undo = True
1767
1768     pattern = StringProperty(name="Pattern", description="Name filter using '*' and '?' wildcard chars", maxlen=32, default="*")
1769     case_sensitive = BoolProperty(name="Case Sensitive", description="Do a case sensitive compare", default=False)
1770     extend = BoolProperty(name="Extend", description="Extend the existing selection", default=True)
1771
1772     def execute(self, context):
1773
1774         import fnmatch
1775
1776         if self.properties.case_sensitive:
1777             pattern_match = fnmatch.fnmatchcase
1778         else:
1779             pattern_match = lambda a, b: fnmatch.fnmatchcase(a.upper(), b.upper())
1780
1781         for ob in context.visible_objects:
1782             if pattern_match(ob.name, self.properties.pattern):
1783                 ob.selected = True
1784             elif not self.properties.extend:
1785                 ob.selected = False
1786
1787         return ('FINISHED',)
1788
1789         # TODO - python cant do popups yet
1790     '''
1791     def invoke(self, context, event):
1792         wm = context.manager
1793         wm.add_fileselect(self)
1794         return ('RUNNING_MODAL',)
1795     '''
1796
1797 bpy.types.register(VIEW3D_HT_header) # Header
1798
1799 bpy.types.register(VIEW3D_MT_view) #View Menus
1800 bpy.types.register(VIEW3D_MT_view_navigation)
1801 bpy.types.register(VIEW3D_MT_view_align)
1802 bpy.types.register(VIEW3D_MT_view_align_selected)
1803 bpy.types.register(VIEW3D_MT_view_cameras)
1804
1805 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1806 bpy.types.register(VIEW3D_MT_select_pose)
1807 bpy.types.register(VIEW3D_MT_select_particle)
1808 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1809 bpy.types.register(VIEW3D_MT_select_edit_curve)
1810 bpy.types.register(VIEW3D_MT_select_edit_surface)
1811 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1812 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1813 bpy.types.register(VIEW3D_MT_select_edit_armature)
1814 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1815
1816 bpy.types.register(VIEW3D_MT_transform) # Object/Edit Menus
1817 bpy.types.register(VIEW3D_MT_mirror) # Object/Edit Menus
1818 bpy.types.register(VIEW3D_MT_snap) # Object/Edit Menus
1819 bpy.types.register(VIEW3D_MT_uv_map) # Edit Menus
1820
1821 bpy.types.register(VIEW3D_MT_object) # Object Menu
1822 bpy.types.register(VIEW3D_MT_object_apply)
1823 bpy.types.register(VIEW3D_MT_object_clear)
1824 bpy.types.register(VIEW3D_MT_object_parent)
1825 bpy.types.register(VIEW3D_MT_object_track)
1826 bpy.types.register(VIEW3D_MT_object_group)
1827 bpy.types.register(VIEW3D_MT_object_constraints)
1828 bpy.types.register(VIEW3D_MT_object_showhide)
1829 bpy.types.register(VIEW3D_MT_make_single_user)
1830 bpy.types.register(VIEW3D_MT_make_links)
1831
1832 bpy.types.register(VIEW3D_MT_hook)
1833
1834 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1835
1836 bpy.types.register(VIEW3D_MT_paint_vertex)
1837
1838 bpy.types.register(VIEW3D_MT_particle) # Particle Menu
1839 bpy.types.register(VIEW3D_MT_particle_showhide)
1840
1841 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1842 bpy.types.register(VIEW3D_MT_pose_transform)
1843 bpy.types.register(VIEW3D_MT_pose_pose)
1844 bpy.types.register(VIEW3D_MT_pose_motion)
1845 bpy.types.register(VIEW3D_MT_pose_group)
1846 bpy.types.register(VIEW3D_MT_pose_ik)
1847 bpy.types.register(VIEW3D_MT_pose_constraints)
1848 bpy.types.register(VIEW3D_MT_pose_showhide)
1849
1850 bpy.types.register(VIEW3D_MT_edit_mesh)
1851 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1852 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1853 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1854 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1855 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1856 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1857
1858 bpy.types.register(VIEW3D_MT_edit_curve)
1859 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1860 bpy.types.register(VIEW3D_MT_edit_curve_segments)
1861 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
1862
1863 bpy.types.register(VIEW3D_MT_edit_surface)
1864
1865 bpy.types.register(VIEW3D_MT_edit_text)
1866 bpy.types.register(VIEW3D_MT_edit_text_chars)
1867
1868 bpy.types.register(VIEW3D_MT_edit_meta)
1869 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
1870
1871 bpy.types.register(VIEW3D_MT_edit_lattice)
1872
1873 bpy.types.register(VIEW3D_MT_edit_armature)
1874 bpy.types.register(VIEW3D_MT_edit_armature_parent)
1875 bpy.types.register(VIEW3D_MT_edit_armature_roll)
1876
1877 bpy.types.register(VIEW3D_MT_armature_specials) # Only as a menu for keybindings
1878
1879  # Panels
1880 bpy.types.register(VIEW3D_PT_3dview_properties)
1881 bpy.types.register(VIEW3D_PT_3dview_display)
1882 bpy.types.register(VIEW3D_PT_3dview_name)
1883 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
1884 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
1885 bpy.types.register(VIEW3D_PT_background_image)
1886 bpy.types.register(VIEW3D_PT_transform_orientations)
1887 bpy.types.register(VIEW3D_PT_etch_a_ton)
1888
1889 bpy.types.register(VIEW3D_PT_context_properties)
1890
1891 bpy.ops.add(OBJECT_OT_select_pattern)