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