Merged changes in the trunk up to revision 51718.
[blender.git] / release / scripts / startup / bl_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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu, Panel
22 from bl_ui.properties_paint_common import UnifiedPaintPanel
23
24
25 class VIEW3D_HT_header(Header):
26     bl_space_type = 'VIEW_3D'
27
28     def draw(self, context):
29         layout = self.layout
30
31         view = context.space_data
32         mode_string = context.mode
33         edit_object = context.edit_object
34         obj = context.active_object
35         toolsettings = context.tool_settings
36
37         row = layout.row(align=True)
38         row.template_header()
39
40         # Menus
41         if context.area.show_menus:
42             sub = row.row(align=True)
43
44             sub.menu("VIEW3D_MT_view")
45
46             # Select Menu
47             if mode_string not in {'EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
48                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
49
50             if edit_object:
51                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
52             elif obj:
53                 if mode_string not in {'PAINT_TEXTURE'}:
54                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
55                 if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}:
56                     sub.menu("VIEW3D_MT_brush")
57                 if mode_string == 'SCULPT':
58                     sub.menu("VIEW3D_MT_hide_mask")
59             else:
60                 sub.menu("VIEW3D_MT_object")
61
62         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
63         row = layout
64         layout.template_header_3D()
65
66         if obj:
67             mode = obj.mode
68             # Particle edit
69             if mode == 'PARTICLE_EDIT':
70                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
71
72             # Occlude geometry
73             if view.viewport_shade not in {'BOUNDBOX', 'WIREFRAME'} and (mode == 'PARTICLE_EDIT' or (mode == 'EDIT' and obj.type == 'MESH')):
74                 row.prop(view, "use_occlude_geometry", text="")
75
76             # Proportional editing
77             if mode in {'EDIT', 'PARTICLE_EDIT'}:
78                 row = layout.row(align=True)
79                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
80                 if toolsettings.proportional_edit != 'DISABLED':
81                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
82             elif mode == 'OBJECT':
83                 row = layout.row(align=True)
84                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
85                 if toolsettings.use_proportional_edit_objects:
86                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
87
88         # Snap
89         if not obj or mode not in {'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT'}:
90             snap_element = toolsettings.snap_element
91             row = layout.row(align=True)
92             row.prop(toolsettings, "use_snap", text="")
93             row.prop(toolsettings, "snap_element", text="", icon_only=True)
94             if snap_element != 'INCREMENT':
95                 row.prop(toolsettings, "snap_target", text="")
96                 if obj:
97                     if mode in {'OBJECT', 'POSE'} and snap_element != 'VOLUME':
98                         row.prop(toolsettings, "use_snap_align_rotation", text="")
99                     elif mode == 'EDIT':
100                         row.prop(toolsettings, "use_snap_self", text="")
101
102             if snap_element == 'VOLUME':
103                 row.prop(toolsettings, "use_snap_peel_object", text="")
104             elif snap_element == 'FACE':
105                 row.prop(toolsettings, "use_snap_project", text="")
106
107         # OpenGL render
108         row = layout.row(align=True)
109         row.operator("render.opengl", text="", icon='RENDER_STILL')
110         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
111         props.animation = True
112
113         # Pose
114         if obj and mode == 'POSE':
115             row = layout.row(align=True)
116             row.operator("pose.copy", text="", icon='COPYDOWN')
117             row.operator("pose.paste", text="", icon='PASTEDOWN')
118             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
119             props.flipped = 1
120
121
122 # ********** Menu **********
123
124 # ********** Utilities **********
125
126
127 class ShowHideMenu():
128     bl_label = "Show/Hide"
129     _operator_name = ""
130
131     def draw(self, context):
132         layout = self.layout
133
134         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
135         layout.operator("%s.hide" % self._operator_name, text="Hide Selected").unselected = False
136         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
137
138
139 # Standard transforms which apply to all cases
140 # NOTE: this doesn't seem to be able to be used directly
141 class VIEW3D_MT_transform_base(Menu):
142     bl_label = "Transform"
143
144     # TODO: get rid of the custom text strings?
145     def draw(self, context):
146         layout = self.layout
147
148         layout.operator("transform.translate", text="Grab/Move")
149         # TODO: sub-menu for grab per axis
150         layout.operator("transform.rotate", text="Rotate")
151         # TODO: sub-menu for rot per axis
152         layout.operator("transform.resize", text="Scale")
153         # TODO: sub-menu for scale per axis
154
155         layout.separator()
156
157         layout.operator("transform.tosphere", text="To Sphere")
158         layout.operator("transform.shear", text="Shear")
159         layout.operator("transform.warp", text="Warp")
160         layout.operator("transform.push_pull", text="Push/Pull")
161
162
163 # Generic transform menu - geometry types
164 class VIEW3D_MT_transform(VIEW3D_MT_transform_base):
165     def draw(self, context):
166         # base menu
167         VIEW3D_MT_transform_base.draw(self, context)
168
169         # generic...
170         layout = self.layout
171         layout.separator()
172
173         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
174         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
175
176
177 # Object-specific extensions to Transform menu
178 class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base):
179     def draw(self, context):
180         layout = self.layout
181
182         # base menu
183         VIEW3D_MT_transform_base.draw(self, context)
184
185         # object-specific option follow...
186         layout.separator()
187
188         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
189         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
190
191         layout.separator()
192
193         layout.operator_context = 'EXEC_REGION_WIN'
194         layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
195
196         layout.separator()
197
198         layout.operator_context = 'EXEC_AREA'
199
200         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
201         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
202         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
203
204         layout.separator()
205
206         layout.operator("object.randomize_transform")
207         layout.operator("object.align")
208
209         layout.separator()
210
211         layout.operator("object.anim_transforms_to_deltas")
212
213
214 # Armature EditMode extensions to Transform menu
215 class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base):
216     def draw(self, context):
217         layout = self.layout
218
219         # base menu
220         VIEW3D_MT_transform_base.draw(self, context)
221
222         # armature specific extensions follow...
223         layout.separator()
224
225         obj = context.object
226         if     (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and
227                 obj.data.draw_type in {'BBONE', 'ENVELOPE'}):
228             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
229
230         if context.edit_object and context.edit_object.type == 'ARMATURE':
231             layout.operator("armature.align")
232
233
234 class VIEW3D_MT_mirror(Menu):
235     bl_label = "Mirror"
236
237     def draw(self, context):
238         layout = self.layout
239
240         layout.operator("transform.mirror", text="Interactive Mirror")
241
242         layout.separator()
243
244         layout.operator_context = 'INVOKE_REGION_WIN'
245
246         props = layout.operator("transform.mirror", text="X Global")
247         props.constraint_axis = (True, False, False)
248         props.constraint_orientation = 'GLOBAL'
249         props = layout.operator("transform.mirror", text="Y Global")
250         props.constraint_axis = (False, True, False)
251         props.constraint_orientation = 'GLOBAL'
252         props = layout.operator("transform.mirror", text="Z Global")
253         props.constraint_axis = (False, False, True)
254         props.constraint_orientation = 'GLOBAL'
255
256         if context.edit_object:
257             layout.separator()
258
259             props = layout.operator("transform.mirror", text="X Local")
260             props.constraint_axis = (True, False, False)
261             props.constraint_orientation = 'LOCAL'
262             props = layout.operator("transform.mirror", text="Y Local")
263             props.constraint_axis = (False, True, False)
264             props.constraint_orientation = 'LOCAL'
265             props = layout.operator("transform.mirror", text="Z Local")
266             props.constraint_axis = (False, False, True)
267             props.constraint_orientation = 'LOCAL'
268
269             layout.operator("object.vertex_group_mirror")
270
271
272 class VIEW3D_MT_snap(Menu):
273     bl_label = "Snap"
274
275     def draw(self, context):
276         layout = self.layout
277
278         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
279         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
280
281         layout.separator()
282
283         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
284         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
285         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
286         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
287
288
289 class VIEW3D_MT_uv_map(Menu):
290     bl_label = "UV Mapping"
291
292     def draw(self, context):
293         layout = self.layout
294
295         layout.operator("uv.unwrap")
296
297         layout.operator_context = 'INVOKE_DEFAULT'
298         layout.operator("uv.smart_project")
299         layout.operator("uv.lightmap_pack")
300         layout.operator("uv.follow_active_quads")
301
302         layout.separator()
303
304         layout.operator_context = 'EXEC_REGION_WIN'
305         layout.operator("uv.cube_project")
306         layout.operator("uv.cylinder_project")
307         layout.operator("uv.sphere_project")
308
309         layout.separator()
310
311         layout.operator_context = 'EXEC_REGION_WIN'
312         layout.operator("uv.project_from_view").scale_to_bounds = False
313         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
314
315         layout.separator()
316
317         layout.operator("uv.reset")
318
319
320 # ********** View menus **********
321
322
323 class VIEW3D_MT_view(Menu):
324     bl_label = "View"
325
326     def draw(self, context):
327         layout = self.layout
328
329         layout.operator("view3d.properties", icon='MENU_PANEL')
330         layout.operator("view3d.toolshelf", icon='MENU_PANEL')
331
332         layout.separator()
333
334         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
335         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
336         layout.operator("view3d.viewnumpad", text="Bottom").type = 'BOTTOM'
337         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
338         layout.operator("view3d.viewnumpad", text="Back").type = 'BACK'
339         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
340         layout.operator("view3d.viewnumpad", text="Left").type = 'LEFT'
341
342         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
343
344         layout.separator()
345
346         layout.operator("view3d.view_persportho")
347
348         layout.separator()
349
350         layout.menu("VIEW3D_MT_view_navigation")
351         layout.menu("VIEW3D_MT_view_align")
352
353         layout.separator()
354
355         layout.operator_context = 'INVOKE_REGION_WIN'
356
357         layout.operator("view3d.clip_border", text="Clipping Border...")
358         layout.operator("view3d.zoom_border", text="Zoom Border...")
359
360         layout.separator()
361
362         layout.operator("view3d.layers", text="Show All Layers").nr = 0
363
364         layout.separator()
365
366         layout.operator("view3d.localview", text="View Global/Local")
367         layout.operator("view3d.view_selected")
368         layout.operator("view3d.view_all")
369
370         layout.separator()
371
372         layout.operator("screen.animation_play", text="Playback Animation")
373
374         layout.separator()
375
376         layout.operator("screen.area_dupli")
377         layout.operator("screen.region_quadview")
378         layout.operator("screen.screen_full_area")
379
380
381 class VIEW3D_MT_view_navigation(Menu):
382     bl_label = "Navigation"
383
384     def draw(self, context):
385         layout = self.layout
386
387         layout.operator_enum("view3d.view_orbit", "type")
388
389         layout.separator()
390
391         layout.operator_enum("view3d.view_pan", "type")
392
393         layout.separator()
394
395         layout.operator("view3d.zoom", text="Zoom In").delta = 1
396         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
397         layout.operator("view3d.zoom_camera_1_to_1", text="Zoom Camera 1:1")
398
399         layout.separator()
400
401         layout.operator("view3d.fly")
402
403
404 class VIEW3D_MT_view_align(Menu):
405     bl_label = "Align View"
406
407     def draw(self, context):
408         layout = self.layout
409
410         layout.menu("VIEW3D_MT_view_align_selected")
411
412         layout.separator()
413
414         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
415         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
416         layout.operator("view3d.camera_to_view_selected", text="Align Active Camera to Selected")
417         layout.operator("view3d.view_selected")
418         layout.operator("view3d.view_center_cursor")
419
420         layout.separator()
421
422         layout.operator("view3d.view_lock_to_active")
423         layout.operator("view3d.view_lock_clear")
424
425
426 class VIEW3D_MT_view_align_selected(Menu):
427     bl_label = "Align View to Selected"
428
429     def draw(self, context):
430         layout = self.layout
431
432         props = layout.operator("view3d.viewnumpad", text="Top")
433         props.align_active = True
434         props.type = 'TOP'
435
436         props = layout.operator("view3d.viewnumpad", text="Bottom")
437         props.align_active = True
438         props.type = 'BOTTOM'
439
440         props = layout.operator("view3d.viewnumpad", text="Front")
441         props.align_active = True
442         props.type = 'FRONT'
443
444         props = layout.operator("view3d.viewnumpad", text="Back")
445         props.align_active = True
446         props.type = 'BACK'
447
448         props = layout.operator("view3d.viewnumpad", text="Right")
449         props.align_active = True
450         props.type = 'RIGHT'
451
452         props = layout.operator("view3d.viewnumpad", text="Left")
453         props.align_active = True
454         props.type = 'LEFT'
455
456
457 class VIEW3D_MT_view_cameras(Menu):
458     bl_label = "Cameras"
459
460     def draw(self, context):
461         layout = self.layout
462
463         layout.operator("view3d.object_as_camera")
464         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
465
466 # ********** Select menus, suffix from context.mode **********
467
468
469 class VIEW3D_MT_select_object(Menu):
470     bl_label = "Select"
471
472     def draw(self, context):
473         layout = self.layout
474
475         layout.operator("view3d.select_border")
476         layout.operator("view3d.select_circle")
477
478         layout.separator()
479
480         layout.operator("object.select_all").action = 'TOGGLE'
481         layout.operator("object.select_all", text="Inverse").action = 'INVERT'
482         layout.operator("object.select_random", text="Random")
483         layout.operator("object.select_mirror", text="Mirror")
484         layout.operator("object.select_by_layer", text="Select All by Layer")
485         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
486         layout.operator("object.select_camera", text="Select Camera")
487
488         layout.separator()
489
490         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
491         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
492         layout.operator("object.select_pattern", text="Select Pattern...")
493
494
495 class VIEW3D_MT_select_pose(Menu):
496     bl_label = "Select"
497
498     def draw(self, context):
499         layout = self.layout
500
501         layout.operator("view3d.select_border")
502
503         layout.separator()
504
505         layout.operator("pose.select_all").action = 'TOGGLE'
506         layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
507         layout.operator("pose.select_flip_active", text="Flip Active")
508         layout.operator("pose.select_constraint_target", text="Constraint Target")
509         layout.operator("pose.select_linked", text="Linked")
510
511         layout.separator()
512
513         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
514         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
515
516         layout.separator()
517
518         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
519         props.extend = True
520         props.direction = 'PARENT'
521
522         props = layout.operator("pose.select_hierarchy", text="Extend Child")
523         props.extend = True
524         props.direction = 'CHILD'
525
526         layout.separator()
527
528         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
529         layout.operator("object.select_pattern", text="Select Pattern...")
530
531
532 class VIEW3D_MT_select_particle(Menu):
533     bl_label = "Select"
534
535     def draw(self, context):
536         layout = self.layout
537
538         layout.operator("view3d.select_border")
539
540         layout.separator()
541
542         layout.operator("particle.select_all").action = 'TOGGLE'
543         layout.operator("particle.select_linked")
544         layout.operator("particle.select_all", text="Inverse").action = 'INVERT'
545
546         layout.separator()
547
548         layout.operator("particle.select_more")
549         layout.operator("particle.select_less")
550
551         layout.separator()
552
553         layout.operator("particle.select_roots", text="Roots")
554         layout.operator("particle.select_tips", text="Tips")
555
556
557 class VIEW3D_MT_select_edit_mesh(Menu):
558     bl_label = "Select"
559
560     def draw(self, context):
561         layout = self.layout
562
563         layout.operator("view3d.select_border")
564         layout.operator("view3d.select_circle")
565
566         layout.separator()
567
568         layout.operator("mesh.select_all").action = 'TOGGLE'
569         layout.operator("mesh.select_all", text="Inverse").action = 'INVERT'
570
571         layout.separator()
572
573         layout.operator("mesh.select_random", text="Random")
574         layout.operator("mesh.select_nth", text="Every N Number of Verts")
575         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
576         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
577         layout.operator("mesh.select_interior_faces", text="Interior Faces")
578         layout.operator("mesh.select_axis", text="Side of Active")
579
580         layout.separator()
581
582         layout.operator("mesh.select_by_number_vertices", text="By Number of Verts")
583         if context.scene.tool_settings.mesh_select_mode[2] is False:
584             layout.operator("mesh.select_non_manifold", text="Non Manifold")
585         layout.operator("mesh.select_loose_verts", text="Loose Verts/Edges")
586         layout.operator_menu_enum("mesh.select_similar", "type", text="Similar")
587
588         layout.separator()
589
590         layout.operator("mesh.select_less", text="Less")
591         layout.operator("mesh.select_more", text="More")
592
593         layout.separator()
594
595         layout.operator("mesh.select_mirror", text="Mirror")
596
597         layout.operator("mesh.select_linked", text="Linked")
598         layout.operator("mesh.select_vertex_path", text="Vertex Path")
599         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
600         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
601
602         layout.separator()
603
604         layout.operator("mesh.loop_to_region")
605         layout.operator("mesh.region_to_loop")
606
607
608 class VIEW3D_MT_select_edit_curve(Menu):
609     bl_label = "Select"
610
611     def draw(self, context):
612         layout = self.layout
613
614         layout.operator("view3d.select_border")
615         layout.operator("view3d.select_circle")
616
617         layout.separator()
618
619         layout.operator("curve.select_all").action = 'TOGGLE'
620         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
621         layout.operator("curve.select_random")
622         layout.operator("curve.select_nth", text="Every Nth Number of Points")
623         layout.operator("curve.select_linked", text="Select Linked")
624
625         layout.separator()
626
627         layout.operator("curve.de_select_first")
628         layout.operator("curve.de_select_last")
629         layout.operator("curve.select_next")
630         layout.operator("curve.select_previous")
631
632         layout.separator()
633
634         layout.operator("curve.select_more")
635         layout.operator("curve.select_less")
636
637
638 class VIEW3D_MT_select_edit_surface(Menu):
639     bl_label = "Select"
640
641     def draw(self, context):
642         layout = self.layout
643
644         layout.operator("view3d.select_border")
645         layout.operator("view3d.select_circle")
646
647         layout.separator()
648
649         layout.operator("curve.select_all").action = 'TOGGLE'
650         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
651         layout.operator("curve.select_random")
652         layout.operator("curve.select_nth", text="Every Nth Number of Points")
653         layout.operator("curve.select_linked", text="Select Linked")
654
655         layout.separator()
656
657         layout.operator("curve.select_row")
658
659         layout.separator()
660
661         layout.operator("curve.select_more")
662         layout.operator("curve.select_less")
663
664
665 class VIEW3D_MT_select_edit_metaball(Menu):
666     bl_label = "Select"
667
668     def draw(self, context):
669         layout = self.layout
670
671         layout.operator("view3d.select_border")
672
673         layout.separator()
674
675         layout.operator("mball.select_all").action = 'TOGGLE'
676         layout.operator("mball.select_all", text="Inverse").action = 'INVERT'
677
678         layout.separator()
679
680         layout.operator("mball.select_random_metaelems")
681
682
683 class VIEW3D_MT_select_edit_lattice(Menu):
684     bl_label = "Select"
685
686     def draw(self, context):
687         layout = self.layout
688
689         layout.operator("view3d.select_border")
690
691         layout.separator()
692
693         layout.operator("lattice.select_all").action = 'TOGGLE'
694         layout.operator("lattice.select_all", text="Inverse").action = 'INVERT'
695
696
697 class VIEW3D_MT_select_edit_armature(Menu):
698     bl_label = "Select"
699
700     def draw(self, context):
701         layout = self.layout
702
703         layout.operator("view3d.select_border")
704
705         layout.separator()
706
707         layout.operator("armature.select_all").action = 'TOGGLE'
708         layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
709
710         layout.separator()
711
712         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
713         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
714
715         layout.separator()
716
717         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
718         props.extend = True
719         props.direction = 'PARENT'
720
721         props = layout.operator("armature.select_hierarchy", text="Extend Child")
722         props.extend = True
723         props.direction = 'CHILD'
724
725         layout.operator_menu_enum("armature.select_similar", "type", text="Similar")
726         layout.operator("object.select_pattern", text="Select Pattern...")
727
728
729 class VIEW3D_MT_select_face(Menu):  # XXX no matching enum
730     bl_label = "Select"
731
732     def draw(self, context):
733         # layout = self.layout
734
735         # TODO
736         # see view3d_select_faceselmenu
737         pass
738
739 # ********** Object menu **********
740
741
742 class VIEW3D_MT_object(Menu):
743     bl_context = "objectmode"
744     bl_label = "Object"
745
746     def draw(self, context):
747         layout = self.layout
748
749         layout.operator("ed.undo")
750         layout.operator("ed.redo")
751         layout.operator("ed.undo_history")
752
753         layout.separator()
754
755         layout.menu("VIEW3D_MT_transform_object")
756         layout.menu("VIEW3D_MT_mirror")
757         layout.menu("VIEW3D_MT_object_clear")
758         layout.menu("VIEW3D_MT_object_apply")
759         layout.menu("VIEW3D_MT_snap")
760
761         layout.separator()
762
763         layout.menu("VIEW3D_MT_object_animation")
764
765         layout.separator()
766
767         layout.operator("object.duplicate_move")
768         layout.operator("object.duplicate_move_linked")
769         layout.operator("object.delete", text="Delete...")
770         layout.operator("object.proxy_make", text="Make Proxy...")
771         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
772         layout.operator("object.make_dupli_face")
773         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
774         layout.menu("VIEW3D_MT_make_single_user")
775
776         layout.separator()
777
778         layout.menu("VIEW3D_MT_object_parent")
779         layout.menu("VIEW3D_MT_object_track")
780         layout.menu("VIEW3D_MT_object_group")
781         layout.menu("VIEW3D_MT_object_constraints")
782
783         layout.separator()
784
785         layout.menu("VIEW3D_MT_object_quick_effects")
786
787         layout.separator()
788
789         layout.menu("VIEW3D_MT_object_game")
790
791         layout.separator()
792
793         layout.operator("object.join")
794
795         layout.separator()
796
797         layout.operator("object.move_to_layer", text="Move to Layer...")
798         layout.menu("VIEW3D_MT_object_showhide")
799
800         layout.operator_menu_enum("object.convert", "target")
801
802
803 class VIEW3D_MT_object_animation(Menu):
804     bl_label = "Animation"
805
806     def draw(self, context):
807         layout = self.layout
808
809         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
810         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframes...")
811         layout.operator("anim.keyframe_clear_v3d", text="Clear Keyframes...")
812         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
813
814         layout.separator()
815
816         layout.operator("nla.bake", text="Bake Action...")
817
818
819 class VIEW3D_MT_object_clear(Menu):
820     bl_label = "Clear"
821
822     def draw(self, context):
823         layout = self.layout
824
825         layout.operator("object.location_clear", text="Location")
826         layout.operator("object.rotation_clear", text="Rotation")
827         layout.operator("object.scale_clear", text="Scale")
828         layout.operator("object.origin_clear", text="Origin")
829
830
831 class VIEW3D_MT_object_specials(Menu):
832     bl_label = "Specials"
833
834     @classmethod
835     def poll(cls, context):
836         # add more special types
837         return context.object
838
839     def draw(self, context):
840         layout = self.layout
841
842         obj = context.object
843         if obj.type == 'CAMERA':
844             layout.operator_context = 'INVOKE_REGION_WIN'
845
846             if obj.data.type == 'PERSP':
847                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
848                 props.data_path_iter = "selected_editable_objects"
849                 props.data_path_item = "data.lens"
850                 props.input_scale = 0.1
851                 if obj.data.lens_unit == 'MILLIMETERS':
852                     props.header_text = "Camera Lens Angle: %.1fmm"
853                 else:
854                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
855
856             else:
857                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
858                 props.data_path_iter = "selected_editable_objects"
859                 props.data_path_item = "data.ortho_scale"
860                 props.input_scale = 0.01
861                 props.header_text = "Camera Lens Scale: %.3f"
862
863             if not obj.data.dof_object:
864                 #layout.label(text="Test Has DOF obj");
865                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
866                 props.data_path_iter = "selected_editable_objects"
867                 props.data_path_item = "data.dof_distance"
868                 props.input_scale = 0.02
869                 props.header_text = "DOF Distance: %.3f"
870
871         if obj.type in {'CURVE', 'FONT'}:
872             layout.operator_context = 'INVOKE_REGION_WIN'
873
874             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
875             props.data_path_iter = "selected_editable_objects"
876             props.data_path_item = "data.extrude"
877             props.input_scale = 0.01
878             props.header_text = "Extrude Size: %.3f"
879
880             props = layout.operator("wm.context_modal_mouse", text="Width Size")
881             props.data_path_iter = "selected_editable_objects"
882             props.data_path_item = "data.offset"
883             props.input_scale = 0.01
884             props.header_text = "Width Size: %.3f"
885
886         if obj.type == 'EMPTY':
887             layout.operator_context = 'INVOKE_REGION_WIN'
888
889             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
890             props.data_path_iter = "selected_editable_objects"
891             props.data_path_item = "empty_draw_size"
892             props.input_scale = 0.01
893             props.header_text = "Empty Draw Size: %.3f"
894
895         if obj.type == 'LAMP':
896             layout.operator_context = 'INVOKE_REGION_WIN'
897
898             props = layout.operator("wm.context_modal_mouse", text="Energy")
899             props.data_path_iter = "selected_editable_objects"
900             props.data_path_item = "data.energy"
901             props.header_text = "Lamp Energy: %.3f"
902
903             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
904                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
905                 props.data_path_iter = "selected_editable_objects"
906                 props.data_path_item = "data.distance"
907                 props.input_scale = 0.1
908                 props.header_text = "Lamp Falloff Distance: %.1f"
909
910             if obj.data.type == 'SPOT':
911                 layout.separator()
912                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
913                 props.data_path_iter = "selected_editable_objects"
914                 props.data_path_item = "data.spot_size"
915                 props.input_scale = 0.01
916                 props.header_text = "Spot Size: %.2f"
917
918                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
919                 props.data_path_iter = "selected_editable_objects"
920                 props.data_path_item = "data.spot_blend"
921                 props.input_scale = -0.01
922                 props.header_text = "Spot Blend: %.2f"
923
924                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
925                 props.data_path_iter = "selected_editable_objects"
926                 props.data_path_item = "data.shadow_buffer_clip_start"
927                 props.input_scale = 0.05
928                 props.header_text = "Clip Start: %.2f"
929
930                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
931                 props.data_path_iter = "selected_editable_objects"
932                 props.data_path_item = "data.shadow_buffer_clip_end"
933                 props.input_scale = 0.05
934                 props.header_text = "Clip End: %.2f"
935
936         layout.separator()
937
938         props = layout.operator("object.isolate_type_render")
939         props = layout.operator("object.hide_render_clear_all")
940
941
942 class VIEW3D_MT_object_apply(Menu):
943     bl_label = "Apply"
944
945     def draw(self, context):
946         layout = self.layout
947
948         props = layout.operator("object.transform_apply", text="Location")
949         props.location, props.rotation, props.scale = True, False, False
950
951         props = layout.operator("object.transform_apply", text="Rotation")
952         props.location, props.rotation, props.scale = False, True, False
953
954         props = layout.operator("object.transform_apply", text="Scale")
955         props.location, props.rotation, props.scale = False, False, True
956         props = layout.operator("object.transform_apply", text="Rotation & Scale")
957         props.location, props.rotation, props.scale = False, True, True
958
959         layout.separator()
960
961         layout.operator("object.visual_transform_apply", text="Visual Transform")
962         layout.operator("object.duplicates_make_real")
963
964
965 class VIEW3D_MT_object_parent(Menu):
966     bl_label = "Parent"
967
968     def draw(self, context):
969         layout = self.layout
970
971         layout.operator_menu_enum("object.parent_set", "type", text="Set")
972         layout.operator_menu_enum("object.parent_clear", "type", text="Clear")
973
974
975 class VIEW3D_MT_object_track(Menu):
976     bl_label = "Track"
977
978     def draw(self, context):
979         layout = self.layout
980
981         layout.operator_menu_enum("object.track_set", "type", text="Set")
982         layout.operator_menu_enum("object.track_clear", "type", text="Clear")
983
984
985 class VIEW3D_MT_object_group(Menu):
986     bl_label = "Group"
987
988     def draw(self, context):
989         layout = self.layout
990
991         layout.operator("group.create")
992         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
993         layout.operator("group.objects_remove")
994         layout.operator("group.objects_remove_all")
995
996         layout.separator()
997
998         layout.operator("group.objects_add_active")
999         layout.operator("group.objects_remove_active")
1000
1001
1002 class VIEW3D_MT_object_constraints(Menu):
1003     bl_label = "Constraints"
1004
1005     def draw(self, context):
1006         layout = self.layout
1007
1008         layout.operator("object.constraint_add_with_targets")
1009         layout.operator("object.constraints_copy")
1010         layout.operator("object.constraints_clear")
1011
1012
1013 class VIEW3D_MT_object_quick_effects(Menu):
1014     bl_label = "Quick Effects"
1015
1016     def draw(self, context):
1017         layout = self.layout
1018
1019         layout.operator("object.quick_fur")
1020         layout.operator("object.quick_explode")
1021         layout.operator("object.quick_smoke")
1022         layout.operator("object.quick_fluid")
1023
1024
1025 class VIEW3D_MT_object_showhide(Menu):
1026     bl_label = "Show/Hide"
1027
1028     def draw(self, context):
1029         layout = self.layout
1030
1031         layout.operator("object.hide_view_clear", text="Show Hidden")
1032         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1033         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1034
1035
1036 class VIEW3D_MT_make_single_user(Menu):
1037     bl_label = "Make Single User"
1038
1039     def draw(self, context):
1040         layout = self.layout
1041
1042         props = layout.operator("object.make_single_user", text="Object")
1043         props.object = True
1044
1045         props = layout.operator("object.make_single_user", text="Object & Data")
1046         props.object = props.obdata = True
1047
1048         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1049         props.object = props.obdata = props.material = props.texture = True
1050
1051         props = layout.operator("object.make_single_user", text="Materials+Tex")
1052         props.material = props.texture = True
1053
1054         props = layout.operator("object.make_single_user", text="Object Animation")
1055         props.animation = True
1056
1057
1058 class VIEW3D_MT_make_links(Menu):
1059     bl_label = "Make Links"
1060
1061     def draw(self, context):
1062         layout = self.layout
1063
1064         if(len(bpy.data.scenes) > 10):
1065             layout.operator_context = 'INVOKE_DEFAULT'
1066             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1067         else:
1068             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1069
1070         layout.operator_enum("object.make_links_data", "type")  # inline
1071
1072         layout.operator("object.join_uvs")  # stupid place to add this!
1073
1074
1075 class VIEW3D_MT_object_game(Menu):
1076     bl_label = "Game"
1077
1078     def draw(self, context):
1079         layout = self.layout
1080
1081         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1082         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1083
1084         layout.separator()
1085
1086         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1087         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1088         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1089
1090         layout.separator()
1091
1092         layout.operator("object.game_property_clear")
1093
1094
1095 # ********** Brush menu **********
1096 class VIEW3D_MT_brush(Menu):
1097     bl_label = "Brush"
1098
1099     def draw(self, context):
1100         layout = self.layout
1101
1102         settings = UnifiedPaintPanel.paint_settings(context)
1103         brush = settings.brush
1104
1105         ups = context.tool_settings.unified_paint_settings
1106         layout.prop(ups, "use_unified_size", text="Unified Size")
1107         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1108         layout.separator()
1109
1110         # brush paint modes
1111         layout.menu("VIEW3D_MT_brush_paint_modes")
1112
1113         # brush tool
1114         if context.sculpt_object:
1115             layout.operator("brush.reset")
1116             layout.prop_menu_enum(brush, "sculpt_tool")
1117         elif context.image_paint_object:
1118             layout.prop_menu_enum(brush, "image_tool")
1119         elif context.vertex_paint_object or context.weight_paint_object:
1120             layout.prop_menu_enum(brush, "vertex_tool")
1121
1122         # skip if no active brush
1123         if not brush:
1124             return
1125
1126         # TODO: still missing a lot of brush options here
1127
1128         # sculpt options
1129         if context.sculpt_object:
1130
1131             sculpt_tool = brush.sculpt_tool
1132
1133             layout.separator()
1134             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1135             layout.separator()
1136
1137             if sculpt_tool != 'GRAB':
1138                 layout.prop_menu_enum(brush, "stroke_method")
1139
1140                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1141                     layout.prop_menu_enum(brush, "direction")
1142
1143                 if sculpt_tool == 'LAYER':
1144                     layout.prop(brush, "use_persistent")
1145                     layout.operator("sculpt.set_persistent_base")
1146
1147
1148 class VIEW3D_MT_brush_paint_modes(Menu):
1149     bl_label = "Enabled Modes"
1150
1151     def draw(self, context):
1152         layout = self.layout
1153
1154         settings = UnifiedPaintPanel.paint_settings(context)
1155         brush = settings.brush
1156
1157         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1158         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1159         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1160         layout.prop(brush, "use_paint_image", text="Texture Paint")
1161
1162 # ********** Vertex paint menu **********
1163
1164
1165 class VIEW3D_MT_paint_vertex(Menu):
1166     bl_label = "Paint"
1167
1168     def draw(self, context):
1169         layout = self.layout
1170
1171         layout.operator("ed.undo")
1172         layout.operator("ed.redo")
1173
1174         layout.separator()
1175
1176         layout.operator("paint.vertex_color_set")
1177         layout.operator("paint.vertex_color_dirt")
1178
1179
1180 class VIEW3D_MT_hook(Menu):
1181     bl_label = "Hooks"
1182
1183     def draw(self, context):
1184         layout = self.layout
1185         layout.operator_context = 'EXEC_AREA'
1186         layout.operator("object.hook_add_newob")
1187         layout.operator("object.hook_add_selob").use_bone = False
1188         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1189
1190         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1191             layout.separator()
1192             layout.operator_menu_enum("object.hook_assign", "modifier")
1193             layout.operator_menu_enum("object.hook_remove", "modifier")
1194             layout.separator()
1195             layout.operator_menu_enum("object.hook_select", "modifier")
1196             layout.operator_menu_enum("object.hook_reset", "modifier")
1197             layout.operator_menu_enum("object.hook_recenter", "modifier")
1198
1199
1200 class VIEW3D_MT_vertex_group(Menu):
1201     bl_label = "Vertex Groups"
1202
1203     def draw(self, context):
1204         layout = self.layout
1205
1206         layout.operator_context = 'EXEC_AREA'
1207         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1208
1209         ob = context.active_object
1210         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1211             if ob.vertex_groups.active:
1212                 layout.separator()
1213                 layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
1214                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1215                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1216                 layout.separator()
1217
1218         if ob.vertex_groups.active:
1219             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1220             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1221             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1222
1223 # ********** Weight paint menu **********
1224
1225
1226 class VIEW3D_MT_paint_weight(Menu):
1227     bl_label = "Weights"
1228
1229     def draw(self, context):
1230         layout = self.layout
1231
1232         layout.operator("ed.undo")
1233         layout.operator("ed.redo")
1234         layout.operator("ed.undo_history")
1235
1236         layout.separator()
1237
1238         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1239         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1240
1241         layout.separator()
1242
1243         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1244         layout.operator("object.vertex_group_normalize", text="Normalize")
1245         layout.operator("object.vertex_group_mirror", text="Mirror")
1246         layout.operator("object.vertex_group_invert", text="Invert")
1247         layout.operator("object.vertex_group_clean", text="Clean")
1248         layout.operator("object.vertex_group_levels", text="Levels")
1249         layout.operator("object.vertex_group_blend", text="Blend")
1250         layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1251         layout.operator("object.vertex_group_limit_total", text="Limit Total")
1252         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1253
1254         layout.separator()
1255
1256         layout.operator("paint.weight_set")
1257
1258 # ********** Sculpt menu **********
1259
1260
1261 class VIEW3D_MT_sculpt(Menu):
1262     bl_label = "Sculpt"
1263
1264     def draw(self, context):
1265         layout = self.layout
1266
1267         toolsettings = context.tool_settings
1268         sculpt = toolsettings.sculpt
1269
1270         layout.operator("ed.undo")
1271         layout.operator("ed.redo")
1272
1273         layout.separator()
1274
1275         layout.prop(sculpt, "use_symmetry_x")
1276         layout.prop(sculpt, "use_symmetry_y")
1277         layout.prop(sculpt, "use_symmetry_z")
1278         layout.separator()
1279         layout.prop(sculpt, "lock_x")
1280         layout.prop(sculpt, "lock_y")
1281         layout.prop(sculpt, "lock_z")
1282
1283         layout.separator()
1284         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1285         layout.prop(sculpt, "show_low_resolution")
1286         layout.prop(sculpt, "show_brush")
1287         layout.prop(sculpt, "use_deform_only")
1288         layout.prop(sculpt, "show_diffuse_color")
1289
1290
1291 class VIEW3D_MT_hide_mask(Menu):
1292     bl_label = "Hide/Mask"
1293
1294     def draw(self, context):
1295         layout = self.layout
1296
1297         op = layout.operator("paint.hide_show", text="Show All")
1298         op.action = 'SHOW'
1299         op.area = 'ALL'
1300
1301         op = layout.operator("paint.hide_show", text="Hide Bounding Box")
1302         op.action = 'HIDE'
1303         op.area = 'INSIDE'
1304
1305         op = layout.operator("paint.hide_show", text="Show Bounding Box")
1306         op.action = 'SHOW'
1307         op.area = 'INSIDE'
1308
1309         op = layout.operator("paint.hide_show", text="Hide Masked")
1310         op.area = 'MASKED'
1311         op.action = 'HIDE'
1312
1313         layout.separator()
1314
1315         op = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1316         op.mode = 'INVERT'
1317
1318         op = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1319         op.mode = 'VALUE'
1320         op.value = 1
1321
1322         op = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1323         op.mode = 'VALUE'
1324         op.value = 0
1325
1326
1327 # ********** Particle menu **********
1328
1329
1330 class VIEW3D_MT_particle(Menu):
1331     bl_label = "Particle"
1332
1333     def draw(self, context):
1334         layout = self.layout
1335
1336         particle_edit = context.tool_settings.particle_edit
1337
1338         layout.operator("ed.undo")
1339         layout.operator("ed.redo")
1340         layout.operator("ed.undo_history")
1341
1342         layout.separator()
1343
1344         layout.operator("particle.mirror")
1345
1346         layout.separator()
1347
1348         layout.operator("particle.remove_doubles")
1349         layout.operator("particle.delete")
1350
1351         if particle_edit.select_mode == 'POINT':
1352             layout.operator("particle.subdivide")
1353
1354         layout.operator("particle.rekey")
1355         layout.operator("particle.weight_set")
1356
1357         layout.separator()
1358
1359         layout.menu("VIEW3D_MT_particle_showhide")
1360
1361
1362 class VIEW3D_MT_particle_specials(Menu):
1363     bl_label = "Specials"
1364
1365     def draw(self, context):
1366         layout = self.layout
1367
1368         particle_edit = context.tool_settings.particle_edit
1369
1370         layout.operator("particle.rekey")
1371
1372         layout.separator()
1373         if particle_edit.select_mode == 'POINT':
1374             layout.operator("particle.subdivide")
1375             layout.operator("particle.select_roots")
1376             layout.operator("particle.select_tips")
1377
1378         layout.operator("particle.remove_doubles")
1379
1380
1381 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1382     _operator_name = "particle"
1383
1384 # ********** Pose Menu **********
1385
1386
1387 class VIEW3D_MT_pose(Menu):
1388     bl_label = "Pose"
1389
1390     def draw(self, context):
1391         layout = self.layout
1392
1393         layout.operator("ed.undo")
1394         layout.operator("ed.redo")
1395         layout.operator("ed.undo_history")
1396
1397         layout.separator()
1398
1399         layout.menu("VIEW3D_MT_transform_armature")
1400
1401         layout.menu("VIEW3D_MT_pose_transform")
1402         layout.menu("VIEW3D_MT_pose_apply")
1403
1404         layout.menu("VIEW3D_MT_snap")
1405
1406         layout.separator()
1407
1408         layout.menu("VIEW3D_MT_object_animation")
1409
1410         layout.separator()
1411
1412         layout.menu("VIEW3D_MT_pose_slide")
1413         layout.menu("VIEW3D_MT_pose_propagate")
1414
1415         layout.separator()
1416
1417         layout.operator("pose.copy")
1418         layout.operator("pose.paste")
1419         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1420
1421         layout.separator()
1422
1423         layout.menu("VIEW3D_MT_pose_library")
1424         layout.menu("VIEW3D_MT_pose_motion")
1425         layout.menu("VIEW3D_MT_pose_group")
1426
1427         layout.separator()
1428
1429         layout.menu("VIEW3D_MT_object_parent")
1430         layout.menu("VIEW3D_MT_pose_ik")
1431         layout.menu("VIEW3D_MT_pose_constraints")
1432
1433         layout.separator()
1434
1435         layout.operator_context = 'EXEC_AREA'
1436         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1437         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1438         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1439
1440         layout.operator("pose.flip_names")
1441
1442         layout.operator("pose.quaternions_flip")
1443
1444         layout.separator()
1445
1446         layout.operator_context = 'INVOKE_AREA'
1447         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1448         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1449
1450         layout.separator()
1451
1452         layout.menu("VIEW3D_MT_pose_showhide")
1453         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1454
1455
1456 class VIEW3D_MT_pose_transform(Menu):
1457     bl_label = "Clear Transform"
1458
1459     def draw(self, context):
1460         layout = self.layout
1461
1462         layout.operator("pose.transforms_clear", text="All")
1463
1464         layout.separator()
1465
1466         layout.operator("pose.loc_clear", text="Location")
1467         layout.operator("pose.rot_clear", text="Rotation")
1468         layout.operator("pose.scale_clear", text="Scale")
1469
1470         layout.separator()
1471
1472         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1473
1474
1475 class VIEW3D_MT_pose_slide(Menu):
1476     bl_label = "In-Betweens"
1477
1478     def draw(self, context):
1479         layout = self.layout
1480
1481         layout.operator("pose.push")
1482         layout.operator("pose.relax")
1483         layout.operator("pose.breakdown")
1484
1485
1486 class VIEW3D_MT_pose_propagate(Menu):
1487     bl_label = "Propagate"
1488
1489     def draw(self, context):
1490         layout = self.layout
1491
1492         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1493
1494         layout.separator()
1495
1496         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1497         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1498
1499         layout.separator()
1500
1501         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1502
1503
1504 class VIEW3D_MT_pose_library(Menu):
1505     bl_label = "Pose Library"
1506
1507     def draw(self, context):
1508         layout = self.layout
1509
1510         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1511
1512         layout.separator()
1513
1514         layout.operator("poselib.pose_add", text="Add Pose...")
1515         layout.operator("poselib.pose_rename", text="Rename Pose...")
1516         layout.operator("poselib.pose_remove", text="Remove Pose...")
1517
1518
1519 class VIEW3D_MT_pose_motion(Menu):
1520     bl_label = "Motion Paths"
1521
1522     def draw(self, context):
1523         layout = self.layout
1524
1525         layout.operator("pose.paths_calculate", text="Calculate")
1526         layout.operator("pose.paths_clear", text="Clear")
1527
1528
1529 class VIEW3D_MT_pose_group(Menu):
1530     bl_label = "Bone Groups"
1531
1532     def draw(self, context):
1533         layout = self.layout
1534         
1535         pose = context.active_object.pose
1536
1537         layout.operator_context = 'EXEC_AREA'
1538         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
1539         if pose.bone_groups:
1540             active_group = pose.bone_groups.active_index + 1
1541             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
1542
1543             layout.separator()
1544
1545             #layout.operator_context = 'INVOKE_AREA'
1546             layout.operator("pose.group_unassign")
1547             layout.operator("pose.group_remove")
1548
1549
1550 class VIEW3D_MT_pose_ik(Menu):
1551     bl_label = "Inverse Kinematics"
1552
1553     def draw(self, context):
1554         layout = self.layout
1555
1556         layout.operator("pose.ik_add")
1557         layout.operator("pose.ik_clear")
1558
1559
1560 class VIEW3D_MT_pose_constraints(Menu):
1561     bl_label = "Constraints"
1562
1563     def draw(self, context):
1564         layout = self.layout
1565
1566         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1567         layout.operator("pose.constraints_copy")
1568         layout.operator("pose.constraints_clear")
1569
1570
1571 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1572     _operator_name = "pose"
1573
1574
1575 class VIEW3D_MT_pose_apply(Menu):
1576     bl_label = "Apply"
1577
1578     def draw(self, context):
1579         layout = self.layout
1580
1581         layout.operator("pose.armature_apply")
1582         layout.operator("pose.visual_transform_apply")
1583
1584
1585 class VIEW3D_MT_pose_specials(Menu):
1586     bl_label = "Specials"
1587
1588     def draw(self, context):
1589         layout = self.layout
1590         layout.operator("pose.select_constraint_target")
1591         layout.operator("pose.flip_names")
1592         layout.operator("pose.paths_calculate")
1593         layout.operator("pose.paths_clear")
1594         layout.operator("pose.user_transforms_clear")
1595         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
1596         layout.operator("pose.relax")
1597
1598         layout.separator()
1599
1600         layout.operator_menu_enum("pose.autoside_names", "axis")
1601
1602
1603 class BoneOptions:
1604     def draw(self, context):
1605         layout = self.layout
1606
1607         options = [
1608             "show_wire",
1609             "use_deform",
1610             "use_envelope_multiply",
1611             "use_inherit_rotation",
1612             "use_inherit_scale",
1613         ]
1614
1615         if context.mode == 'EDIT_ARMATURE':
1616             bone_props = bpy.types.EditBone.bl_rna.properties
1617             data_path_iter = "selected_bones"
1618             opt_suffix = ""
1619             options.append("lock")
1620         else:  # pose-mode
1621             bone_props = bpy.types.Bone.bl_rna.properties
1622             data_path_iter = "selected_pose_bones"
1623             opt_suffix = "bone."
1624
1625         for opt in options:
1626             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1627             props.data_path_iter = data_path_iter
1628             props.data_path_item = opt_suffix + opt
1629             props.type = self.type
1630
1631
1632 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1633     bl_label = "Toggle Bone Options"
1634     type = 'TOGGLE'
1635
1636
1637 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1638     bl_label = "Enable Bone Options"
1639     type = 'ENABLE'
1640
1641
1642 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1643     bl_label = "Disable Bone Options"
1644     type = 'DISABLE'
1645
1646 # ********** Edit Menus, suffix from ob.type **********
1647
1648
1649 class VIEW3D_MT_edit_mesh(Menu):
1650     bl_label = "Mesh"
1651
1652     def draw(self, context):
1653         layout = self.layout
1654
1655         toolsettings = context.tool_settings
1656
1657         layout.operator("ed.undo")
1658         layout.operator("ed.redo")
1659         layout.operator("ed.undo_history")
1660
1661         layout.separator()
1662
1663         layout.menu("VIEW3D_MT_transform")
1664         layout.menu("VIEW3D_MT_mirror")
1665         layout.menu("VIEW3D_MT_snap")
1666
1667         layout.separator()
1668
1669         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1670
1671         layout.separator()
1672         layout.operator("mesh.symmetrize")
1673         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1674         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1675         layout.operator("mesh.duplicate_move")
1676         layout.menu("VIEW3D_MT_edit_mesh_delete")
1677         layout.menu("VIEW3D_MT_edit_mesh_dissolve")
1678
1679         layout.separator()
1680
1681         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1682         layout.menu("VIEW3D_MT_edit_mesh_edges")
1683         layout.menu("VIEW3D_MT_edit_mesh_faces")
1684         layout.menu("VIEW3D_MT_edit_mesh_normals")
1685
1686         layout.separator()
1687
1688         layout.prop(toolsettings, "use_mesh_automerge")
1689         layout.prop_menu_enum(toolsettings, "proportional_edit")
1690         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1691
1692         layout.separator()
1693
1694         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1695
1696
1697 class VIEW3D_MT_edit_mesh_specials(Menu):
1698     bl_label = "Specials"
1699
1700     def draw(self, context):
1701         layout = self.layout
1702
1703         layout.operator_context = 'INVOKE_REGION_WIN'
1704
1705         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1706         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1707         layout.operator("mesh.merge", text="Merge...")
1708         layout.operator("mesh.remove_doubles")
1709         layout.operator("mesh.hide", text="Hide").unselected = False
1710         layout.operator("mesh.reveal", text="Reveal")
1711         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
1712         layout.operator("mesh.flip_normals")
1713         layout.operator("mesh.vertices_smooth", text="Smooth")
1714         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
1715         layout.operator("mesh.inset")
1716         layout.operator("mesh.bevel", text="Bevel")
1717         layout.operator("mesh.bridge_edge_loops")
1718         layout.operator("mesh.faces_shade_smooth")
1719         layout.operator("mesh.faces_shade_flat")
1720         layout.operator("mesh.blend_from_shape")
1721         layout.operator("mesh.shape_propagate_to_all")
1722         layout.operator("mesh.select_vertex_path")
1723         layout.operator("mesh.sort_elements")
1724         layout.operator("mesh.symmetrize")
1725
1726
1727 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1728     bl_label = "Mesh Select Mode"
1729
1730     def draw(self, context):
1731         layout = self.layout
1732
1733         layout.operator_context = 'INVOKE_REGION_WIN'
1734
1735         props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1736         props.value = "(True, False, False)"
1737         props.data_path = "tool_settings.mesh_select_mode"
1738
1739         props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1740         props.value = "(False, True, False)"
1741         props.data_path = "tool_settings.mesh_select_mode"
1742
1743         props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1744         props.value = "(False, False, True)"
1745         props.data_path = "tool_settings.mesh_select_mode"
1746
1747
1748 class VIEW3D_MT_edit_mesh_extrude(Menu):
1749     bl_label = "Extrude"
1750
1751     _extrude_funcs = {
1752         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1753         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1754         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1755         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1756     }
1757
1758     @staticmethod
1759     def extrude_options(context):
1760         mesh = context.object.data
1761         select_mode = context.tool_settings.mesh_select_mode
1762
1763         menu = []
1764         if mesh.total_face_sel:
1765             menu += ['REGION', 'FACE']
1766         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1767             menu += ['EDGE']
1768         if mesh.total_vert_sel and select_mode[0]:
1769             menu += ['VERT']
1770
1771         # should never get here
1772         return menu
1773
1774     def draw(self, context):
1775         layout = self.layout
1776         layout.operator_context = 'INVOKE_REGION_WIN'
1777
1778         for menu_id in self.extrude_options(context):
1779             self._extrude_funcs[menu_id](layout)
1780
1781
1782 class VIEW3D_MT_edit_mesh_vertices(Menu):
1783     bl_label = "Vertices"
1784
1785     def draw(self, context):
1786         layout = self.layout
1787         layout.operator_context = 'INVOKE_REGION_WIN'
1788
1789         layout.operator("mesh.merge")
1790         layout.operator("mesh.rip_move")
1791         layout.operator("mesh.rip_move_fill")
1792         layout.operator("mesh.split")
1793         layout.operator_menu_enum("mesh.separate", "type")
1794         layout.operator("mesh.vert_connect")
1795         layout.operator("mesh.vert_slide")
1796
1797         layout.separator()
1798
1799         layout.operator("mesh.vertices_smooth")
1800         layout.operator("mesh.remove_doubles")
1801         layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {'VERT'}
1802
1803         layout.operator("mesh.select_vertex_path")
1804
1805         layout.operator("mesh.blend_from_shape")
1806
1807         layout.operator("object.vertex_group_blend")
1808         layout.operator("mesh.shape_propagate_to_all")
1809
1810         layout.separator()
1811
1812         layout.menu("VIEW3D_MT_vertex_group")
1813         layout.menu("VIEW3D_MT_hook")
1814
1815
1816 class VIEW3D_MT_edit_mesh_edges(Menu):
1817     bl_label = "Edges"
1818
1819     def draw(self, context):
1820         layout = self.layout
1821
1822         layout.operator_context = 'INVOKE_REGION_WIN'
1823
1824         layout.operator("mesh.edge_face_add")
1825         layout.operator("mesh.subdivide")
1826         layout.operator("mesh.unsubdivide")
1827
1828         layout.separator()
1829
1830         layout.operator("transform.edge_crease")
1831         layout.operator("transform.edge_bevelweight")
1832
1833         layout.separator()
1834
1835         layout.operator("mesh.mark_seam").clear = False
1836         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1837
1838         layout.separator()
1839
1840         layout.operator("mesh.mark_sharp").clear = False
1841         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1842
1843         layout.separator()
1844
1845         layout.operator("mesh.mark_freestyle_edge").clear = False
1846         layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
1847
1848         layout.separator()
1849
1850         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1851         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1852
1853         layout.separator()
1854
1855         layout.operator("mesh.bevel")
1856         layout.operator("mesh.edge_split")
1857         layout.operator("mesh.bridge_edge_loops")
1858         layout.operator("mesh.sort_elements", text="Sort Edges").elements = {'EDGE'}
1859
1860         layout.separator()
1861
1862         layout.operator("transform.edge_slide")
1863         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1864         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1865         layout.operator("mesh.loop_to_region")
1866         layout.operator("mesh.region_to_loop")
1867
1868
1869 class VIEW3D_MT_edit_mesh_faces(Menu):
1870     bl_label = "Faces"
1871     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1872
1873     def draw(self, context):
1874         layout = self.layout
1875
1876         layout.operator_context = 'INVOKE_REGION_WIN'
1877
1878         layout.operator("mesh.flip_normals")
1879         layout.operator("mesh.edge_face_add")
1880         layout.operator("mesh.fill")
1881         layout.operator("mesh.beautify_fill")
1882         layout.operator("mesh.inset")
1883         layout.operator("mesh.bevel")
1884         layout.operator("mesh.solidify")
1885         layout.operator("mesh.wireframe")
1886         layout.operator("mesh.sort_elements", text="Sort Faces").elements = {'FACE'}
1887
1888         layout.separator()
1889
1890         layout.operator("mesh.mark_freestyle_face").clear = False
1891         layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
1892
1893         layout.separator()
1894
1895         layout.operator("mesh.quads_convert_to_tris")
1896         layout.operator("mesh.tris_convert_to_quads")
1897
1898         layout.separator()
1899
1900         layout.operator("mesh.faces_shade_smooth")
1901         layout.operator("mesh.faces_shade_flat")
1902
1903         layout.separator()
1904
1905         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1906
1907         layout.separator()
1908
1909         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1910         layout.operator("mesh.uvs_reverse")
1911         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1912         layout.operator("mesh.colors_reverse")
1913
1914
1915 class VIEW3D_MT_edit_mesh_normals(Menu):
1916     bl_label = "Normals"
1917
1918     def draw(self, context):
1919         layout = self.layout
1920
1921         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1922         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1923
1924         layout.separator()
1925
1926         layout.operator("mesh.flip_normals")
1927
1928
1929 class VIEW3D_MT_edit_mesh_delete(Menu):
1930     bl_label = "Delete"
1931
1932     def draw(self, context):
1933         layout = self.layout
1934
1935         layout.operator_enum("mesh.delete", "type")
1936
1937         layout.separator()
1938
1939         layout.operator("mesh.dissolve")
1940         layout.operator("mesh.edge_collapse")
1941         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
1942
1943
1944 class VIEW3D_MT_edit_mesh_dissolve(Menu):
1945     bl_label = "Dissolve"
1946
1947     def draw(self, context):
1948         layout = self.layout
1949
1950         layout.operator("mesh.dissolve")
1951
1952         layout.separator()
1953
1954         layout.operator_enum("mesh.dissolve", "type")
1955
1956         layout.separator()
1957
1958         layout.operator("mesh.dissolve_limited")
1959
1960
1961 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1962     _operator_name = "mesh"
1963
1964 # Edit Curve
1965 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1966
1967
1968 def draw_curve(self, context):
1969     layout = self.layout
1970
1971     toolsettings = context.tool_settings
1972
1973     layout.menu("VIEW3D_MT_transform")
1974     layout.menu("VIEW3D_MT_mirror")
1975     layout.menu("VIEW3D_MT_snap")
1976
1977     layout.separator()
1978
1979     layout.operator("curve.extrude_move")
1980     layout.operator("curve.duplicate_move")
1981     layout.operator("curve.separate")
1982     layout.operator("curve.make_segment")
1983     layout.operator("curve.cyclic_toggle")
1984     layout.operator("curve.delete", text="Delete...")
1985
1986     layout.separator()
1987
1988     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1989     layout.menu("VIEW3D_MT_edit_curve_segments")
1990
1991     layout.separator()
1992
1993     layout.prop_menu_enum(toolsettings, "proportional_edit")
1994     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1995
1996     layout.separator()
1997
1998     layout.menu("VIEW3D_MT_edit_curve_showhide")
1999
2000
2001 class VIEW3D_MT_edit_curve(Menu):
2002     bl_label = "Curve"
2003
2004     draw = draw_curve
2005
2006
2007 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2008     bl_label = "Control Points"
2009
2010     def draw(self, context):
2011         layout = self.layout
2012
2013         edit_object = context.edit_object
2014
2015         if edit_object.type == 'CURVE':
2016             layout.operator("transform.tilt")
2017             layout.operator("curve.tilt_clear")
2018             layout.operator("curve.separate")
2019
2020             layout.separator()
2021
2022             layout.operator_menu_enum("curve.handle_type_set", "type")
2023
2024             layout.separator()
2025
2026         layout.menu("VIEW3D_MT_hook")
2027
2028
2029 class VIEW3D_MT_edit_curve_segments(Menu):
2030     bl_label = "Segments"
2031
2032     def draw(self, context):
2033         layout = self.layout
2034
2035         layout.operator("curve.subdivide")
2036         layout.operator("curve.switch_direction")
2037
2038
2039 class VIEW3D_MT_edit_curve_specials(Menu):
2040     bl_label = "Specials"
2041
2042     def draw(self, context):
2043         layout = self.layout
2044
2045         layout.operator("curve.subdivide")
2046         layout.operator("curve.switch_direction")
2047         layout.operator("curve.spline_weight_set")
2048         layout.operator("curve.radius_set")
2049         layout.operator("curve.smooth")
2050         layout.operator("curve.smooth_radius")
2051
2052
2053 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2054     _operator_name = "curve"
2055
2056
2057 class VIEW3D_MT_edit_surface(Menu):
2058     bl_label = "Surface"
2059
2060     draw = draw_curve
2061
2062
2063 class VIEW3D_MT_edit_font(Menu):
2064     bl_label = "Text"
2065
2066     def draw(self, context):
2067         layout = self.layout
2068
2069         layout.operator("font.file_paste")
2070
2071         layout.separator()
2072
2073         layout.menu("VIEW3D_MT_edit_text_chars")
2074
2075         layout.separator()
2076
2077         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2078         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2079         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2080         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2081
2082
2083 class VIEW3D_MT_edit_text_chars(Menu):
2084     bl_label = "Special Characters"
2085
2086     def draw(self, context):
2087         layout = self.layout
2088
2089         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2090         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2091
2092         layout.separator()
2093
2094         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2095         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2096         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2097         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2098         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2099         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2100         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2101         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2102         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2103
2104         layout.separator()
2105
2106         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2107         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2108         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2109
2110         layout.separator()
2111
2112         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2113         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2114         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2115
2116
2117 class VIEW3D_MT_edit_meta(Menu):
2118     bl_label = "Metaball"
2119
2120     def draw(self, context):
2121         layout = self.layout
2122
2123         toolsettings = context.tool_settings
2124
2125         layout.operator("ed.undo")
2126         layout.operator("ed.redo")
2127         layout.operator("ed.undo_history")
2128
2129         layout.separator()
2130
2131         layout.menu("VIEW3D_MT_transform")
2132         layout.menu("VIEW3D_MT_mirror")
2133         layout.menu("VIEW3D_MT_snap")
2134
2135         layout.separator()
2136
2137         layout.operator("mball.delete_metaelems", text="Delete...")
2138         layout.operator("mball.duplicate_metaelems")
2139
2140         layout.separator()
2141
2142         layout.prop_menu_enum(toolsettings, "proportional_edit")
2143         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2144
2145         layout.separator()
2146
2147         layout.menu("VIEW3D_MT_edit_meta_showhide")
2148
2149
2150 class VIEW3D_MT_edit_meta_showhide(Menu):
2151     bl_label = "Show/Hide"
2152
2153     def draw(self, context):
2154         layout = self.layout
2155
2156         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2157         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2158         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2159
2160
2161 class VIEW3D_MT_edit_lattice(Menu):
2162     bl_label = "Lattice"
2163
2164     def draw(self, context):
2165         layout = self.layout
2166
2167         toolsettings = context.tool_settings
2168
2169         layout.menu("VIEW3D_MT_transform")
2170         layout.menu("VIEW3D_MT_mirror")
2171         layout.menu("VIEW3D_MT_snap")
2172         layout.operator_menu_enum("lattice.flip", "axis")
2173
2174         layout.separator()
2175
2176         layout.operator("lattice.make_regular")
2177
2178         layout.separator()
2179
2180         layout.prop_menu_enum(toolsettings, "proportional_edit")
2181         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2182
2183
2184 class VIEW3D_MT_edit_armature(Menu):
2185     bl_label = "Armature"
2186
2187     def draw(self, context):
2188         layout = self.layout
2189
2190         edit_object = context.edit_object
2191         arm = edit_object.data
2192
2193         layout.menu("VIEW3D_MT_transform_armature")
2194         layout.menu("VIEW3D_MT_mirror")
2195         layout.menu("VIEW3D_MT_snap")
2196         layout.menu("VIEW3D_MT_edit_armature_roll")
2197
2198         layout.separator()
2199
2200         layout.operator("armature.extrude_move")
2201
2202         if arm.use_mirror_x:
2203             layout.operator("armature.extrude_forked")
2204
2205         layout.operator("armature.duplicate_move")
2206         layout.operator("armature.merge")
2207         layout.operator("armature.fill")
2208         layout.operator("armature.delete")
2209         layout.operator("armature.separate")
2210
2211         layout.separator()
2212
2213         layout.operator("armature.subdivide", text="Subdivide")
2214         layout.operator("armature.switch_direction", text="Switch Direction")
2215
2216         layout.separator()
2217
2218         layout.operator_context = 'EXEC_AREA'
2219         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2220         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2221         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2222         layout.operator("armature.flip_names")
2223
2224         layout.separator()
2225
2226         layout.operator_context = 'INVOKE_DEFAULT'
2227         layout.operator("armature.armature_layers")
2228         layout.operator("armature.bone_layers")
2229
2230         layout.separator()
2231
2232         layout.menu("VIEW3D_MT_edit_armature_parent")
2233
2234         layout.separator()
2235
2236         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2237
2238
2239 class VIEW3D_MT_armature_specials(Menu):
2240     bl_label = "Specials"
2241
2242     def draw(self, context):
2243         layout = self.layout
2244
2245         layout.operator_context = 'INVOKE_REGION_WIN'
2246
2247         layout.operator("armature.subdivide", text="Subdivide")
2248         layout.operator("armature.switch_direction", text="Switch Direction")
2249
2250         layout.separator()
2251
2252         layout.operator_context = 'EXEC_REGION_WIN'
2253         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2254         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2255         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2256         layout.operator("armature.flip_names", text="Flip Names")
2257
2258
2259 class VIEW3D_MT_edit_armature_parent(Menu):
2260     bl_label = "Parent"
2261
2262     def draw(self, context):
2263         layout = self.layout
2264
2265         layout.operator("armature.parent_set", text="Make")
2266         layout.operator("armature.parent_clear", text="Clear")
2267
2268
2269 class VIEW3D_MT_edit_armature_roll(Menu):
2270     bl_label = "Bone Roll"
2271
2272     def draw(self, context):
2273         layout = self.layout
2274
2275         layout.operator_menu_enum("armature.calculate_roll", "type")
2276
2277         layout.separator()
2278
2279         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2280
2281 # ********** Panel **********
2282
2283
2284 class VIEW3D_PT_view3d_properties(Panel):
2285     bl_space_type = 'VIEW_3D'
2286     bl_region_type = 'UI'
2287     bl_label = "View"
2288
2289     @classmethod
2290     def poll(cls, context):
2291         view = context.space_data
2292         return (view)
2293
2294     def draw(self, context):
2295         layout = self.layout
2296
2297         view = context.space_data
2298
2299         col = layout.column()
2300         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2301                           view.region_quadview)
2302         col.prop(view, "lens")
2303         col.label(text="Lock to Object:")
2304         col.prop(view, "lock_object", text="")
2305         lock_object = view.lock_object
2306         if lock_object:
2307             if lock_object.type == 'ARMATURE':
2308                 col.prop_search(view, "lock_bone", lock_object.data,
2309                                 "edit_bones" if lock_object.mode == 'EDIT'
2310                                 else "bones",
2311                                 text="")
2312         else:
2313             col.prop(view, "lock_cursor", text="Lock to Cursor")
2314
2315         col = layout.column()
2316         col.prop(view, "lock_camera")
2317
2318         col = layout.column(align=True)
2319         col.label(text="Clip:")
2320         col.prop(view, "clip_start", text="Start")
2321         col.prop(view, "clip_end", text="End")
2322
2323         subcol = col.column()
2324         subcol.enabled = not view.lock_camera_and_layers
2325         subcol.label(text="Local Camera:")
2326         subcol.prop(view, "camera", text="")
2327
2328         col = layout.column(align=True)
2329         col.prop(view, "use_render_border")
2330
2331
2332 class VIEW3D_PT_view3d_cursor(Panel):
2333     bl_space_type = 'VIEW_3D'
2334     bl_region_type = 'UI'
2335     bl_label = "3D Cursor"
2336
2337     @classmethod
2338     def poll(cls, context):
2339         view = context.space_data
2340         return (view is not None)
2341
2342     def draw(self, context):
2343         layout = self.layout
2344
2345         view = context.space_data
2346         layout.column().prop(view, "cursor_location", text="Location")
2347
2348
2349 class VIEW3D_PT_view3d_name(Panel):
2350     bl_space_type = 'VIEW_3D'
2351     bl_region_type = 'UI'
2352     bl_label = "Item"
2353
2354     @classmethod
2355     def poll(cls, context):
2356         return (context.space_data and context.active_object)
2357
2358     def draw(self, context):
2359         layout = self.layout
2360
2361         ob = context.active_object
2362         row = layout.row()
2363         row.label(text="", icon='OBJECT_DATA')
2364         row.prop(ob, "name", text="")
2365
2366         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2367             bone = context.active_bone
2368             if bone:
2369                 row = layout.row()
2370                 row.label(text="", icon='BONE_DATA')
2371                 row.prop(bone, "name", text="")
2372
2373
2374 class VIEW3D_PT_view3d_display(Panel):
2375     bl_space_type = 'VIEW_3D'
2376     bl_region_type = 'UI'
2377     bl_label = "Display"
2378     bl_options = {'DEFAULT_CLOSED'}
2379
2380     @classmethod
2381     def poll(cls, context):
2382         view = context.space_data
2383         return (view)
2384
2385     def draw(self, context):
2386         layout = self.layout
2387
2388         view = context.space_data
2389         scene = context.scene
2390         gs = scene.game_settings
2391         ob = context.object
2392
2393         col = layout.column()
2394         col.prop(view, "show_only_render")
2395
2396         col = layout.column()
2397         display_all = not view.show_only_render
2398         col.active = display_all
2399         col.prop(view, "show_outline_selected")
2400         col.prop(view, "show_all_objects_origin")
2401         col.prop(view, "show_relationship_lines")
2402         if ob and ob.type == 'MESH':
2403             mesh = ob.data
2404             col.prop(mesh, "show_all_edges")
2405
2406         col = layout.column()
2407         col.active = display_all
2408         split = col.split(percentage=0.55)
2409         split.prop(view, "show_floor", text="Grid Floor")
2410
2411         row = split.row(align=True)
2412         row.prop(view, "show_axis_x", text="X", toggle=True)
2413         row.prop(view, "show_axis_y", text="Y", toggle=True)
2414         row.prop(view, "show_axis_z", text="Z", toggle=True)
2415
2416         sub = col.column(align=True)
2417         sub.active = (display_all and view.show_floor)
2418         sub.prop(view, "grid_lines", text="Lines")
2419         sub.prop(view, "grid_scale", text="Scale")
2420         subsub = sub.column(align=True)
2421         subsub.active = scene.unit_settings.system == 'NONE'
2422         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2423
2424         if not scene.render.use_shading_nodes:
2425             col = layout.column()
2426             col.label(text="Shading:")
2427             col.prop(gs, "material_mode", text="")
2428             col.prop(view, "show_textured_solid")
2429
2430         col.prop(view, "show_backface_culling")
2431
2432         layout.separator()
2433
2434         region = view.region_quadview
2435
2436         layout.operator("screen.region_quadview", text="Toggle Quad View")
2437
2438         if region:
2439             col = layout.column()
2440             col.prop(region, "lock_rotation")
2441             row = col.row()
2442             row.enabled = region.lock_rotation
2443             row.prop(region, "show_sync_view")
2444             row = col.row()
2445             row.enabled = region.lock_rotation and region.show_sync_view
2446             row.prop(region, "use_box_clip")
2447
2448
2449 class VIEW3D_PT_view3d_motion_tracking(Panel):
2450     bl_space_type = 'VIEW_3D'
2451     bl_region_type = 'UI'
2452     bl_label = "Motion Tracking"
2453     bl_options = {'DEFAULT_CLOSED'}
2454
2455     @classmethod
2456     def poll(cls, context):
2457         view = context.space_data
2458         return (view)
2459
2460     def draw_header(self, context):
2461         view = context.space_data
2462
2463         self.layout.prop(view, "show_reconstruction", text="")
2464
2465     def draw(self, context):
2466         layout = self.layout
2467
2468         view = context.space_data
2469
2470         col = layout.column()
2471         col.active = view.show_reconstruction
2472         col.prop(view, "show_bundle_names")
2473         col.prop(view, "show_camera_path")
2474         col.label(text="Tracks:")
2475         col.prop(view, "tracks_draw_type", text="")
2476         col.prop(view, "tracks_draw_size", text="Size")
2477
2478
2479 class VIEW3D_PT_view3d_meshdisplay(Panel):
2480     bl_space_type = 'VIEW_3D'
2481     bl_region_type = 'UI'
2482     bl_label = "Mesh Display"
2483
2484     @classmethod
2485     def poll(cls, context):
2486         # The active object check is needed because of local-mode
2487         return (context.active_object and (context.mode == 'EDIT_MESH'))
2488
2489     def draw(self, context):
2490         layout = self.layout
2491
2492         mesh = context.active_object.data
2493
2494         col = layout.column()
2495         col.label(text="Overlays:")
2496         col.prop(mesh, "show_edges", text="Edges")
2497         col.prop(mesh, "show_faces", text="Faces")
2498         col.prop(mesh, "show_edge_crease", text="Creases")
2499         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2500         col.prop(mesh, "show_edge_seams", text="Seams")
2501         col.prop(mesh, "show_edge_sharp", text="Sharp")
2502         col.prop(mesh, "show_freestyle_edge_marks", text="Freestyle Edge Marks")
2503         col.prop(mesh, "show_freestyle_face_marks", text="Freestyle Face Marks")
2504
2505         col.separator()
2506         col.label(text="Normals:")
2507         row = col.row()
2508         sub = row.row(align=True)
2509         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2510         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2511         row.prop(context.scene.tool_settings, "normal_size", text="Size")
2512
2513         col.separator()
2514         col.label(text="Numerics:")
2515         col.prop(mesh, "show_extra_edge_length")
2516         col.prop(mesh, "show_extra_face_angle")
2517         col.prop(mesh, "show_extra_face_area")
2518         if bpy.app.debug:
2519             col.prop(mesh, "show_extra_indices")
2520
2521
2522 class VIEW3D_PT_view3d_curvedisplay(Panel):
2523     bl_space_type = 'VIEW_3D'
2524     bl_region_type = 'UI'
2525     bl_label = "Curve Display"
2526
2527     @classmethod
2528     def poll(cls, context):
2529         editmesh = context.mode == 'EDIT_CURVE'
2530         return (editmesh)
2531
2532     def draw(self, context):
2533         layout = self.layout
2534
2535         curve = context.active_object.data
2536
2537         col = layout.column()
2538         col.label(text="Overlays:")
2539         col.prop(curve, "show_handles", text="Handles")
2540         col.prop(curve, "show_normal_face", text="Normals")
2541         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2542
2543
2544 class VIEW3D_PT_background_image(Panel):
2545     bl_space_type = 'VIEW_3D'
2546     bl_region_type = 'UI'
2547     bl_label = "Background Images"
2548     bl_options = {'DEFAULT_CLOSED'}
2549
2550     def draw_header(self, context):
2551         view = context.space_data
2552
2553         self.layout.prop(view, "show_background_images", text="")
2554
2555     def draw(self, context):
2556         layout = self.layout
2557
2558         view = context.space_data
2559
2560         col = layout.column()
2561         col.operator("view3d.background_image_add", text="Add Image")
2562
2563         for i, bg in enumerate(view.background_images):
2564             layout.active = view.show_background_images
2565             box = layout.box()
2566             row = box.row(align=True)
2567             row.prop(bg, "show_expanded", text="", emboss=False)
2568             if bg.source == 'IMAGE' and bg.image:
2569                 row.prop(bg.image, "name", text="", emboss=False)
2570             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2571                 row.prop(bg.clip, "name", text="", emboss=False)
2572             else:
2573                 row.label(text="Not Set")
2574
2575             if bg.show_background_image:
2576                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2577             else:
2578                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2579
2580             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2581
2582             box.prop(bg, "view_axis", text="Axis")
2583
2584             if bg.show_expanded:
2585                 row = box.row()
2586                 row.prop(bg, "source", expand=True)
2587
2588                 has_bg = False
2589                 if bg.source == 'IMAGE':
2590                     row = box.row()
2591                     row.template_ID(bg, "image", open="image.open")
2592                     if bg.image is not None:
2593                         box.template_image(bg, "image", bg.image_user, compact=True)
2594                         has_bg = True
2595
2596                 elif bg.source == 'MOVIE_CLIP':
2597                     box.prop(bg, "use_camera_clip")
2598
2599                     column = box.column()
2600                     column.active = not bg.use_camera_clip
2601                     column.template_ID(bg, "clip", open="clip.open")
2602
2603                     if bg.clip:
2604                         column.template_movieclip(bg, "clip", compact=True)
2605
2606                     if bg.use_camera_clip or bg.clip:
2607                         has_bg = True
2608
2609                     column = box.column()
2610                     column.active = has_bg
2611                     column.prop(bg.clip_user, "proxy_render_size", text="")
2612                     column.prop(bg.clip_user, "use_render_undistorted")
2613
2614                 if has_bg:
2615                     col = box.column()
2616                     col.prop(bg, "opacity", slider=True)
2617
2618                     rowsub = col.row()
2619                     rowsub.prop(bg, "draw_depth", expand=True)
2620
2621                     if bg.view_axis in {'CAMERA', 'ALL'}:
2622                         rowsub = col.row()
2623                         rowsub.prop(bg, "frame_method", expand=True)
2624
2625                     row = col.row(align=True)
2626                     row.prop(bg, "offset_x", text="X")
2627                     row.prop(bg, "offset_y", text="Y")
2628
2629                     if bg.view_axis != 'CAMERA':
2630                         col.prop(bg, "size")
2631
2632
2633 class VIEW3D_PT_transform_orientations(Panel):
2634     bl_space_type = 'VIEW_3D'
2635     bl_region_type = 'UI'
2636     bl_label = "Transform Orientations"
2637     bl_options = {'DEFAULT_CLOSED'}
2638
2639     @classmethod
2640     def poll(cls, context):
2641         view = context.space_data
2642         return (view)
2643
2644     def draw(self, context):
2645         layout = self.layout
2646
2647         view = context.space_data
2648         orientation = view.current_orientation
2649
2650         row = layout.row(align=True)
2651         row.prop(view, "transform_orientation", text="")
2652         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2653
2654         if orientation:
2655             row = layout.row(align=True)
2656             row.prop(orientation, "name", text="")
2657             row.operator("transform.delete_orientation", text="", icon="X")
2658
2659
2660 class VIEW3D_PT_etch_a_ton(Panel):
2661     bl_space_type = 'VIEW_3D'
2662     bl_region_type = 'UI'
2663     bl_label = "Skeleton Sketching"
2664     bl_options = {'DEFAULT_CLOSED'}
2665
2666     @classmethod
2667     def poll(cls, context):
2668         scene = context.space_data
2669         ob = context.active_object
2670         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2671
2672     def draw_header(self, context):
2673         layout = self.layout
2674         toolsettings = context.scene.tool_settings
2675
2676         layout.prop(toolsettings, "use_bone_sketching", text="")
2677
2678     def draw(self, context):
2679         layout = self.layout
2680
2681         toolsettings = context.scene.tool_settings
2682
2683         col = layout.column()
2684
2685         col.prop(toolsettings, "use_etch_quick")
2686         col.prop(toolsettings, "use_etch_overdraw")
2687
2688         col.prop(toolsettings, "etch_convert_mode")
2689
2690         if toolsettings.etch_convert_mode == 'LENGTH':
2691             col.prop(toolsettings, "etch_length_limit")
2692         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2693             col.prop(toolsettings, "etch_adaptive_limit")
2694         elif toolsettings.etch_convert_mode == 'FIXED':
2695             col.prop(toolsettings, "etch_subdivision_number")
2696         elif toolsettings.etch_convert_mode == 'RETARGET':
2697             col.prop(toolsettings, "etch_template")
2698             col.prop(toolsettings, "etch_roll_mode")
2699             col.prop(toolsettings, "use_etch_autoname")
2700             col.prop(toolsettings, "etch_number")
2701             col.prop(toolsettings, "etch_side")
2702
2703         col.operator("sketch.convert", text="Convert")
2704
2705
2706 class VIEW3D_PT_context_properties(Panel):
2707     bl_space_type = 'VIEW_3D'
2708     bl_region_type = 'UI'
2709     bl_label = "Properties"
2710     bl_options = {'DEFAULT_CLOSED'}
2711
2712     def _active_context_member(context):
2713         obj = context.object
2714         if obj:
2715             mode = obj.mode
2716             if mode == 'POSE':
2717                 return "active_pose_bone"
2718             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2719                 return "active_bone"
2720             else:
2721                 return "object"
2722
2723         return ""
2724
2725     @classmethod
2726     def poll(cls, context):
2727         member = cls._active_context_member(context)
2728         if member:
2729             context_member = getattr(context, member)
2730             return context_member and context_member.keys()
2731
2732         return False
2733
2734     def draw(self, context):
2735         import rna_prop_ui
2736         member = VIEW3D_PT_context_properties._active_context_member(context)
2737
2738         if member:
2739             # Draw with no edit button
2740             rna_prop_ui.draw(self.layout, context, member, object, False)
2741
2742
2743 def register():
2744     bpy.utils.register_module(__name__)
2745
2746
2747 def unregister():
2748     bpy.utils.unregister_module(__name__)
2749
2750 if __name__ == "__main__":
2751     register()
2752
2753 if __name__ == "__main__":  # only for live edit.
2754     bpy.utils.register_module(__name__)