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