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