c6a26cd9bbf79c5492aba2c507c837d90ed13d3b
[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 from bpy.types import Header, Menu, Panel
22
23
24 class VIEW3D_HT_header(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         
58         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
59         row = layout.row() #XXX Narrowed down vert/edge/face selector in edit mode/solid drawmode. -DingTo 
60         row.template_header_3D()
61         
62         if obj:
63             # Particle edit
64             if obj.mode == 'PARTICLE_EDIT':
65                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
66
67             # Occlude geometry
68             if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
69                 row.prop(view, "use_occlude_geometry", text="")
70
71             # Proportional editing
72             if obj.mode in {'EDIT', 'PARTICLE_EDIT'}:
73                 row = layout.row(align=True)
74                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
75                 if toolsettings.proportional_edit != 'DISABLED':
76                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
77             elif obj.mode == 'OBJECT':
78                 row = layout.row(align=True)
79                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
80                 if toolsettings.use_proportional_edit_objects:
81                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
82
83         # Snap
84         snap_element = toolsettings.snap_element
85         row = layout.row(align=True)
86         row.prop(toolsettings, "use_snap", text="")
87         row.prop(toolsettings, "snap_element", text="", icon_only=True)
88         if snap_element != 'INCREMENT':
89             row.prop(toolsettings, "snap_target", text="")
90             if obj:
91                 if obj.mode == 'OBJECT':
92                     row.prop(toolsettings, "use_snap_align_rotation", text="")
93                 elif obj.mode == 'EDIT':
94                     row.prop(toolsettings, "use_snap_self", text="")
95
96         if snap_element == 'VOLUME':
97             row.prop(toolsettings, "use_snap_peel_object", text="")
98         elif snap_element == 'FACE':
99             row.prop(toolsettings, "use_snap_project", text="")
100
101         # OpenGL render
102         row = layout.row(align=True)
103         row.operator("render.opengl", text="", icon='RENDER_STILL')
104         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
105         props.animation = True
106
107         # Pose
108         if obj and obj.mode == 'POSE':
109             row = layout.row(align=True)
110             row.operator("pose.copy", text="", icon='COPYDOWN')
111             row.operator("pose.paste", text="", icon='PASTEDOWN')
112             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
113             props.flipped = 1
114
115
116 # ********** Menu **********
117
118 # ********** Utilities **********
119
120
121 class ShowHideMenu():
122     bl_label = "Show/Hide"
123     _operator_name = ""
124
125     def draw(self, context):
126         layout = self.layout
127
128         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
129         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
130         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
131
132
133 class VIEW3D_MT_transform(Menu):
134     bl_label = "Transform"
135
136     # TODO: get rid of the custom text strings?
137     def draw(self, context):
138         layout = self.layout
139
140         layout.operator("transform.translate", text="Grab/Move")
141         # TODO: sub-menu for grab per axis
142         layout.operator("transform.rotate", text="Rotate")
143         # TODO: sub-menu for rot per axis
144         layout.operator("transform.resize", text="Scale")
145         # TODO: sub-menu for scale per axis
146
147         layout.separator()
148
149         layout.operator("transform.tosphere", text="To Sphere")
150         layout.operator("transform.shear", text="Shear")
151         layout.operator("transform.warp", text="Warp")
152         layout.operator("transform.push_pull", text="Push/Pull")
153
154         layout.separator()
155
156         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
157         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
158
159         layout.separator()
160
161         obj = context.object
162         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}:
163             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
164
165         if context.edit_object and context.edit_object.type == 'ARMATURE':
166             layout.operator("armature.align")
167         else:
168             layout.operator_context = 'EXEC_REGION_WIN'
169             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
170
171         layout.separator()
172
173         layout.operator_context = 'EXEC_AREA'
174
175         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
176         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
177         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
178
179         layout.separator()
180
181         layout.operator("object.randomize_transform")
182         layout.operator("object.align")
183
184         layout.separator()
185
186         layout.operator("object.anim_transforms_to_deltas")
187
188
189 class VIEW3D_MT_mirror(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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_quick_effects")
726
727         layout.separator()
728
729         layout.menu("VIEW3D_MT_object_game")
730
731         layout.separator()
732
733         layout.operator("object.join")
734
735         layout.separator()
736
737         layout.operator("object.move_to_layer", text="Move to Layer...")
738         layout.menu("VIEW3D_MT_object_showhide")
739
740         layout.operator_menu_enum("object.convert", "target")
741
742
743 class VIEW3D_MT_object_animation(Menu):
744     bl_label = "Animation"
745
746     def draw(self, context):
747         layout = self.layout
748
749         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
750         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
751         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
752
753
754 class VIEW3D_MT_object_clear(Menu):
755     bl_label = "Clear"
756
757     def draw(self, context):
758         layout = self.layout
759
760         layout.operator("object.location_clear", text="Location")
761         layout.operator("object.rotation_clear", text="Rotation")
762         layout.operator("object.scale_clear", text="Scale")
763         layout.operator("object.origin_clear", text="Origin")
764
765
766 class VIEW3D_MT_object_specials(Menu):
767     bl_label = "Specials"
768
769     @classmethod
770     def poll(cls, context):
771         # add more special types
772         return context.object
773
774     def draw(self, context):
775         layout = self.layout
776
777         obj = context.object
778         if obj.type == 'CAMERA':
779             layout.operator_context = 'INVOKE_REGION_WIN'
780
781             if obj.data.type == 'PERSP':
782                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
783                 props.data_path_iter = "selected_editable_objects"
784                 props.data_path_item = "data.lens"
785                 props.input_scale = 0.1
786             else:
787                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
788                 props.data_path_iter = "selected_editable_objects"
789                 props.data_path_item = "data.ortho_scale"
790                 props.input_scale = 0.01
791
792             if not obj.data.dof_object:
793                 #layout.label(text="Test Has DOF obj");
794                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
795                 props.data_path_iter = "selected_editable_objects"
796                 props.data_path_item = "data.dof_distance"
797                 props.input_scale = 0.02
798
799         if obj.type in {'CURVE', 'FONT'}:
800             layout.operator_context = 'INVOKE_REGION_WIN'
801
802             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
803             props.data_path_iter = "selected_editable_objects"
804             props.data_path_item = "data.extrude"
805             props.input_scale = 0.01
806
807             props = layout.operator("wm.context_modal_mouse", text="Width Size")
808             props.data_path_iter = "selected_editable_objects"
809             props.data_path_item = "data.offset"
810             props.input_scale = 0.01
811
812         if obj.type == 'EMPTY':
813             layout.operator_context = 'INVOKE_REGION_WIN'
814
815             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
816             props.data_path_iter = "selected_editable_objects"
817             props.data_path_item = "empty_draw_size"
818             props.input_scale = 0.01
819
820         if obj.type == 'LAMP':
821             layout.operator_context = 'INVOKE_REGION_WIN'
822
823             props = layout.operator("wm.context_modal_mouse", text="Energy")
824             props.data_path_iter = "selected_editable_objects"
825             props.data_path_item = "data.energy"
826
827             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
828                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
829                 props.data_path_iter = "selected_editable_objects"
830                 props.data_path_item = "data.distance"
831                 props.input_scale = 0.1
832
833             if obj.data.type == 'SPOT':
834                 layout.separator()
835                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
836                 props.data_path_iter = "selected_editable_objects"
837                 props.data_path_item = "data.spot_size"
838                 props.input_scale = 0.01
839
840                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
841                 props.data_path_iter = "selected_editable_objects"
842                 props.data_path_item = "data.spot_blend"
843                 props.input_scale = -0.01
844
845                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
846                 props.data_path_iter = "selected_editable_objects"
847                 props.data_path_item = "data.shadow_buffer_clip_start"
848                 props.input_scale = 0.05
849
850                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
851                 props.data_path_iter = "selected_editable_objects"
852                 props.data_path_item = "data.shadow_buffer_clip_end"
853                 props.input_scale = 0.05
854
855         layout.separator()
856
857         props = layout.operator("object.isolate_type_render")
858         props = layout.operator("object.hide_render_clear_all")
859
860
861 class VIEW3D_MT_object_apply(Menu):
862     bl_label = "Apply"
863
864     def draw(self, context):
865         layout = self.layout
866
867         layout.operator("object.transform_apply", text="Location").location = True
868         layout.operator("object.transform_apply", text="Rotation").rotation = True
869         layout.operator("object.transform_apply", text="Scale").scale = True
870         props = layout.operator("object.transform_apply", text="Rotation & Scale")
871         props.scale = True
872         props.rotation = True
873
874         layout.separator()
875
876         layout.operator("object.visual_transform_apply", text="Visual Transform")
877         layout.operator("object.duplicates_make_real")
878
879
880 class VIEW3D_MT_object_parent(Menu):
881     bl_label = "Parent"
882
883     def draw(self, context):
884         layout = self.layout
885
886         layout.operator_menu_enum("object.parent_set", "type", text="Set")
887         layout.operator_menu_enum("object.parent_clear", "type", text="Clear")
888
889
890 class VIEW3D_MT_object_track(Menu):
891     bl_label = "Track"
892
893     def draw(self, context):
894         layout = self.layout
895
896         layout.operator_menu_enum("object.track_set", "type", text="Set")
897         layout.operator_menu_enum("object.track_clear", "type", text="Clear")
898
899
900 class VIEW3D_MT_object_group(Menu):
901     bl_label = "Group"
902
903     def draw(self, context):
904         layout = self.layout
905
906         layout.operator("group.create")
907         layout.operator("group.objects_remove")
908
909         layout.separator()
910
911         layout.operator("group.objects_add_active")
912         layout.operator("group.objects_remove_active")
913
914
915 class VIEW3D_MT_object_constraints(Menu):
916     bl_label = "Constraints"
917
918     def draw(self, context):
919         layout = self.layout
920
921         layout.operator("object.constraint_add_with_targets")
922         layout.operator("object.constraints_copy")
923         layout.operator("object.constraints_clear")
924
925
926 class VIEW3D_MT_object_quick_effects(Menu):
927     bl_label = "Quick Effects"
928
929     def draw(self, context):
930         layout = self.layout
931
932         layout.operator("object.quick_fur")
933         layout.operator("object.quick_explode")
934         layout.operator("object.quick_smoke")
935         layout.operator("object.quick_fluid")
936
937
938 class VIEW3D_MT_object_showhide(Menu):
939     bl_label = "Show/Hide"
940
941     def draw(self, context):
942         layout = self.layout
943
944         layout.operator("object.hide_view_clear", text="Show Hidden")
945         layout.operator("object.hide_view_set", text="Hide Selected")
946         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
947
948
949 class VIEW3D_MT_make_single_user(Menu):
950     bl_label = "Make Single User"
951
952     def draw(self, context):
953         layout = self.layout
954
955         props = layout.operator("object.make_single_user", text="Object")
956         props.object = True
957
958         props = layout.operator("object.make_single_user", text="Object & Data")
959         props.object = props.obdata = True
960
961         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
962         props.object = props.obdata = props.material = props.texture = True
963
964         props = layout.operator("object.make_single_user", text="Materials+Tex")
965         props.material = props.texture = True
966
967         props = layout.operator("object.make_single_user", text="Object Animation")
968         props.animation = True
969
970
971 class VIEW3D_MT_make_links(Menu):
972     bl_label = "Make Links"
973
974     def draw(self, context):
975         layout = self.layout
976
977         if(len(bpy.data.scenes) > 10):
978             layout.operator_context = 'INVOKE_DEFAULT'
979             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
980             layout.operator("object.make_links_scene", text="Markers to Scene...", icon='OUTLINER_OB_EMPTY')
981         else:
982             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
983             layout.operator_menu_enum("marker.make_links_scene", "scene", text="Markers to Scene...")
984
985         layout.operator_enum("object.make_links_data", "type")  # inline
986
987         layout.operator("object.join_uvs")  # stupid place to add this!
988
989
990 class VIEW3D_MT_object_game(Menu):
991     bl_label = "Game"
992
993     def draw(self, context):
994         layout = self.layout
995
996         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
997
998         layout.separator()
999
1000         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1001         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1002         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1003
1004         layout.separator()
1005
1006         layout.operator("object.game_property_clear")
1007
1008
1009 # ********** Vertex paint menu **********
1010
1011
1012 class VIEW3D_MT_paint_vertex(Menu):
1013     bl_label = "Paint"
1014
1015     def draw(self, context):
1016         layout = self.layout
1017
1018         layout.operator("ed.undo")
1019         layout.operator("ed.redo")
1020
1021         layout.separator()
1022
1023         layout.operator("paint.vertex_color_set")
1024         layout.operator("paint.vertex_color_dirt")
1025
1026
1027 class VIEW3D_MT_hook(Menu):
1028     bl_label = "Hooks"
1029
1030     def draw(self, context):
1031         layout = self.layout
1032         layout.operator_context = 'EXEC_AREA'
1033         layout.operator("object.hook_add_newob")
1034         layout.operator("object.hook_add_selob")
1035
1036         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1037             layout.separator()
1038             layout.operator_menu_enum("object.hook_assign", "modifier")
1039             layout.operator_menu_enum("object.hook_remove", "modifier")
1040             layout.separator()
1041             layout.operator_menu_enum("object.hook_select", "modifier")
1042             layout.operator_menu_enum("object.hook_reset", "modifier")
1043             layout.operator_menu_enum("object.hook_recenter", "modifier")
1044
1045
1046 class VIEW3D_MT_vertex_group(Menu):
1047     bl_label = "Vertex Groups"
1048
1049     def draw(self, context):
1050         layout = self.layout
1051         layout.operator_context = 'EXEC_AREA'
1052         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1053
1054         ob = context.active_object
1055         if ob.mode == 'EDIT':
1056             if ob.vertex_groups.active:
1057                 layout.separator()
1058                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1059                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
1060                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1061                 layout.separator()
1062
1063         if ob.vertex_groups.active:
1064             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1065             layout.operator("object.vertex_group_remove", text="Remove Active Group")
1066             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1067
1068 # ********** Weight paint menu **********
1069
1070
1071 class VIEW3D_MT_paint_weight(Menu):
1072     bl_label = "Weights"
1073
1074     def draw(self, context):
1075         layout = self.layout
1076
1077         layout.operator("ed.undo")
1078         layout.operator("ed.redo")
1079         layout.operator("ed.undo_history")
1080
1081         layout.separator()
1082
1083         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1084         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1085
1086         layout.separator()
1087
1088         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1089         layout.operator("object.vertex_group_normalize", text="Normalize")
1090         layout.operator("object.vertex_group_invert", text="Invert")
1091         layout.operator("object.vertex_group_clean", text="Clean")
1092         layout.operator("object.vertex_group_levels", text="Levels")
1093         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1094
1095         layout.separator()
1096
1097         layout.operator("paint.weight_set")
1098
1099 # ********** Sculpt menu **********
1100
1101
1102 class VIEW3D_MT_sculpt(Menu):
1103     bl_label = "Sculpt"
1104
1105     def draw(self, context):
1106         layout = self.layout
1107
1108         tool_settings = context.tool_settings
1109         sculpt = tool_settings.sculpt
1110         brush = tool_settings.sculpt.brush
1111
1112         layout.operator("ed.undo")
1113         layout.operator("ed.redo")
1114
1115         layout.separator()
1116
1117         layout.prop(sculpt, "use_symmetry_x")
1118         layout.prop(sculpt, "use_symmetry_y")
1119         layout.prop(sculpt, "use_symmetry_z")
1120         layout.separator()
1121         layout.prop(sculpt, "lock_x")
1122         layout.prop(sculpt, "lock_y")
1123         layout.prop(sculpt, "lock_z")
1124         layout.separator()
1125         layout.operator_menu_enum("brush.curve_preset", "shape")
1126         layout.separator()
1127
1128         if brush is not None:  # unlikely but can happen
1129             sculpt_tool = brush.sculpt_tool
1130
1131             if sculpt_tool != 'GRAB':
1132                 layout.prop_menu_enum(brush, "stroke_method")
1133
1134                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1135                     layout.prop_menu_enum(brush, "direction")
1136
1137                 if sculpt_tool == 'LAYER':
1138                     layout.prop(brush, "use_persistent")
1139                     layout.operator("sculpt.set_persistent_base")
1140
1141         layout.separator()
1142         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1143         layout.prop(sculpt, "show_brush")
1144
1145         # TODO, make available from paint menu!
1146         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Unify Size")
1147         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Unify Strength")
1148
1149 # ********** Particle menu **********
1150
1151
1152 class VIEW3D_MT_particle(Menu):
1153     bl_label = "Particle"
1154
1155     def draw(self, context):
1156         layout = self.layout
1157
1158         particle_edit = context.tool_settings.particle_edit
1159
1160         layout.operator("ed.undo")
1161         layout.operator("ed.redo")
1162         layout.operator("ed.undo_history")
1163
1164         layout.separator()
1165
1166         layout.operator("particle.mirror")
1167
1168         layout.separator()
1169
1170         layout.operator("particle.remove_doubles")
1171         layout.operator("particle.delete")
1172
1173         if particle_edit.select_mode == 'POINT':
1174             layout.operator("particle.subdivide")
1175
1176         layout.operator("particle.rekey")
1177         layout.operator("particle.weight_set")
1178
1179         layout.separator()
1180
1181         layout.menu("VIEW3D_MT_particle_showhide")
1182
1183
1184 class VIEW3D_MT_particle_specials(Menu):
1185     bl_label = "Specials"
1186
1187     def draw(self, context):
1188         layout = self.layout
1189         particle_edit = context.tool_settings.particle_edit
1190
1191         layout.operator("particle.rekey")
1192
1193         layout.separator()
1194         if particle_edit.select_mode == 'POINT':
1195             layout.operator("particle.subdivide")
1196             layout.operator("particle.select_roots")
1197             layout.operator("particle.select_tips")
1198
1199         layout.operator("particle.remove_doubles")
1200
1201
1202 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1203     _operator_name = "particle"
1204
1205 # ********** Pose Menu **********
1206
1207
1208 class VIEW3D_MT_pose(Menu):
1209     bl_label = "Pose"
1210
1211     def draw(self, context):
1212         layout = self.layout
1213
1214         layout.operator("ed.undo")
1215         layout.operator("ed.redo")
1216         layout.operator("ed.undo_history")
1217
1218         layout.separator()
1219
1220         layout.menu("VIEW3D_MT_transform")
1221
1222         layout.menu("VIEW3D_MT_pose_transform")
1223         layout.menu("VIEW3D_MT_pose_apply")
1224
1225         layout.menu("VIEW3D_MT_snap")
1226
1227         layout.separator()
1228
1229         layout.menu("VIEW3D_MT_object_animation")
1230
1231         layout.separator()
1232
1233         layout.menu("VIEW3D_MT_pose_slide")
1234         layout.menu("VIEW3D_MT_pose_propagate")
1235
1236         layout.separator()
1237
1238         layout.operator("pose.copy")
1239         layout.operator("pose.paste")
1240         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1241
1242         layout.separator()
1243
1244         layout.menu("VIEW3D_MT_pose_library")
1245         layout.menu("VIEW3D_MT_pose_motion")
1246         layout.menu("VIEW3D_MT_pose_group")
1247
1248         layout.separator()
1249
1250         layout.menu("VIEW3D_MT_object_parent")
1251         layout.menu("VIEW3D_MT_pose_ik")
1252         layout.menu("VIEW3D_MT_pose_constraints")
1253
1254         layout.separator()
1255
1256         layout.operator_context = 'EXEC_AREA'
1257         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1258         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1259         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1260
1261         layout.operator("pose.flip_names")
1262
1263         layout.operator("pose.quaternions_flip")
1264
1265         layout.separator()
1266
1267         layout.operator_context = 'INVOKE_AREA'
1268         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1269         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1270
1271         layout.separator()
1272
1273         layout.menu("VIEW3D_MT_pose_showhide")
1274         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1275
1276
1277 class VIEW3D_MT_pose_transform(Menu):
1278     bl_label = "Clear Transform"
1279
1280     def draw(self, context):
1281         layout = self.layout
1282
1283         layout.operator("pose.transforms_clear", text="All")
1284
1285         layout.separator()
1286
1287         layout.operator("pose.loc_clear", text="Location")
1288         layout.operator("pose.rot_clear", text="Rotation")
1289         layout.operator("pose.scale_clear", text="Scale")
1290
1291         layout.separator()
1292
1293         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1294
1295
1296 class VIEW3D_MT_pose_slide(Menu):
1297     bl_label = "In-Betweens"
1298
1299     def draw(self, context):
1300         layout = self.layout
1301
1302         layout.operator("pose.push")
1303         layout.operator("pose.relax")
1304         layout.operator("pose.breakdown")
1305
1306
1307 class VIEW3D_MT_pose_propagate(Menu):
1308     bl_label = "Propagate"
1309
1310     def draw(self, context):
1311         layout = self.layout
1312
1313         layout.operator("pose.propagate")
1314
1315         layout.separator()
1316
1317         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1318         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1319
1320         layout.separator()
1321
1322         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1323
1324
1325 class VIEW3D_MT_pose_library(Menu):
1326     bl_label = "Pose Library"
1327
1328     def draw(self, context):
1329         layout = self.layout
1330
1331         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1332
1333         layout.separator()
1334
1335         layout.operator("poselib.pose_add", text="Add Pose...")
1336         layout.operator("poselib.pose_rename", text="Rename Pose...")
1337         layout.operator("poselib.pose_remove", text="Remove Pose...")
1338
1339
1340 class VIEW3D_MT_pose_motion(Menu):
1341     bl_label = "Motion Paths"
1342
1343     def draw(self, context):
1344         layout = self.layout
1345
1346         layout.operator("pose.paths_calculate", text="Calculate")
1347         layout.operator("pose.paths_clear", text="Clear")
1348
1349
1350 class VIEW3D_MT_pose_group(Menu):
1351     bl_label = "Bone Groups"
1352
1353     def draw(self, context):
1354         layout = self.layout
1355         layout.operator("pose.group_add")
1356         layout.operator("pose.group_remove")
1357
1358         layout.separator()
1359
1360         layout.operator("pose.group_assign")
1361         layout.operator("pose.group_unassign")
1362
1363
1364 class VIEW3D_MT_pose_ik(Menu):
1365     bl_label = "Inverse Kinematics"
1366
1367     def draw(self, context):
1368         layout = self.layout
1369
1370         layout.operator("pose.ik_add")
1371         layout.operator("pose.ik_clear")
1372
1373
1374 class VIEW3D_MT_pose_constraints(Menu):
1375     bl_label = "Constraints"
1376
1377     def draw(self, context):
1378         layout = self.layout
1379
1380         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1381         layout.operator("pose.constraints_copy")
1382         layout.operator("pose.constraints_clear")
1383
1384
1385 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1386     _operator_name = "pose"
1387
1388
1389 class VIEW3D_MT_pose_apply(Menu):
1390     bl_label = "Apply"
1391
1392     def draw(self, context):
1393         layout = self.layout
1394
1395         layout.operator("pose.armature_apply")
1396         layout.operator("pose.visual_transform_apply")
1397
1398
1399 class BoneOptions:
1400     def draw(self, context):
1401         layout = self.layout
1402
1403         options = [
1404             "show_wire",
1405             "use_deform",
1406             "use_envelope_multiply",
1407             "use_inherit_rotation",
1408             "use_inherit_scale",
1409         ]
1410
1411         if context.mode == 'EDIT_ARMATURE':
1412             bone_props = bpy.types.EditBone.bl_rna.properties
1413             data_path_iter = "selected_bones"
1414             opt_suffix = ""
1415             options.append("lock")
1416         else:  # pose-mode
1417             bone_props = bpy.types.Bone.bl_rna.properties
1418             data_path_iter = "selected_pose_bones"
1419             opt_suffix = "bone."
1420
1421         for opt in options:
1422             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1423             props.data_path_iter = data_path_iter
1424             props.data_path_item = opt_suffix + opt
1425             props.type = self.type
1426
1427
1428 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1429     bl_label = "Toggle Bone Options"
1430     type = 'TOGGLE'
1431
1432
1433 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1434     bl_label = "Enable Bone Options"
1435     type = 'ENABLE'
1436
1437
1438 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1439     bl_label = "Disable Bone Options"
1440     type = 'DISABLE'
1441
1442 # ********** Edit Menus, suffix from ob.type **********
1443
1444
1445 class VIEW3D_MT_edit_mesh(Menu):
1446     bl_label = "Mesh"
1447
1448     def draw(self, context):
1449         layout = self.layout
1450
1451         settings = context.tool_settings
1452
1453         layout.operator("ed.undo")
1454         layout.operator("ed.redo")
1455         layout.operator("ed.undo_history")
1456
1457         layout.separator()
1458
1459         layout.menu("VIEW3D_MT_transform")
1460         layout.menu("VIEW3D_MT_mirror")
1461         layout.menu("VIEW3D_MT_snap")
1462
1463         layout.separator()
1464
1465         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1466
1467         layout.separator()
1468
1469         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1470         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1471         layout.operator("mesh.duplicate_move")
1472         layout.operator("mesh.delete", text="Delete...")
1473
1474         layout.separator()
1475
1476         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1477         layout.menu("VIEW3D_MT_edit_mesh_edges")
1478         layout.menu("VIEW3D_MT_edit_mesh_faces")
1479         layout.menu("VIEW3D_MT_edit_mesh_normals")
1480
1481         layout.separator()
1482
1483         layout.prop(settings, "use_mesh_automerge")
1484         layout.prop_menu_enum(settings, "proportional_edit")
1485         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1486
1487         layout.separator()
1488
1489         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1490
1491
1492 class VIEW3D_MT_edit_mesh_specials(Menu):
1493     bl_label = "Specials"
1494
1495     def draw(self, context):
1496         layout = self.layout
1497
1498         layout.operator_context = 'INVOKE_REGION_WIN'
1499
1500         layout.operator("mesh.subdivide", text="Subdivide")
1501         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1502         layout.operator("mesh.merge", text="Merge...")
1503         layout.operator("mesh.remove_doubles")
1504         layout.operator("mesh.hide", text="Hide")
1505         layout.operator("mesh.reveal", text="Reveal")
1506         layout.operator("mesh.select_inverse")
1507         layout.operator("mesh.flip_normals")
1508         layout.operator("mesh.vertices_smooth", text="Smooth")
1509         # layout.operator("mesh.bevel", text="Bevel")
1510         layout.operator("mesh.faces_shade_smooth")
1511         layout.operator("mesh.faces_shade_flat")
1512         layout.operator("mesh.blend_from_shape")
1513         layout.operator("mesh.shape_propagate_to_all")
1514         layout.operator("mesh.select_vertex_path")
1515
1516
1517 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1518     bl_label = "Mesh Select Mode"
1519
1520     def draw(self, context):
1521         layout = self.layout
1522
1523         layout.operator_context = 'INVOKE_REGION_WIN'
1524
1525         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1526         prop.value = "(True, False, False)"
1527         prop.data_path = "tool_settings.mesh_select_mode"
1528
1529         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1530         prop.value = "(False, True, False)"
1531         prop.data_path = "tool_settings.mesh_select_mode"
1532
1533         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1534         prop.value = "(False, False, True)"
1535         prop.data_path = "tool_settings.mesh_select_mode"
1536
1537
1538 class VIEW3D_MT_edit_mesh_extrude(Menu):
1539     bl_label = "Extrude"
1540
1541     _extrude_funcs = { \
1542         "VERT": lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1543         "EDGE": lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1544         "FACE": lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1545         "REGION": lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1546     }
1547
1548     @staticmethod
1549     def extrude_options(context):
1550         mesh = context.object.data
1551         select_mode = context.tool_settings.mesh_select_mode
1552
1553         menu = []
1554         if mesh.total_face_sel:
1555             menu += ["REGION", "FACE"]
1556         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1557             menu += ["EDGE"]
1558         if mesh.total_vert_sel and select_mode[0]:
1559             menu += ["VERT"]
1560
1561         # should never get here
1562         return menu
1563
1564     def draw(self, context):
1565         layout = self.layout
1566         layout.operator_context = 'INVOKE_REGION_WIN'
1567
1568         for menu_id in self.extrude_options(context):
1569             self._extrude_funcs[menu_id](layout)
1570
1571
1572 class VIEW3D_MT_edit_mesh_vertices(Menu):
1573     bl_label = "Vertices"
1574
1575     def draw(self, context):
1576         layout = self.layout
1577         layout.operator_context = 'INVOKE_REGION_WIN'
1578
1579         layout.operator("mesh.merge")
1580         layout.operator("mesh.rip_move")
1581         layout.operator("mesh.split")
1582         layout.operator("mesh.separate")
1583
1584         layout.separator()
1585
1586         layout.operator("mesh.vertices_smooth")
1587         layout.operator("mesh.remove_doubles")
1588         layout.operator("mesh.vertices_sort")
1589         layout.operator("mesh.vertices_randomize")
1590
1591         layout.operator("mesh.select_vertex_path")
1592
1593         layout.operator("mesh.blend_from_shape")
1594
1595         layout.operator("object.vertex_group_blend")
1596         layout.operator("mesh.shape_propagate_to_all")
1597
1598         layout.separator()
1599
1600         layout.menu("VIEW3D_MT_vertex_group")
1601         layout.menu("VIEW3D_MT_hook")
1602
1603
1604 class VIEW3D_MT_edit_mesh_edges(Menu):
1605     bl_label = "Edges"
1606
1607     def draw(self, context):
1608         layout = self.layout
1609         layout.operator_context = 'INVOKE_REGION_WIN'
1610
1611         layout.operator("mesh.edge_face_add")
1612         layout.operator("mesh.subdivide")
1613
1614         layout.separator()
1615
1616         layout.operator("mesh.mark_seam")
1617         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1618
1619         layout.separator()
1620
1621         layout.operator("mesh.mark_sharp")
1622         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1623
1624         layout.separator()
1625
1626         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1627         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1628
1629         layout.separator()
1630
1631         layout.operator("TRANSFORM_OT_edge_slide")
1632         layout.operator("TRANSFORM_OT_edge_crease")
1633         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1634
1635         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1636         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1637
1638         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1639
1640         layout.operator("mesh.loop_to_region")
1641         layout.operator("mesh.region_to_loop")
1642
1643
1644 class VIEW3D_MT_edit_mesh_faces(Menu):
1645     bl_label = "Faces"
1646     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1647
1648     def draw(self, context):
1649         layout = self.layout
1650         layout.operator_context = 'INVOKE_REGION_WIN'
1651
1652         layout.operator("mesh.flip_normals")
1653         # layout.operator("mesh.bevel")
1654         # layout.operator("mesh.bevel")
1655         layout.operator("mesh.edge_face_add")
1656         layout.operator("mesh.fill")
1657         layout.operator("mesh.beautify_fill")
1658         layout.operator("mesh.solidify")
1659         layout.operator("mesh.sort_faces")
1660
1661         layout.separator()
1662
1663         layout.operator("mesh.fgon_make")
1664         layout.operator("mesh.fgon_clear")
1665
1666         layout.separator()
1667
1668         layout.operator("mesh.quads_convert_to_tris")
1669         layout.operator("mesh.tris_convert_to_quads")
1670         layout.operator("mesh.edge_flip")
1671
1672         layout.separator()
1673
1674         layout.operator("mesh.faces_shade_smooth")
1675         layout.operator("mesh.faces_shade_flat")
1676
1677         layout.separator()
1678
1679         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1680         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1681
1682         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1683
1684         layout.separator()
1685
1686         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1687         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1688         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1689         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1690
1691
1692 class VIEW3D_MT_edit_mesh_normals(Menu):
1693     bl_label = "Normals"
1694
1695     def draw(self, context):
1696         layout = self.layout
1697
1698         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1699         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1700
1701         layout.separator()
1702
1703         layout.operator("mesh.flip_normals")
1704
1705
1706 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1707     _operator_name = "mesh"
1708
1709 # Edit Curve
1710 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1711
1712
1713 def draw_curve(self, context):
1714     layout = self.layout
1715
1716     settings = context.tool_settings
1717
1718     layout.menu("VIEW3D_MT_transform")
1719     layout.menu("VIEW3D_MT_mirror")
1720     layout.menu("VIEW3D_MT_snap")
1721
1722     layout.separator()
1723
1724     layout.operator("curve.extrude")
1725     layout.operator("curve.duplicate")
1726     layout.operator("curve.separate")
1727     layout.operator("curve.make_segment")
1728     layout.operator("curve.cyclic_toggle")
1729     layout.operator("curve.delete", text="Delete...")
1730
1731     layout.separator()
1732
1733     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1734     layout.menu("VIEW3D_MT_edit_curve_segments")
1735
1736     layout.separator()
1737
1738     layout.prop_menu_enum(settings, "proportional_edit")
1739     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1740
1741     layout.separator()
1742
1743     layout.menu("VIEW3D_MT_edit_curve_showhide")
1744
1745
1746 class VIEW3D_MT_edit_curve(Menu):
1747     bl_label = "Curve"
1748
1749     draw = draw_curve
1750
1751
1752 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1753     bl_label = "Control Points"
1754
1755     def draw(self, context):
1756         layout = self.layout
1757
1758         edit_object = context.edit_object
1759
1760         if edit_object.type == 'CURVE':
1761             layout.operator("transform.transform", text="Tilt").mode = 'TILT'
1762             layout.operator("curve.tilt_clear")
1763             layout.operator("curve.separate")
1764
1765             layout.separator()
1766
1767             layout.operator_menu_enum("curve.handle_type_set", "type")
1768
1769             layout.separator()
1770
1771             layout.menu("VIEW3D_MT_hook")
1772
1773
1774 class VIEW3D_MT_edit_curve_segments(Menu):
1775     bl_label = "Segments"
1776
1777     def draw(self, context):
1778         layout = self.layout
1779
1780         layout.operator("curve.subdivide")
1781         layout.operator("curve.switch_direction")
1782
1783
1784 class VIEW3D_MT_edit_curve_specials(Menu):
1785     bl_label = "Specials"
1786
1787     def draw(self, context):
1788         layout = self.layout
1789
1790         layout.operator("curve.subdivide")
1791         layout.operator("curve.switch_direction")
1792         layout.operator("curve.spline_weight_set")
1793         layout.operator("curve.radius_set")
1794         layout.operator("curve.smooth")
1795         layout.operator("curve.smooth_radius")
1796
1797
1798 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
1799     _operator_name = "curve"
1800
1801
1802 class VIEW3D_MT_edit_surface(Menu):
1803     bl_label = "Surface"
1804
1805     draw = draw_curve
1806
1807
1808 class VIEW3D_MT_edit_font(Menu):
1809     bl_label = "Text"
1810
1811     def draw(self, context):
1812         layout = self.layout
1813
1814         layout.operator("font.file_paste")
1815
1816         layout.separator()
1817
1818         layout.menu("VIEW3D_MT_edit_text_chars")
1819
1820         layout.separator()
1821
1822         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1823         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1824         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1825         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1826
1827
1828 class VIEW3D_MT_edit_text_chars(Menu):
1829     bl_label = "Special Characters"
1830
1831     def draw(self, context):
1832         layout = self.layout
1833
1834         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1835         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1836
1837         layout.separator()
1838
1839         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1840         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1841         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1842         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1843         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1844         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1845         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1846         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1847         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1848
1849         layout.separator()
1850
1851         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1852         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1853         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1854
1855         layout.separator()
1856
1857         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1858         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1859         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1860
1861
1862 class VIEW3D_MT_edit_meta(Menu):
1863     bl_label = "Metaball"
1864
1865     def draw(self, context):
1866         layout = self.layout
1867
1868         settings = context.tool_settings
1869
1870         layout.operator("ed.undo")
1871         layout.operator("ed.redo")
1872         layout.operator("ed.undo_history")
1873
1874         layout.separator()
1875
1876         layout.menu("VIEW3D_MT_transform")
1877         layout.menu("VIEW3D_MT_mirror")
1878         layout.menu("VIEW3D_MT_snap")
1879
1880         layout.separator()
1881
1882         layout.operator("mball.delete_metaelems", text="Delete...")
1883         layout.operator("mball.duplicate_metaelems")
1884
1885         layout.separator()
1886
1887         layout.prop_menu_enum(settings, "proportional_edit")
1888         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1889
1890         layout.separator()
1891
1892         layout.menu("VIEW3D_MT_edit_meta_showhide")
1893
1894
1895 class VIEW3D_MT_edit_meta_showhide(Menu):
1896     bl_label = "Show/Hide"
1897
1898     def draw(self, context):
1899         layout = self.layout
1900
1901         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1902         layout.operator("mball.hide_metaelems", text="Hide Selected")
1903         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1904
1905
1906 class VIEW3D_MT_edit_lattice(Menu):
1907     bl_label = "Lattice"
1908
1909     def draw(self, context):
1910         layout = self.layout
1911
1912         settings = context.tool_settings
1913
1914         layout.menu("VIEW3D_MT_transform")
1915         layout.menu("VIEW3D_MT_mirror")
1916         layout.menu("VIEW3D_MT_snap")
1917
1918         layout.separator()
1919
1920         layout.operator("lattice.make_regular")
1921
1922         layout.separator()
1923
1924         layout.prop_menu_enum(settings, "proportional_edit")
1925         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1926
1927
1928 class VIEW3D_MT_edit_armature(Menu):
1929     bl_label = "Armature"
1930
1931     def draw(self, context):
1932         layout = self.layout
1933
1934         edit_object = context.edit_object
1935         arm = edit_object.data
1936
1937         layout.menu("VIEW3D_MT_transform")
1938         layout.menu("VIEW3D_MT_mirror")
1939         layout.menu("VIEW3D_MT_snap")
1940         layout.menu("VIEW3D_MT_edit_armature_roll")
1941
1942         layout.separator()
1943
1944         layout.operator("armature.extrude_move")
1945
1946         if arm.use_mirror_x:
1947             layout.operator("armature.extrude_forked")
1948
1949         layout.operator("armature.duplicate_move")
1950         layout.operator("armature.merge")
1951         layout.operator("armature.fill")
1952         layout.operator("armature.delete")
1953         layout.operator("armature.separate")
1954
1955         layout.separator()
1956
1957         layout.operator("armature.subdivide", text="Subdivide")
1958         layout.operator("armature.switch_direction", text="Switch Direction")
1959
1960         layout.separator()
1961
1962         layout.operator_context = 'EXEC_AREA'
1963         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1964         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1965         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1966         layout.operator("armature.flip_names")
1967
1968         layout.separator()
1969
1970         layout.operator_context = 'INVOKE_DEFAULT'
1971         layout.operator("armature.armature_layers")
1972         layout.operator("armature.bone_layers")
1973
1974         layout.separator()
1975
1976         layout.menu("VIEW3D_MT_edit_armature_parent")
1977
1978         layout.separator()
1979
1980         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1981
1982
1983 class VIEW3D_MT_armature_specials(Menu):
1984     bl_label = "Specials"
1985
1986     def draw(self, context):
1987         layout = self.layout
1988
1989         layout.operator_context = 'INVOKE_REGION_WIN'
1990
1991         layout.operator("armature.subdivide", text="Subdivide")
1992         layout.operator("armature.switch_direction", text="Switch Direction")
1993
1994         layout.separator()
1995
1996         layout.operator_context = 'EXEC_REGION_WIN'
1997         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1998         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1999         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2000         layout.operator("armature.flip_names", text="Flip Names")
2001
2002
2003 class VIEW3D_MT_edit_armature_parent(Menu):
2004     bl_label = "Parent"
2005
2006     def draw(self, context):
2007         layout = self.layout
2008
2009         layout.operator("armature.parent_set", text="Make")
2010         layout.operator("armature.parent_clear", text="Clear")
2011
2012
2013 class VIEW3D_MT_edit_armature_roll(Menu):
2014     bl_label = "Bone Roll"
2015
2016     def draw(self, context):
2017         layout = self.layout
2018
2019         layout.operator_menu_enum("armature.calculate_roll", "type")
2020
2021         layout.separator()
2022
2023         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2024
2025 # ********** Panel **********
2026
2027
2028 class VIEW3D_PT_view3d_properties(Panel):
2029     bl_space_type = 'VIEW_3D'
2030     bl_region_type = 'UI'
2031     bl_label = "View"
2032
2033     @classmethod
2034     def poll(cls, context):
2035         view = context.space_data
2036         return (view)
2037
2038     def draw(self, context):
2039         layout = self.layout
2040
2041         view = context.space_data
2042
2043         col = layout.column()
2044         col.active = view.region_3d.view_perspective != 'CAMERA'
2045         col.prop(view, "lens")
2046         col.label(text="Lock to Object:")
2047         col.prop(view, "lock_object", text="")
2048         lock_object = view.lock_object
2049         if lock_object:
2050             if lock_object.type == 'ARMATURE':
2051                 col.prop_search(view, "lock_bone", lock_object.data, "edit_bones" if lock_object.mode == 'EDIT' else "bones", text="")
2052         else:
2053             col.prop(view, "lock_cursor", text="Lock to Cursor")
2054
2055         col = layout.column()
2056         col.prop(view, "lock_camera")
2057
2058         col = layout.column(align=True)
2059         col.label(text="Clip:")
2060         col.prop(view, "clip_start", text="Start")
2061         col.prop(view, "clip_end", text="End")
2062
2063         subcol = col.column()
2064         subcol.enabled = not view.lock_camera_and_layers
2065         subcol.label(text="Local Camera:")
2066         subcol.prop(view, "camera", text="")
2067
2068         layout.column().prop(view, "cursor_location")
2069
2070
2071 class VIEW3D_PT_view3d_name(Panel):
2072     bl_space_type = 'VIEW_3D'
2073     bl_region_type = 'UI'
2074     bl_label = "Item"
2075
2076     @classmethod
2077     def poll(cls, context):
2078         return (context.space_data and context.active_object)
2079
2080     def draw(self, context):
2081         layout = self.layout
2082
2083         ob = context.active_object
2084         row = layout.row()
2085         row.label(text="", icon='OBJECT_DATA')
2086         row.prop(ob, "name", text="")
2087
2088         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2089             bone = context.active_bone
2090             if bone:
2091                 row = layout.row()
2092                 row.label(text="", icon='BONE_DATA')
2093                 row.prop(bone, "name", text="")
2094
2095
2096 class VIEW3D_PT_view3d_display(Panel):
2097     bl_space_type = 'VIEW_3D'
2098     bl_region_type = 'UI'
2099     bl_label = "Display"
2100     bl_options = {'DEFAULT_CLOSED'}
2101
2102     @classmethod
2103     def poll(cls, context):
2104         view = context.space_data
2105         return (view)
2106
2107     def draw(self, context):
2108         layout = self.layout
2109
2110         view = context.space_data
2111         scene = context.scene
2112         gs = scene.game_settings
2113         ob = context.object
2114
2115         col = layout.column()
2116         col.prop(view, "show_only_render")
2117
2118         col = layout.column()
2119         display_all = not view.show_only_render
2120         col.active = display_all
2121         col.prop(view, "show_outline_selected")
2122         col.prop(view, "show_all_objects_origin")
2123         col.prop(view, "show_relationship_lines")
2124         if ob and ob.type == 'MESH':
2125             mesh = ob.data
2126             col.prop(mesh, "show_all_edges")
2127
2128         col = layout.column()
2129         col.active = display_all
2130         split = col.split(percentage=0.55)
2131         split.prop(view, "show_floor", text="Grid Floor")
2132
2133         row = split.row(align=True)
2134         row.prop(view, "show_axis_x", text="X", toggle=True)
2135         row.prop(view, "show_axis_y", text="Y", toggle=True)
2136         row.prop(view, "show_axis_z", text="Z", toggle=True)
2137
2138         sub = col.column(align=True)
2139         sub.active = (display_all and view.show_floor)
2140         sub.prop(view, "grid_lines", text="Lines")
2141         sub.prop(view, "grid_scale", text="Scale")
2142         subsub = sub.column(align=True)
2143         subsub.active = scene.unit_settings.system == 'NONE'
2144         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2145
2146         col = layout.column()
2147         col.label(text="Shading:")
2148         col.prop(gs, "material_mode", text="")
2149         col.prop(view, "show_textured_solid")
2150
2151         layout.separator()
2152
2153         region = view.region_quadview
2154
2155         layout.operator("screen.region_quadview", text="Toggle Quad View")
2156
2157         if region:
2158             col = layout.column()
2159             col.prop(region, "lock_rotation")
2160             row = col.row()
2161             row.enabled = region.lock_rotation
2162             row.prop(region, "show_sync_view")
2163             row = col.row()
2164             row.enabled = region.lock_rotation and region.show_sync_view
2165             row.prop(region, "use_box_clip")
2166
2167
2168 class VIEW3D_PT_view3d_meshdisplay(Panel):
2169     bl_space_type = 'VIEW_3D'
2170     bl_region_type = 'UI'
2171     bl_label = "Mesh Display"
2172
2173     @classmethod
2174     def poll(cls, context):
2175         # The active object check is needed because of local-mode
2176         return (context.active_object and (context.mode == 'EDIT_MESH'))
2177
2178     def draw(self, context):
2179         layout = self.layout
2180
2181         mesh = context.active_object.data
2182
2183         col = layout.column()
2184         col.label(text="Overlays:")
2185         col.prop(mesh, "show_edges", text="Edges")
2186         col.prop(mesh, "show_faces", text="Faces")
2187         col.prop(mesh, "show_edge_crease", text="Creases")
2188         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2189         col.prop(mesh, "show_edge_seams", text="Seams")
2190         col.prop(mesh, "show_edge_sharp", text="Sharp")
2191
2192         col.separator()
2193         col.label(text="Normals:")
2194         col.prop(mesh, "show_normal_face", text="Face")
2195         col.prop(mesh, "show_normal_vertex", text="Vertex")
2196         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2197
2198         col.separator()
2199         col.label(text="Numerics:")
2200         col.prop(mesh, "show_extra_edge_length")
2201         col.prop(mesh, "show_extra_face_angle")
2202         col.prop(mesh, "show_extra_face_area")
2203
2204
2205 class VIEW3D_PT_view3d_curvedisplay(Panel):
2206     bl_space_type = 'VIEW_3D'
2207     bl_region_type = 'UI'
2208     bl_label = "Curve Display"
2209
2210     @classmethod
2211     def poll(cls, context):
2212         editmesh = context.mode == 'EDIT_CURVE'
2213         return (editmesh)
2214
2215     def draw(self, context):
2216         layout = self.layout
2217
2218         curve = context.active_object.data
2219
2220         col = layout.column()
2221         col.label(text="Overlays:")
2222         col.prop(curve, "show_handles", text="Handles")
2223         col.prop(curve, "show_normal_face", text="Normals")
2224         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2225
2226
2227 class VIEW3D_PT_background_image(Panel):
2228     bl_space_type = 'VIEW_3D'
2229     bl_region_type = 'UI'
2230     bl_label = "Background Images"
2231     bl_options = {'DEFAULT_CLOSED'}
2232
2233     @classmethod
2234     def poll(cls, context):
2235         view = context.space_data
2236         #~ bg = context.space_data.background_image
2237         return (view)
2238
2239     def draw_header(self, context):
2240         layout = self.layout
2241         view = context.space_data
2242
2243         layout.prop(view, "show_background_images", text="")
2244
2245     def draw(self, context):
2246         layout = self.layout
2247
2248         view = context.space_data
2249
2250         col = layout.column()
2251         col.operator("view3d.background_image_add", text="Add Image")
2252
2253         for i, bg in enumerate(view.background_images):
2254             layout.active = view.show_background_images
2255             box = layout.box()
2256             row = box.row(align=True)
2257             row.prop(bg, "show_expanded", text="", emboss=False)
2258             if bg.image:
2259                 row.prop(bg.image, "name", text="", emboss=False)
2260             else:
2261                 row.label(text="Not Set")
2262             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2263
2264             box.prop(bg, "view_axis", text="Axis")
2265
2266             if bg.show_expanded:
2267                 row = box.row()
2268                 row.template_ID(bg, "image", open="image.open")
2269                 if (bg.image):
2270                     box.template_image(bg, "image", bg.image_user, compact=True)
2271
2272                     box.prop(bg, "opacity", slider=True)
2273                     if bg.view_axis != 'CAMERA':
2274                         box.prop(bg, "size")
2275                         row = box.row(align=True)
2276                         row.prop(bg, "offset_x", text="X")
2277                         row.prop(bg, "offset_y", text="Y")
2278
2279
2280 class VIEW3D_PT_transform_orientations(Panel):
2281     bl_space_type = 'VIEW_3D'
2282     bl_region_type = 'UI'
2283     bl_label = "Transform Orientations"
2284     bl_options = {'DEFAULT_CLOSED'}
2285
2286     @classmethod
2287     def poll(cls, context):
2288         view = context.space_data
2289         return (view)
2290
2291     def draw(self, context):
2292         layout = self.layout
2293
2294         view = context.space_data
2295
2296         col = layout.column()
2297
2298         col.prop(view, "transform_orientation")
2299         col.operator("transform.create_orientation", text="Create")
2300
2301         orientation = view.current_orientation
2302
2303         if orientation:
2304             col.prop(orientation, "name")
2305             col.operator("transform.delete_orientation", text="Delete")
2306
2307
2308 class VIEW3D_PT_etch_a_ton(Panel):
2309     bl_space_type = 'VIEW_3D'
2310     bl_region_type = 'UI'
2311     bl_label = "Skeleton Sketching"
2312     bl_options = {'DEFAULT_CLOSED'}
2313
2314     @classmethod
2315     def poll(cls, context):
2316         scene = context.space_data
2317         ob = context.active_object
2318         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2319
2320     def draw_header(self, context):
2321         layout = self.layout
2322         toolsettings = context.scene.tool_settings
2323
2324         layout.prop(toolsettings, "use_bone_sketching", text="")
2325
2326     def draw(self, context):
2327         layout = self.layout
2328         toolsettings = context.scene.tool_settings
2329
2330         col = layout.column()
2331
2332         col.prop(toolsettings, "use_etch_quick")
2333         col.prop(toolsettings, "use_etch_overdraw")
2334
2335         col.prop(toolsettings, "etch_convert_mode")
2336
2337         if toolsettings.etch_convert_mode == 'LENGTH':
2338             col.prop(toolsettings, "etch_length_limit")
2339         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2340             col.prop(toolsettings, "etch_adaptive_limit")
2341         elif toolsettings.etch_convert_mode == 'FIXED':
2342             col.prop(toolsettings, "etch_subdivision_number")
2343         elif toolsettings.etch_convert_mode == 'RETARGET':
2344             col.prop(toolsettings, "etch_template")
2345             col.prop(toolsettings, "etch_roll_mode")
2346             col.prop(toolsettings, "use_etch_autoname")
2347             col.prop(toolsettings, "etch_number")
2348             col.prop(toolsettings, "etch_side")
2349
2350         col.operator("sketch.convert", text="Convert")
2351
2352
2353 class VIEW3D_PT_context_properties(Panel):
2354     bl_space_type = 'VIEW_3D'
2355     bl_region_type = 'UI'
2356     bl_label = "Properties"
2357     bl_options = {'DEFAULT_CLOSED'}
2358
2359     def _active_context_member(context):
2360         obj = context.object
2361         if obj:
2362             mode = obj.mode
2363             if mode == 'POSE':
2364                 return "active_pose_bone"
2365             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2366                 return "active_bone"
2367             else:
2368                 return "object"
2369
2370         return ""
2371
2372     @classmethod
2373     def poll(cls, context):
2374         member = cls._active_context_member(context)
2375         if member:
2376             context_member = getattr(context, member)
2377             return context_member and context_member.keys()
2378
2379         return False
2380
2381     def draw(self, context):
2382         import rna_prop_ui
2383         member = VIEW3D_PT_context_properties._active_context_member(context)
2384
2385         if member:
2386             # Draw with no edit button
2387             rna_prop_ui.draw(self.layout, context, member, object, False)
2388
2389
2390 def register():
2391     bpy.utils.register_module(__name__)
2392
2393
2394 def unregister():
2395     bpy.utils.unregister_module(__name__)
2396
2397 if __name__ == "__main__":
2398     register()
2399
2400 if __name__ == "__main__":  # only for live edit.
2401     bpy.utils.register_module(__name__)