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