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