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