fix own bug [#29875] Due to operators now reusing there last-used settings, some...
[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_inverse")
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="Triangles").type = 'TRIANGLES'
527         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
528         if context.scene.tool_settings.mesh_select_mode[2] == False:
529             layout.operator("mesh.select_non_manifold", text="Non Manifold")
530         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
531         layout.operator("mesh.select_similar", text="Similar")
532
533         layout.separator()
534
535         layout.operator("mesh.select_less", text="Less")
536         layout.operator("mesh.select_more", text="More")
537
538         layout.separator()
539
540         layout.operator("mesh.select_mirror", text="Mirror")
541
542         layout.operator("mesh.select_linked", text="Linked")
543         layout.operator("mesh.select_vertex_path", text="Vertex Path")
544         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
545         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
546
547         layout.separator()
548
549         layout.operator("mesh.loop_to_region")
550         layout.operator("mesh.region_to_loop")
551
552
553 class VIEW3D_MT_select_edit_curve(Menu):
554     bl_label = "Select"
555
556     def draw(self, context):
557         layout = self.layout
558
559         layout.operator("view3d.select_border")
560         layout.operator("view3d.select_circle")
561
562         layout.separator()
563
564         layout.operator("curve.select_all", text="Select/Deselect All").action = 'TOGGLE'
565         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
566         layout.operator("curve.select_random")
567         layout.operator("curve.select_nth", text="Every Nth Number of Points")
568
569         layout.separator()
570
571         layout.operator("curve.de_select_first")
572         layout.operator("curve.de_select_last")
573         layout.operator("curve.select_next")
574         layout.operator("curve.select_previous")
575
576         layout.separator()
577
578         layout.operator("curve.select_more")
579         layout.operator("curve.select_less")
580
581
582 class VIEW3D_MT_select_edit_surface(Menu):
583     bl_label = "Select"
584
585     def draw(self, context):
586         layout = self.layout
587
588         layout.operator("view3d.select_border")
589         layout.operator("view3d.select_circle")
590
591         layout.separator()
592
593         layout.operator("curve.select_all", text="Select/Deselect All").action = 'TOGGLE'
594         layout.operator("curve.select_all", text="Inverse").action = 'INVERT'
595         layout.operator("curve.select_random")
596         layout.operator("curve.select_nth", text="Every Nth Number of Points")
597
598         layout.separator()
599
600         layout.operator("curve.select_row")
601
602         layout.separator()
603
604         layout.operator("curve.select_more")
605         layout.operator("curve.select_less")
606
607
608 class VIEW3D_MT_select_edit_metaball(Menu):
609     bl_label = "Select"
610
611     def draw(self, context):
612         layout = self.layout
613
614         layout.operator("view3d.select_border")
615
616         layout.separator()
617
618         layout.operator("mball.select_all").action = 'TOGGLE'
619         layout.operator("mball.select_all").action = 'INVERT'
620
621         layout.separator()
622
623         layout.operator("mball.select_random_metaelems")
624
625
626 class VIEW3D_MT_select_edit_lattice(Menu):
627     bl_label = "Select"
628
629     def draw(self, context):
630         layout = self.layout
631
632         layout.operator("view3d.select_border")
633
634         layout.separator()
635
636         layout.operator("lattice.select_all", text="Select/Deselect All")
637
638
639 class VIEW3D_MT_select_edit_armature(Menu):
640     bl_label = "Select"
641
642     def draw(self, context):
643         layout = self.layout
644
645         layout.operator("view3d.select_border")
646
647         layout.separator()
648
649         layout.operator("armature.select_all", text="Select/Deselect All")
650         layout.operator("armature.select_inverse", text="Inverse")
651
652         layout.separator()
653
654         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
655         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
656
657         layout.separator()
658
659         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
660         props.extend = True
661         props.direction = 'PARENT'
662
663         props = layout.operator("armature.select_hierarchy", text="Extend Child")
664         props.extend = True
665         props.direction = 'CHILD'
666
667         layout.operator("object.select_pattern", text="Select Pattern...")
668
669
670 class VIEW3D_MT_select_face(Menu):  # XXX no matching enum
671     bl_label = "Select"
672
673     def draw(self, context):
674         # layout = self.layout
675
676         # TODO
677         # see view3d_select_faceselmenu
678         pass
679
680 # ********** Object menu **********
681
682
683 class VIEW3D_MT_object(Menu):
684     bl_context = "objectmode"
685     bl_label = "Object"
686
687     def draw(self, context):
688         layout = self.layout
689
690         layout.operator("ed.undo")
691         layout.operator("ed.redo")
692         layout.operator("ed.undo_history")
693
694         layout.separator()
695
696         layout.menu("VIEW3D_MT_transform")
697         layout.menu("VIEW3D_MT_mirror")
698         layout.menu("VIEW3D_MT_object_clear")
699         layout.menu("VIEW3D_MT_object_apply")
700         layout.menu("VIEW3D_MT_snap")
701
702         layout.separator()
703
704         layout.menu("VIEW3D_MT_object_animation")
705
706         layout.separator()
707
708         layout.operator("object.duplicate_move")
709         layout.operator("object.duplicate_move_linked")
710         layout.operator("object.delete", text="Delete...")
711         layout.operator("object.proxy_make", text="Make Proxy...")
712         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
713         layout.operator("object.make_dupli_face")
714         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
715         layout.menu("VIEW3D_MT_make_single_user")
716
717         layout.separator()
718
719         layout.menu("VIEW3D_MT_object_parent")
720         layout.menu("VIEW3D_MT_object_track")
721         layout.menu("VIEW3D_MT_object_group")
722         layout.menu("VIEW3D_MT_object_constraints")
723
724         layout.separator()
725
726         layout.menu("VIEW3D_MT_object_quick_effects")
727
728         layout.separator()
729
730         layout.menu("VIEW3D_MT_object_game")
731
732         layout.separator()
733
734         layout.operator("object.join")
735
736         layout.separator()
737
738         layout.operator("object.move_to_layer", text="Move to Layer...")
739         layout.menu("VIEW3D_MT_object_showhide")
740
741         layout.operator_menu_enum("object.convert", "target")
742
743
744 class VIEW3D_MT_object_animation(Menu):
745     bl_label = "Animation"
746
747     def draw(self, context):
748         layout = self.layout
749
750         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
751         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
752         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
753
754
755 class VIEW3D_MT_object_clear(Menu):
756     bl_label = "Clear"
757
758     def draw(self, context):
759         layout = self.layout
760
761         layout.operator("object.location_clear", text="Location")
762         layout.operator("object.rotation_clear", text="Rotation")
763         layout.operator("object.scale_clear", text="Scale")
764         layout ("object.origin_clear", text="Origin")
765
766
767 class VIEW3D_MT_object_specials(Menu):
768     bl_label = "Specials"
769
770     @classmethod
771     def poll(cls, context):
772         # add more special types
773         return context.object
774
775     def draw(self, context):
776         layout = self.layout
777
778         obj = context.object
779         if obj.type == 'CAMERA':
780             layout.operator_context = 'INVOKE_REGION_WIN'
781
782             if obj.data.type == 'PERSP':
783                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Angle")
784                 props.data_path_iter = "selected_editable_objects"
785                 props.data_path_item = "data.lens"
786                 props.input_scale = 0.1
787             else:
788                 props = layout.operator("wm.context_modal_mouse", text="Camera Lens Scale")
789                 props.data_path_iter = "selected_editable_objects"
790                 props.data_path_item = "data.ortho_scale"
791                 props.input_scale = 0.01
792
793             if not obj.data.dof_object:
794                 #layout.label(text="Test Has DOF obj");
795                 props = layout.operator("wm.context_modal_mouse", text="DOF Distance")
796                 props.data_path_iter = "selected_editable_objects"
797                 props.data_path_item = "data.dof_distance"
798                 props.input_scale = 0.02
799
800         if obj.type in {'CURVE', 'FONT'}:
801             layout.operator_context = 'INVOKE_REGION_WIN'
802
803             props = layout.operator("wm.context_modal_mouse", text="Extrude Size")
804             props.data_path_iter = "selected_editable_objects"
805             props.data_path_item = "data.extrude"
806             props.input_scale = 0.01
807
808             props = layout.operator("wm.context_modal_mouse", text="Width Size")
809             props.data_path_iter = "selected_editable_objects"
810             props.data_path_item = "data.offset"
811             props.input_scale = 0.01
812
813         if obj.type == 'EMPTY':
814             layout.operator_context = 'INVOKE_REGION_WIN'
815
816             props = layout.operator("wm.context_modal_mouse", text="Empty Draw Size")
817             props.data_path_iter = "selected_editable_objects"
818             props.data_path_item = "empty_draw_size"
819             props.input_scale = 0.01
820
821         if obj.type == 'LAMP':
822             layout.operator_context = 'INVOKE_REGION_WIN'
823
824             props = layout.operator("wm.context_modal_mouse", text="Energy")
825             props.data_path_iter = "selected_editable_objects"
826             props.data_path_item = "data.energy"
827
828             if obj.data.type in {'SPOT', 'AREA', 'POINT'}:
829                 props = layout.operator("wm.context_modal_mouse", text="Falloff Distance")
830                 props.data_path_iter = "selected_editable_objects"
831                 props.data_path_item = "data.distance"
832                 props.input_scale = 0.1
833
834             if obj.data.type == 'SPOT':
835                 layout.separator()
836                 props = layout.operator("wm.context_modal_mouse", text="Spot Size")
837                 props.data_path_iter = "selected_editable_objects"
838                 props.data_path_item = "data.spot_size"
839                 props.input_scale = 0.01
840
841                 props = layout.operator("wm.context_modal_mouse", text="Spot Blend")
842                 props.data_path_iter = "selected_editable_objects"
843                 props.data_path_item = "data.spot_blend"
844                 props.input_scale = -0.01
845
846                 props = layout.operator("wm.context_modal_mouse", text="Clip Start")
847                 props.data_path_iter = "selected_editable_objects"
848                 props.data_path_item = "data.shadow_buffer_clip_start"
849                 props.input_scale = 0.05
850
851                 props = layout.operator("wm.context_modal_mouse", text="Clip End")
852                 props.data_path_iter = "selected_editable_objects"
853                 props.data_path_item = "data.shadow_buffer_clip_end"
854                 props.input_scale = 0.05
855
856         layout.separator()
857
858         props = layout.operator("object.isolate_type_render")
859         props = layout.operator("object.hide_render_clear_all")
860
861
862 class VIEW3D_MT_object_apply(Menu):
863     bl_label = "Apply"
864
865     def draw(self, context):
866         layout = self.layout
867
868         props = layout.operator("object.transform_apply", text="Location")
869         props.location, props.rotation, props.scale = True, False, False
870
871         props = layout.operator("object.transform_apply", text="Rotation")
872         props.location, props.rotation, props.scale = False, True, False
873
874         props = layout.operator("object.transform_apply", text="Scale")
875         props.location, props.rotation, props.scale = False, False, True
876         props = layout.operator("object.transform_apply", text="Rotation & Scale")
877         props.location, props.rotation, props.scale = False, True, True
878
879         layout.separator()
880
881         layout.operator("object.visual_transform_apply", text="Visual Transform")
882         layout.operator("object.duplicates_make_real")
883
884
885 class VIEW3D_MT_object_parent(Menu):
886     bl_label = "Parent"
887
888     def draw(self, context):
889         layout = self.layout
890
891         layout.operator_menu_enum("object.parent_set", "type", text="Set")
892         layout.operator_menu_enum("object.parent_clear", "type", text="Clear")
893
894
895 class VIEW3D_MT_object_track(Menu):
896     bl_label = "Track"
897
898     def draw(self, context):
899         layout = self.layout
900
901         layout.operator_menu_enum("object.track_set", "type", text="Set")
902         layout.operator_menu_enum("object.track_clear", "type", text="Clear")
903
904
905 class VIEW3D_MT_object_group(Menu):
906     bl_label = "Group"
907
908     def draw(self, context):
909         layout = self.layout
910
911         layout.operator("group.create")
912         layout.operator("group.objects_remove")
913
914         layout.separator()
915
916         layout.operator("group.objects_add_active")
917         layout.operator("group.objects_remove_active")
918
919
920 class VIEW3D_MT_object_constraints(Menu):
921     bl_label = "Constraints"
922
923     def draw(self, context):
924         layout = self.layout
925
926         layout.operator("object.constraint_add_with_targets")
927         layout.operator("object.constraints_copy")
928         layout.operator("object.constraints_clear")
929
930
931 class VIEW3D_MT_object_quick_effects(Menu):
932     bl_label = "Quick Effects"
933
934     def draw(self, context):
935         layout = self.layout
936
937         layout.operator("object.quick_fur")
938         layout.operator("object.quick_explode")
939         layout.operator("object.quick_smoke")
940         layout.operator("object.quick_fluid")
941
942
943 class VIEW3D_MT_object_showhide(Menu):
944     bl_label = "Show/Hide"
945
946     def draw(self, context):
947         layout = self.layout
948
949         layout.operator("object.hide_view_clear", text="Show Hidden")
950         layout.operator("object.hide_view_set", text="Hide Selected").unselected = False
951         layout.operator("object.hide_view_set", text="Hide Unselected").unselected = True
952
953
954 class VIEW3D_MT_make_single_user(Menu):
955     bl_label = "Make Single User"
956
957     def draw(self, context):
958         layout = self.layout
959
960         props = layout.operator("object.make_single_user", text="Object")
961         props.object = True
962
963         props = layout.operator("object.make_single_user", text="Object & Data")
964         props.object = props.obdata = True
965
966         props = layout.operator("object.make_single_user", text="Object & Data & Materials+Tex")
967         props.object = props.obdata = props.material = props.texture = True
968
969         props = layout.operator("object.make_single_user", text="Materials+Tex")
970         props.material = props.texture = True
971
972         props = layout.operator("object.make_single_user", text="Object Animation")
973         props.animation = True
974
975
976 class VIEW3D_MT_make_links(Menu):
977     bl_label = "Make Links"
978
979     def draw(self, context):
980         layout = self.layout
981
982         if(len(bpy.data.scenes) > 10):
983             layout.operator_context = 'INVOKE_DEFAULT'
984             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
985         else:
986             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
987
988         layout.operator_enum("object.make_links_data", "type")  # inline
989
990         layout.operator("object.join_uvs")  # stupid place to add this!
991
992
993 class VIEW3D_MT_object_game(Menu):
994     bl_label = "Game"
995
996     def draw(self, context):
997         layout = self.layout
998
999         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1000         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1001
1002         layout.separator()
1003
1004         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1005         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1006         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1007
1008         layout.separator()
1009
1010         layout.operator("object.game_property_clear")
1011
1012
1013 # ********** Vertex paint menu **********
1014
1015
1016 class VIEW3D_MT_paint_vertex(Menu):
1017     bl_label = "Paint"
1018
1019     def draw(self, context):
1020         layout = self.layout
1021
1022         layout.operator("ed.undo")
1023         layout.operator("ed.redo")
1024
1025         layout.separator()
1026
1027         layout.operator("paint.vertex_color_set")
1028         layout.operator("paint.vertex_color_dirt")
1029
1030
1031 class VIEW3D_MT_hook(Menu):
1032     bl_label = "Hooks"
1033
1034     def draw(self, context):
1035         layout = self.layout
1036         layout.operator_context = 'EXEC_AREA'
1037         layout.operator("object.hook_add_newob")
1038         layout.operator("object.hook_add_selob")
1039
1040         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1041             layout.separator()
1042             layout.operator_menu_enum("object.hook_assign", "modifier")
1043             layout.operator_menu_enum("object.hook_remove", "modifier")
1044             layout.separator()
1045             layout.operator_menu_enum("object.hook_select", "modifier")
1046             layout.operator_menu_enum("object.hook_reset", "modifier")
1047             layout.operator_menu_enum("object.hook_recenter", "modifier")
1048
1049
1050 class VIEW3D_MT_vertex_group(Menu):
1051     bl_label = "Vertex Groups"
1052
1053     def draw(self, context):
1054         layout = self.layout
1055         layout.operator_context = 'EXEC_AREA'
1056         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1057
1058         ob = context.active_object
1059         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1060             if ob.vertex_groups.active:
1061                 layout.separator()
1062                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
1063                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1064                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1065                 layout.separator()
1066
1067         if ob.vertex_groups.active:
1068             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1069             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1070             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1071
1072 # ********** Weight paint menu **********
1073
1074
1075 class VIEW3D_MT_paint_weight(Menu):
1076     bl_label = "Weights"
1077
1078     def draw(self, context):
1079         layout = self.layout
1080
1081         layout.operator("ed.undo")
1082         layout.operator("ed.redo")
1083         layout.operator("ed.undo_history")
1084
1085         layout.separator()
1086
1087         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1088         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1089
1090         layout.separator()
1091
1092         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1093         layout.operator("object.vertex_group_normalize", text="Normalize")
1094         layout.operator("object.vertex_group_mirror", text="Mirror")
1095         layout.operator("object.vertex_group_invert", text="Invert")
1096         layout.operator("object.vertex_group_clean", text="Clean")
1097         layout.operator("object.vertex_group_levels", text="Levels")
1098         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1099
1100         layout.separator()
1101
1102         layout.operator("paint.weight_set")
1103
1104 # ********** Sculpt menu **********
1105
1106
1107 class VIEW3D_MT_sculpt(Menu):
1108     bl_label = "Sculpt"
1109
1110     def draw(self, context):
1111         layout = self.layout
1112
1113         tool_settings = context.tool_settings
1114         sculpt = tool_settings.sculpt
1115         brush = tool_settings.sculpt.brush
1116
1117         layout.operator("ed.undo")
1118         layout.operator("ed.redo")
1119
1120         layout.separator()
1121
1122         layout.prop(sculpt, "use_symmetry_x")
1123         layout.prop(sculpt, "use_symmetry_y")
1124         layout.prop(sculpt, "use_symmetry_z")
1125         layout.separator()
1126         layout.prop(sculpt, "lock_x")
1127         layout.prop(sculpt, "lock_y")
1128         layout.prop(sculpt, "lock_z")
1129         layout.separator()
1130         layout.operator_menu_enum("brush.curve_preset", "shape")
1131         layout.separator()
1132
1133         if brush is not None:  # unlikely but can happen
1134             sculpt_tool = brush.sculpt_tool
1135
1136             if sculpt_tool != 'GRAB':
1137                 layout.prop_menu_enum(brush, "stroke_method")
1138
1139                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1140                     layout.prop_menu_enum(brush, "direction")
1141
1142                 if sculpt_tool == 'LAYER':
1143                     layout.prop(brush, "use_persistent")
1144                     layout.operator("sculpt.set_persistent_base")
1145
1146         layout.separator()
1147         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1148         layout.prop(sculpt, "show_brush")
1149
1150         # TODO, make available from paint menu!
1151         layout.prop(tool_settings, "sculpt_paint_use_unified_size", text="Unify Size")
1152         layout.prop(tool_settings, "sculpt_paint_use_unified_strength", text="Unify Strength")
1153
1154 # ********** Particle menu **********
1155
1156
1157 class VIEW3D_MT_particle(Menu):
1158     bl_label = "Particle"
1159
1160     def draw(self, context):
1161         layout = self.layout
1162
1163         particle_edit = context.tool_settings.particle_edit
1164
1165         layout.operator("ed.undo")
1166         layout.operator("ed.redo")
1167         layout.operator("ed.undo_history")
1168
1169         layout.separator()
1170
1171         layout.operator("particle.mirror")
1172
1173         layout.separator()
1174
1175         layout.operator("particle.remove_doubles")
1176         layout.operator("particle.delete")
1177
1178         if particle_edit.select_mode == 'POINT':
1179             layout.operator("particle.subdivide")
1180
1181         layout.operator("particle.rekey")
1182         layout.operator("particle.weight_set")
1183
1184         layout.separator()
1185
1186         layout.menu("VIEW3D_MT_particle_showhide")
1187
1188
1189 class VIEW3D_MT_particle_specials(Menu):
1190     bl_label = "Specials"
1191
1192     def draw(self, context):
1193         layout = self.layout
1194         particle_edit = context.tool_settings.particle_edit
1195
1196         layout.operator("particle.rekey")
1197
1198         layout.separator()
1199         if particle_edit.select_mode == 'POINT':
1200             layout.operator("particle.subdivide")
1201             layout.operator("particle.select_roots")
1202             layout.operator("particle.select_tips")
1203
1204         layout.operator("particle.remove_doubles")
1205
1206
1207 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1208     _operator_name = "particle"
1209
1210 # ********** Pose Menu **********
1211
1212
1213 class VIEW3D_MT_pose(Menu):
1214     bl_label = "Pose"
1215
1216     def draw(self, context):
1217         layout = self.layout
1218
1219         layout.operator("ed.undo")
1220         layout.operator("ed.redo")
1221         layout.operator("ed.undo_history")
1222
1223         layout.separator()
1224
1225         layout.menu("VIEW3D_MT_transform")
1226
1227         layout.menu("VIEW3D_MT_pose_transform")
1228         layout.menu("VIEW3D_MT_pose_apply")
1229
1230         layout.menu("VIEW3D_MT_snap")
1231
1232         layout.separator()
1233
1234         layout.menu("VIEW3D_MT_object_animation")
1235
1236         layout.separator()
1237
1238         layout.menu("VIEW3D_MT_pose_slide")
1239         layout.menu("VIEW3D_MT_pose_propagate")
1240
1241         layout.separator()
1242
1243         layout.operator("pose.copy")
1244         layout.operator("pose.paste")
1245         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1246
1247         layout.separator()
1248
1249         layout.menu("VIEW3D_MT_pose_library")
1250         layout.menu("VIEW3D_MT_pose_motion")
1251         layout.menu("VIEW3D_MT_pose_group")
1252
1253         layout.separator()
1254
1255         layout.menu("VIEW3D_MT_object_parent")
1256         layout.menu("VIEW3D_MT_pose_ik")
1257         layout.menu("VIEW3D_MT_pose_constraints")
1258
1259         layout.separator()
1260
1261         layout.operator_context = 'EXEC_AREA'
1262         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1263         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1264         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1265
1266         layout.operator("pose.flip_names")
1267
1268         layout.operator("pose.quaternions_flip")
1269
1270         layout.separator()
1271
1272         layout.operator_context = 'INVOKE_AREA'
1273         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1274         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1275
1276         layout.separator()
1277
1278         layout.menu("VIEW3D_MT_pose_showhide")
1279         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1280
1281
1282 class VIEW3D_MT_pose_transform(Menu):
1283     bl_label = "Clear Transform"
1284
1285     def draw(self, context):
1286         layout = self.layout
1287
1288         layout.operator("pose.transforms_clear", text="All")
1289
1290         layout.separator()
1291
1292         layout.operator("pose.loc_clear", text="Location")
1293         layout.operator("pose.rot_clear", text="Rotation")
1294         layout.operator("pose.scale_clear", text="Scale")
1295
1296         layout.separator()
1297
1298         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1299
1300
1301 class VIEW3D_MT_pose_slide(Menu):
1302     bl_label = "In-Betweens"
1303
1304     def draw(self, context):
1305         layout = self.layout
1306
1307         layout.operator("pose.push")
1308         layout.operator("pose.relax")
1309         layout.operator("pose.breakdown")
1310
1311
1312 class VIEW3D_MT_pose_propagate(Menu):
1313     bl_label = "Propagate"
1314
1315     def draw(self, context):
1316         layout = self.layout
1317
1318         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1319
1320         layout.separator()
1321
1322         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1323         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1324
1325         layout.separator()
1326
1327         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1328
1329
1330 class VIEW3D_MT_pose_library(Menu):
1331     bl_label = "Pose Library"
1332
1333     def draw(self, context):
1334         layout = self.layout
1335
1336         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1337
1338         layout.separator()
1339
1340         layout.operator("poselib.pose_add", text="Add Pose...")
1341         layout.operator("poselib.pose_rename", text="Rename Pose...")
1342         layout.operator("poselib.pose_remove", text="Remove Pose...")
1343
1344
1345 class VIEW3D_MT_pose_motion(Menu):
1346     bl_label = "Motion Paths"
1347
1348     def draw(self, context):
1349         layout = self.layout
1350
1351         layout.operator("pose.paths_calculate", text="Calculate")
1352         layout.operator("pose.paths_clear", text="Clear")
1353
1354
1355 class VIEW3D_MT_pose_group(Menu):
1356     bl_label = "Bone Groups"
1357
1358     def draw(self, context):
1359         layout = self.layout
1360         layout.operator("pose.group_add")
1361         layout.operator("pose.group_remove")
1362
1363         layout.separator()
1364
1365         layout.operator("pose.group_assign")
1366         layout.operator("pose.group_unassign")
1367
1368
1369 class VIEW3D_MT_pose_ik(Menu):
1370     bl_label = "Inverse Kinematics"
1371
1372     def draw(self, context):
1373         layout = self.layout
1374
1375         layout.operator("pose.ik_add")
1376         layout.operator("pose.ik_clear")
1377
1378
1379 class VIEW3D_MT_pose_constraints(Menu):
1380     bl_label = "Constraints"
1381
1382     def draw(self, context):
1383         layout = self.layout
1384
1385         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1386         layout.operator("pose.constraints_copy")
1387         layout.operator("pose.constraints_clear")
1388
1389
1390 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1391     _operator_name = "pose"
1392
1393
1394 class VIEW3D_MT_pose_apply(Menu):
1395     bl_label = "Apply"
1396
1397     def draw(self, context):
1398         layout = self.layout
1399
1400         layout.operator("pose.armature_apply")
1401         layout.operator("pose.visual_transform_apply")
1402
1403
1404 class BoneOptions:
1405     def draw(self, context):
1406         layout = self.layout
1407
1408         options = [
1409             "show_wire",
1410             "use_deform",
1411             "use_envelope_multiply",
1412             "use_inherit_rotation",
1413             "use_inherit_scale",
1414         ]
1415
1416         if context.mode == 'EDIT_ARMATURE':
1417             bone_props = bpy.types.EditBone.bl_rna.properties
1418             data_path_iter = "selected_bones"
1419             opt_suffix = ""
1420             options.append("lock")
1421         else:  # pose-mode
1422             bone_props = bpy.types.Bone.bl_rna.properties
1423             data_path_iter = "selected_pose_bones"
1424             opt_suffix = "bone."
1425
1426         for opt in options:
1427             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1428             props.data_path_iter = data_path_iter
1429             props.data_path_item = opt_suffix + opt
1430             props.type = self.type
1431
1432
1433 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1434     bl_label = "Toggle Bone Options"
1435     type = 'TOGGLE'
1436
1437
1438 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1439     bl_label = "Enable Bone Options"
1440     type = 'ENABLE'
1441
1442
1443 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1444     bl_label = "Disable Bone Options"
1445     type = 'DISABLE'
1446
1447 # ********** Edit Menus, suffix from ob.type **********
1448
1449
1450 class VIEW3D_MT_edit_mesh(Menu):
1451     bl_label = "Mesh"
1452
1453     def draw(self, context):
1454         layout = self.layout
1455
1456         settings = context.tool_settings
1457
1458         layout.operator("ed.undo")
1459         layout.operator("ed.redo")
1460         layout.operator("ed.undo_history")
1461
1462         layout.separator()
1463
1464         layout.menu("VIEW3D_MT_transform")
1465         layout.menu("VIEW3D_MT_mirror")
1466         layout.menu("VIEW3D_MT_snap")
1467
1468         layout.separator()
1469
1470         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1471
1472         layout.separator()
1473
1474         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1475         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1476         layout.operator("mesh.duplicate_move")
1477         layout.operator("mesh.delete", text="Delete...")
1478
1479         layout.separator()
1480
1481         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1482         layout.menu("VIEW3D_MT_edit_mesh_edges")
1483         layout.menu("VIEW3D_MT_edit_mesh_faces")
1484         layout.menu("VIEW3D_MT_edit_mesh_normals")
1485
1486         layout.separator()
1487
1488         layout.prop(settings, "use_mesh_automerge")
1489         layout.prop_menu_enum(settings, "proportional_edit")
1490         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1491
1492         layout.separator()
1493
1494         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1495
1496
1497 class VIEW3D_MT_edit_mesh_specials(Menu):
1498     bl_label = "Specials"
1499
1500     def draw(self, context):
1501         layout = self.layout
1502
1503         layout.operator_context = 'INVOKE_REGION_WIN'
1504
1505         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1506         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1507         layout.operator("mesh.merge", text="Merge...")
1508         layout.operator("mesh.remove_doubles")
1509         layout.operator("mesh.hide", text="Hide")
1510         layout.operator("mesh.reveal", text="Reveal")
1511         layout.operator("mesh.select_inverse")
1512         layout.operator("mesh.flip_normals")
1513         layout.operator("mesh.vertices_smooth", text="Smooth")
1514         # layout.operator("mesh.bevel", text="Bevel")
1515         layout.operator("mesh.faces_shade_smooth")
1516         layout.operator("mesh.faces_shade_flat")
1517         layout.operator("mesh.blend_from_shape")
1518         layout.operator("mesh.shape_propagate_to_all")
1519         layout.operator("mesh.select_vertex_path")
1520
1521
1522 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1523     bl_label = "Mesh Select Mode"
1524
1525     def draw(self, context):
1526         layout = self.layout
1527
1528         layout.operator_context = 'INVOKE_REGION_WIN'
1529
1530         props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1531         props.value = "(True, False, False)"
1532         props.data_path = "tool_settings.mesh_select_mode"
1533
1534         props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1535         props.value = "(False, True, False)"
1536         props.data_path = "tool_settings.mesh_select_mode"
1537
1538         props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1539         props.value = "(False, False, True)"
1540         props.data_path = "tool_settings.mesh_select_mode"
1541
1542
1543 class VIEW3D_MT_edit_mesh_extrude(Menu):
1544     bl_label = "Extrude"
1545
1546     _extrude_funcs = {
1547         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1548         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1549         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1550         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1551     }
1552
1553     @staticmethod
1554     def extrude_options(context):
1555         mesh = context.object.data
1556         select_mode = context.tool_settings.mesh_select_mode
1557
1558         menu = []
1559         if mesh.total_face_sel:
1560             menu += ['REGION', 'FACE']
1561         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1562             menu += ['EDGE']
1563         if mesh.total_vert_sel and select_mode[0]:
1564             menu += ['VERT']
1565
1566         # should never get here
1567         return menu
1568
1569     def draw(self, context):
1570         layout = self.layout
1571         layout.operator_context = 'INVOKE_REGION_WIN'
1572
1573         for menu_id in self.extrude_options(context):
1574             self._extrude_funcs[menu_id](layout)
1575
1576
1577 class VIEW3D_MT_edit_mesh_vertices(Menu):
1578     bl_label = "Vertices"
1579
1580     def draw(self, context):
1581         layout = self.layout
1582         layout.operator_context = 'INVOKE_REGION_WIN'
1583
1584         layout.operator("mesh.merge")
1585         layout.operator("mesh.rip_move")
1586         layout.operator("mesh.split")
1587         layout.operator("mesh.separate")
1588
1589         layout.separator()
1590
1591         layout.operator("mesh.vertices_smooth")
1592         layout.operator("mesh.remove_doubles")
1593         layout.operator("mesh.vertices_sort")
1594         layout.operator("mesh.vertices_randomize")
1595
1596         layout.operator("mesh.select_vertex_path")
1597
1598         layout.operator("mesh.blend_from_shape")
1599
1600         layout.operator("object.vertex_group_blend")
1601         layout.operator("mesh.shape_propagate_to_all")
1602
1603         layout.separator()
1604
1605         layout.menu("VIEW3D_MT_vertex_group")
1606         layout.menu("VIEW3D_MT_hook")
1607
1608
1609 class VIEW3D_MT_edit_mesh_edges(Menu):
1610     bl_label = "Edges"
1611
1612     def draw(self, context):
1613         layout = self.layout
1614         layout.operator_context = 'INVOKE_REGION_WIN'
1615
1616         layout.operator("mesh.edge_face_add")
1617         layout.operator("mesh.subdivide")
1618
1619         layout.separator()
1620
1621         layout.operator("mesh.mark_seam").clear = False
1622         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1623
1624         layout.separator()
1625
1626         layout.operator("mesh.mark_sharp").clear = False
1627         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1628
1629         layout.separator()
1630
1631         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1632         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1633
1634         layout.separator()
1635
1636         layout.operator("TRANSFORM_OT_edge_slide")
1637         layout.operator("TRANSFORM_OT_edge_crease")
1638         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1639
1640         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1641         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1642
1643         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1644
1645         layout.operator("mesh.loop_to_region")
1646         layout.operator("mesh.region_to_loop")
1647
1648
1649 class VIEW3D_MT_edit_mesh_faces(Menu):
1650     bl_label = "Faces"
1651     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1652
1653     def draw(self, context):
1654         layout = self.layout
1655         layout.operator_context = 'INVOKE_REGION_WIN'
1656
1657         layout.operator("mesh.flip_normals")
1658         # layout.operator("mesh.bevel")
1659         # layout.operator("mesh.bevel")
1660         layout.operator("mesh.edge_face_add")
1661         layout.operator("mesh.fill")
1662         layout.operator("mesh.beautify_fill")
1663         layout.operator("mesh.solidify")
1664         layout.operator("mesh.sort_faces")
1665
1666         layout.separator()
1667
1668         layout.operator("mesh.fgon_make")
1669         layout.operator("mesh.fgon_clear")
1670
1671         layout.separator()
1672
1673         layout.operator("mesh.quads_convert_to_tris")
1674         layout.operator("mesh.tris_convert_to_quads")
1675         layout.operator("mesh.edge_flip")
1676
1677         layout.separator()
1678
1679         layout.operator("mesh.faces_shade_smooth")
1680         layout.operator("mesh.faces_shade_flat")
1681
1682         layout.separator()
1683
1684         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1685         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1686
1687         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1688
1689         layout.separator()
1690
1691         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1692         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1693         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1694         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1695
1696
1697 class VIEW3D_MT_edit_mesh_normals(Menu):
1698     bl_label = "Normals"
1699
1700     def draw(self, context):
1701         layout = self.layout
1702
1703         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1704         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1705
1706         layout.separator()
1707
1708         layout.operator("mesh.flip_normals")
1709
1710
1711 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1712     _operator_name = "mesh"
1713
1714 # Edit Curve
1715 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1716
1717
1718 def draw_curve(self, context):
1719     layout = self.layout
1720
1721     settings = context.tool_settings
1722
1723     layout.menu("VIEW3D_MT_transform")
1724     layout.menu("VIEW3D_MT_mirror")
1725     layout.menu("VIEW3D_MT_snap")
1726
1727     layout.separator()
1728
1729     layout.operator("curve.extrude")
1730     layout.operator("curve.duplicate")
1731     layout.operator("curve.separate")
1732     layout.operator("curve.make_segment")
1733     layout.operator("curve.cyclic_toggle")
1734     layout.operator("curve.delete", text="Delete...")
1735
1736     layout.separator()
1737
1738     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1739     layout.menu("VIEW3D_MT_edit_curve_segments")
1740
1741     layout.separator()
1742
1743     layout.prop_menu_enum(settings, "proportional_edit")
1744     layout.prop_menu_enum(settings, "proportional_edit_falloff")
1745
1746     layout.separator()
1747
1748     layout.menu("VIEW3D_MT_edit_curve_showhide")
1749
1750
1751 class VIEW3D_MT_edit_curve(Menu):
1752     bl_label = "Curve"
1753
1754     draw = draw_curve
1755
1756
1757 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1758     bl_label = "Control Points"
1759
1760     def draw(self, context):
1761         layout = self.layout
1762
1763         edit_object = context.edit_object
1764
1765         if edit_object.type == 'CURVE':
1766             layout.operator("transform.tilt")
1767             layout.operator("curve.tilt_clear")
1768             layout.operator("curve.separate")
1769
1770             layout.separator()
1771
1772             layout.operator_menu_enum("curve.handle_type_set", "type")
1773
1774             layout.separator()
1775
1776             layout.menu("VIEW3D_MT_hook")
1777
1778
1779 class VIEW3D_MT_edit_curve_segments(Menu):
1780     bl_label = "Segments"
1781
1782     def draw(self, context):
1783         layout = self.layout
1784
1785         layout.operator("curve.subdivide")
1786         layout.operator("curve.switch_direction")
1787
1788
1789 class VIEW3D_MT_edit_curve_specials(Menu):
1790     bl_label = "Specials"
1791
1792     def draw(self, context):
1793         layout = self.layout
1794
1795         layout.operator("curve.subdivide")
1796         layout.operator("curve.switch_direction")
1797         layout.operator("curve.spline_weight_set")
1798         layout.operator("curve.radius_set")
1799         layout.operator("curve.smooth")
1800         layout.operator("curve.smooth_radius")
1801
1802
1803 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
1804     _operator_name = "curve"
1805
1806
1807 class VIEW3D_MT_edit_surface(Menu):
1808     bl_label = "Surface"
1809
1810     draw = draw_curve
1811
1812
1813 class VIEW3D_MT_edit_font(Menu):
1814     bl_label = "Text"
1815
1816     def draw(self, context):
1817         layout = self.layout
1818
1819         layout.operator("font.file_paste")
1820
1821         layout.separator()
1822
1823         layout.menu("VIEW3D_MT_edit_text_chars")
1824
1825         layout.separator()
1826
1827         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1828         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1829         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1830         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1831
1832
1833 class VIEW3D_MT_edit_text_chars(Menu):
1834     bl_label = "Special Characters"
1835
1836     def draw(self, context):
1837         layout = self.layout
1838
1839         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
1840         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
1841
1842         layout.separator()
1843
1844         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
1845         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
1846         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
1847         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
1848         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
1849         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
1850         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
1851         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
1852         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
1853
1854         layout.separator()
1855
1856         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
1857         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
1858         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
1859
1860         layout.separator()
1861
1862         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
1863         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
1864         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
1865
1866
1867 class VIEW3D_MT_edit_meta(Menu):
1868     bl_label = "Metaball"
1869
1870     def draw(self, context):
1871         layout = self.layout
1872
1873         settings = context.tool_settings
1874
1875         layout.operator("ed.undo")
1876         layout.operator("ed.redo")
1877         layout.operator("ed.undo_history")
1878
1879         layout.separator()
1880
1881         layout.menu("VIEW3D_MT_transform")
1882         layout.menu("VIEW3D_MT_mirror")
1883         layout.menu("VIEW3D_MT_snap")
1884
1885         layout.separator()
1886
1887         layout.operator("mball.delete_metaelems", text="Delete...")
1888         layout.operator("mball.duplicate_metaelems")
1889
1890         layout.separator()
1891
1892         layout.prop_menu_enum(settings, "proportional_edit")
1893         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1894
1895         layout.separator()
1896
1897         layout.menu("VIEW3D_MT_edit_meta_showhide")
1898
1899
1900 class VIEW3D_MT_edit_meta_showhide(Menu):
1901     bl_label = "Show/Hide"
1902
1903     def draw(self, context):
1904         layout = self.layout
1905
1906         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1907         layout.operator("mball.hide_metaelems", text="Hide Selected")
1908         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1909
1910
1911 class VIEW3D_MT_edit_lattice(Menu):
1912     bl_label = "Lattice"
1913
1914     def draw(self, context):
1915         layout = self.layout
1916
1917         settings = context.tool_settings
1918
1919         layout.menu("VIEW3D_MT_transform")
1920         layout.menu("VIEW3D_MT_mirror")
1921         layout.menu("VIEW3D_MT_snap")
1922
1923         layout.separator()
1924
1925         layout.operator("lattice.make_regular")
1926
1927         layout.separator()
1928
1929         layout.prop_menu_enum(settings, "proportional_edit")
1930         layout.prop_menu_enum(settings, "proportional_edit_falloff")
1931
1932
1933 class VIEW3D_MT_edit_armature(Menu):
1934     bl_label = "Armature"
1935
1936     def draw(self, context):
1937         layout = self.layout
1938
1939         edit_object = context.edit_object
1940         arm = edit_object.data
1941
1942         layout.menu("VIEW3D_MT_transform")
1943         layout.menu("VIEW3D_MT_mirror")
1944         layout.menu("VIEW3D_MT_snap")
1945         layout.menu("VIEW3D_MT_edit_armature_roll")
1946
1947         layout.separator()
1948
1949         layout.operator("armature.extrude_move")
1950
1951         if arm.use_mirror_x:
1952             layout.operator("armature.extrude_forked")
1953
1954         layout.operator("armature.duplicate_move")
1955         layout.operator("armature.merge")
1956         layout.operator("armature.fill")
1957         layout.operator("armature.delete")
1958         layout.operator("armature.separate")
1959
1960         layout.separator()
1961
1962         layout.operator("armature.subdivide", text="Subdivide")
1963         layout.operator("armature.switch_direction", text="Switch Direction")
1964
1965         layout.separator()
1966
1967         layout.operator_context = 'EXEC_AREA'
1968         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1969         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1970         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1971         layout.operator("armature.flip_names")
1972
1973         layout.separator()
1974
1975         layout.operator_context = 'INVOKE_DEFAULT'
1976         layout.operator("armature.armature_layers")
1977         layout.operator("armature.bone_layers")
1978
1979         layout.separator()
1980
1981         layout.menu("VIEW3D_MT_edit_armature_parent")
1982
1983         layout.separator()
1984
1985         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1986
1987
1988 class VIEW3D_MT_armature_specials(Menu):
1989     bl_label = "Specials"
1990
1991     def draw(self, context):
1992         layout = self.layout
1993
1994         layout.operator_context = 'INVOKE_REGION_WIN'
1995
1996         layout.operator("armature.subdivide", text="Subdivide")
1997         layout.operator("armature.switch_direction", text="Switch Direction")
1998
1999         layout.separator()
2000
2001         layout.operator_context = 'EXEC_REGION_WIN'
2002         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2003         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2004         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2005         layout.operator("armature.flip_names", text="Flip Names")
2006
2007
2008 class VIEW3D_MT_edit_armature_parent(Menu):
2009     bl_label = "Parent"
2010
2011     def draw(self, context):
2012         layout = self.layout
2013
2014         layout.operator("armature.parent_set", text="Make")
2015         layout.operator("armature.parent_clear", text="Clear")
2016
2017
2018 class VIEW3D_MT_edit_armature_roll(Menu):
2019     bl_label = "Bone Roll"
2020
2021     def draw(self, context):
2022         layout = self.layout
2023
2024         layout.operator_menu_enum("armature.calculate_roll", "type")
2025
2026         layout.separator()
2027
2028         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2029
2030 # ********** Panel **********
2031
2032
2033 class VIEW3D_PT_view3d_properties(Panel):
2034     bl_space_type = 'VIEW_3D'
2035     bl_region_type = 'UI'
2036     bl_label = "View"
2037
2038     @classmethod
2039     def poll(cls, context):
2040         view = context.space_data
2041         return (view)
2042
2043     def draw(self, context):
2044         layout = self.layout
2045
2046         view = context.space_data
2047
2048         col = layout.column()
2049         col.active = view.region_3d.view_perspective != 'CAMERA'
2050         col.prop(view, "lens")
2051         col.label(text="Lock to Object:")
2052         col.prop(view, "lock_object", text="")
2053         lock_object = view.lock_object
2054         if lock_object:
2055             if lock_object.type == 'ARMATURE':
2056                 col.prop_search(view, "lock_bone", lock_object.data, "edit_bones" if lock_object.mode == 'EDIT' else "bones", text="")
2057         else:
2058             col.prop(view, "lock_cursor", text="Lock to Cursor")
2059
2060         col = layout.column()
2061         col.prop(view, "lock_camera")
2062
2063         col = layout.column(align=True)
2064         col.label(text="Clip:")
2065         col.prop(view, "clip_start", text="Start")
2066         col.prop(view, "clip_end", text="End")
2067
2068         subcol = col.column()
2069         subcol.enabled = not view.lock_camera_and_layers
2070         subcol.label(text="Local Camera:")
2071         subcol.prop(view, "camera", text="")
2072
2073
2074 class VIEW3D_PT_view3d_cursor(Panel):
2075     bl_space_type = 'VIEW_3D'
2076     bl_region_type = 'UI'
2077     bl_label = "3D Cursor"
2078
2079     @classmethod
2080     def poll(cls, context):
2081         view = context.space_data
2082         return (view)
2083
2084     def draw(self, context):
2085         layout = self.layout
2086
2087         view = context.space_data
2088         layout.column().prop(view, "cursor_location", text="Location")
2089
2090
2091 class VIEW3D_PT_view3d_name(Panel):
2092     bl_space_type = 'VIEW_3D'
2093     bl_region_type = 'UI'
2094     bl_label = "Item"
2095
2096     @classmethod
2097     def poll(cls, context):
2098         return (context.space_data and context.active_object)
2099
2100     def draw(self, context):
2101         layout = self.layout
2102
2103         ob = context.active_object
2104         row = layout.row()
2105         row.label(text="", icon='OBJECT_DATA')
2106         row.prop(ob, "name", text="")
2107
2108         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2109             bone = context.active_bone
2110             if bone:
2111                 row = layout.row()
2112                 row.label(text="", icon='BONE_DATA')
2113                 row.prop(bone, "name", text="")
2114
2115
2116 class VIEW3D_PT_view3d_display(Panel):
2117     bl_space_type = 'VIEW_3D'
2118     bl_region_type = 'UI'
2119     bl_label = "Display"
2120     bl_options = {'DEFAULT_CLOSED'}
2121
2122     @classmethod
2123     def poll(cls, context):
2124         view = context.space_data
2125         return (view)
2126
2127     def draw(self, context):
2128         layout = self.layout
2129
2130         view = context.space_data
2131         scene = context.scene
2132         gs = scene.game_settings
2133         ob = context.object
2134
2135         col = layout.column()
2136         col.prop(view, "show_only_render")
2137
2138         col = layout.column()
2139         display_all = not view.show_only_render
2140         col.active = display_all
2141         col.prop(view, "show_outline_selected")
2142         col.prop(view, "show_all_objects_origin")
2143         col.prop(view, "show_relationship_lines")
2144         if ob and ob.type == 'MESH':
2145             mesh = ob.data
2146             col.prop(mesh, "show_all_edges")
2147
2148         col = layout.column()
2149         col.active = display_all
2150         split = col.split(percentage=0.55)
2151         split.prop(view, "show_floor", text="Grid Floor")
2152
2153         row = split.row(align=True)
2154         row.prop(view, "show_axis_x", text="X", toggle=True)
2155         row.prop(view, "show_axis_y", text="Y", toggle=True)
2156         row.prop(view, "show_axis_z", text="Z", toggle=True)
2157
2158         sub = col.column(align=True)
2159         sub.active = (display_all and view.show_floor)
2160         sub.prop(view, "grid_lines", text="Lines")
2161         sub.prop(view, "grid_scale", text="Scale")
2162         subsub = sub.column(align=True)
2163         subsub.active = scene.unit_settings.system == 'NONE'
2164         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2165
2166         if not scene.render.use_shading_nodes:
2167             col = layout.column()
2168             col.label(text="Shading:")
2169             col.prop(gs, "material_mode", text="")
2170             col.prop(view, "show_textured_solid")
2171
2172         layout.separator()
2173
2174         region = view.region_quadview
2175
2176         layout.operator("screen.region_quadview", text="Toggle Quad View")
2177
2178         if region:
2179             col = layout.column()
2180             col.prop(region, "lock_rotation")
2181             row = col.row()
2182             row.enabled = region.lock_rotation
2183             row.prop(region, "show_sync_view")
2184             row = col.row()
2185             row.enabled = region.lock_rotation and region.show_sync_view
2186             row.prop(region, "use_box_clip")
2187
2188
2189 class VIEW3D_PT_view3d_motion_tracking(Panel):
2190     bl_space_type = 'VIEW_3D'
2191     bl_region_type = 'UI'
2192     bl_label = "Motion Tracking"
2193     bl_options = {'DEFAULT_CLOSED'}
2194
2195     @classmethod
2196     def poll(cls, context):
2197         view = context.space_data
2198         return (view)
2199
2200     def draw_header(self, context):
2201         view = context.space_data
2202
2203         self.layout.prop(view, "show_reconstruction", text="")
2204
2205     def draw(self, context):
2206         layout = self.layout
2207
2208         view = context.space_data
2209
2210         col = layout.column()
2211         col.active = view.show_reconstruction
2212         col.prop(view, "show_bundle_names")
2213         col.prop(view, "show_camera_path")
2214         col.label(text="Tracks:")
2215         col.prop(view, "tracks_draw_type", text="")
2216         col.prop(view, "tracks_draw_size", text="Size")
2217
2218
2219 class VIEW3D_PT_view3d_meshdisplay(Panel):
2220     bl_space_type = 'VIEW_3D'
2221     bl_region_type = 'UI'
2222     bl_label = "Mesh Display"
2223
2224     @classmethod
2225     def poll(cls, context):
2226         # The active object check is needed because of local-mode
2227         return (context.active_object and (context.mode == 'EDIT_MESH'))
2228
2229     def draw(self, context):
2230         layout = self.layout
2231
2232         mesh = context.active_object.data
2233
2234         col = layout.column()
2235         col.label(text="Overlays:")
2236         col.prop(mesh, "show_edges", text="Edges")
2237         col.prop(mesh, "show_faces", text="Faces")
2238         col.prop(mesh, "show_edge_crease", text="Creases")
2239         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2240         col.prop(mesh, "show_edge_seams", text="Seams")
2241         col.prop(mesh, "show_edge_sharp", text="Sharp")
2242
2243         col.separator()
2244         col.label(text="Normals:")
2245         col.prop(mesh, "show_normal_face", text="Face")
2246         col.prop(mesh, "show_normal_vertex", text="Vertex")
2247         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2248
2249         col.separator()
2250         col.label(text="Numerics:")
2251         col.prop(mesh, "show_extra_edge_length")
2252         col.prop(mesh, "show_extra_face_angle")
2253         col.prop(mesh, "show_extra_face_area")
2254         if bpy.app.debug:
2255             col.prop(mesh, "show_extra_indices")
2256
2257
2258 class VIEW3D_PT_view3d_curvedisplay(Panel):
2259     bl_space_type = 'VIEW_3D'
2260     bl_region_type = 'UI'
2261     bl_label = "Curve Display"
2262
2263     @classmethod
2264     def poll(cls, context):
2265         editmesh = context.mode == 'EDIT_CURVE'
2266         return (editmesh)
2267
2268     def draw(self, context):
2269         layout = self.layout
2270
2271         curve = context.active_object.data
2272
2273         col = layout.column()
2274         col.label(text="Overlays:")
2275         col.prop(curve, "show_handles", text="Handles")
2276         col.prop(curve, "show_normal_face", text="Normals")
2277         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2278
2279
2280 class VIEW3D_PT_background_image(Panel):
2281     bl_space_type = 'VIEW_3D'
2282     bl_region_type = 'UI'
2283     bl_label = "Background Images"
2284     bl_options = {'DEFAULT_CLOSED'}
2285
2286     def draw_header(self, context):
2287         view = context.space_data
2288
2289         self.layout.prop(view, "show_background_images", text="")
2290
2291     def draw(self, context):
2292         layout = self.layout
2293
2294         view = context.space_data
2295
2296         col = layout.column()
2297         col.operator("view3d.background_image_add", text="Add Image")
2298
2299         for i, bg in enumerate(view.background_images):
2300             layout.active = view.show_background_images
2301             box = layout.box()
2302             row = box.row(align=True)
2303             row.prop(bg, "show_expanded", text="", emboss=False)
2304             if bg.source == 'IMAGE' and bg.image:
2305                 row.prop(bg.image, "name", text="", emboss=False)
2306             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2307                 row.prop(bg.clip, "name", text="", emboss=False)
2308             else:
2309                 row.label(text="Not Set")
2310
2311             if bg.show_background_image:
2312                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2313             else:
2314                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2315
2316             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2317
2318             box.prop(bg, "view_axis", text="Axis")
2319
2320             if bg.show_expanded:
2321                 row = box.row()
2322                 row.prop(bg, "source", expand=True)
2323
2324                 has_bg = False
2325                 if bg.source == 'IMAGE':
2326                     row = box.row()
2327                     row.template_ID(bg, "image", open="image.open")
2328                     if (bg.image):
2329                         box.template_image(bg, "image", bg.image_user, compact=True)
2330                         has_bg = True
2331
2332                 elif bg.source == 'MOVIE_CLIP':
2333                     box.prop(bg, 'use_camera_clip')
2334
2335                     column = box.column()
2336                     column.active = not bg.use_camera_clip
2337                     column.template_ID(bg, "clip", open="clip.open")
2338
2339                     if bg.clip:
2340                         column.template_movieclip(bg, "clip", compact=True)
2341
2342                     if bg.use_camera_clip or bg.clip:
2343                         has_bg = True
2344
2345                     column = box.column()
2346                     column.active = has_bg
2347                     column.prop(bg.clip_user, "proxy_render_size", text="")
2348                     column.prop(bg.clip_user, "use_render_undistorted")
2349
2350                 if has_bg:
2351                     box.prop(bg, "opacity", slider=True)
2352                     if bg.view_axis != 'CAMERA':
2353                         box.prop(bg, "size")
2354                         row = box.row(align=True)
2355                         row.prop(bg, "offset_x", text="X")
2356                         row.prop(bg, "offset_y", text="Y")
2357
2358
2359 class VIEW3D_PT_transform_orientations(Panel):
2360     bl_space_type = 'VIEW_3D'
2361     bl_region_type = 'UI'
2362     bl_label = "Transform Orientations"
2363     bl_options = {'DEFAULT_CLOSED'}
2364
2365     @classmethod
2366     def poll(cls, context):
2367         view = context.space_data
2368         return (view)
2369
2370     def draw(self, context):
2371         layout = self.layout
2372
2373         view = context.space_data
2374         orientation = view.current_orientation
2375
2376         row = layout.row(align=True)
2377         row.prop(view, "transform_orientation", text="")
2378         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2379
2380         if orientation:
2381             row = layout.row(align=True)
2382             row.prop(orientation, "name", text="")
2383             row.operator("transform.delete_orientation", text="", icon="X")
2384
2385
2386 class VIEW3D_PT_etch_a_ton(Panel):
2387     bl_space_type = 'VIEW_3D'
2388     bl_region_type = 'UI'
2389     bl_label = "Skeleton Sketching"
2390     bl_options = {'DEFAULT_CLOSED'}
2391
2392     @classmethod
2393     def poll(cls, context):
2394         scene = context.space_data
2395         ob = context.active_object
2396         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2397
2398     def draw_header(self, context):
2399         layout = self.layout
2400         toolsettings = context.scene.tool_settings
2401
2402         layout.prop(toolsettings, "use_bone_sketching", text="")
2403
2404     def draw(self, context):
2405         layout = self.layout
2406         toolsettings = context.scene.tool_settings
2407
2408         col = layout.column()
2409
2410         col.prop(toolsettings, "use_etch_quick")
2411         col.prop(toolsettings, "use_etch_overdraw")
2412
2413         col.prop(toolsettings, "etch_convert_mode")
2414
2415         if toolsettings.etch_convert_mode == 'LENGTH':
2416             col.prop(toolsettings, "etch_length_limit")
2417         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2418             col.prop(toolsettings, "etch_adaptive_limit")
2419         elif toolsettings.etch_convert_mode == 'FIXED':
2420             col.prop(toolsettings, "etch_subdivision_number")
2421         elif toolsettings.etch_convert_mode == 'RETARGET':
2422             col.prop(toolsettings, "etch_template")
2423             col.prop(toolsettings, "etch_roll_mode")
2424             col.prop(toolsettings, "use_etch_autoname")
2425             col.prop(toolsettings, "etch_number")
2426             col.prop(toolsettings, "etch_side")
2427
2428         col.operator("sketch.convert", text="Convert")
2429
2430
2431 class VIEW3D_PT_context_properties(Panel):
2432     bl_space_type = 'VIEW_3D'
2433     bl_region_type = 'UI'
2434     bl_label = "Properties"
2435     bl_options = {'DEFAULT_CLOSED'}
2436
2437     def _active_context_member(context):
2438         obj = context.object
2439         if obj:
2440             mode = obj.mode
2441             if mode == 'POSE':
2442                 return "active_pose_bone"
2443             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2444                 return "active_bone"
2445             else:
2446                 return "object"
2447
2448         return ""
2449
2450     @classmethod
2451     def poll(cls, context):
2452         member = cls._active_context_member(context)
2453         if member:
2454             context_member = getattr(context, member)
2455             return context_member and context_member.keys()
2456
2457         return False
2458
2459     def draw(self, context):
2460         import rna_prop_ui
2461         member = VIEW3D_PT_context_properties._active_context_member(context)
2462
2463         if member:
2464             # Draw with no edit button
2465             rna_prop_ui.draw(self.layout, context, member, object, False)
2466
2467
2468 def register():
2469     bpy.utils.register_module(__name__)
2470
2471
2472 def unregister():
2473     bpy.utils.unregister_module(__name__)
2474
2475 if __name__ == "__main__":
2476     register()
2477
2478 if __name__ == "__main__":  # only for live edit.
2479     bpy.utils.register_module(__name__)