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