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