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