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