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