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