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