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