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