Merged changes in the trunk up to revision 49986.
[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] == 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("mesh.select_similar", 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("object.select_pattern", text="Select Pattern...")
726
727
728 class VIEW3D_MT_select_face(Menu):  # XXX no matching enum
729     bl_label = "Select"
730
731     def draw(self, context):
732         # layout = self.layout
733
734         # TODO
735         # see view3d_select_faceselmenu
736         pass
737
738 # ********** Object menu **********
739
740
741 class VIEW3D_MT_object(Menu):
742     bl_context = "objectmode"
743     bl_label = "Object"
744
745     def draw(self, context):
746         layout = self.layout
747
748         layout.operator("ed.undo")
749         layout.operator("ed.redo")
750         layout.operator("ed.undo_history")
751
752         layout.separator()
753
754         layout.menu("VIEW3D_MT_transform_object")
755         layout.menu("VIEW3D_MT_mirror")
756         layout.menu("VIEW3D_MT_object_clear")
757         layout.menu("VIEW3D_MT_object_apply")
758         layout.menu("VIEW3D_MT_snap")
759
760         layout.separator()
761
762         layout.menu("VIEW3D_MT_object_animation")
763
764         layout.separator()
765
766         layout.operator("object.duplicate_move")
767         layout.operator("object.duplicate_move_linked")
768         layout.operator("object.delete", text="Delete...")
769         layout.operator("object.proxy_make", text="Make Proxy...")
770         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
771         layout.operator("object.make_dupli_face")
772         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
773         layout.menu("VIEW3D_MT_make_single_user")
774
775         layout.separator()
776
777         layout.menu("VIEW3D_MT_object_parent")
778         layout.menu("VIEW3D_MT_object_track")
779         layout.menu("VIEW3D_MT_object_group")
780         layout.menu("VIEW3D_MT_object_constraints")
781
782         layout.separator()
783
784         layout.menu("VIEW3D_MT_object_quick_effects")
785
786         layout.separator()
787
788         layout.menu("VIEW3D_MT_object_game")
789
790         layout.separator()
791
792         layout.operator("object.join")
793
794         layout.separator()
795
796         layout.operator("object.move_to_layer", text="Move to Layer...")
797         layout.menu("VIEW3D_MT_object_showhide")
798
799         layout.operator_menu_enum("object.convert", "target")
800
801
802 class VIEW3D_MT_object_animation(Menu):
803     bl_label = "Animation"
804
805     def draw(self, context):
806         layout = self.layout
807
808         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
809         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
810         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
811
812         layout.separator()
813
814         layout.operator("nla.bake", text="Bake Action...")
815
816
817 class VIEW3D_MT_object_clear(Menu):
818     bl_label = "Clear"
819
820     def draw(self, context):
821         layout = self.layout
822
823         layout.operator("object.location_clear", text="Location")
824         layout.operator("object.rotation_clear", text="Rotation")
825         layout.operator("object.scale_clear", text="Scale")
826         layout.operator("object.origin_clear", text="Origin")
827
828
829 class VIEW3D_MT_object_specials(Menu):
830     bl_label = "Specials"
831
832     @classmethod
833     def poll(cls, context):
834         # add more special types
835         return context.object
836
837     def draw(self, context):
838         layout = self.layout
839
840         obj = context.object
841         if obj.type == 'CAMERA':
842             layout.operator_context = 'INVOKE_REGION_WIN'
843
844             if obj.data.type == 'PERSP':
845                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
846                 props.data_path_iter = "selected_editable_objects"
847                 props.data_path_item = "data.lens"
848                 props.input_scale = 0.1
849                 if obj.data.lens_unit == 'MILLIMETERS':
850                     props.header_text = "Camera Lens Angle: %.1fmm"
851                 else:
852                     props.header_text = "Camera Lens Angle: %.1f\u00B0"
853
854             else:
855                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
856                 props.data_path_iter = "selected_editable_objects"
857                 props.data_path_item = "data.ortho_scale"
858                 props.input_scale = 0.01
859                 props.header_text = "Camera Lens Scale: %.3f"
860
861             if not obj.data.dof_object:
862                 #layout.label(text="Test Has DOF obj");
863                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
864                 props.data_path_iter = "selected_editable_objects"
865                 props.data_path_item = "data.dof_distance"
866                 props.input_scale = 0.02
867                 props.header_text = "DOF Distance: %.3f"
868
869         if obj.type in {'CURVE', 'FONT'}:
870             layout.operator_context = 'INVOKE_REGION_WIN'
871
872             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
873             props.data_path_iter = "selected_editable_objects"
874             props.data_path_item = "data.extrude"
875             props.input_scale = 0.01
876             props.header_text = "Extrude Size: %.3f"
877
878             props = layout.operator("wm.context_modal_mouse", text="Width Size")
879             props.data_path_iter = "selected_editable_objects"
880             props.data_path_item = "data.offset"
881             props.input_scale = 0.01
882             props.header_text = "Width Size: %.3f"
883
884         if obj.type == 'EMPTY':
885             layout.operator_context = 'INVOKE_REGION_WIN'
886
887             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
888             props.data_path_iter = "selected_editable_objects"
889             props.data_path_item = "empty_draw_size"
890             props.input_scale = 0.01
891             props.header_text = "Empty Draw Size: %.3f"
892
893         if obj.type == 'LAMP':
894             layout.operator_context = 'INVOKE_REGION_WIN'
895
896             props = layout.operator("wm.context_modal_mouse", text="Energy")
897             props.data_path_iter = "selected_editable_objects"
898             props.data_path_item = "data.energy"
899             props.header_text = "Lamp Energy: %.3f"
900
901             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
902                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
903                 props.data_path_iter = "selected_editable_objects"
904                 props.data_path_item = "data.distance"
905                 props.input_scale = 0.1
906                 props.header_text = "Lamp Falloff Distance: %.1f"
907
908             if obj.data.type == 'SPOT':
909                 layout.separator()
910                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
911                 props.data_path_iter = "selected_editable_objects"
912                 props.data_path_item = "data.spot_size"
913                 props.input_scale = 0.01
914                 props.header_text = "Spot Size: %.2f"
915
916                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
917                 props.data_path_iter = "selected_editable_objects"
918                 props.data_path_item = "data.spot_blend"
919                 props.input_scale = -0.01
920                 props.header_text = "Spot Blend: %.2f"
921
922                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
923                 props.data_path_iter = "selected_editable_objects"
924                 props.data_path_item = "data.shadow_buffer_clip_start"
925                 props.input_scale = 0.05
926                 props.header_text = "Clip Start: %.2f"
927
928                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
929                 props.data_path_iter = "selected_editable_objects"
930                 props.data_path_item = "data.shadow_buffer_clip_end"
931                 props.input_scale = 0.05
932                 props.header_text = "Clip End: %.2f"
933
934         layout.separator()
935
936         props = layout.operator("object.isolate_type_render")
937         props = layout.operator("object.hide_render_clear_all")
938
939
940 class VIEW3D_MT_object_apply(Menu):
941     bl_label = "Apply"
942
943     def draw(self, context):
944         layout = self.layout
945
946         props = layout.operator("object.transform_apply", text="Location")
947         props.location, props.rotation, props.scale = True, False, False
948
949         props = layout.operator("object.transform_apply", text="Rotation")
950         props.location, props.rotation, props.scale = False, True, False
951
952         props = layout.operator("object.transform_apply", text="Scale")
953         props.location, props.rotation, props.scale = False, False, True
954         props = layout.operator("object.transform_apply", text="Rotation & Scale")
955         props.location, props.rotation, props.scale = False, True, True
956
957         layout.separator()
958
959         layout.operator("object.visual_transform_apply", text="Visual Transform")
960         layout.operator("object.duplicates_make_real")
961
962
963 class VIEW3D_MT_object_parent(Menu):
964     bl_label = "Parent"
965
966     def draw(self, context):
967         layout = self.layout
968
969         layout.operator_menu_enum("object.parent_set", "type", text="Set")
970         layout.operator_menu_enum("object.parent_clear", "type", text="Clear")
971
972
973 class VIEW3D_MT_object_track(Menu):
974     bl_label = "Track"
975
976     def draw(self, context):
977         layout = self.layout
978
979         layout.operator_menu_enum("object.track_set", "type", text="Set")
980         layout.operator_menu_enum("object.track_clear", "type", text="Clear")
981
982
983 class VIEW3D_MT_object_group(Menu):
984     bl_label = "Group"
985
986     def draw(self, context):
987         layout = self.layout
988
989         layout.operator("group.create")
990         # layout.operator_menu_enum("group.objects_remove", "group")  # BUGGY
991         layout.operator("group.objects_remove")
992         layout.operator("group.objects_remove_all")
993
994         layout.separator()
995
996         layout.operator("group.objects_add_active")
997         layout.operator("group.objects_remove_active")
998
999
1000 class VIEW3D_MT_object_constraints(Menu):
1001     bl_label = "Constraints"
1002
1003     def draw(self, context):
1004         layout = self.layout
1005
1006         layout.operator("object.constraint_add_with_targets")
1007         layout.operator("object.constraints_copy")
1008         layout.operator("object.constraints_clear")
1009
1010
1011 class VIEW3D_MT_object_quick_effects(Menu):
1012     bl_label = "Quick Effects"
1013
1014     def draw(self, context):
1015         layout = self.layout
1016
1017         layout.operator("object.quick_fur")
1018         layout.operator("object.quick_explode")
1019         layout.operator("object.quick_smoke")
1020         layout.operator("object.quick_fluid")
1021
1022
1023 class VIEW3D_MT_object_showhide(Menu):
1024     bl_label = "Show/Hide"
1025
1026     def draw(self, context):
1027         layout = self.layout
1028
1029         layout.operator("object.hide_view_clear", text="Show Hidden")
1030         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
1031         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
1032
1033
1034 class VIEW3D_MT_make_single_user(Menu):
1035     bl_label = "Make Single User"
1036
1037     def draw(self, context):
1038         layout = self.layout
1039
1040         props = layout.operator("object.make_single_user", text="Object")
1041         props.object = True
1042
1043         props = layout.operator("object.make_single_user", text="Object & Data")
1044         props.object = props.obdata = True
1045
1046         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
1047         props.object = props.obdata = props.material = props.texture = True
1048
1049         props = layout.operator("object.make_single_user", text="Materials+Tex")
1050         props.material = props.texture = True
1051
1052         props = layout.operator("object.make_single_user", text="Object Animation")
1053         props.animation = True
1054
1055
1056 class VIEW3D_MT_make_links(Menu):
1057     bl_label = "Make Links"
1058
1059     def draw(self, context):
1060         layout = self.layout
1061
1062         if(len(bpy.data.scenes) > 10):
1063             layout.operator_context = 'INVOKE_DEFAULT'
1064             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1065         else:
1066             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1067
1068         layout.operator_enum("object.make_links_data", "type")  # inline
1069
1070         layout.operator("object.join_uvs")  # stupid place to add this!
1071
1072
1073 class VIEW3D_MT_object_game(Menu):
1074     bl_label = "Game"
1075
1076     def draw(self, context):
1077         layout = self.layout
1078
1079         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1080         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1081
1082         layout.separator()
1083
1084         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1085         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1086         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1087
1088         layout.separator()
1089
1090         layout.operator("object.game_property_clear")
1091
1092
1093 # ********** Brush menu **********
1094 class VIEW3D_MT_brush(Menu):
1095     bl_label = "Brush"
1096
1097     def draw(self, context):
1098         layout = self.layout
1099
1100         settings = UnifiedPaintPanel.paint_settings(context)
1101         brush = settings.brush
1102
1103         ups = context.tool_settings.unified_paint_settings
1104         layout.prop(ups, "use_unified_size", text="Unified Size")
1105         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1106         layout.separator()
1107
1108         # brush paint modes
1109         layout.menu("VIEW3D_MT_brush_paint_modes")
1110
1111         # brush tool
1112         if context.sculpt_object:
1113             layout.operator("brush.reset")
1114             layout.prop_menu_enum(brush, "sculpt_tool")
1115         elif context.image_paint_object:
1116             layout.prop_menu_enum(brush, "image_tool")
1117         elif context.vertex_paint_object or context.weight_paint_object:
1118             layout.prop_menu_enum(brush, "vertex_tool")
1119
1120         # skip if no active brush
1121         if not brush:
1122             return
1123
1124         # TODO: still missing a lot of brush options here
1125
1126         # sculpt options
1127         if context.sculpt_object:
1128
1129             sculpt_tool = brush.sculpt_tool
1130
1131             layout.separator()
1132             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1133             layout.separator()
1134
1135             if sculpt_tool != 'GRAB':
1136                 layout.prop_menu_enum(brush, "stroke_method")
1137
1138                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1139                     layout.prop_menu_enum(brush, "direction")
1140
1141                 if sculpt_tool == 'LAYER':
1142                     layout.prop(brush, "use_persistent")
1143                     layout.operator("sculpt.set_persistent_base")
1144
1145
1146 class VIEW3D_MT_brush_paint_modes(Menu):
1147     bl_label = "Enabled Modes"
1148
1149     def draw(self, context):
1150         layout = self.layout
1151
1152         settings = UnifiedPaintPanel.paint_settings(context)
1153         brush = settings.brush
1154
1155         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1156         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1157         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1158         layout.prop(brush, "use_paint_image", text="Texture Paint")
1159
1160 # ********** Vertex paint menu **********
1161
1162
1163 class VIEW3D_MT_paint_vertex(Menu):
1164     bl_label = "Paint"
1165
1166     def draw(self, context):
1167         layout = self.layout
1168
1169         layout.operator("ed.undo")
1170         layout.operator("ed.redo")
1171
1172         layout.separator()
1173
1174         layout.operator("paint.vertex_color_set")
1175         layout.operator("paint.vertex_color_dirt")
1176
1177
1178 class VIEW3D_MT_hook(Menu):
1179     bl_label = "Hooks"
1180
1181     def draw(self, context):
1182         layout = self.layout
1183         layout.operator_context = 'EXEC_AREA'
1184         layout.operator("object.hook_add_newob")
1185         layout.operator("object.hook_add_selob")
1186         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1187
1188         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1189             layout.separator()
1190             layout.operator_menu_enum("object.hook_assign", "modifier")
1191             layout.operator_menu_enum("object.hook_remove", "modifier")
1192             layout.separator()
1193             layout.operator_menu_enum("object.hook_select", "modifier")
1194             layout.operator_menu_enum("object.hook_reset", "modifier")
1195             layout.operator_menu_enum("object.hook_recenter", "modifier")
1196
1197
1198 class VIEW3D_MT_vertex_group(Menu):
1199     bl_label = "Vertex Groups"
1200
1201     def draw(self, context):
1202         layout = self.layout
1203
1204         layout.operator_context = 'EXEC_AREA'
1205         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1206
1207         ob = context.active_object
1208         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1209             if ob.vertex_groups.active:
1210                 layout.separator()
1211                 layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
1212                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1213                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1214                 layout.separator()
1215
1216         if ob.vertex_groups.active:
1217             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1218             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1219             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1220
1221 # ********** Weight paint menu **********
1222
1223
1224 class VIEW3D_MT_paint_weight(Menu):
1225     bl_label = "Weights"
1226
1227     def draw(self, context):
1228         layout = self.layout
1229
1230         layout.operator("ed.undo")
1231         layout.operator("ed.redo")
1232         layout.operator("ed.undo_history")
1233
1234         layout.separator()
1235
1236         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1237         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1238
1239         layout.separator()
1240
1241         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1242         layout.operator("object.vertex_group_normalize", text="Normalize")
1243         layout.operator("object.vertex_group_mirror", text="Mirror")
1244         layout.operator("object.vertex_group_invert", text="Invert")
1245         layout.operator("object.vertex_group_clean", text="Clean")
1246         layout.operator("object.vertex_group_levels", text="Levels")
1247         layout.operator("object.vertex_group_blend", text="Blend")
1248         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1249
1250         layout.separator()
1251
1252         layout.operator("paint.weight_set")
1253
1254 # ********** Sculpt menu **********
1255
1256
1257 class VIEW3D_MT_sculpt(Menu):
1258     bl_label = "Sculpt"
1259
1260     def draw(self, context):
1261         layout = self.layout
1262
1263         toolsettings = context.tool_settings
1264         sculpt = toolsettings.sculpt
1265
1266         layout.operator("ed.undo")
1267         layout.operator("ed.redo")
1268
1269         layout.separator()
1270
1271         layout.prop(sculpt, "use_symmetry_x")
1272         layout.prop(sculpt, "use_symmetry_y")
1273         layout.prop(sculpt, "use_symmetry_z")
1274         layout.separator()
1275         layout.prop(sculpt, "lock_x")
1276         layout.prop(sculpt, "lock_y")
1277         layout.prop(sculpt, "lock_z")
1278
1279         layout.separator()
1280         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1281         layout.prop(sculpt, "show_low_resolution")
1282         layout.prop(sculpt, "show_brush")
1283         layout.prop(sculpt, "use_deform_only")
1284
1285
1286 class VIEW3D_MT_hide_mask(Menu):
1287     bl_label = "Hide/Mask"
1288
1289     def draw(self, context):
1290         layout = self.layout
1291
1292         op = layout.operator("paint.hide_show", text="Show All")
1293         op.action = 'SHOW'
1294         op.area = 'ALL'
1295
1296         op = layout.operator("paint.hide_show", text="Hide Bounding Box")
1297         op.action = 'HIDE'
1298         op.area = 'INSIDE'
1299
1300         op = layout.operator("paint.hide_show", text="Show Bounding Box")
1301         op.action = 'SHOW'
1302         op.area = 'INSIDE'
1303
1304         op = layout.operator("paint.hide_show", text="Hide Masked")
1305         op.area = 'MASKED'
1306         op.action = 'HIDE'
1307
1308         layout.separator()
1309
1310         op = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1311         op.mode = 'INVERT'
1312
1313         op = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1314         op.mode = 'VALUE'
1315         op.value = 1
1316
1317         op = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1318         op.mode = 'VALUE'
1319         op.value = 0
1320
1321
1322 # ********** Particle menu **********
1323
1324
1325 class VIEW3D_MT_particle(Menu):
1326     bl_label = "Particle"
1327
1328     def draw(self, context):
1329         layout = self.layout
1330
1331         particle_edit = context.tool_settings.particle_edit
1332
1333         layout.operator("ed.undo")
1334         layout.operator("ed.redo")
1335         layout.operator("ed.undo_history")
1336
1337         layout.separator()
1338
1339         layout.operator("particle.mirror")
1340
1341         layout.separator()
1342
1343         layout.operator("particle.remove_doubles")
1344         layout.operator("particle.delete")
1345
1346         if particle_edit.select_mode == 'POINT':
1347             layout.operator("particle.subdivide")
1348
1349         layout.operator("particle.rekey")
1350         layout.operator("particle.weight_set")
1351
1352         layout.separator()
1353
1354         layout.menu("VIEW3D_MT_particle_showhide")
1355
1356
1357 class VIEW3D_MT_particle_specials(Menu):
1358     bl_label = "Specials"
1359
1360     def draw(self, context):
1361         layout = self.layout
1362
1363         particle_edit = context.tool_settings.particle_edit
1364
1365         layout.operator("particle.rekey")
1366
1367         layout.separator()
1368         if particle_edit.select_mode == 'POINT':
1369             layout.operator("particle.subdivide")
1370             layout.operator("particle.select_roots")
1371             layout.operator("particle.select_tips")
1372
1373         layout.operator("particle.remove_doubles")
1374
1375
1376 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1377     _operator_name = "particle"
1378
1379 # ********** Pose Menu **********
1380
1381
1382 class VIEW3D_MT_pose(Menu):
1383     bl_label = "Pose"
1384
1385     def draw(self, context):
1386         layout = self.layout
1387
1388         layout.operator("ed.undo")
1389         layout.operator("ed.redo")
1390         layout.operator("ed.undo_history")
1391
1392         layout.separator()
1393
1394         layout.menu("VIEW3D_MT_transform_armature")
1395
1396         layout.menu("VIEW3D_MT_pose_transform")
1397         layout.menu("VIEW3D_MT_pose_apply")
1398
1399         layout.menu("VIEW3D_MT_snap")
1400
1401         layout.separator()
1402
1403         layout.menu("VIEW3D_MT_object_animation")
1404
1405         layout.separator()
1406
1407         layout.menu("VIEW3D_MT_pose_slide")
1408         layout.menu("VIEW3D_MT_pose_propagate")
1409
1410         layout.separator()
1411
1412         layout.operator("pose.copy")
1413         layout.operator("pose.paste")
1414         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1415
1416         layout.separator()
1417
1418         layout.menu("VIEW3D_MT_pose_library")
1419         layout.menu("VIEW3D_MT_pose_motion")
1420         layout.menu("VIEW3D_MT_pose_group")
1421
1422         layout.separator()
1423
1424         layout.menu("VIEW3D_MT_object_parent")
1425         layout.menu("VIEW3D_MT_pose_ik")
1426         layout.menu("VIEW3D_MT_pose_constraints")
1427
1428         layout.separator()
1429
1430         layout.operator_context = 'EXEC_AREA'
1431         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1432         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1433         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1434
1435         layout.operator("pose.flip_names")
1436
1437         layout.operator("pose.quaternions_flip")
1438
1439         layout.separator()
1440
1441         layout.operator_context = 'INVOKE_AREA'
1442         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1443         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1444
1445         layout.separator()
1446
1447         layout.menu("VIEW3D_MT_pose_showhide")
1448         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1449
1450
1451 class VIEW3D_MT_pose_transform(Menu):
1452     bl_label = "Clear Transform"
1453
1454     def draw(self, context):
1455         layout = self.layout
1456
1457         layout.operator("pose.transforms_clear", text="All")
1458
1459         layout.separator()
1460
1461         layout.operator("pose.loc_clear", text="Location")
1462         layout.operator("pose.rot_clear", text="Rotation")
1463         layout.operator("pose.scale_clear", text="Scale")
1464
1465         layout.separator()
1466
1467         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1468
1469
1470 class VIEW3D_MT_pose_slide(Menu):
1471     bl_label = "In-Betweens"
1472
1473     def draw(self, context):
1474         layout = self.layout
1475
1476         layout.operator("pose.push")
1477         layout.operator("pose.relax")
1478         layout.operator("pose.breakdown")
1479
1480
1481 class VIEW3D_MT_pose_propagate(Menu):
1482     bl_label = "Propagate"
1483
1484     def draw(self, context):
1485         layout = self.layout
1486
1487         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1488
1489         layout.separator()
1490
1491         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1492         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1493
1494         layout.separator()
1495
1496         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1497
1498
1499 class VIEW3D_MT_pose_library(Menu):
1500     bl_label = "Pose Library"
1501
1502     def draw(self, context):
1503         layout = self.layout
1504
1505         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1506
1507         layout.separator()
1508
1509         layout.operator("poselib.pose_add", text="Add Pose...")
1510         layout.operator("poselib.pose_rename", text="Rename Pose...")
1511         layout.operator("poselib.pose_remove", text="Remove Pose...")
1512
1513
1514 class VIEW3D_MT_pose_motion(Menu):
1515     bl_label = "Motion Paths"
1516
1517     def draw(self, context):
1518         layout = self.layout
1519
1520         layout.operator("pose.paths_calculate", text="Calculate")
1521         layout.operator("pose.paths_clear", text="Clear")
1522
1523
1524 class VIEW3D_MT_pose_group(Menu):
1525     bl_label = "Bone Groups"
1526
1527     def draw(self, context):
1528         layout = self.layout
1529         layout.operator("pose.group_add")
1530         layout.operator("pose.group_remove")
1531
1532         layout.separator()
1533
1534         layout.operator("pose.group_assign")
1535         layout.operator("pose.group_unassign")
1536
1537
1538 class VIEW3D_MT_pose_ik(Menu):
1539     bl_label = "Inverse Kinematics"
1540
1541     def draw(self, context):
1542         layout = self.layout
1543
1544         layout.operator("pose.ik_add")
1545         layout.operator("pose.ik_clear")
1546
1547
1548 class VIEW3D_MT_pose_constraints(Menu):
1549     bl_label = "Constraints"
1550
1551     def draw(self, context):
1552         layout = self.layout
1553
1554         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1555         layout.operator("pose.constraints_copy")
1556         layout.operator("pose.constraints_clear")
1557
1558
1559 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1560     _operator_name = "pose"
1561
1562
1563 class VIEW3D_MT_pose_apply(Menu):
1564     bl_label = "Apply"
1565
1566     def draw(self, context):
1567         layout = self.layout
1568
1569         layout.operator("pose.armature_apply")
1570         layout.operator("pose.visual_transform_apply")
1571
1572
1573 class VIEW3D_MT_pose_specials(Menu):
1574     bl_label = "Specials"
1575
1576     def draw(self, context):
1577         layout = self.layout
1578         layout.operator("pose.select_constraint_target")
1579         layout.operator("pose.flip_names")
1580         layout.operator("pose.paths_calculate")
1581         layout.operator("pose.paths_clear")
1582         layout.operator("pose.user_transforms_clear")
1583         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
1584         layout.operator("pose.relax")
1585
1586         layout.separator()
1587
1588         layout.operator_menu_enum("pose.autoside_names", "axis")
1589
1590
1591 class BoneOptions:
1592     def draw(self, context):
1593         layout = self.layout
1594
1595         options = [
1596             "show_wire",
1597             "use_deform",
1598             "use_envelope_multiply",
1599             "use_inherit_rotation",
1600             "use_inherit_scale",
1601         ]
1602
1603         if context.mode == 'EDIT_ARMATURE':
1604             bone_props = bpy.types.EditBone.bl_rna.properties
1605             data_path_iter = "selected_bones"
1606             opt_suffix = ""
1607             options.append("lock")
1608         else:  # pose-mode
1609             bone_props = bpy.types.Bone.bl_rna.properties
1610             data_path_iter = "selected_pose_bones"
1611             opt_suffix = "bone."
1612
1613         for opt in options:
1614             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1615             props.data_path_iter = data_path_iter
1616             props.data_path_item = opt_suffix + opt
1617             props.type = self.type
1618
1619
1620 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1621     bl_label = "Toggle Bone Options"
1622     type = 'TOGGLE'
1623
1624
1625 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1626     bl_label = "Enable Bone Options"
1627     type = 'ENABLE'
1628
1629
1630 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1631     bl_label = "Disable Bone Options"
1632     type = 'DISABLE'
1633
1634 # ********** Edit Menus, suffix from ob.type **********
1635
1636
1637 class VIEW3D_MT_edit_mesh(Menu):
1638     bl_label = "Mesh"
1639
1640     def draw(self, context):
1641         layout = self.layout
1642
1643         toolsettings = context.tool_settings
1644
1645         layout.operator("ed.undo")
1646         layout.operator("ed.redo")
1647         layout.operator("ed.undo_history")
1648
1649         layout.separator()
1650
1651         layout.menu("VIEW3D_MT_transform")
1652         layout.menu("VIEW3D_MT_mirror")
1653         layout.menu("VIEW3D_MT_snap")
1654
1655         layout.separator()
1656
1657         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1658
1659         layout.separator()
1660
1661         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1662         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1663         layout.operator("mesh.duplicate_move")
1664         layout.menu("VIEW3D_MT_edit_mesh_delete")
1665         layout.menu("VIEW3D_MT_edit_mesh_dissolve")
1666
1667         layout.separator()
1668
1669         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1670         layout.menu("VIEW3D_MT_edit_mesh_edges")
1671         layout.menu("VIEW3D_MT_edit_mesh_faces")
1672         layout.menu("VIEW3D_MT_edit_mesh_normals")
1673
1674         layout.separator()
1675
1676         layout.prop(toolsettings, "use_mesh_automerge")
1677         layout.prop_menu_enum(toolsettings, "proportional_edit")
1678         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1679
1680         layout.separator()
1681
1682         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1683
1684
1685 class VIEW3D_MT_edit_mesh_specials(Menu):
1686     bl_label = "Specials"
1687
1688     def draw(self, context):
1689         layout = self.layout
1690
1691         layout.operator_context = 'INVOKE_REGION_WIN'
1692
1693         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1694         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1695         layout.operator("mesh.merge", text="Merge...")
1696         layout.operator("mesh.remove_doubles")
1697         layout.operator("mesh.hide", text="Hide").unselected = False
1698         layout.operator("mesh.reveal", text="Reveal")
1699         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
1700         layout.operator("mesh.flip_normals")
1701         layout.operator("mesh.vertices_smooth", text="Smooth")
1702         layout.operator("mesh.inset")
1703         layout.operator("mesh.bevel", text="Bevel")
1704         layout.operator("mesh.bridge_edge_loops")
1705         layout.operator("mesh.faces_shade_smooth")
1706         layout.operator("mesh.faces_shade_flat")
1707         layout.operator("mesh.blend_from_shape")
1708         layout.operator("mesh.shape_propagate_to_all")
1709         layout.operator("mesh.select_vertex_path")
1710         layout.operator("mesh.sort_elements")
1711
1712
1713 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1714     bl_label = "Mesh Select Mode"
1715
1716     def draw(self, context):
1717         layout = self.layout
1718
1719         layout.operator_context = 'INVOKE_REGION_WIN'
1720
1721         props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1722         props.value = "(True, False, False)"
1723         props.data_path = "tool_settings.mesh_select_mode"
1724
1725         props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1726         props.value = "(False, True, False)"
1727         props.data_path = "tool_settings.mesh_select_mode"
1728
1729         props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1730         props.value = "(False, False, True)"
1731         props.data_path = "tool_settings.mesh_select_mode"
1732
1733
1734 class VIEW3D_MT_edit_mesh_extrude(Menu):
1735     bl_label = "Extrude"
1736
1737     _extrude_funcs = {
1738         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1739         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1740         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1741         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1742     }
1743
1744     @staticmethod
1745     def extrude_options(context):
1746         mesh = context.object.data
1747         select_mode = context.tool_settings.mesh_select_mode
1748
1749         menu = []
1750         if mesh.total_face_sel:
1751             menu += ['REGION', 'FACE']
1752         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1753             menu += ['EDGE']
1754         if mesh.total_vert_sel and select_mode[0]:
1755             menu += ['VERT']
1756
1757         # should never get here
1758         return menu
1759
1760     def draw(self, context):
1761         layout = self.layout
1762         layout.operator_context = 'INVOKE_REGION_WIN'
1763
1764         for menu_id in self.extrude_options(context):
1765             self._extrude_funcs[menu_id](layout)
1766
1767
1768 class VIEW3D_MT_edit_mesh_vertices(Menu):
1769     bl_label = "Vertices"
1770
1771     def draw(self, context):
1772         layout = self.layout
1773         layout.operator_context = 'INVOKE_REGION_WIN'
1774
1775         layout.operator("mesh.merge")
1776         layout.operator("mesh.rip_move")
1777         layout.operator("mesh.split")
1778         layout.operator_menu_enum("mesh.separate", "type")
1779         layout.operator("mesh.vert_connect")
1780         layout.operator("mesh.vert_slide")
1781
1782         layout.separator()
1783
1784         layout.operator("mesh.vertices_smooth")
1785         layout.operator("mesh.remove_doubles")
1786         layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {'VERT'}
1787
1788         layout.operator("mesh.select_vertex_path")
1789
1790         layout.operator("mesh.blend_from_shape")
1791
1792         layout.operator("object.vertex_group_blend")
1793         layout.operator("mesh.shape_propagate_to_all")
1794
1795         layout.separator()
1796
1797         layout.menu("VIEW3D_MT_vertex_group")
1798         layout.menu("VIEW3D_MT_hook")
1799
1800
1801 class VIEW3D_MT_edit_mesh_edges(Menu):
1802     bl_label = "Edges"
1803
1804     def draw(self, context):
1805         layout = self.layout
1806
1807         layout.operator_context = 'INVOKE_REGION_WIN'
1808
1809         layout.operator("mesh.edge_face_add")
1810         layout.operator("mesh.subdivide")
1811
1812         layout.separator()
1813
1814         layout.operator("transform.edge_crease")
1815         layout.operator("transform.edge_bevelweight")
1816
1817         layout.separator()
1818
1819         layout.operator("mesh.mark_seam").clear = False
1820         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1821
1822         layout.separator()
1823
1824         layout.operator("mesh.mark_sharp").clear = False
1825         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1826
1827         layout.separator()
1828
1829         layout.operator("mesh.mark_freestyle_edge").clear = False
1830         layout.operator("mesh.mark_freestyle_edge", text="Clear Freestyle Edge").clear = True
1831
1832         layout.separator()
1833
1834         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1835         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1836
1837         layout.separator()
1838
1839         layout.operator("mesh.bevel")
1840         layout.operator("mesh.edge_split")
1841         layout.operator("mesh.bridge_edge_loops")
1842         layout.operator("mesh.sort_elements", text="Sort Edges").elements = {'EDGE'}
1843
1844         layout.separator()
1845
1846         layout.operator("transform.edge_slide")
1847         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1848         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1849         layout.operator("mesh.loop_to_region")
1850         layout.operator("mesh.region_to_loop")
1851
1852
1853 class VIEW3D_MT_edit_mesh_faces(Menu):
1854     bl_label = "Faces"
1855     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1856
1857     def draw(self, context):
1858         layout = self.layout
1859
1860         layout.operator_context = 'INVOKE_REGION_WIN'
1861
1862         layout.operator("mesh.flip_normals")
1863         layout.operator("mesh.edge_face_add")
1864         layout.operator("mesh.fill")
1865         layout.operator("mesh.beautify_fill")
1866         layout.operator("mesh.inset")
1867         layout.operator("mesh.bevel")
1868         layout.operator("mesh.solidify")
1869         layout.operator("mesh.wireframe")
1870         layout.operator("mesh.sort_elements", text="Sort Faces").elements = {'FACE'}
1871
1872         layout.separator()
1873
1874         layout.operator("mesh.mark_freestyle_face").clear = False
1875         layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle Face").clear = True
1876
1877         layout.separator()
1878
1879         layout.operator("mesh.quads_convert_to_tris")
1880         layout.operator("mesh.tris_convert_to_quads")
1881
1882         layout.separator()
1883
1884         layout.operator("mesh.faces_shade_smooth")
1885         layout.operator("mesh.faces_shade_flat")
1886
1887         layout.separator()
1888
1889         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1890
1891         layout.separator()
1892
1893         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1894         layout.operator("mesh.uvs_reverse")
1895         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1896         layout.operator("mesh.colors_reverse")
1897
1898
1899 class VIEW3D_MT_edit_mesh_normals(Menu):
1900     bl_label = "Normals"
1901
1902     def draw(self, context):
1903         layout = self.layout
1904
1905         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1906         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1907
1908         layout.separator()
1909
1910         layout.operator("mesh.flip_normals")
1911
1912
1913 class VIEW3D_MT_edit_mesh_delete(Menu):
1914     bl_label = "Delete"
1915
1916     def draw(self, context):
1917         layout = self.layout
1918
1919         layout.operator_enum("mesh.delete", "type")
1920
1921         layout.separator()
1922
1923         layout.operator("mesh.dissolve")
1924         layout.operator("mesh.edge_collapse")
1925         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
1926
1927
1928 class VIEW3D_MT_edit_mesh_dissolve(Menu):
1929     bl_label = "Dissolve"
1930
1931     def draw(self, context):
1932         layout = self.layout
1933
1934         layout.operator("mesh.dissolve")
1935
1936         layout.separator()
1937
1938         layout.operator_enum("mesh.dissolve", "type")
1939
1940         layout.separator()
1941
1942         layout.operator("mesh.dissolve_limited")
1943
1944
1945 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1946     _operator_name = "mesh"
1947
1948 # Edit Curve
1949 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1950
1951
1952 def draw_curve(self, context):
1953     layout = self.layout
1954
1955     toolsettings = context.tool_settings
1956
1957     layout.menu("VIEW3D_MT_transform")
1958     layout.menu("VIEW3D_MT_mirror")
1959     layout.menu("VIEW3D_MT_snap")
1960
1961     layout.separator()
1962
1963     layout.operator("curve.extrude_move")
1964     layout.operator("curve.duplicate_move")
1965     layout.operator("curve.separate")
1966     layout.operator("curve.make_segment")
1967     layout.operator("curve.cyclic_toggle")
1968     layout.operator("curve.delete", text="Delete...")
1969
1970     layout.separator()
1971
1972     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1973     layout.menu("VIEW3D_MT_edit_curve_segments")
1974
1975     layout.separator()
1976
1977     layout.prop_menu_enum(toolsettings, "proportional_edit")
1978     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1979
1980     layout.separator()
1981
1982     layout.menu("VIEW3D_MT_edit_curve_showhide")
1983
1984
1985 class VIEW3D_MT_edit_curve(Menu):
1986     bl_label = "Curve"
1987
1988     draw = draw_curve
1989
1990
1991 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1992     bl_label = "Control Points"
1993
1994     def draw(self, context):
1995         layout = self.layout
1996
1997         edit_object = context.edit_object
1998
1999         if edit_object.type == 'CURVE':
2000             layout.operator("transform.tilt")
2001             layout.operator("curve.tilt_clear")
2002             layout.operator("curve.separate")
2003
2004             layout.separator()
2005
2006             layout.operator_menu_enum("curve.handle_type_set", "type")
2007
2008             layout.separator()
2009
2010         layout.menu("VIEW3D_MT_hook")
2011
2012
2013 class VIEW3D_MT_edit_curve_segments(Menu):
2014     bl_label = "Segments"
2015
2016     def draw(self, context):
2017         layout = self.layout
2018
2019         layout.operator("curve.subdivide")
2020         layout.operator("curve.switch_direction")
2021
2022
2023 class VIEW3D_MT_edit_curve_specials(Menu):
2024     bl_label = "Specials"
2025
2026     def draw(self, context):
2027         layout = self.layout
2028
2029         layout.operator("curve.subdivide")
2030         layout.operator("curve.switch_direction")
2031         layout.operator("curve.spline_weight_set")
2032         layout.operator("curve.radius_set")
2033         layout.operator("curve.smooth")
2034         layout.operator("curve.smooth_radius")
2035
2036
2037 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2038     _operator_name = "curve"
2039
2040
2041 class VIEW3D_MT_edit_surface(Menu):
2042     bl_label = "Surface"
2043
2044     draw = draw_curve
2045
2046
2047 class VIEW3D_MT_edit_font(Menu):
2048     bl_label = "Text"
2049
2050     def draw(self, context):
2051         layout = self.layout
2052
2053         layout.operator("font.file_paste")
2054
2055         layout.separator()
2056
2057         layout.menu("VIEW3D_MT_edit_text_chars")
2058
2059         layout.separator()
2060
2061         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2062         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2063         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2064         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2065
2066
2067 class VIEW3D_MT_edit_text_chars(Menu):
2068     bl_label = "Special Characters"
2069
2070     def draw(self, context):
2071         layout = self.layout
2072
2073         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2074         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2075
2076         layout.separator()
2077
2078         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2079         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2080         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2081         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2082         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2083         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2084         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2085         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2086         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2087
2088         layout.separator()
2089
2090         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2091         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2092         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2093
2094         layout.separator()
2095
2096         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2097         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2098         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2099
2100
2101 class VIEW3D_MT_edit_meta(Menu):
2102     bl_label = "Metaball"
2103
2104     def draw(self, context):
2105         layout = self.layout
2106
2107         toolsettings = context.tool_settings
2108
2109         layout.operator("ed.undo")
2110         layout.operator("ed.redo")
2111         layout.operator("ed.undo_history")
2112
2113         layout.separator()
2114
2115         layout.menu("VIEW3D_MT_transform")
2116         layout.menu("VIEW3D_MT_mirror")
2117         layout.menu("VIEW3D_MT_snap")
2118
2119         layout.separator()
2120
2121         layout.operator("mball.delete_metaelems", text="Delete...")
2122         layout.operator("mball.duplicate_metaelems")
2123
2124         layout.separator()
2125
2126         layout.prop_menu_enum(toolsettings, "proportional_edit")
2127         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2128
2129         layout.separator()
2130
2131         layout.menu("VIEW3D_MT_edit_meta_showhide")
2132
2133
2134 class VIEW3D_MT_edit_meta_showhide(Menu):
2135     bl_label = "Show/Hide"
2136
2137     def draw(self, context):
2138         layout = self.layout
2139
2140         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2141         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2142         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2143
2144
2145 class VIEW3D_MT_edit_lattice(Menu):
2146     bl_label = "Lattice"
2147
2148     def draw(self, context):
2149         layout = self.layout
2150
2151         toolsettings = context.tool_settings
2152
2153         layout.menu("VIEW3D_MT_transform")
2154         layout.menu("VIEW3D_MT_mirror")
2155         layout.menu("VIEW3D_MT_snap")
2156
2157         layout.separator()
2158
2159         layout.operator("lattice.make_regular")
2160
2161         layout.separator()
2162
2163         layout.prop_menu_enum(toolsettings, "proportional_edit")
2164         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2165
2166
2167 class VIEW3D_MT_edit_armature(Menu):
2168     bl_label = "Armature"
2169
2170     def draw(self, context):
2171         layout = self.layout
2172
2173         edit_object = context.edit_object
2174         arm = edit_object.data
2175
2176         layout.menu("VIEW3D_MT_transform_armature")
2177         layout.menu("VIEW3D_MT_mirror")
2178         layout.menu("VIEW3D_MT_snap")
2179         layout.menu("VIEW3D_MT_edit_armature_roll")
2180
2181         layout.separator()
2182
2183         layout.operator("armature.extrude_move")
2184
2185         if arm.use_mirror_x:
2186             layout.operator("armature.extrude_forked")
2187
2188         layout.operator("armature.duplicate_move")
2189         layout.operator("armature.merge")
2190         layout.operator("armature.fill")
2191         layout.operator("armature.delete")
2192         layout.operator("armature.separate")
2193
2194         layout.separator()
2195
2196         layout.operator("armature.subdivide", text="Subdivide")
2197         layout.operator("armature.switch_direction", text="Switch Direction")
2198
2199         layout.separator()
2200
2201         layout.operator_context = 'EXEC_AREA'
2202         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2203         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2204         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2205         layout.operator("armature.flip_names")
2206
2207         layout.separator()
2208
2209         layout.operator_context = 'INVOKE_DEFAULT'
2210         layout.operator("armature.armature_layers")
2211         layout.operator("armature.bone_layers")
2212
2213         layout.separator()
2214
2215         layout.menu("VIEW3D_MT_edit_armature_parent")
2216
2217         layout.separator()
2218
2219         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2220
2221
2222 class VIEW3D_MT_armature_specials(Menu):
2223     bl_label = "Specials"
2224
2225     def draw(self, context):
2226         layout = self.layout
2227
2228         layout.operator_context = 'INVOKE_REGION_WIN'
2229
2230         layout.operator("armature.subdivide", text="Subdivide")
2231         layout.operator("armature.switch_direction", text="Switch Direction")
2232
2233         layout.separator()
2234
2235         layout.operator_context = 'EXEC_REGION_WIN'
2236         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2237         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2238         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2239         layout.operator("armature.flip_names", text="Flip Names")
2240
2241
2242 class VIEW3D_MT_edit_armature_parent(Menu):
2243     bl_label = "Parent"
2244
2245     def draw(self, context):
2246         layout = self.layout
2247
2248         layout.operator("armature.parent_set", text="Make")
2249         layout.operator("armature.parent_clear", text="Clear")
2250
2251
2252 class VIEW3D_MT_edit_armature_roll(Menu):
2253     bl_label = "Bone Roll"
2254
2255     def draw(self, context):
2256         layout = self.layout
2257
2258         layout.operator_menu_enum("armature.calculate_roll", "type")
2259
2260         layout.separator()
2261
2262         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2263
2264 # ********** Panel **********
2265
2266
2267 class VIEW3D_PT_view3d_properties(Panel):
2268     bl_space_type = 'VIEW_3D'
2269     bl_region_type = 'UI'
2270     bl_label = "View"
2271
2272     @classmethod
2273     def poll(cls, context):
2274         view = context.space_data
2275         return (view)
2276
2277     def draw(self, context):
2278         layout = self.layout
2279
2280         view = context.space_data
2281
2282         col = layout.column()
2283         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2284                           view.region_quadview)
2285         col.prop(view, "lens")
2286         col.label(text="Lock to Object:")
2287         col.prop(view, "lock_object", text="")
2288         lock_object = view.lock_object
2289         if lock_object:
2290             if lock_object.type == 'ARMATURE':
2291                 col.prop_search(view, "lock_bone", lock_object.data,
2292                                 "edit_bones" if lock_object.mode == 'EDIT'
2293                                              else "bones",
2294                                 text="")
2295         else:
2296             col.prop(view, "lock_cursor", text="Lock to Cursor")
2297
2298         col = layout.column()
2299         col.prop(view, "lock_camera")
2300
2301         col = layout.column(align=True)
2302         col.label(text="Clip:")
2303         col.prop(view, "clip_start", text="Start")
2304         col.prop(view, "clip_end", text="End")
2305
2306         subcol = col.column()
2307         subcol.enabled = not view.lock_camera_and_layers
2308         subcol.label(text="Local Camera:")
2309         subcol.prop(view, "camera", text="")
2310
2311
2312 class VIEW3D_PT_view3d_cursor(Panel):
2313     bl_space_type = 'VIEW_3D'
2314     bl_region_type = 'UI'
2315     bl_label = "3D Cursor"
2316
2317     @classmethod
2318     def poll(cls, context):
2319         view = context.space_data
2320         return (view is not None)
2321
2322     def draw(self, context):
2323         layout = self.layout
2324
2325         view = context.space_data
2326         layout.column().prop(view, "cursor_location", text="Location")
2327
2328
2329 class VIEW3D_PT_view3d_name(Panel):
2330     bl_space_type = 'VIEW_3D'
2331     bl_region_type = 'UI'
2332     bl_label = "Item"
2333
2334     @classmethod
2335     def poll(cls, context):
2336         return (context.space_data and context.active_object)
2337
2338     def draw(self, context):
2339         layout = self.layout
2340
2341         ob = context.active_object
2342         row = layout.row()
2343         row.label(text="", icon='OBJECT_DATA')
2344         row.prop(ob, "name", text="")
2345
2346         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2347             bone = context.active_bone
2348             if bone:
2349                 row = layout.row()
2350                 row.label(text="", icon='BONE_DATA')
2351                 row.prop(bone, "name", text="")
2352
2353
2354 class VIEW3D_PT_view3d_display(Panel):
2355     bl_space_type = 'VIEW_3D'
2356     bl_region_type = 'UI'
2357     bl_label = "Display"
2358     bl_options = {'DEFAULT_CLOSED'}
2359
2360     @classmethod
2361     def poll(cls, context):
2362         view = context.space_data
2363         return (view)
2364
2365     def draw(self, context):
2366         layout = self.layout
2367
2368         view = context.space_data
2369         scene = context.scene
2370         gs = scene.game_settings
2371         ob = context.object
2372
2373         col = layout.column()
2374         col.prop(view, "show_only_render")
2375
2376         col = layout.column()
2377         display_all = not view.show_only_render
2378         col.active = display_all
2379         col.prop(view, "show_outline_selected")
2380         col.prop(view, "show_all_objects_origin")
2381         col.prop(view, "show_relationship_lines")
2382         if ob and ob.type == 'MESH':
2383             mesh = ob.data
2384             col.prop(mesh, "show_all_edges")
2385
2386         col = layout.column()
2387         col.active = display_all
2388         split = col.split(percentage=0.55)
2389         split.prop(view, "show_floor", text="Grid Floor")
2390
2391         row = split.row(align=True)
2392         row.prop(view, "show_axis_x", text="X", toggle=True)
2393         row.prop(view, "show_axis_y", text="Y", toggle=True)
2394         row.prop(view, "show_axis_z", text="Z", toggle=True)
2395
2396         sub = col.column(align=True)
2397         sub.active = (display_all and view.show_floor)
2398         sub.prop(view, "grid_lines", text="Lines")
2399         sub.prop(view, "grid_scale", text="Scale")
2400         subsub = sub.column(align=True)
2401         subsub.active = scene.unit_settings.system == 'NONE'
2402         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2403
2404         if not scene.render.use_shading_nodes:
2405             col = layout.column()
2406             col.label(text="Shading:")
2407             col.prop(gs, "material_mode", text="")
2408             col.prop(view, "show_textured_solid")
2409
2410         col.prop(view, "show_backface_culling")
2411
2412         layout.separator()
2413
2414         region = view.region_quadview
2415
2416         layout.operator("screen.region_quadview", text="Toggle Quad View")
2417
2418         if region:
2419             col = layout.column()
2420             col.prop(region, "lock_rotation")
2421             row = col.row()
2422             row.enabled = region.lock_rotation
2423             row.prop(region, "show_sync_view")
2424             row = col.row()
2425             row.enabled = region.lock_rotation and region.show_sync_view
2426             row.prop(region, "use_box_clip")
2427
2428
2429 class VIEW3D_PT_view3d_motion_tracking(Panel):
2430     bl_space_type = 'VIEW_3D'
2431     bl_region_type = 'UI'
2432     bl_label = "Motion Tracking"
2433     bl_options = {'DEFAULT_CLOSED'}
2434
2435     @classmethod
2436     def poll(cls, context):
2437         view = context.space_data
2438         return (view)
2439
2440     def draw_header(self, context):
2441         view = context.space_data
2442
2443         self.layout.prop(view, "show_reconstruction", text="")
2444
2445     def draw(self, context):
2446         layout = self.layout
2447
2448         view = context.space_data
2449
2450         col = layout.column()
2451         col.active = view.show_reconstruction
2452         col.prop(view, "show_bundle_names")
2453         col.prop(view, "show_camera_path")
2454         col.label(text="Tracks:")
2455         col.prop(view, "tracks_draw_type", text="")
2456         col.prop(view, "tracks_draw_size", text="Size")
2457
2458
2459 class VIEW3D_PT_view3d_meshdisplay(Panel):
2460     bl_space_type = 'VIEW_3D'
2461     bl_region_type = 'UI'
2462     bl_label = "Mesh Display"
2463
2464     @classmethod
2465     def poll(cls, context):
2466         # The active object check is needed because of local-mode
2467         return (context.active_object and (context.mode == 'EDIT_MESH'))
2468
2469     def draw(self, context):
2470         layout = self.layout
2471
2472         mesh = context.active_object.data
2473
2474         col = layout.column()
2475         col.label(text="Overlays:")
2476         col.prop(mesh, "show_edges", text="Edges")
2477         col.prop(mesh, "show_faces", text="Faces")
2478         col.prop(mesh, "show_edge_crease", text="Creases")
2479         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2480         col.prop(mesh, "show_edge_seams", text="Seams")
2481         col.prop(mesh, "show_edge_sharp", text="Sharp")
2482         col.prop(mesh, "show_freestyle_edge_marks", text="Freestyle Edge Marks")
2483         col.prop(mesh, "show_freestyle_face_marks", text="Freestyle Face Marks")
2484
2485         col.separator()
2486         col.label(text="Normals:")
2487         row = col.row()
2488         sub = row.row(align=True)
2489         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2490         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2491         row.prop(context.scene.tool_settings, "normal_size", text="Size")
2492
2493         col.separator()
2494         col.label(text="Numerics:")
2495         col.prop(mesh, "show_extra_edge_length")
2496         col.prop(mesh, "show_extra_face_angle")
2497         col.prop(mesh, "show_extra_face_area")
2498         if bpy.app.debug:
2499             col.prop(mesh, "show_extra_indices")
2500
2501
2502 class VIEW3D_PT_view3d_curvedisplay(Panel):
2503     bl_space_type = 'VIEW_3D'
2504     bl_region_type = 'UI'
2505     bl_label = "Curve Display"
2506
2507     @classmethod
2508     def poll(cls, context):
2509         editmesh = context.mode == 'EDIT_CURVE'
2510         return (editmesh)
2511
2512     def draw(self, context):
2513         layout = self.layout
2514
2515         curve = context.active_object.data
2516
2517         col = layout.column()
2518         col.label(text="Overlays:")
2519         col.prop(curve, "show_handles", text="Handles")
2520         col.prop(curve, "show_normal_face", text="Normals")
2521         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2522
2523
2524 class VIEW3D_PT_background_image(Panel):
2525     bl_space_type = 'VIEW_3D'
2526     bl_region_type = 'UI'
2527     bl_label = "Background Images"
2528     bl_options = {'DEFAULT_CLOSED'}
2529
2530     def draw_header(self, context):
2531         view = context.space_data
2532
2533         self.layout.prop(view, "show_background_images", text="")
2534
2535     def draw(self, context):
2536         layout = self.layout
2537
2538         view = context.space_data
2539
2540         col = layout.column()
2541         col.operator("view3d.background_image_add", text="Add Image")
2542
2543         for i, bg in enumerate(view.background_images):
2544             layout.active = view.show_background_images
2545             box = layout.box()
2546             row = box.row(align=True)
2547             row.prop(bg, "show_expanded", text="", emboss=False)
2548             if bg.source == 'IMAGE' and bg.image:
2549                 row.prop(bg.image, "name", text="", emboss=False)
2550             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2551                 row.prop(bg.clip, "name", text="", emboss=False)
2552             else:
2553                 row.label(text="Not Set")
2554
2555             if bg.show_background_image:
2556                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2557             else:
2558                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2559
2560             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2561
2562             box.prop(bg, "view_axis", text="Axis")
2563
2564             if bg.show_expanded:
2565                 row = box.row()
2566                 row.prop(bg, "source", expand=True)
2567
2568                 has_bg = False
2569                 if bg.source == 'IMAGE':
2570                     row = box.row()
2571                     row.template_ID(bg, "image", open="image.open")
2572                     if bg.image is not None:
2573                         box.template_image(bg, "image", bg.image_user, compact=True)
2574                         has_bg = True
2575
2576                 elif bg.source == 'MOVIE_CLIP':
2577                     box.prop(bg, "use_camera_clip")
2578
2579                     column = box.column()
2580                     column.active = not bg.use_camera_clip
2581                     column.template_ID(bg, "clip", open="clip.open")
2582
2583                     if bg.clip:
2584                         column.template_movieclip(bg, "clip", compact=True)
2585
2586                     if bg.use_camera_clip or bg.clip:
2587                         has_bg = True
2588
2589                     column = box.column()
2590                     column.active = has_bg
2591                     column.prop(bg.clip_user, "proxy_render_size", text="")
2592                     column.prop(bg.clip_user, "use_render_undistorted")
2593
2594                 if has_bg:
2595                     col = box.column()
2596                     col.prop(bg, "opacity", slider=True)
2597
2598                     rowsub = col.row()
2599                     rowsub.prop(bg, "draw_depth", expand=True)
2600
2601                     if bg.view_axis in {'CAMERA', 'ALL'}:
2602                         rowsub = col.row()
2603                         rowsub.prop(bg, "frame_method", expand=True)
2604
2605                     row = col.row(align=True)
2606                     row.prop(bg, "offset_x", text="X")
2607                     row.prop(bg, "offset_y", text="Y")
2608
2609                     if bg.view_axis != 'CAMERA':
2610                         col.prop(bg, "size")
2611
2612
2613 class VIEW3D_PT_transform_orientations(Panel):
2614     bl_space_type = 'VIEW_3D'
2615     bl_region_type = 'UI'
2616     bl_label = "Transform Orientations"
2617     bl_options = {'DEFAULT_CLOSED'}
2618
2619     @classmethod
2620     def poll(cls, context):
2621         view = context.space_data
2622         return (view)
2623
2624     def draw(self, context):
2625         layout = self.layout
2626
2627         view = context.space_data
2628         orientation = view.current_orientation
2629
2630         row = layout.row(align=True)
2631         row.prop(view, "transform_orientation", text="")
2632         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2633
2634         if orientation:
2635             row = layout.row(align=True)
2636             row.prop(orientation, "name", text="")
2637             row.operator("transform.delete_orientation", text="", icon="X")
2638
2639
2640 class VIEW3D_PT_etch_a_ton(Panel):
2641     bl_space_type = 'VIEW_3D'
2642     bl_region_type = 'UI'
2643     bl_label = "Skeleton Sketching"
2644     bl_options = {'DEFAULT_CLOSED'}
2645
2646     @classmethod
2647     def poll(cls, context):
2648         scene = context.space_data
2649         ob = context.active_object
2650         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2651
2652     def draw_header(self, context):
2653         layout = self.layout
2654         toolsettings = context.scene.tool_settings
2655
2656         layout.prop(toolsettings, "use_bone_sketching", text="")
2657
2658     def draw(self, context):
2659         layout = self.layout
2660
2661         toolsettings = context.scene.tool_settings
2662
2663         col = layout.column()
2664
2665         col.prop(toolsettings, "use_etch_quick")
2666         col.prop(toolsettings, "use_etch_overdraw")
2667
2668         col.prop(toolsettings, "etch_convert_mode")
2669
2670         if toolsettings.etch_convert_mode == 'LENGTH':
2671             col.prop(toolsettings, "etch_length_limit")
2672         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2673             col.prop(toolsettings, "etch_adaptive_limit")
2674         elif toolsettings.etch_convert_mode == 'FIXED':
2675             col.prop(toolsettings, "etch_subdivision_number")
2676         elif toolsettings.etch_convert_mode == 'RETARGET':
2677             col.prop(toolsettings, "etch_template")
2678             col.prop(toolsettings, "etch_roll_mode")
2679             col.prop(toolsettings, "use_etch_autoname")
2680             col.prop(toolsettings, "etch_number")
2681             col.prop(toolsettings, "etch_side")
2682
2683         col.operator("sketch.convert", text="Convert")
2684
2685
2686 class VIEW3D_PT_context_properties(Panel):
2687     bl_space_type = 'VIEW_3D'
2688     bl_region_type = 'UI'
2689     bl_label = "Properties"
2690     bl_options = {'DEFAULT_CLOSED'}
2691
2692     def _active_context_member(context):
2693         obj = context.object
2694         if obj:
2695             mode = obj.mode
2696             if mode == 'POSE':
2697                 return "active_pose_bone"
2698             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2699                 return "active_bone"
2700             else:
2701                 return "object"
2702
2703         return ""
2704
2705     @classmethod
2706     def poll(cls, context):
2707         member = cls._active_context_member(context)
2708         if member:
2709             context_member = getattr(context, member)
2710             return context_member and context_member.keys()
2711
2712         return False
2713
2714     def draw(self, context):
2715         import rna_prop_ui
2716         member = VIEW3D_PT_context_properties._active_context_member(context)
2717
2718         if member:
2719             # Draw with no edit button
2720             rna_prop_ui.draw(self.layout, context, member, object, False)
2721
2722
2723 def register():
2724     bpy.utils.register_module(__name__)
2725
2726
2727 def unregister():
2728     bpy.utils.unregister_module(__name__)
2729
2730 if __name__ == "__main__":
2731     register()
2732
2733 if __name__ == "__main__":  # only for live edit.
2734     bpy.utils.register_module(__name__)