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