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