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