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