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