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