svn merge ^/trunk/blender -r43381:43392
[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         # Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
58         row = layout
59         layout.template_header_3D()
60
61         if obj:
62             # Particle edit
63             if obj.mode == 'PARTICLE_EDIT':
64                 row.prop(toolsettings.particle_edit, "select_mode", text="", expand=True)
65
66             # Occlude geometry
67             if view.viewport_shade in {'SOLID', 'SHADED', 'TEXTURED'} and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
68                 row.prop(view, "use_occlude_geometry", text="")
69
70             # Proportional editing
71             if obj.mode in {'EDIT', 'PARTICLE_EDIT'}:
72                 row = layout.row(align=True)
73                 row.prop(toolsettings, "proportional_edit", text="", icon_only=True)
74                 if toolsettings.proportional_edit != 'DISABLED':
75                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
76             elif obj.mode == 'OBJECT':
77                 row = layout.row(align=True)
78                 row.prop(toolsettings, "use_proportional_edit_objects", text="", icon_only=True)
79                 if toolsettings.use_proportional_edit_objects:
80                     row.prop(toolsettings, "proportional_edit_falloff", text="", icon_only=True)
81
82         # Snap
83         snap_element = toolsettings.snap_element
84         row = layout.row(align=True)
85         row.prop(toolsettings, "use_snap", text="")
86         row.prop(toolsettings, "snap_element", text="", icon_only=True)
87         if snap_element != 'INCREMENT':
88             row.prop(toolsettings, "snap_target", text="")
89             if obj:
90                 if obj.mode == 'OBJECT':
91                     row.prop(toolsettings, "use_snap_align_rotation", text="")
92                 elif obj.mode == 'EDIT':
93                     row.prop(toolsettings, "use_snap_self", text="")
94
95         if snap_element == 'VOLUME':
96             row.prop(toolsettings, "use_snap_peel_object", text="")
97         elif snap_element == 'FACE':
98             row.prop(toolsettings, "use_snap_project", text="")
99
100         # OpenGL render
101         row = layout.row(align=True)
102         row.operator("render.opengl", text="", icon='RENDER_STILL')
103         props = row.operator("render.opengl", text="", icon='RENDER_ANIMATION')
104         props.animation = True
105
106         # Pose
107         if obj and obj.mode == 'POSE':
108             row = layout.row(align=True)
109             row.operator("pose.copy", text="", icon='COPYDOWN')
110             row.operator("pose.paste", text="", icon='PASTEDOWN')
111             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
112             props.flipped = 1
113
114
115 # ********** Menu **********
116
117 # ********** Utilities **********
118
119
120 class ShowHideMenu():
121     bl_label = "Show/Hide"
122     _operator_name = ""
123
124     def draw(self, context):
125         layout = self.layout
126
127         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
128         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
129         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
130
131
132 class VIEW3D_MT_transform(Menu):
133     bl_label = "Transform"
134
135     # TODO: get rid of the custom text strings?
136     def draw(self, context):
137         layout = self.layout
138
139         layout.operator("transform.translate", text="Grab/Move")
140         # TODO: sub-menu for grab per axis
141         layout.operator("transform.rotate", text="Rotate")
142         # TODO: sub-menu for rot per axis
143         layout.operator("transform.resize", text="Scale")
144         # TODO: sub-menu for scale per axis
145
146         layout.separator()
147
148         layout.operator("transform.tosphere", text="To Sphere")
149         layout.operator("transform.shear", text="Shear")
150         layout.operator("transform.warp", text="Warp")
151         layout.operator("transform.push_pull", text="Push/Pull")
152
153         layout.separator()
154
155         layout.operator("transform.translate", text="Move Texture Space").texture_space = True
156         layout.operator("transform.resize", text="Scale Texture Space").texture_space = True
157
158         layout.separator()
159
160         obj = context.object
161         if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}:
162             layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE'
163
164         if context.edit_object and context.edit_object.type == 'ARMATURE':
165             layout.operator("armature.align")
166         else:
167             layout.operator_context = 'EXEC_REGION_WIN'
168             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN'  # XXX see alignmenu() in edit.c of b2.4x to get this working
169
170         layout.separator()
171
172         layout.operator_context = 'EXEC_AREA'
173
174         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
175         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
176         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
177
178         layout.separator()
179
180         layout.operator("object.randomize_transform")
181         layout.operator("object.align")
182
183         layout.separator()
184
185         layout.operator("object.anim_transforms_to_deltas")
186
187
188 class VIEW3D_MT_mirror(Menu):
189     bl_label = "Mirror"
190
191     def draw(self, context):
192         layout = self.layout
193
194         layout.operator("transform.mirror", text="Interactive Mirror")
195
196         layout.separator()
197
198         layout.operator_context = 'INVOKE_REGION_WIN'
199
200         props = layout.operator("transform.mirror", text="X Global")
201         props.constraint_axis = (True, False, False)
202         props.constraint_orientation = 'GLOBAL'
203         props = layout.operator("transform.mirror", text="Y Global")
204         props.constraint_axis = (False, True, False)
205         props.constraint_orientation = 'GLOBAL'
206         props = layout.operator("transform.mirror", text="Z Global")
207         props.constraint_axis = (False, False, True)
208         props.constraint_orientation = 'GLOBAL'
209
210         if context.edit_object:
211             layout.separator()
212
213             props = layout.operator("transform.mirror", text="X Local")
214             props.constraint_axis = (True, False, False)
215             props.constraint_orientation = 'LOCAL'
216             props = layout.operator("transform.mirror", text="Y Local")
217             props.constraint_axis = (False, True, False)
218             props.constraint_orientation = 'LOCAL'
219             props = layout.operator("transform.mirror", text="Z Local")
220             props.constraint_axis = (False, False, True)
221             props.constraint_orientation = 'LOCAL'
222
223             layout.operator("object.vertex_group_mirror")
224
225
226 class VIEW3D_MT_snap(Menu):
227     bl_label = "Snap"
228
229     def draw(self, context):
230         layout = self.layout
231
232         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
233         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
234
235         layout.separator()
236
237         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
238         layout.operator("view3d.snap_cursor_to_center", text="Cursor to Center")
239         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
240         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
241
242
243 class VIEW3D_MT_uv_map(Menu):
244     bl_label = "UV Mapping"
245
246     def draw(self, context):
247         layout = self.layout
248
249         layout.operator("uv.unwrap")
250
251         layout.operator_context = 'INVOKE_DEFAULT'
252         layout.operator("uv.smart_project")
253         layout.operator("uv.lightmap_pack")
254         layout.operator("uv.follow_active_quads")
255
256         layout.separator()
257
258         layout.operator_context = 'EXEC_REGION_WIN'
259         layout.operator("uv.cube_project")
260         layout.operator("uv.cylinder_project")
261         layout.operator("uv.sphere_project")
262
263         layout.separator()
264
265         layout.operator_context = 'EXEC_REGION_WIN'
266         layout.operator("uv.project_from_view").scale_to_bounds = False
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.camera_to_view_selected", text="Align Active Camera to Selected")
371         layout.operator("view3d.view_selected")
372         layout.operator("view3d.view_center_cursor")
373
374
375 class VIEW3D_MT_view_align_selected(Menu):
376     bl_label = "Align View to Selected"
377
378     def draw(self, context):
379         layout = self.layout
380
381         props = layout.operator("view3d.viewnumpad", text="Top")
382         props.align_active = True
383         props.type = 'TOP'
384         props = layout.operator("view3d.viewnumpad", text="Bottom")
385         props.align_active = True
386         props.type = 'BOTTOM'
387         props = layout.operator("view3d.viewnumpad", text="Front")
388         props.align_active = True
389         props.type = 'FRONT'
390         props = layout.operator("view3d.viewnumpad", text="Back")
391         props.align_active = True
392         props.type = 'BACK'
393         props = layout.operator("view3d.viewnumpad", text="Right")
394         props.align_active = True
395         props.type = 'RIGHT'
396         props = layout.operator("view3d.viewnumpad", text="Left")
397         props.align_active = True
398         props.type = 'LEFT'
399
400
401 class VIEW3D_MT_view_cameras(Menu):
402     bl_label = "Cameras"
403
404     def draw(self, context):
405         layout = self.layout
406
407         layout.operator("view3d.object_as_camera")
408         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
409
410 # ********** Select menus, suffix from context.mode **********
411
412
413 class VIEW3D_MT_select_object(Menu):
414     bl_label = "Select"
415
416     def draw(self, context):
417         layout = self.layout
418
419         layout.operator("view3d.select_border")
420         layout.operator("view3d.select_circle")
421
422         layout.separator()
423
424         layout.operator("object.select_all", text="Select/Deselect All").action = 'TOGGLE'
425         layout.operator("object.select_all", text="Inverse").action = 'INVERT'
426         layout.operator("object.select_random", text="Random")
427         layout.operator("object.select_mirror", text="Mirror")
428         layout.operator("object.select_by_layer", text="Select All by Layer")
429         layout.operator_menu_enum("object.select_by_type", "type", text="Select All by Type...")
430         layout.operator("object.select_camera", text="Select Camera")
431
432         layout.separator()
433
434         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
435         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
436         layout.operator("object.select_pattern", text="Select Pattern...")
437
438
439 class VIEW3D_MT_select_pose(Menu):
440     bl_label = "Select"
441
442     def draw(self, context):
443         layout = self.layout
444
445         layout.operator("view3d.select_border")
446
447         layout.separator()
448
449         layout.operator("pose.select_all", text="Select/Deselect All").action = 'TOGGLE'
450         layout.operator("pose.select_all", text="Inverse").action = 'INVERT'
451         layout.operator("pose.select_flip_active", text="Flip Active")
452         layout.operator("pose.select_constraint_target", text="Constraint Target")
453         layout.operator("pose.select_linked", text="Linked")
454
455         layout.separator()
456
457         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
458         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
459
460         layout.separator()
461
462         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
463         props.extend = True
464         props.direction = 'PARENT'
465
466         props = layout.operator("pose.select_hierarchy", text="Extend Child")
467         props.extend = True
468         props.direction = 'CHILD'
469
470         layout.separator()
471
472         layout.operator_menu_enum("pose.select_grouped", "type", text="Grouped")
473         layout.operator("object.select_pattern", text="Select Pattern...")
474
475
476 class VIEW3D_MT_select_particle(Menu):
477     bl_label = "Select"
478
479     def draw(self, context):
480         layout = self.layout
481
482         layout.operator("view3d.select_border")
483
484         layout.separator()
485
486         layout.operator("particle.select_all", text="Select/Deselect All").action = 'TOGGLE'
487         layout.operator("particle.select_linked")
488         layout.operator("particle.select_all").action = 'INVERT'
489
490         layout.separator()
491
492         layout.operator("particle.select_more")
493         layout.operator("particle.select_less")
494
495         layout.separator()
496
497         layout.operator("particle.select_roots", text="Roots")
498         layout.operator("particle.select_tips", text="Tips")
499
500
501 class VIEW3D_MT_select_edit_mesh(Menu):
502     bl_label = "Select"
503
504     def draw(self, context):
505         layout = self.layout
506
507         layout.operator("view3d.select_border")
508         layout.operator("view3d.select_circle")
509
510         layout.separator()
511
512         layout.operator("mesh.select_all", text="Select/Deselect All").action = 'TOGGLE'
513         layout.operator("mesh.select_all", text="Inverse").action = 'INVERT'
514
515         layout.separator()
516
517         layout.operator("mesh.select_random", text="Random")
518         layout.operator("mesh.select_nth", text="Every N Number of Verts")
519         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
520         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
521         layout.operator("mesh.faces_select_interior", text="Interior Faces")
522         layout.operator("mesh.select_axis", text="Side of Active")
523
524         layout.separator()
525
526         layout.operator("mesh.select_by_number_vertices", text = "By Number of Verts")
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_loose_verts", text = "Loose Verts/Edges")
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").ring = False
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").action = 'TOGGLE'
564         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
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").action = 'TOGGLE'
593         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
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_all").action = 'INVERT'
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").action = 'TOGGLE'
649         layout.operator("armature.select_all", text="Inverse").action = 'INVERT'
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 ("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         props = layout.operator("object.transform_apply", text="Location")
868         props.location, props.rotation, props.scale = True, False, False
869
870         props = layout.operator("object.transform_apply", text="Rotation")
871         props.location, props.rotation, props.scale = False, True, False
872
873         props = layout.operator("object.transform_apply", text="Scale")
874         props.location, props.rotation, props.scale = False, False, True
875         props = layout.operator("object.transform_apply", text="Rotation & Scale")
876         props.location, props.rotation, props.scale = False, True, True
877
878         layout.separator()
879
880         layout.operator("object.visual_transform_apply", text="Visual Transform")
881         layout.operator("object.duplicates_make_real")
882
883
884 class VIEW3D_MT_object_parent(Menu):
885     bl_label = "Parent"
886
887     def draw(self, context):
888         layout = self.layout
889
890         layout.operator_menu_enum("object.parent_set", "type", text="Set")
891         layout.operator_menu_enum("object.parent_clear", "type", text="Clear")
892
893
894 class VIEW3D_MT_object_track(Menu):
895     bl_label = "Track"
896
897     def draw(self, context):
898         layout = self.layout
899
900         layout.operator_menu_enum("object.track_set", "type", text="Set")
901         layout.operator_menu_enum("object.track_clear", "type", text="Clear")
902
903
904 class VIEW3D_MT_object_group(Menu):
905     bl_label = "Group"
906
907     def draw(self, context):
908         layout = self.layout
909
910         layout.operator("group.create")
911         layout.operator("group.objects_remove")
912
913         layout.separator()
914
915         layout.operator("group.objects_add_active")
916         layout.operator("group.objects_remove_active")
917
918
919 class VIEW3D_MT_object_constraints(Menu):
920     bl_label = "Constraints"
921
922     def draw(self, context):
923         layout = self.layout
924
925         layout.operator("object.constraint_add_with_targets")
926         layout.operator("object.constraints_copy")
927         layout.operator("object.constraints_clear")
928
929
930 class VIEW3D_MT_object_quick_effects(Menu):
931     bl_label = "Quick Effects"
932
933     def draw(self, context):
934         layout = self.layout
935
936         layout.operator("object.quick_fur")
937         layout.operator("object.quick_explode")
938         layout.operator("object.quick_smoke")
939         layout.operator("object.quick_fluid")
940
941
942 class VIEW3D_MT_object_showhide(Menu):
943     bl_label = "Show/Hide"
944
945     def draw(self, context):
946         layout = self.layout
947
948         layout.operator("object.hide_view_clear", text="Show Hidden")
949         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
950         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
951
952
953 class VIEW3D_MT_make_single_user(Menu):
954     bl_label = "Make Single User"
955
956     def draw(self, context):
957         layout = self.layout
958
959         props = layout.operator("object.make_single_user", text="Object")
960         props.object = True
961
962         props = layout.operator("object.make_single_user", text="Object & Data")
963         props.object = props.obdata = True
964
965         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
966         props.object = props.obdata = props.material = props.texture = True
967
968         props = layout.operator("object.make_single_user", text="Materials+Tex")
969         props.material = props.texture = True
970
971         props = layout.operator("object.make_single_user", text="Object Animation")
972         props.animation = True
973
974
975 class VIEW3D_MT_make_links(Menu):
976     bl_label = "Make Links"
977
978     def draw(self, context):
979         layout = self.layout
980
981         if(len(bpy.data.scenes) > 10):
982             layout.operator_context = 'INVOKE_DEFAULT'
983             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
984         else:
985             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
986
987         layout.operator_enum("object.make_links_data", "type")  # inline
988
989         layout.operator("object.join_uvs")  # stupid place to add this!
990
991
992 class VIEW3D_MT_object_game(Menu):
993     bl_label = "Game"
994
995     def draw(self, context):
996         layout = self.layout
997
998         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
999         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1000
1001         layout.separator()
1002
1003         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1004         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1005         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1006
1007         layout.separator()
1008
1009         layout.operator("object.game_property_clear")
1010
1011
1012 # ********** Vertex paint menu **********
1013
1014
1015 class VIEW3D_MT_paint_vertex(Menu):
1016     bl_label = "Paint"
1017
1018     def draw(self, context):
1019         layout = self.layout
1020
1021         layout.operator("ed.undo")
1022         layout.operator("ed.redo")
1023
1024         layout.separator()
1025
1026         layout.operator("paint.vertex_color_set")
1027         layout.operator("paint.vertex_color_dirt")
1028
1029
1030 class VIEW3D_MT_hook(Menu):
1031     bl_label = "Hooks"
1032
1033     def draw(self, context):
1034         layout = self.layout
1035         layout.operator_context = 'EXEC_AREA'
1036         layout.operator("object.hook_add_newob")
1037         layout.operator("object.hook_add_selob")
1038
1039         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1040             layout.separator()
1041             layout.operator_menu_enum("object.hook_assign", "modifier")
1042             layout.operator_menu_enum("object.hook_remove", "modifier")
1043             layout.separator()
1044             layout.operator_menu_enum("object.hook_select", "modifier")
1045             layout.operator_menu_enum("object.hook_reset", "modifier")
1046             layout.operator_menu_enum("object.hook_recenter", "modifier")
1047
1048
1049 class VIEW3D_MT_vertex_group(Menu):
1050     bl_label = "Vertex Groups"
1051
1052     def draw(self, context):
1053         layout = self.layout
1054         layout.operator_context = 'EXEC_AREA'
1055         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1056
1057         ob = context.active_object
1058         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1059             if ob.vertex_groups.active:
1060                 layout.separator()
1061                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1062                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1063                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1064                 layout.separator()
1065
1066         if ob.vertex_groups.active:
1067             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1068             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1069             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1070
1071 # ********** Weight paint menu **********
1072
1073
1074 class VIEW3D_MT_paint_weight(Menu):
1075     bl_label = "Weights"
1076
1077     def draw(self, context):
1078         layout = self.layout
1079
1080         layout.operator("ed.undo")
1081         layout.operator("ed.redo")
1082         layout.operator("ed.undo_history")
1083
1084         layout.separator()
1085
1086         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1087         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1088
1089         layout.separator()
1090
1091         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1092         layout.operator("object.vertex_group_normalize", text="Normalize")
1093         layout.operator("object.vertex_group_mirror", text="Mirror")
1094         layout.operator("object.vertex_group_invert", text="Invert")
1095         layout.operator("object.vertex_group_clean", text="Clean")
1096         layout.operator("object.vertex_group_levels", text="Levels")
1097         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1098
1099         layout.separator()
1100
1101         layout.operator("paint.weight_set")
1102
1103 # ********** Sculpt menu **********
1104
1105
1106 class VIEW3D_MT_sculpt(Menu):
1107     bl_label = "Sculpt"
1108
1109     def draw(self, context):
1110         layout = self.layout
1111
1112         tool_settings = context.tool_settings
1113         sculpt = tool_settings.sculpt
1114         brush = tool_settings.sculpt.brush
1115
1116         layout.operator("ed.undo")
1117         layout.operator("ed.redo")
1118
1119         layout.separator()
1120
1121         layout.prop(sculpt, "use_symmetry_x")
1122         layout.prop(sculpt, "use_symmetry_y")
1123         layout.prop(sculpt, "use_symmetry_z")
1124         layout.separator()
1125         layout.prop(sculpt, "lock_x")
1126         layout.prop(sculpt, "lock_y")
1127         layout.prop(sculpt, "lock_z")
1128         layout.separator()
1129         layout.operator_menu_enum("brush.curve_preset", "shape")
1130         layout.separator()
1131
1132         if brush is not None:  # unlikely but can happen
1133             sculpt_tool = brush.sculpt_tool
1134
1135             if sculpt_tool != 'GRAB':
1136                 layout.prop_menu_enum(brush, "stroke_method")
1137
1138                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1139                     layout.prop_menu_enum(brush, "direction")
1140
1141                 if sculpt_tool == 'LAYER':
1142                     layout.prop(brush, "use_persistent")
1143                     layout.operator("sculpt.set_persistent_base")
1144
1145         layout.separator()
1146         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1147         layout.prop(sculpt, "show_brush")
1148
1149         # TODO, make available from paint menu!
1150         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Unify Size")
1151         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Unify Strength")
1152
1153 # ********** Particle menu **********
1154
1155
1156 class VIEW3D_MT_particle(Menu):
1157     bl_label = "Particle"
1158
1159     def draw(self, context):
1160         layout = self.layout
1161
1162         particle_edit = context.tool_settings.particle_edit
1163
1164         layout.operator("ed.undo")
1165         layout.operator("ed.redo")
1166         layout.operator("ed.undo_history")
1167
1168         layout.separator()
1169
1170         layout.operator("particle.mirror")
1171
1172         layout.separator()
1173
1174         layout.operator("particle.remove_doubles")
1175         layout.operator("particle.delete")
1176
1177         if particle_edit.select_mode == 'POINT':
1178             layout.operator("particle.subdivide")
1179
1180         layout.operator("particle.rekey")
1181         layout.operator("particle.weight_set")
1182
1183         layout.separator()
1184
1185         layout.menu("VIEW3D_MT_particle_showhide")
1186
1187
1188 class VIEW3D_MT_particle_specials(Menu):
1189     bl_label = "Specials"
1190
1191     def draw(self, context):
1192         layout = self.layout
1193         particle_edit = context.tool_settings.particle_edit
1194
1195         layout.operator("particle.rekey")
1196
1197         layout.separator()
1198         if particle_edit.select_mode == 'POINT':
1199             layout.operator("particle.subdivide")
1200             layout.operator("particle.select_roots")
1201             layout.operator("particle.select_tips")
1202
1203         layout.operator("particle.remove_doubles")
1204
1205
1206 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1207     _operator_name = "particle"
1208
1209 # ********** Pose Menu **********
1210
1211
1212 class VIEW3D_MT_pose(Menu):
1213     bl_label = "Pose"
1214
1215     def draw(self, context):
1216         layout = self.layout
1217
1218         layout.operator("ed.undo")
1219         layout.operator("ed.redo")
1220         layout.operator("ed.undo_history")
1221
1222         layout.separator()
1223
1224         layout.menu("VIEW3D_MT_transform")
1225
1226         layout.menu("VIEW3D_MT_pose_transform")
1227         layout.menu("VIEW3D_MT_pose_apply")
1228
1229         layout.menu("VIEW3D_MT_snap")
1230
1231         layout.separator()
1232
1233         layout.menu("VIEW3D_MT_object_animation")
1234
1235         layout.separator()
1236
1237         layout.menu("VIEW3D_MT_pose_slide")
1238         layout.menu("VIEW3D_MT_pose_propagate")
1239
1240         layout.separator()
1241
1242         layout.operator("pose.copy")
1243         layout.operator("pose.paste")
1244         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1245
1246         layout.separator()
1247
1248         layout.menu("VIEW3D_MT_pose_library")
1249         layout.menu("VIEW3D_MT_pose_motion")
1250         layout.menu("VIEW3D_MT_pose_group")
1251
1252         layout.separator()
1253
1254         layout.menu("VIEW3D_MT_object_parent")
1255         layout.menu("VIEW3D_MT_pose_ik")
1256         layout.menu("VIEW3D_MT_pose_constraints")
1257
1258         layout.separator()
1259
1260         layout.operator_context = 'EXEC_AREA'
1261         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1262         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1263         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1264
1265         layout.operator("pose.flip_names")
1266
1267         layout.operator("pose.quaternions_flip")
1268
1269         layout.separator()
1270
1271         layout.operator_context = 'INVOKE_AREA'
1272         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1273         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1274
1275         layout.separator()
1276
1277         layout.menu("VIEW3D_MT_pose_showhide")
1278         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1279
1280
1281 class VIEW3D_MT_pose_transform(Menu):
1282     bl_label = "Clear Transform"
1283
1284     def draw(self, context):
1285         layout = self.layout
1286
1287         layout.operator("pose.transforms_clear", text="All")
1288
1289         layout.separator()
1290
1291         layout.operator("pose.loc_clear", text="Location")
1292         layout.operator("pose.rot_clear", text="Rotation")
1293         layout.operator("pose.scale_clear", text="Scale")
1294
1295         layout.separator()
1296
1297         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1298
1299
1300 class VIEW3D_MT_pose_slide(Menu):
1301     bl_label = "In-Betweens"
1302
1303     def draw(self, context):
1304         layout = self.layout
1305
1306         layout.operator("pose.push")
1307         layout.operator("pose.relax")
1308         layout.operator("pose.breakdown")
1309
1310
1311 class VIEW3D_MT_pose_propagate(Menu):
1312     bl_label = "Propagate"
1313
1314     def draw(self, context):
1315         layout = self.layout
1316
1317         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1318
1319         layout.separator()
1320
1321         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1322         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1323
1324         layout.separator()
1325
1326         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1327
1328
1329 class VIEW3D_MT_pose_library(Menu):
1330     bl_label = "Pose Library"
1331
1332     def draw(self, context):
1333         layout = self.layout
1334
1335         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1336
1337         layout.separator()
1338
1339         layout.operator("poselib.pose_add", text="Add Pose...")
1340         layout.operator("poselib.pose_rename", text="Rename Pose...")
1341         layout.operator("poselib.pose_remove", text="Remove Pose...")
1342
1343
1344 class VIEW3D_MT_pose_motion(Menu):
1345     bl_label = "Motion Paths"
1346
1347     def draw(self, context):
1348         layout = self.layout
1349
1350         layout.operator("pose.paths_calculate", text="Calculate")
1351         layout.operator("pose.paths_clear", text="Clear")
1352
1353
1354 class VIEW3D_MT_pose_group(Menu):
1355     bl_label = "Bone Groups"
1356
1357     def draw(self, context):
1358         layout = self.layout
1359         layout.operator("pose.group_add")
1360         layout.operator("pose.group_remove")
1361
1362         layout.separator()
1363
1364         layout.operator("pose.group_assign")
1365         layout.operator("pose.group_unassign")
1366
1367
1368 class VIEW3D_MT_pose_ik(Menu):
1369     bl_label = "Inverse Kinematics"
1370
1371     def draw(self, context):
1372         layout = self.layout
1373
1374         layout.operator("pose.ik_add")
1375         layout.operator("pose.ik_clear")
1376
1377
1378 class VIEW3D_MT_pose_constraints(Menu):
1379     bl_label = "Constraints"
1380
1381     def draw(self, context):
1382         layout = self.layout
1383
1384         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1385         layout.operator("pose.constraints_copy")
1386         layout.operator("pose.constraints_clear")
1387
1388
1389 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1390     _operator_name = "pose"
1391
1392
1393 class VIEW3D_MT_pose_apply(Menu):
1394     bl_label = "Apply"
1395
1396     def draw(self, context):
1397         layout = self.layout
1398
1399         layout.operator("pose.armature_apply")
1400         layout.operator("pose.visual_transform_apply")
1401
1402
1403 class BoneOptions:
1404     def draw(self, context):
1405         layout = self.layout
1406
1407         options = [
1408             "show_wire",
1409             "use_deform",
1410             "use_envelope_multiply",
1411             "use_inherit_rotation",
1412             "use_inherit_scale",
1413         ]
1414
1415         if context.mode == 'EDIT_ARMATURE':
1416             bone_props = bpy.types.EditBone.bl_rna.properties
1417             data_path_iter = "selected_bones"
1418             opt_suffix = ""
1419             options.append("lock")
1420         else:  # pose-mode
1421             bone_props = bpy.types.Bone.bl_rna.properties
1422             data_path_iter = "selected_pose_bones"
1423             opt_suffix = "bone."
1424
1425         for opt in options:
1426             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1427             props.data_path_iter = data_path_iter
1428             props.data_path_item = opt_suffix + opt
1429             props.type = self.type
1430
1431
1432 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1433     bl_label = "Toggle Bone Options"
1434     type = 'TOGGLE'
1435
1436
1437 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1438     bl_label = "Enable Bone Options"
1439     type = 'ENABLE'
1440
1441
1442 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1443     bl_label = "Disable Bone Options"
1444     type = 'DISABLE'
1445
1446 # ********** Edit Menus, suffix from ob.type **********
1447
1448
1449 class VIEW3D_MT_edit_mesh(Menu):
1450     bl_label = "Mesh"
1451
1452     def draw(self, context):
1453         layout = self.layout
1454
1455         settings = context.tool_settings
1456
1457         layout.operator("ed.undo")
1458         layout.operator("ed.redo")
1459         layout.operator("ed.undo_history")
1460
1461         layout.separator()
1462
1463         layout.menu("VIEW3D_MT_transform")
1464         layout.menu("VIEW3D_MT_mirror")
1465         layout.menu("VIEW3D_MT_snap")
1466
1467         layout.separator()
1468
1469         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1470
1471         layout.separator()
1472
1473         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1474         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1475         layout.operator("mesh.duplicate_move")
1476         layout.operator("mesh.delete", text="Delete...")
1477
1478         layout.separator()
1479
1480         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1481         layout.menu("VIEW3D_MT_edit_mesh_edges")
1482         layout.menu("VIEW3D_MT_edit_mesh_faces")
1483         layout.menu("VIEW3D_MT_edit_mesh_normals")
1484
1485         layout.separator()
1486
1487         layout.prop(settings, "use_mesh_automerge")
1488         layout.prop_menu_enum(settings, "proportional_edit")
1489         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1490
1491         layout.separator()
1492
1493         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1494
1495
1496 class VIEW3D_MT_edit_mesh_specials(Menu):
1497     bl_label = "Specials"
1498
1499     def draw(self, context):
1500         layout = self.layout
1501
1502         layout.operator_context = 'INVOKE_REGION_WIN'
1503
1504         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1505         """
1506         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1507         """
1508         layout.operator("mesh.merge", text="Merge...")
1509         layout.operator("mesh.remove_doubles")
1510         layout.operator("mesh.hide", text="Hide")
1511         layout.operator("mesh.reveal", text="Reveal")
1512         layout.operator("mesh.select_all").action = 'INVERT'
1513         layout.operator("mesh.flip_normals")
1514         layout.operator("mesh.vertices_smooth", text="Smooth")
1515         layout.operator("mesh.bevel", text="Bevel")
1516         layout.operator("mesh.faces_shade_smooth")
1517         layout.operator("mesh.faces_shade_flat")
1518         layout.operator("mesh.blend_from_shape")
1519         layout.operator("mesh.shape_propagate_to_all")
1520         layout.operator("mesh.select_vertex_path")
1521
1522
1523 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1524     bl_label = "Mesh Select Mode"
1525
1526     def draw(self, context):
1527         layout = self.layout
1528
1529         layout.operator_context = 'INVOKE_REGION_WIN'
1530
1531         props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1532         props.value = "(True, False, False)"
1533         props.data_path = "tool_settings.mesh_select_mode"
1534
1535         props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1536         props.value = "(False, True, False)"
1537         props.data_path = "tool_settings.mesh_select_mode"
1538
1539         props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1540         props.value = "(False, False, True)"
1541         props.data_path = "tool_settings.mesh_select_mode"
1542
1543
1544 class VIEW3D_MT_edit_mesh_extrude(Menu):
1545     bl_label = "Extrude"
1546
1547     _extrude_funcs = {
1548         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1549         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1550         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1551         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1552     }
1553
1554     @staticmethod
1555     def extrude_options(context):
1556         mesh = context.object.data
1557         select_mode = context.tool_settings.mesh_select_mode
1558
1559         menu = []
1560         if mesh.total_face_sel:
1561             menu += ['REGION', 'FACE']
1562         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1563             menu += ['EDGE']
1564         if mesh.total_vert_sel and select_mode[0]:
1565             menu += ['VERT']
1566
1567         # should never get here
1568         return menu
1569
1570     def draw(self, context):
1571         layout = self.layout
1572         layout.operator_context = 'INVOKE_REGION_WIN'
1573
1574         for menu_id in self.extrude_options(context):
1575             self._extrude_funcs[menu_id](layout)
1576
1577
1578 class VIEW3D_MT_edit_mesh_vertices(Menu):
1579     bl_label = "Vertices"
1580
1581     def draw(self, context):
1582         layout = self.layout
1583         layout.operator_context = 'INVOKE_REGION_WIN'
1584
1585         layout.operator("mesh.merge")
1586         layout.operator("mesh.rip_move")
1587         layout.operator("mesh.split")
1588         layout.operator("mesh.separate")
1589         layout.operator("mesh.vert_connect")
1590
1591         layout.separator()
1592
1593         layout.operator("mesh.vertices_smooth")
1594         layout.operator("mesh.remove_doubles")
1595         layout.operator("mesh.vertices_sort")
1596         layout.operator("mesh.vertices_randomize")
1597
1598         layout.operator("mesh.select_vertex_path")
1599
1600         layout.operator("mesh.blend_from_shape")
1601
1602         layout.operator("object.vertex_group_blend")
1603         layout.operator("mesh.shape_propagate_to_all")
1604
1605         layout.separator()
1606
1607         layout.menu("VIEW3D_MT_vertex_group")
1608         layout.menu("VIEW3D_MT_hook")
1609
1610
1611 class VIEW3D_MT_edit_mesh_edges(Menu):
1612     bl_label = "Edges"
1613
1614     def draw(self, context):
1615         layout = self.layout
1616         layout.operator_context = 'INVOKE_REGION_WIN'
1617
1618         layout.operator("mesh.edge_face_add")
1619         layout.operator("mesh.subdivide")
1620
1621         layout.separator()
1622
1623         layout.operator("mesh.mark_seam").clear = False
1624         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1625
1626         layout.separator()
1627
1628         layout.operator("mesh.mark_sharp").clear = False
1629         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1630
1631         layout.separator()
1632
1633         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1634         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1635
1636         layout.separator()
1637
1638         layout.operator("mesh.bridge_edge_loops", text="Bridge Two Edge Loops")
1639
1640         layout.separator()
1641
1642         layout.operator("TRANSFORM_OT_edge_slide")
1643         layout.operator("TRANSFORM_OT_edge_crease")
1644         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1645
1646         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1647         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1648
1649         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1650
1651         layout.operator("mesh.loop_to_region")
1652         layout.operator("mesh.region_to_loop")
1653
1654
1655 class VIEW3D_MT_edit_mesh_faces(Menu):
1656     bl_label = "Faces"
1657     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1658
1659     def draw(self, context):
1660         layout = self.layout
1661         layout.operator_context = 'INVOKE_REGION_WIN'
1662
1663         layout.operator("mesh.flip_normals")
1664         # layout.operator("mesh.bevel")
1665         # layout.operator("mesh.bevel")
1666         layout.operator("mesh.edge_face_add")
1667         layout.operator("mesh.fill")
1668         layout.operator("mesh.beautify_fill")
1669         layout.operator("mesh.solidify")
1670         layout.operator("mesh.sort_faces")
1671
1672         layout.separator()
1673
1674         layout.operator("mesh.quads_convert_to_tris")
1675         layout.operator("mesh.tris_convert_to_quads")
1676         layout.operator("mesh.edge_flip")
1677
1678         layout.separator()
1679
1680         layout.operator("mesh.faces_shade_smooth")
1681         layout.operator("mesh.faces_shade_flat")
1682
1683         layout.separator()
1684
1685         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1686         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1687
1688         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1689
1690         layout.separator()
1691
1692         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1693         layout.operator("mesh.uvs_reverse")
1694         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1695         layout.operator("mesh.colors_reverse")
1696
1697
1698 class VIEW3D_MT_edit_mesh_normals(Menu):
1699     bl_label = "Normals"
1700
1701     def draw(self, context):
1702         layout = self.layout
1703
1704         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1705         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1706
1707         layout.separator()
1708
1709         layout.operator("mesh.flip_normals")
1710
1711
1712 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1713     _operator_name = "mesh"
1714
1715 # Edit Curve
1716 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1717
1718
1719 def draw_curve(self, context):
1720     layout = self.layout
1721
1722     settings = context.tool_settings
1723
1724     layout.menu("VIEW3D_MT_transform")
1725     layout.menu("VIEW3D_MT_mirror")
1726     layout.menu("VIEW3D_MT_snap")
1727
1728     layout.separator()
1729
1730     layout.operator("curve.extrude")
1731     layout.operator("curve.duplicate")
1732     layout.operator("curve.separate")
1733     layout.operator("curve.make_segment")
1734     layout.operator("curve.cyclic_toggle")
1735     layout.operator("curve.delete", text="Delete...")
1736
1737     layout.separator()
1738
1739     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1740     layout.menu("VIEW3D_MT_edit_curve_segments")
1741
1742     layout.separator()
1743
1744     layout.prop_menu_enum(settings, "proportional_edit")
1745     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1746
1747     layout.separator()
1748
1749     layout.menu("VIEW3D_MT_edit_curve_showhide")
1750
1751
1752 class VIEW3D_MT_edit_curve(Menu):
1753     bl_label = "Curve"
1754
1755     draw = draw_curve
1756
1757
1758 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1759     bl_label = "Control Points"
1760
1761     def draw(self, context):
1762         layout = self.layout
1763
1764         edit_object = context.edit_object
1765
1766         if edit_object.type == 'CURVE':
1767             layout.operator("transform.tilt")
1768             layout.operator("curve.tilt_clear")
1769             layout.operator("curve.separate")
1770
1771             layout.separator()
1772
1773             layout.operator_menu_enum("curve.handle_type_set", "type")
1774
1775             layout.separator()
1776
1777             layout.menu("VIEW3D_MT_hook")
1778
1779
1780 class VIEW3D_MT_edit_curve_segments(Menu):
1781     bl_label = "Segments"
1782
1783     def draw(self, context):
1784         layout = self.layout
1785
1786         layout.operator("curve.subdivide")
1787         layout.operator("curve.switch_direction")
1788
1789
1790 class VIEW3D_MT_edit_curve_specials(Menu):
1791     bl_label = "Specials"
1792
1793     def draw(self, context):
1794         layout = self.layout
1795
1796         layout.operator("curve.subdivide")
1797         layout.operator("curve.switch_direction")
1798         layout.operator("curve.spline_weight_set")
1799         layout.operator("curve.radius_set")
1800         layout.operator("curve.smooth")
1801         layout.operator("curve.smooth_radius")
1802
1803
1804 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
1805     _operator_name = "curve"
1806
1807
1808 class VIEW3D_MT_edit_surface(Menu):
1809     bl_label = "Surface"
1810
1811     draw = draw_curve
1812
1813
1814 class VIEW3D_MT_edit_font(Menu):
1815     bl_label = "Text"
1816
1817     def draw(self, context):
1818         layout = self.layout
1819
1820         layout.operator("font.file_paste")
1821
1822         layout.separator()
1823
1824         layout.menu("VIEW3D_MT_edit_text_chars")
1825
1826         layout.separator()
1827
1828         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1829         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1830         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1831         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1832
1833
1834 class VIEW3D_MT_edit_text_chars(Menu):
1835     bl_label = "Special Characters"
1836
1837     def draw(self, context):
1838         layout = self.layout
1839
1840         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
1841         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
1842
1843         layout.separator()
1844
1845         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
1846         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
1847         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
1848         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
1849         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
1850         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
1851         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
1852         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
1853         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
1854
1855         layout.separator()
1856
1857         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
1858         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
1859         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
1860
1861         layout.separator()
1862
1863         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
1864         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
1865         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
1866
1867
1868 class VIEW3D_MT_edit_meta(Menu):
1869     bl_label = "Metaball"
1870
1871     def draw(self, context):
1872         layout = self.layout
1873
1874         settings = context.tool_settings
1875
1876         layout.operator("ed.undo")
1877         layout.operator("ed.redo")
1878         layout.operator("ed.undo_history")
1879
1880         layout.separator()
1881
1882         layout.menu("VIEW3D_MT_transform")
1883         layout.menu("VIEW3D_MT_mirror")
1884         layout.menu("VIEW3D_MT_snap")
1885
1886         layout.separator()
1887
1888         layout.operator("mball.delete_metaelems", text="Delete...")
1889         layout.operator("mball.duplicate_metaelems")
1890
1891         layout.separator()
1892
1893         layout.prop_menu_enum(settings, "proportional_edit")
1894         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1895
1896         layout.separator()
1897
1898         layout.menu("VIEW3D_MT_edit_meta_showhide")
1899
1900
1901 class VIEW3D_MT_edit_meta_showhide(Menu):
1902     bl_label = "Show/Hide"
1903
1904     def draw(self, context):
1905         layout = self.layout
1906
1907         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1908         layout.operator("mball.hide_metaelems", text="Hide Selected")
1909         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1910
1911
1912 class VIEW3D_MT_edit_lattice(Menu):
1913     bl_label = "Lattice"
1914
1915     def draw(self, context):
1916         layout = self.layout
1917
1918         settings = context.tool_settings
1919
1920         layout.menu("VIEW3D_MT_transform")
1921         layout.menu("VIEW3D_MT_mirror")
1922         layout.menu("VIEW3D_MT_snap")
1923
1924         layout.separator()
1925
1926         layout.operator("lattice.make_regular")
1927
1928         layout.separator()
1929
1930         layout.prop_menu_enum(settings, "proportional_edit")
1931         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1932
1933
1934 class VIEW3D_MT_edit_armature(Menu):
1935     bl_label = "Armature"
1936
1937     def draw(self, context):
1938         layout = self.layout
1939
1940         edit_object = context.edit_object
1941         arm = edit_object.data
1942
1943         layout.menu("VIEW3D_MT_transform")
1944         layout.menu("VIEW3D_MT_mirror")
1945         layout.menu("VIEW3D_MT_snap")
1946         layout.menu("VIEW3D_MT_edit_armature_roll")
1947
1948         layout.separator()
1949
1950         layout.operator("armature.extrude_move")
1951
1952         if arm.use_mirror_x:
1953             layout.operator("armature.extrude_forked")
1954
1955         layout.operator("armature.duplicate_move")
1956         layout.operator("armature.merge")
1957         layout.operator("armature.fill")
1958         layout.operator("armature.delete")
1959         layout.operator("armature.separate")
1960
1961         layout.separator()
1962
1963         layout.operator("armature.subdivide", text="Subdivide")
1964         layout.operator("armature.switch_direction", text="Switch Direction")
1965
1966         layout.separator()
1967
1968         layout.operator_context = 'EXEC_AREA'
1969         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1970         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1971         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1972         layout.operator("armature.flip_names")
1973
1974         layout.separator()
1975
1976         layout.operator_context = 'INVOKE_DEFAULT'
1977         layout.operator("armature.armature_layers")
1978         layout.operator("armature.bone_layers")
1979
1980         layout.separator()
1981
1982         layout.menu("VIEW3D_MT_edit_armature_parent")
1983
1984         layout.separator()
1985
1986         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1987
1988
1989 class VIEW3D_MT_armature_specials(Menu):
1990     bl_label = "Specials"
1991
1992     def draw(self, context):
1993         layout = self.layout
1994
1995         layout.operator_context = 'INVOKE_REGION_WIN'
1996
1997         layout.operator("armature.subdivide", text="Subdivide")
1998         layout.operator("armature.switch_direction", text="Switch Direction")
1999
2000         layout.separator()
2001
2002         layout.operator_context = 'EXEC_REGION_WIN'
2003         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2004         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2005         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2006         layout.operator("armature.flip_names", text="Flip Names")
2007
2008
2009 class VIEW3D_MT_edit_armature_parent(Menu):
2010     bl_label = "Parent"
2011
2012     def draw(self, context):
2013         layout = self.layout
2014
2015         layout.operator("armature.parent_set", text="Make")
2016         layout.operator("armature.parent_clear", text="Clear")
2017
2018
2019 class VIEW3D_MT_edit_armature_roll(Menu):
2020     bl_label = "Bone Roll"
2021
2022     def draw(self, context):
2023         layout = self.layout
2024
2025         layout.operator_menu_enum("armature.calculate_roll", "type")
2026
2027         layout.separator()
2028
2029         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2030
2031 # ********** Panel **********
2032
2033
2034 class VIEW3D_PT_view3d_properties(Panel):
2035     bl_space_type = 'VIEW_3D'
2036     bl_region_type = 'UI'
2037     bl_label = "View"
2038
2039     @classmethod
2040     def poll(cls, context):
2041         view = context.space_data
2042         return (view)
2043
2044     def draw(self, context):
2045         layout = self.layout
2046
2047         view = context.space_data
2048
2049         col = layout.column()
2050         col.active = view.region_3d.view_perspective != 'CAMERA'
2051         col.prop(view, "lens")
2052         col.label(text="Lock to Object:")
2053         col.prop(view, "lock_object", text="")
2054         lock_object = view.lock_object
2055         if lock_object:
2056             if lock_object.type == 'ARMATURE':
2057                 col.prop_search(view, "lock_bone", lock_object.data, "edit_bones" if lock_object.mode == 'EDIT' else "bones", text="")
2058         else:
2059             col.prop(view, "lock_cursor", text="Lock to Cursor")
2060
2061         col = layout.column()
2062         col.prop(view, "lock_camera")
2063
2064         col = layout.column(align=True)
2065         col.label(text="Clip:")
2066         col.prop(view, "clip_start", text="Start")
2067         col.prop(view, "clip_end", text="End")
2068
2069         subcol = col.column()
2070         subcol.enabled = not view.lock_camera_and_layers
2071         subcol.label(text="Local Camera:")
2072         subcol.prop(view, "camera", text="")
2073
2074
2075 class VIEW3D_PT_view3d_cursor(Panel):
2076     bl_space_type = 'VIEW_3D'
2077     bl_region_type = 'UI'
2078     bl_label = "3D Cursor"
2079
2080     @classmethod
2081     def poll(cls, context):
2082         view = context.space_data
2083         return (view)
2084
2085     def draw(self, context):
2086         layout = self.layout
2087
2088         view = context.space_data
2089         layout.column().prop(view, "cursor_location", text="Location")
2090
2091
2092 class VIEW3D_PT_view3d_name(Panel):
2093     bl_space_type = 'VIEW_3D'
2094     bl_region_type = 'UI'
2095     bl_label = "Item"
2096
2097     @classmethod
2098     def poll(cls, context):
2099         return (context.space_data and context.active_object)
2100
2101     def draw(self, context):
2102         layout = self.layout
2103
2104         ob = context.active_object
2105         row = layout.row()
2106         row.label(text="", icon='OBJECT_DATA')
2107         row.prop(ob, "name", text="")
2108
2109         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2110             bone = context.active_bone
2111             if bone:
2112                 row = layout.row()
2113                 row.label(text="", icon='BONE_DATA')
2114                 row.prop(bone, "name", text="")
2115
2116
2117 class VIEW3D_PT_view3d_display(Panel):
2118     bl_space_type = 'VIEW_3D'
2119     bl_region_type = 'UI'
2120     bl_label = "Display"
2121     bl_options = {'DEFAULT_CLOSED'}
2122
2123     @classmethod
2124     def poll(cls, context):
2125         view = context.space_data
2126         return (view)
2127
2128     def draw(self, context):
2129         layout = self.layout
2130
2131         view = context.space_data
2132         scene = context.scene
2133         gs = scene.game_settings
2134         ob = context.object
2135
2136         col = layout.column()
2137         col.prop(view, "show_only_render")
2138
2139         col = layout.column()
2140         display_all = not view.show_only_render
2141         col.active = display_all
2142         col.prop(view, "show_outline_selected")
2143         col.prop(view, "show_all_objects_origin")
2144         col.prop(view, "show_relationship_lines")
2145         if ob and ob.type == 'MESH':
2146             mesh = ob.data
2147             col.prop(mesh, "show_all_edges")
2148
2149         col = layout.column()
2150         col.active = display_all
2151         split = col.split(percentage=0.55)
2152         split.prop(view, "show_floor", text="Grid Floor")
2153
2154         row = split.row(align=True)
2155         row.prop(view, "show_axis_x", text="X", toggle=True)
2156         row.prop(view, "show_axis_y", text="Y", toggle=True)
2157         row.prop(view, "show_axis_z", text="Z", toggle=True)
2158
2159         sub = col.column(align=True)
2160         sub.active = (display_all and view.show_floor)
2161         sub.prop(view, "grid_lines", text="Lines")
2162         sub.prop(view, "grid_scale", text="Scale")
2163         subsub = sub.column(align=True)
2164         subsub.active = scene.unit_settings.system == 'NONE'
2165         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2166
2167         if not scene.render.use_shading_nodes:
2168             col = layout.column()
2169             col.label(text="Shading:")
2170             col.prop(gs, "material_mode", text="")
2171             col.prop(view, "show_textured_solid")
2172
2173         layout.separator()
2174
2175         region = view.region_quadview
2176
2177         layout.operator("screen.region_quadview", text="Toggle Quad View")
2178
2179         if region:
2180             col = layout.column()
2181             col.prop(region, "lock_rotation")
2182             row = col.row()
2183             row.enabled = region.lock_rotation
2184             row.prop(region, "show_sync_view")
2185             row = col.row()
2186             row.enabled = region.lock_rotation and region.show_sync_view
2187             row.prop(region, "use_box_clip")
2188
2189
2190 class VIEW3D_PT_view3d_motion_tracking(Panel):
2191     bl_space_type = 'VIEW_3D'
2192     bl_region_type = 'UI'
2193     bl_label = "Motion Tracking"
2194     bl_options = {'DEFAULT_CLOSED'}
2195
2196     @classmethod
2197     def poll(cls, context):
2198         view = context.space_data
2199         return (view)
2200
2201     def draw_header(self, context):
2202         view = context.space_data
2203
2204         self.layout.prop(view, "show_reconstruction", text="")
2205
2206     def draw(self, context):
2207         layout = self.layout
2208
2209         view = context.space_data
2210
2211         col = layout.column()
2212         col.active = view.show_reconstruction
2213         col.prop(view, "show_bundle_names")
2214         col.prop(view, "show_camera_path")
2215         col.label(text="Tracks:")
2216         col.prop(view, "tracks_draw_type", text="")
2217         col.prop(view, "tracks_draw_size", text="Size")
2218
2219
2220 class VIEW3D_PT_view3d_meshdisplay(Panel):
2221     bl_space_type = 'VIEW_3D'
2222     bl_region_type = 'UI'
2223     bl_label = "Mesh Display"
2224
2225     @classmethod
2226     def poll(cls, context):
2227         # The active object check is needed because of local-mode
2228         return (context.active_object and (context.mode == 'EDIT_MESH'))
2229
2230     def draw(self, context):
2231         layout = self.layout
2232
2233         mesh = context.active_object.data
2234
2235         col = layout.column()
2236         col.label(text="Overlays:")
2237         col.prop(mesh, "show_edges", text="Edges")
2238         col.prop(mesh, "show_faces", text="Faces")
2239         col.prop(mesh, "show_edge_crease", text="Creases")
2240         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2241         col.prop(mesh, "show_edge_seams", text="Seams")
2242         col.prop(mesh, "show_edge_sharp", text="Sharp")
2243
2244         col.separator()
2245         col.label(text="Normals:")
2246         col.prop(mesh, "show_normal_face", text="Face")
2247         col.prop(mesh, "show_normal_vertex", text="Vertex")
2248         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2249
2250         col.separator()
2251         col.label(text="Numerics:")
2252         col.prop(mesh, "show_extra_edge_length")
2253         col.prop(mesh, "show_extra_face_angle")
2254         col.prop(mesh, "show_extra_face_area")
2255         if bpy.app.debug:
2256             col.prop(mesh, "show_extra_indices")
2257
2258
2259 class VIEW3D_PT_view3d_curvedisplay(Panel):
2260     bl_space_type = 'VIEW_3D'
2261     bl_region_type = 'UI'
2262     bl_label = "Curve Display"
2263
2264     @classmethod
2265     def poll(cls, context):
2266         editmesh = context.mode == 'EDIT_CURVE'
2267         return (editmesh)
2268
2269     def draw(self, context):
2270         layout = self.layout
2271
2272         curve = context.active_object.data
2273
2274         col = layout.column()
2275         col.label(text="Overlays:")
2276         col.prop(curve, "show_handles", text="Handles")
2277         col.prop(curve, "show_normal_face", text="Normals")
2278         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2279
2280
2281 class VIEW3D_PT_background_image(Panel):
2282     bl_space_type = 'VIEW_3D'
2283     bl_region_type = 'UI'
2284     bl_label = "Background Images"
2285     bl_options = {'DEFAULT_CLOSED'}
2286
2287     def draw_header(self, context):
2288         view = context.space_data
2289
2290         self.layout.prop(view, "show_background_images", text="")
2291
2292     def draw(self, context):
2293         layout = self.layout
2294
2295         view = context.space_data
2296
2297         col = layout.column()
2298         col.operator("view3d.background_image_add", text="Add Image")
2299
2300         for i, bg in enumerate(view.background_images):
2301             layout.active = view.show_background_images
2302             box = layout.box()
2303             row = box.row(align=True)
2304             row.prop(bg, "show_expanded", text="", emboss=False)
2305             if bg.source == 'IMAGE' and bg.image:
2306                 row.prop(bg.image, "name", text="", emboss=False)
2307             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2308                 row.prop(bg.clip, "name", text="", emboss=False)
2309             else:
2310                 row.label(text="Not Set")
2311
2312             if bg.show_background_image:
2313                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2314             else:
2315                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2316
2317             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2318
2319             box.prop(bg, "view_axis", text="Axis")
2320
2321             if bg.show_expanded:
2322                 row = box.row()
2323                 row.prop(bg, "source", expand=True)
2324
2325                 has_bg = False
2326                 if bg.source == 'IMAGE':
2327                     row = box.row()
2328                     row.template_ID(bg, "image", open="image.open")
2329                     if (bg.image):
2330                         box.template_image(bg, "image", bg.image_user, compact=True)
2331                         has_bg = True
2332
2333                 elif bg.source == 'MOVIE_CLIP':
2334                     box.prop(bg, 'use_camera_clip')
2335
2336                     column = box.column()
2337                     column.active = not bg.use_camera_clip
2338                     column.template_ID(bg, "clip", open="clip.open")
2339
2340                     if bg.clip:
2341                         column.template_movieclip(bg, "clip", compact=True)
2342
2343                     if bg.use_camera_clip or bg.clip:
2344                         has_bg = True
2345
2346                     column = box.column()
2347                     column.active = has_bg
2348                     column.prop(bg.clip_user, "proxy_render_size", text="")
2349                     column.prop(bg.clip_user, "use_render_undistorted")
2350
2351                 if has_bg:
2352                     box.prop(bg, "opacity", slider=True)
2353                     if bg.view_axis != 'CAMERA':
2354                         box.prop(bg, "size")
2355                         row = box.row(align=True)
2356                         row.prop(bg, "offset_x", text="X")
2357                         row.prop(bg, "offset_y", text="Y")
2358
2359
2360 class VIEW3D_PT_transform_orientations(Panel):
2361     bl_space_type = 'VIEW_3D'
2362     bl_region_type = 'UI'
2363     bl_label = "Transform Orientations"
2364     bl_options = {'DEFAULT_CLOSED'}
2365
2366     @classmethod
2367     def poll(cls, context):
2368         view = context.space_data
2369         return (view)
2370
2371     def draw(self, context):
2372         layout = self.layout
2373
2374         view = context.space_data
2375         orientation = view.current_orientation
2376
2377         row = layout.row(align=True)
2378         row.prop(view, "transform_orientation", text="")
2379         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2380
2381         if orientation:
2382             row = layout.row(align=True)
2383             row.prop(orientation, "name", text="")
2384             row.operator("transform.delete_orientation", text="", icon="X")
2385
2386
2387 class VIEW3D_PT_etch_a_ton(Panel):
2388     bl_space_type = 'VIEW_3D'
2389     bl_region_type = 'UI'
2390     bl_label = "Skeleton Sketching"
2391     bl_options = {'DEFAULT_CLOSED'}
2392
2393     @classmethod
2394     def poll(cls, context):
2395         scene = context.space_data
2396         ob = context.active_object
2397         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2398
2399     def draw_header(self, context):
2400         layout = self.layout
2401         toolsettings = context.scene.tool_settings
2402
2403         layout.prop(toolsettings, "use_bone_sketching", text="")
2404
2405     def draw(self, context):
2406         layout = self.layout
2407         toolsettings = context.scene.tool_settings
2408
2409         col = layout.column()
2410
2411         col.prop(toolsettings, "use_etch_quick")
2412         col.prop(toolsettings, "use_etch_overdraw")
2413
2414         col.prop(toolsettings, "etch_convert_mode")
2415
2416         if toolsettings.etch_convert_mode == 'LENGTH':
2417             col.prop(toolsettings, "etch_length_limit")
2418         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2419             col.prop(toolsettings, "etch_adaptive_limit")
2420         elif toolsettings.etch_convert_mode == 'FIXED':
2421             col.prop(toolsettings, "etch_subdivision_number")
2422         elif toolsettings.etch_convert_mode == 'RETARGET':
2423             col.prop(toolsettings, "etch_template")
2424             col.prop(toolsettings, "etch_roll_mode")
2425             col.prop(toolsettings, "use_etch_autoname")
2426             col.prop(toolsettings, "etch_number")
2427             col.prop(toolsettings, "etch_side")
2428
2429         col.operator("sketch.convert", text="Convert")
2430
2431
2432 class VIEW3D_PT_context_properties(Panel):
2433     bl_space_type = 'VIEW_3D'
2434     bl_region_type = 'UI'
2435     bl_label = "Properties"
2436     bl_options = {'DEFAULT_CLOSED'}
2437
2438     def _active_context_member(context):
2439         obj = context.object
2440         if obj:
2441             mode = obj.mode
2442             if mode == 'POSE':
2443                 return "active_pose_bone"
2444             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2445                 return "active_bone"
2446             else:
2447                 return "object"
2448
2449         return ""
2450
2451     @classmethod
2452     def poll(cls, context):
2453         member = cls._active_context_member(context)
2454         if member:
2455             context_member = getattr(context, member)
2456             return context_member and context_member.keys()
2457
2458         return False
2459
2460     def draw(self, context):
2461         import rna_prop_ui
2462         member = VIEW3D_PT_context_properties._active_context_member(context)
2463
2464         if member:
2465             # Draw with no edit button
2466             rna_prop_ui.draw(self.layout, context, member, object, False)
2467
2468
2469 def register():
2470     bpy.utils.register_module(__name__)
2471
2472
2473 def unregister():
2474     bpy.utils.unregister_module(__name__)
2475
2476 if __name__ == "__main__":
2477     register()
2478
2479 if __name__ == "__main__":  # only for live edit.
2480     bpy.utils.register_module(__name__)