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