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