Audaspace Py API documentation fixes.
[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         sculpt = context.tool_settings.sculpt
1005         brush = context.tool_settings.sculpt.brush
1006
1007         layout.prop(sculpt, "symmetry_x")
1008         layout.prop(sculpt, "symmetry_y")
1009         layout.prop(sculpt, "symmetry_z")
1010         layout.separator()
1011         layout.prop(sculpt, "lock_x")
1012         layout.prop(sculpt, "lock_y")
1013         layout.prop(sculpt, "lock_z")
1014         layout.separator()
1015         layout.operator_menu_enum("brush.curve_preset", "shape")
1016         layout.separator()
1017
1018         sculpt_tool = brush.sculpt_tool
1019
1020         if sculpt_tool != 'GRAB':
1021             layout.prop(brush, "use_airbrush")
1022
1023             if sculpt_tool != 'LAYER':
1024                 layout.prop(brush, "use_anchor")
1025
1026             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
1027                 layout.prop(brush, "flip_direction")
1028
1029             if sculpt_tool == 'LAYER':
1030                 layout.prop(brush, "use_persistent")
1031                 layout.operator("sculpt.set_persistent_base")
1032
1033 # ********** Particle menu **********
1034
1035
1036 class VIEW3D_MT_particle(bpy.types.Menu):
1037     bl_label = "Particle"
1038
1039     def draw(self, context):
1040         layout = self.layout
1041
1042         particle_edit = context.tool_settings.particle_edit
1043
1044         layout.operator("particle.mirror")
1045
1046         layout.separator()
1047
1048         layout.operator("particle.remove_doubles")
1049         layout.operator("particle.delete")
1050
1051         if particle_edit.selection_mode == 'POINT':
1052             layout.operator("particle.subdivide")
1053
1054         layout.operator("particle.rekey")
1055         layout.operator("particle.weight_set")
1056
1057         layout.separator()
1058
1059         layout.menu("VIEW3D_MT_particle_showhide")
1060
1061
1062 class VIEW3D_MT_particle_specials(bpy.types.Menu):
1063     bl_label = "Specials"
1064
1065     def draw(self, context):
1066         layout = self.layout
1067         particle_edit = context.tool_settings.particle_edit
1068
1069         layout.operator("particle.rekey")
1070
1071         layout.separator()
1072         if particle_edit.selection_mode == 'POINT':
1073             layout.operator("particle.subdivide")
1074             layout.operator("particle.select_roots")
1075             layout.operator("particle.select_tips")
1076
1077         layout.operator("particle.remove_doubles")
1078
1079
1080 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
1081     _operator_name = "particle"
1082
1083 # ********** Pose Menu **********
1084
1085
1086 class VIEW3D_MT_pose(bpy.types.Menu):
1087     bl_label = "Pose"
1088
1089     def draw(self, context):
1090         layout = self.layout
1091
1092         arm = context.active_object.data
1093
1094         layout.menu("VIEW3D_MT_transform")
1095         layout.menu("VIEW3D_MT_snap")
1096         if arm.drawtype in ('BBONE', 'ENVELOPE'):
1097             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1098
1099         layout.menu("VIEW3D_MT_pose_transform")
1100
1101         layout.separator()
1102
1103         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
1104         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
1105         layout.operator("anim.keying_set_active_set", text="Change Keying Set...")
1106
1107         layout.separator()
1108
1109         layout.operator("pose.relax")
1110
1111         layout.separator()
1112
1113         layout.menu("VIEW3D_MT_pose_apply")
1114
1115         layout.separator()
1116
1117         layout.operator("pose.copy")
1118         layout.operator("pose.paste")
1119         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1120
1121         layout.separator()
1122
1123         layout.menu("VIEW3D_MT_pose_pose")
1124         layout.menu("VIEW3D_MT_pose_motion")
1125         layout.menu("VIEW3D_MT_pose_group")
1126
1127         layout.separator()
1128
1129         layout.menu("VIEW3D_MT_pose_ik")
1130         layout.menu("VIEW3D_MT_pose_constraints")
1131
1132         layout.separator()
1133
1134         layout.operator_context = 'EXEC_AREA'
1135         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1136         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1137         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1138
1139         layout.operator("pose.flip_names")
1140
1141         layout.operator("pose.quaternions_flip")
1142
1143         layout.separator()
1144
1145         layout.operator_context = 'INVOKE_AREA'
1146         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1147         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1148
1149         layout.separator()
1150
1151         layout.menu("VIEW3D_MT_pose_showhide")
1152         layout.operator_menu_enum("pose.flags_set", 'mode', text="Bone Settings")
1153
1154
1155 class VIEW3D_MT_pose_transform(bpy.types.Menu):
1156     bl_label = "Clear Transform"
1157
1158     def draw(self, context):
1159         layout = self.layout
1160
1161         layout.label(text="User Transform")
1162
1163         layout.operator("pose.loc_clear", text="Location")
1164         layout.operator("pose.rot_clear", text="Rotation")
1165         layout.operator("pose.scale_clear", text="Scale")
1166
1167         layout.label(text="Origin")
1168
1169
1170 class VIEW3D_MT_pose_pose(bpy.types.Menu):
1171     bl_label = "Pose Library"
1172
1173     def draw(self, context):
1174         layout = self.layout
1175
1176         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1177
1178         layout.separator()
1179
1180         layout.operator("poselib.pose_add", text="Add Pose...")
1181         layout.operator("poselib.pose_rename", text="Rename Pose...")
1182         layout.operator("poselib.pose_remove", text="Remove Pose...")
1183
1184
1185 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1186     bl_label = "Motion Paths"
1187
1188     def draw(self, context):
1189         layout = self.layout
1190
1191         layout.operator("pose.paths_calculate", text="Calculate")
1192         layout.operator("pose.paths_clear", text="Clear")
1193
1194
1195 class VIEW3D_MT_pose_group(bpy.types.Menu):
1196     bl_label = "Bone Groups"
1197
1198     def draw(self, context):
1199         layout = self.layout
1200         layout.operator("pose.group_add")
1201         layout.operator("pose.group_remove")
1202
1203         layout.separator()
1204
1205         layout.operator("pose.group_assign")
1206         layout.operator("pose.group_unassign")
1207
1208
1209 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1210     bl_label = "Inverse Kinematics"
1211
1212     def draw(self, context):
1213         layout = self.layout
1214
1215         layout.operator("pose.ik_add")
1216         layout.operator("pose.ik_clear")
1217
1218
1219 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1220     bl_label = "Constraints"
1221
1222     def draw(self, context):
1223         layout = self.layout
1224
1225         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1226         layout.operator("pose.constraints_copy")
1227         layout.operator("pose.constraints_clear")
1228
1229
1230 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
1231     _operator_name = "pose"
1232
1233
1234 class VIEW3D_MT_pose_apply(bpy.types.Menu):
1235     bl_label = "Apply"
1236
1237     def draw(self, context):
1238         layout = self.layout
1239
1240         layout.operator("pose.armature_apply")
1241         layout.operator("pose.visual_transform_apply")
1242
1243
1244 # ********** Edit Menus, suffix from ob.type **********
1245
1246
1247 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1248     bl_label = "Mesh"
1249
1250     def draw(self, context):
1251         layout = self.layout
1252
1253         settings = context.tool_settings
1254
1255         layout.operator("ed.undo")
1256         layout.operator("ed.redo")
1257
1258         layout.separator()
1259
1260         layout.menu("VIEW3D_MT_transform")
1261         layout.menu("VIEW3D_MT_mirror")
1262         layout.menu("VIEW3D_MT_snap")
1263
1264         layout.separator()
1265
1266         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1267
1268         layout.separator()
1269
1270         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1271         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1272         layout.operator("mesh.duplicate_move")
1273         layout.operator("mesh.delete", text="Delete...")
1274
1275         layout.separator()
1276
1277         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1278         layout.menu("VIEW3D_MT_edit_mesh_edges")
1279         layout.menu("VIEW3D_MT_edit_mesh_faces")
1280         layout.menu("VIEW3D_MT_edit_mesh_normals")
1281
1282         layout.separator()
1283
1284         layout.prop(settings, "automerge_editing")
1285         layout.prop_menu_enum(settings, "proportional_editing")
1286         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1287
1288         layout.separator()
1289
1290         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1291
1292
1293 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1294     bl_label = "Specials"
1295
1296     def draw(self, context):
1297         layout = self.layout
1298
1299         layout.operator_context = 'INVOKE_REGION_WIN'
1300
1301         layout.operator("mesh.subdivide", text="Subdivide")
1302         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1303         layout.operator("mesh.merge", text="Merge...")
1304         layout.operator("mesh.remove_doubles")
1305         layout.operator("mesh.hide", text="Hide")
1306         layout.operator("mesh.reveal", text="Reveal")
1307         layout.operator("mesh.select_inverse")
1308         layout.operator("mesh.flip_normals")
1309         layout.operator("mesh.vertices_smooth", text="Smooth")
1310         # layout.operator("mesh.bevel", text="Bevel")
1311         layout.operator("mesh.faces_shade_smooth")
1312         layout.operator("mesh.faces_shade_flat")
1313         layout.operator("mesh.blend_from_shape")
1314         layout.operator("mesh.shape_propagate_to_all")
1315         layout.operator("mesh.select_vertex_path")
1316
1317
1318 class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu):
1319     bl_label = "Mesh Select Mode"
1320
1321     def draw(self, context):
1322         layout = self.layout
1323
1324         layout.operator_context = 'INVOKE_REGION_WIN'
1325
1326         prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1327         prop.value = "(True, False, False)"
1328         prop.data_path = "tool_settings.mesh_selection_mode"
1329
1330         prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1331         prop.value = "(False, True, False)"
1332         prop.data_path = "tool_settings.mesh_selection_mode"
1333
1334         prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1335         prop.value = "(False, False, True)"
1336         prop.data_path = "tool_settings.mesh_selection_mode"
1337
1338
1339 class VIEW3D_MT_edit_mesh_extrude(bpy.types.Menu):
1340     bl_label = "Extrude"
1341
1342     @staticmethod
1343     def extrude_options(context):
1344         mesh = context.object.data
1345         selection_mode = context.tool_settings.mesh_selection_mode
1346
1347         totface = mesh.total_face_sel
1348         totedge = mesh.total_edge_sel
1349         totvert = mesh.total_vert_sel
1350
1351         # the following is dependent on selection modes
1352         # we don't really want that
1353 #        if selection_mode[0]: # vert
1354 #            if totvert == 0:
1355 #                return ()
1356 #            elif totvert == 1:
1357 #                return (3,)
1358 #            elif totedge == 0:
1359 #                return (3,)
1360 #            elif totface == 0:
1361 #                return (2, 3)
1362 #            elif totface == 1:
1363 #                return (0, 2, 3)
1364 #            else:
1365 #                return (0, 1, 2, 3)
1366 #        elif selection_mode[1]: # edge
1367 #            if totedge == 0:
1368 #                return ()
1369 #            elif totedge == 1:
1370 #                return (2,)
1371 #            elif totface == 0:
1372 #                return (2,)
1373 #            elif totface == 1:
1374 #                return (0, 2)
1375 #            else:
1376 #                return (0, 1, 2)
1377 #        elif selection_mode[2]: # face
1378 #            if totface == 0:
1379 #                return ()
1380 #            elif totface == 1:
1381 #                return (0,)
1382 #            else:
1383 #                return (0, 1)
1384
1385         if totvert == 0:
1386             return ()
1387         elif totedge == 0:
1388             return (0, 3)
1389         elif totface == 0:
1390             return (0, 2, 3)
1391         else:
1392             return (0, 1, 2, 3)
1393
1394         # should never get here
1395         return ()
1396
1397     def draw(self, context):
1398         layout = self.layout
1399         layout.operator_context = 'INVOKE_REGION_WIN'
1400
1401         def region_menu():
1402             layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region")
1403
1404         def face_menu():
1405             layout.operator("mesh.extrude_faces_move", text="Individual Faces")
1406
1407         def edge_menu():
1408             layout.operator("mesh.extrude_edges_move", text="Edges Only")
1409
1410         def vert_menu():
1411             layout.operator("mesh.extrude_vertices_move", text="Vertices Only")
1412
1413         menu_funcs = region_menu, face_menu, edge_menu, vert_menu
1414
1415         for i in self.extrude_options(context):
1416             func = menu_funcs[i]
1417             func()
1418
1419
1420 class VIEW3D_OT_edit_mesh_extrude_individual_move(bpy.types.Operator):
1421     "Extrude individual elements and move"
1422     bl_label = "Extrude Individual and Move"
1423     bl_idname = "view3d.edit_mesh_extrude_individual_move"
1424
1425     def execute(self, context):
1426         mesh = context.object.data
1427         selection_mode = context.tool_settings.mesh_selection_mode
1428
1429         totface = mesh.total_face_sel
1430         totedge = mesh.total_edge_sel
1431         totvert = mesh.total_vert_sel
1432
1433         if selection_mode[2] and totface == 1:
1434             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [False, False, True]})
1435         elif selection_mode[2] and totface > 1:
1436             return bpy.ops.mesh.extrude_faces_move('INVOKE_REGION_WIN')
1437         elif selection_mode[1] and totedge >= 1:
1438             return bpy.ops.mesh.extrude_edges_move('INVOKE_REGION_WIN')
1439         else:
1440             return bpy.ops.mesh.extrude_vertices_move('INVOKE_REGION_WIN')
1441
1442     def invoke(self, context, event):
1443         return self.execute(context)
1444
1445
1446 class VIEW3D_OT_edit_mesh_extrude_move(bpy.types.Operator):
1447     "Extrude and move along normals"
1448     bl_label = "Extrude and Move on Normals"
1449     bl_idname = "view3d.edit_mesh_extrude_move_normal"
1450
1451     def execute(self, context):
1452         mesh = context.object.data
1453
1454         totface = mesh.total_face_sel
1455         totedge = mesh.total_edge_sel
1456         totvert = mesh.total_vert_sel
1457
1458         if totface >= 1:
1459             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [False, False, True]})
1460         elif totedge == 1:
1461             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN', TRANSFORM_OT_translate={"constraint_orientation": "NORMAL", "constraint_axis": [True, True, False]})
1462         else:
1463             return bpy.ops.mesh.extrude_region_move('INVOKE_REGION_WIN')
1464
1465     def invoke(self, context, event):
1466         return self.execute(context)
1467
1468
1469 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1470     bl_label = "Vertices"
1471
1472     def draw(self, context):
1473         layout = self.layout
1474         layout.operator_context = 'INVOKE_REGION_WIN'
1475
1476         layout.operator("mesh.merge")
1477         layout.operator("mesh.rip")
1478         layout.operator("mesh.split")
1479         layout.operator("mesh.separate")
1480
1481         layout.separator()
1482
1483         layout.operator("mesh.vertices_smooth")
1484         layout.operator("mesh.remove_doubles")
1485
1486         layout.operator("mesh.select_vertex_path")
1487
1488         layout.operator("mesh.blend_from_shape")
1489
1490         layout.operator("object.vertex_group_blend")
1491         layout.operator("mesh.shape_propagate_to_all")
1492
1493         layout.separator()
1494
1495         layout.menu("VIEW3D_MT_vertex_group")
1496         layout.menu("VIEW3D_MT_hook")
1497
1498
1499 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1500     bl_label = "Edges"
1501
1502     def draw(self, context):
1503         layout = self.layout
1504         layout.operator_context = 'INVOKE_REGION_WIN'
1505
1506         layout.operator("mesh.edge_face_add")
1507         layout.operator("mesh.subdivide")
1508
1509         layout.separator()
1510
1511         layout.operator("mesh.mark_seam")
1512         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1513
1514         layout.separator()
1515
1516         layout.operator("mesh.mark_sharp")
1517         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1518
1519         layout.separator()
1520
1521         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1522         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1523
1524         layout.separator()
1525
1526         layout.operator("TRANSFORM_OT_edge_slide")
1527         layout.operator("TRANSFORM_OT_edge_crease")
1528         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1529
1530         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1531         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1532
1533         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1534
1535         layout.operator("mesh.loop_to_region")
1536         layout.operator("mesh.region_to_loop")
1537
1538
1539 class VIEW3D_MT_edit_mesh_faces(bpy.types.Menu):
1540     bl_label = "Faces"
1541     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1542
1543     def draw(self, context):
1544         layout = self.layout
1545         layout.operator_context = 'INVOKE_REGION_WIN'
1546
1547         layout.operator("mesh.flip_normals")
1548         # layout.operator("mesh.bevel")
1549         # layout.operator("mesh.bevel")
1550         layout.operator("mesh.edge_face_add")
1551         layout.operator("mesh.fill")
1552         layout.operator("mesh.beautify_fill")
1553         layout.operator("mesh.solidify")
1554         layout.operator("mesh.sort_faces")
1555
1556         layout.separator()
1557
1558         layout.operator("mesh.quads_convert_to_tris")
1559         layout.operator("mesh.tris_convert_to_quads")
1560         layout.operator("mesh.edge_flip")
1561
1562         layout.separator()
1563
1564         layout.operator("mesh.faces_shade_smooth")
1565         layout.operator("mesh.faces_shade_flat")
1566
1567         layout.separator()
1568
1569         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1570         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1571
1572         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1573
1574         layout.separator()
1575
1576         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1577         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1578         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1579         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1580
1581
1582 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1583     bl_label = "Normals"
1584
1585     def draw(self, context):
1586         layout = self.layout
1587
1588         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1589         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1590
1591         layout.separator()
1592
1593         layout.operator("mesh.flip_normals")
1594
1595
1596 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1597     _operator_name = "mesh"
1598
1599 # Edit Curve
1600 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1601
1602
1603 def draw_curve(self, context):
1604     layout = self.layout
1605
1606     settings = context.tool_settings
1607
1608     layout.menu("VIEW3D_MT_transform")
1609     layout.menu("VIEW3D_MT_mirror")
1610     layout.menu("VIEW3D_MT_snap")
1611
1612     layout.separator()
1613
1614     layout.operator("curve.extrude")
1615     layout.operator("curve.duplicate")
1616     layout.operator("curve.separate")
1617     layout.operator("curve.make_segment")
1618     layout.operator("curve.cyclic_toggle")
1619     layout.operator("curve.delete", text="Delete...")
1620
1621     layout.separator()
1622
1623     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1624     layout.menu("VIEW3D_MT_edit_curve_segments")
1625
1626     layout.separator()
1627
1628     layout.prop_menu_enum(settings, "proportional_editing")
1629     layout.prop_menu_enum(settings, "proportional_editing_falloff")
1630
1631     layout.separator()
1632
1633     layout.menu("VIEW3D_MT_edit_curve_showhide")
1634
1635
1636 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1637     bl_label = "Curve"
1638
1639     draw = draw_curve
1640
1641
1642 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1643     bl_label = "Control Points"
1644
1645     def draw(self, context):
1646         layout = self.layout
1647
1648         edit_object = context.edit_object
1649
1650         if edit_object.type == 'CURVE':
1651             layout.operator("transform.transform").mode = 'TILT'
1652             layout.operator("curve.tilt_clear")
1653             layout.operator("curve.separate")
1654
1655             layout.separator()
1656
1657             layout.operator_menu_enum("curve.handle_type_set", "type")
1658
1659             layout.separator()
1660
1661             layout.menu("VIEW3D_MT_hook")
1662
1663
1664 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1665     bl_label = "Segments"
1666
1667     def draw(self, context):
1668         layout = self.layout
1669
1670         layout.operator("curve.subdivide")
1671         layout.operator("curve.switch_direction")
1672
1673
1674 class VIEW3D_MT_edit_curve_specials(bpy.types.Menu):
1675     bl_label = "Specials"
1676
1677     def draw(self, context):
1678         layout = self.layout
1679
1680         layout.operator("curve.subdivide")
1681         layout.operator("curve.switch_direction")
1682         layout.operator("curve.spline_weight_set")
1683         layout.operator("curve.radius_set")
1684         layout.operator("curve.smooth")
1685         layout.operator("curve.smooth_radius")
1686
1687
1688 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1689     _operator_name = "curve"
1690
1691
1692 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1693     bl_label = "Surface"
1694
1695     draw = draw_curve
1696
1697
1698 class VIEW3D_MT_edit_text(bpy.types.Menu):
1699     bl_label = "Text"
1700
1701     def draw(self, context):
1702         layout = self.layout
1703
1704         layout.operator("font.file_paste")
1705
1706         layout.separator()
1707
1708         layout.menu("VIEW3D_MT_edit_text_chars")
1709
1710         layout.separator()
1711         
1712         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1713         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1714         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1715         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1716
1717
1718 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1719     bl_label = "Special Characters"
1720
1721     def draw(self, context):
1722         layout = self.layout
1723
1724         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1725         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1726
1727         layout.separator()
1728
1729         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1730         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1731         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1732         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1733         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1734         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1735         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1736         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1737         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1738
1739         layout.separator()
1740
1741         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1742         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1743         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1744
1745         layout.separator()
1746
1747         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1748         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1749         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1750
1751
1752 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1753     bl_label = "Metaball"
1754
1755     def draw(self, context):
1756         layout = self.layout
1757
1758         settings = context.tool_settings
1759
1760         layout.operator("ed.undo")
1761         layout.operator("ed.redo")
1762
1763         layout.separator()
1764
1765         layout.menu("VIEW3D_MT_transform")
1766         layout.menu("VIEW3D_MT_mirror")
1767         layout.menu("VIEW3D_MT_snap")
1768
1769         layout.separator()
1770
1771         layout.operator("mball.delete_metaelems", text="Delete...")
1772         layout.operator("mball.duplicate_metaelems")
1773
1774         layout.separator()
1775
1776         layout.prop_menu_enum(settings, "proportional_editing")
1777         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1778
1779         layout.separator()
1780
1781         layout.menu("VIEW3D_MT_edit_meta_showhide")
1782
1783
1784 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1785     bl_label = "Show/Hide"
1786
1787     def draw(self, context):
1788         layout = self.layout
1789
1790         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1791         layout.operator("mball.hide_metaelems", text="Hide Selected")
1792         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1793
1794
1795 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1796     bl_label = "Lattice"
1797
1798     def draw(self, context):
1799         layout = self.layout
1800
1801         settings = context.tool_settings
1802
1803         layout.menu("VIEW3D_MT_transform")
1804         layout.menu("VIEW3D_MT_mirror")
1805         layout.menu("VIEW3D_MT_snap")
1806
1807         layout.separator()
1808
1809         layout.operator("lattice.make_regular")
1810
1811         layout.separator()
1812
1813         layout.prop_menu_enum(settings, "proportional_editing")
1814         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1815
1816
1817 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1818     bl_label = "Armature"
1819
1820     def draw(self, context):
1821         layout = self.layout
1822
1823         edit_object = context.edit_object
1824         arm = edit_object.data
1825
1826         layout.menu("VIEW3D_MT_transform")
1827         layout.menu("VIEW3D_MT_mirror")
1828         layout.menu("VIEW3D_MT_snap")
1829         layout.menu("VIEW3D_MT_edit_armature_roll")
1830
1831         if arm.drawtype == 'ENVELOPE':
1832             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1833         else:
1834             layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
1835
1836         layout.separator()
1837
1838         layout.operator("armature.extrude_move")
1839
1840         if arm.x_axis_mirror:
1841             layout.operator("armature.extrude_forked")
1842
1843         layout.operator("armature.duplicate_move")
1844         layout.operator("armature.merge")
1845         layout.operator("armature.fill")
1846         layout.operator("armature.delete")
1847         layout.operator("armature.separate")
1848
1849         layout.separator()
1850
1851         layout.operator("armature.subdivide_multi", text="Subdivide")
1852         layout.operator("armature.switch_direction", text="Switch Direction")
1853
1854         layout.separator()
1855
1856         layout.operator_context = 'EXEC_AREA'
1857         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1858         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1859         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1860         layout.operator("armature.flip_names")
1861
1862         layout.separator()
1863
1864         layout.operator_context = 'INVOKE_DEFAULT'
1865         layout.operator("armature.armature_layers")
1866         layout.operator("armature.bone_layers")
1867
1868         layout.separator()
1869
1870         layout.menu("VIEW3D_MT_edit_armature_parent")
1871
1872         layout.separator()
1873
1874         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1875
1876
1877 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1878     bl_label = "Specials"
1879
1880     def draw(self, context):
1881         layout = self.layout
1882
1883         layout.operator_context = 'INVOKE_REGION_WIN'
1884
1885         layout.operator("armature.subdivide_multi", text="Subdivide")
1886         layout.operator("armature.switch_direction", text="Switch Direction")
1887
1888         layout.separator()
1889
1890         layout.operator_context = 'EXEC_REGION_WIN'
1891         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1892         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1893         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1894         layout.operator("armature.flip_names", text="Flip Names")
1895
1896
1897 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1898     bl_label = "Parent"
1899
1900     def draw(self, context):
1901         layout = self.layout
1902
1903         layout.operator("armature.parent_set", text="Make")
1904         layout.operator("armature.parent_clear", text="Clear")
1905
1906
1907 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1908     bl_label = "Bone Roll"
1909
1910     def draw(self, context):
1911         layout = self.layout
1912
1913         layout.operator("armature.calculate_roll", text="Clear Roll (Z-Axis Up)").type = 'GLOBALUP'
1914         layout.operator("armature.calculate_roll", text="Roll to Cursor").type = 'CURSOR'
1915
1916         layout.separator()
1917
1918         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
1919
1920 # ********** Panel **********
1921
1922
1923 class VIEW3D_PT_view3d_properties(bpy.types.Panel):
1924     bl_space_type = 'VIEW_3D'
1925     bl_region_type = 'UI'
1926     bl_label = "View"
1927
1928     def poll(self, context):
1929         view = context.space_data
1930         return (view)
1931
1932     def draw(self, context):
1933         layout = self.layout
1934
1935         view = context.space_data
1936         scene = context.scene
1937
1938         col = layout.column()
1939         col.active = view.region_3d.view_perspective != 'CAMERA'
1940         col.prop(view, "lens")
1941         col.label(text="Lock to Object:")
1942         col.prop(view, "lock_object", text="")
1943         if view.lock_object and view.lock_object.type == 'ARMATURE':
1944             col.prop_object(view, "lock_bone", view.lock_object.data, "bones", text="")
1945
1946         col = layout.column(align=True)
1947         col.label(text="Clip:")
1948         col.prop(view, "clip_start", text="Start")
1949         col.prop(view, "clip_end", text="End")
1950
1951         subcol = col.column()
1952         subcol.enabled = not view.lock_camera_and_layers
1953         subcol.label(text="Local Camera:")
1954         subcol.prop(view, "camera", text="")
1955
1956         layout.column().prop(view, "cursor_location")
1957
1958
1959 class VIEW3D_PT_view3d_name(bpy.types.Panel):
1960     bl_space_type = 'VIEW_3D'
1961     bl_region_type = 'UI'
1962     bl_label = "Item"
1963
1964     def poll(self, context):
1965         return (context.space_data and context.active_object)
1966
1967     def draw(self, context):
1968         layout = self.layout
1969
1970         ob = context.active_object
1971         row = layout.row()
1972         row.label(text="", icon='OBJECT_DATA')
1973         row.prop(ob, "name", text="")
1974
1975         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1976             bone = context.active_bone
1977             if bone:
1978                 row = layout.row()
1979                 row.label(text="", icon='BONE_DATA')
1980                 row.prop(bone, "name", text="")
1981
1982
1983 class VIEW3D_PT_view3d_display(bpy.types.Panel):
1984     bl_space_type = 'VIEW_3D'
1985     bl_region_type = 'UI'
1986     bl_label = "Display"
1987     bl_default_closed = True
1988
1989     def poll(self, context):
1990         view = context.space_data
1991         return (view)
1992
1993     def draw(self, context):
1994         layout = self.layout
1995
1996         view = context.space_data
1997         gs = context.scene.game_data
1998         ob = context.object
1999
2000         col = layout.column()
2001         col.prop(view, "display_render_override")
2002
2003         col = layout.column()
2004         display_all = not view.display_render_override
2005         col.active = display_all
2006         col.prop(view, "outline_selected")
2007         col.prop(view, "all_object_origins")
2008         col.prop(view, "relationship_lines")
2009         if ob and ob.type == 'MESH':
2010             mesh = ob.data
2011             col.prop(mesh, "all_edges")
2012
2013         col = layout.column()
2014         col.active = display_all
2015         split = col.split(percentage=0.55)
2016         split.prop(view, "display_floor", text="Grid Floor")
2017
2018         row = split.row(align=True)
2019         row.prop(view, "display_x_axis", text="X", toggle=True)
2020         row.prop(view, "display_y_axis", text="Y", toggle=True)
2021         row.prop(view, "display_z_axis", text="Z", toggle=True)
2022
2023         sub = col.column(align=True)
2024         sub.active = (display_all and view.display_floor)
2025         sub.prop(view, "grid_lines", text="Lines")
2026         sub.prop(view, "grid_spacing", text="Spacing")
2027         sub.prop(view, "grid_subdivisions", text="Subdivisions")
2028
2029         col = layout.column()
2030         col.label(text="Shading:")
2031         col.prop(gs, "material_mode", text="")
2032         col.prop(view, "textured_solid")
2033
2034         layout.separator()
2035
2036         region = view.region_quadview
2037
2038         layout.operator("screen.region_quadview", text="Toggle Quad View")
2039
2040         if region:
2041             col = layout.column()
2042             col.prop(region, "lock_rotation")
2043             row = col.row()
2044             row.enabled = region.lock_rotation
2045             row.prop(region, "box_preview")
2046             row = col.row()
2047             row.enabled = region.lock_rotation and region.box_preview
2048             row.prop(region, "box_clip")
2049
2050
2051 class VIEW3D_PT_view3d_meshdisplay(bpy.types.Panel):
2052     bl_space_type = 'VIEW_3D'
2053     bl_region_type = 'UI'
2054     bl_label = "Mesh Display"
2055
2056     def poll(self, context):
2057         # The active object check is needed because of localmode
2058         return (context.active_object and (context.mode == 'EDIT_MESH'))
2059
2060     def draw(self, context):
2061         layout = self.layout
2062
2063         mesh = context.active_object.data
2064
2065         col = layout.column()
2066         col.label(text="Overlays:")
2067         col.prop(mesh, "draw_edges", text="Edges")
2068         col.prop(mesh, "draw_faces", text="Faces")
2069         col.prop(mesh, "draw_creases", text="Creases")
2070         col.prop(mesh, "draw_bevel_weights", text="Bevel Weights")
2071         col.prop(mesh, "draw_seams", text="Seams")
2072         col.prop(mesh, "draw_sharp", text="Sharp")
2073
2074         col.separator()
2075         col.label(text="Normals:")
2076         col.prop(mesh, "draw_normals", text="Face")
2077         col.prop(mesh, "draw_vertex_normals", text="Vertex")
2078         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2079
2080         col.separator()
2081         col.label(text="Numerics:")
2082         col.prop(mesh, "draw_edge_lenght")
2083         col.prop(mesh, "draw_edge_angle")
2084         col.prop(mesh, "draw_face_area")
2085
2086
2087 class VIEW3D_PT_view3d_curvedisplay(bpy.types.Panel):
2088     bl_space_type = 'VIEW_3D'
2089     bl_region_type = 'UI'
2090     bl_label = "Curve Display"
2091
2092     def poll(self, context):
2093         editmesh = context.mode == 'EDIT_CURVE'
2094         return (editmesh)
2095
2096     def draw(self, context):
2097         layout = self.layout
2098
2099         curve = context.active_object.data
2100
2101         col = layout.column()
2102         col.label(text="Overlays:")
2103         col.prop(curve, "draw_handles", text="Handles")
2104         col.prop(curve, "draw_normals", text="Normals")
2105         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2106
2107
2108 class VIEW3D_PT_background_image(bpy.types.Panel):
2109     bl_space_type = 'VIEW_3D'
2110     bl_region_type = 'UI'
2111     bl_label = "Background Images"
2112     bl_default_closed = True
2113
2114     def poll(self, context):
2115         view = context.space_data
2116         # bg = context.space_data.background_image
2117         return (view)
2118
2119     def draw_header(self, context):
2120         layout = self.layout
2121         view = context.space_data
2122
2123         layout.prop(view, "display_background_images", text="")
2124
2125     def draw(self, context):
2126         layout = self.layout
2127
2128         view = context.space_data
2129
2130         col = layout.column()
2131         col.operator("view3d.add_background_image", text="Add Image")
2132
2133         for i, bg in enumerate(view.background_images):
2134             layout.active = view.display_background_images
2135             box = layout.box()
2136             row = box.row(align=True)
2137             row.prop(bg, "show_expanded", text="", emboss=False)
2138             row.label(text=getattr(bg.image, "name", "Not Set"))
2139             row.operator("view3d.remove_background_image", text="", icon='X').index = i
2140
2141             box.prop(bg, "view_axis", text="Axis")
2142
2143             if bg.show_expanded:
2144                 row = box.row()
2145                 row.template_ID(bg, "image", open="image.open")
2146                 if (bg.image):
2147                     box.template_image(bg, "image", bg.image_user, compact=True)
2148
2149                     box.prop(bg, "transparency", slider=True)
2150                     if bg.view_axis != 'CAMERA':
2151                         box.prop(bg, "size")
2152                         row = box.row(align=True)
2153                         row.prop(bg, "offset_x", text="X")
2154                         row.prop(bg, "offset_y", text="Y")
2155
2156
2157 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
2158     bl_space_type = 'VIEW_3D'
2159     bl_region_type = 'UI'
2160     bl_label = "Transform Orientations"
2161     bl_default_closed = True
2162
2163     def poll(self, context):
2164         view = context.space_data
2165         return (view)
2166
2167     def draw(self, context):
2168         layout = self.layout
2169
2170         view = context.space_data
2171
2172         col = layout.column()
2173
2174         col.prop(view, "transform_orientation")
2175         col.operator("transform.create_orientation", text="Create")
2176
2177         orientation = view.current_orientation
2178
2179         if orientation:
2180             col.prop(orientation, "name")
2181             col.operator("transform.delete_orientation", text="Delete")
2182
2183
2184 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
2185     bl_space_type = 'VIEW_3D'
2186     bl_region_type = 'UI'
2187     bl_label = "Skeleton Sketching"
2188     bl_default_closed = True
2189
2190     def poll(self, context):
2191         scene = context.space_data
2192         ob = context.active_object
2193         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2194
2195     def draw_header(self, context):
2196         layout = self.layout
2197         toolsettings = context.scene.tool_settings
2198
2199         layout.prop(toolsettings, "bone_sketching", text="")
2200
2201     def draw(self, context):
2202         layout = self.layout
2203         toolsettings = context.scene.tool_settings
2204
2205         col = layout.column()
2206
2207         col.prop(toolsettings, "etch_quick")
2208         col.prop(toolsettings, "etch_overdraw")
2209
2210         col.prop(toolsettings, "etch_convert_mode")
2211
2212         if toolsettings.etch_convert_mode == 'LENGTH':
2213             col.prop(toolsettings, "etch_length_limit")
2214         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2215             col.prop(toolsettings, "etch_adaptive_limit")
2216         elif toolsettings.etch_convert_mode == 'FIXED':
2217             col.prop(toolsettings, "etch_subdivision_number")
2218         elif toolsettings.etch_convert_mode == 'RETARGET':
2219             col.prop(toolsettings, "etch_template")
2220             col.prop(toolsettings, "etch_roll_mode")
2221             col.prop(toolsettings, "etch_autoname")
2222             col.prop(toolsettings, "etch_number")
2223             col.prop(toolsettings, "etch_side")
2224             col.operator("sketch.convert", text="Convert")
2225
2226
2227 class VIEW3D_PT_context_properties(bpy.types.Panel):
2228     bl_space_type = 'VIEW_3D'
2229     bl_region_type = 'UI'
2230     bl_label = "Properties"
2231     bl_default_closed = True
2232
2233     def _active_context_member(self, context):
2234         obj = context.object
2235         if obj:
2236             mode = obj.mode
2237             if mode == 'POSE':
2238                 return "active_pose_bone"
2239             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2240                 return "active_bone"
2241             else:
2242                 return "object"
2243
2244         return ""
2245
2246     def poll(self, context):
2247         member = self._active_context_member(context)
2248         if member:
2249             context_member = getattr(context, member)
2250             return context_member and context_member.keys()
2251
2252         return False
2253
2254     def draw(self, context):
2255         import rna_prop_ui
2256         # reload(rna_prop_ui)
2257         member = self._active_context_member(context)
2258
2259         if member:
2260             # Draw with no edit button
2261             rna_prop_ui.draw(self.layout, context, member, False)
2262
2263 classes = [
2264     VIEW3D_OT_edit_mesh_extrude_move, # detects constraints setup and extrude region
2265     VIEW3D_OT_edit_mesh_extrude_individual_move,
2266
2267     VIEW3D_HT_header, # Header
2268
2269     VIEW3D_MT_view, #View Menus
2270     VIEW3D_MT_view_navigation,
2271     VIEW3D_MT_view_align,
2272     VIEW3D_MT_view_align_selected,
2273     VIEW3D_MT_view_cameras,
2274
2275     VIEW3D_MT_select_object, # Select Menus
2276     VIEW3D_MT_select_pose,
2277     VIEW3D_MT_select_particle,
2278     VIEW3D_MT_select_edit_mesh,
2279     VIEW3D_MT_select_edit_curve,
2280     VIEW3D_MT_select_edit_surface,
2281     VIEW3D_MT_select_edit_metaball,
2282     VIEW3D_MT_select_edit_lattice,
2283     VIEW3D_MT_select_edit_armature,
2284     VIEW3D_MT_select_face, # XXX todo
2285
2286     VIEW3D_MT_transform, # Object/Edit Menus
2287     VIEW3D_MT_mirror, # Object/Edit Menus
2288     VIEW3D_MT_snap, # Object/Edit Menus
2289     VIEW3D_MT_uv_map, # Edit Menus
2290
2291     VIEW3D_MT_object, # Object Menu
2292     VIEW3D_MT_object_specials,
2293     VIEW3D_MT_object_apply,
2294     VIEW3D_MT_object_clear,
2295     VIEW3D_MT_object_parent,
2296     VIEW3D_MT_object_track,
2297     VIEW3D_MT_object_group,
2298     VIEW3D_MT_object_constraints,
2299     VIEW3D_MT_object_showhide,
2300     VIEW3D_MT_make_single_user,
2301     VIEW3D_MT_make_links,
2302     VIEW3D_MT_object_game_properties,
2303     VIEW3D_MT_object_game_logicbricks,
2304
2305     VIEW3D_MT_hook,
2306     VIEW3D_MT_vertex_group,
2307
2308     VIEW3D_MT_sculpt, # Sculpt Menu
2309     VIEW3D_MT_paint_vertex,
2310     VIEW3D_MT_paint_weight,
2311
2312     VIEW3D_MT_particle, # Particle Menu
2313     VIEW3D_MT_particle_specials,
2314     VIEW3D_MT_particle_showhide,
2315
2316     VIEW3D_MT_pose, # POSE Menu
2317     VIEW3D_MT_pose_transform,
2318     VIEW3D_MT_pose_pose,
2319     VIEW3D_MT_pose_motion,
2320     VIEW3D_MT_pose_group,
2321     VIEW3D_MT_pose_ik,
2322     VIEW3D_MT_pose_constraints,
2323     VIEW3D_MT_pose_showhide,
2324     VIEW3D_MT_pose_apply,
2325
2326     VIEW3D_MT_edit_mesh,
2327     VIEW3D_MT_edit_mesh_specials, # Only as a menu for keybindings
2328     VIEW3D_MT_edit_mesh_selection_mode, # Only as a menu for keybindings
2329     VIEW3D_MT_edit_mesh_vertices,
2330     VIEW3D_MT_edit_mesh_edges,
2331     VIEW3D_MT_edit_mesh_faces,
2332     VIEW3D_MT_edit_mesh_normals,
2333     VIEW3D_MT_edit_mesh_showhide,
2334     VIEW3D_MT_edit_mesh_extrude, # use with VIEW3D_OT_edit_mesh_extrude_menu
2335
2336     VIEW3D_MT_edit_curve,
2337     VIEW3D_MT_edit_curve_ctrlpoints,
2338     VIEW3D_MT_edit_curve_segments,
2339     VIEW3D_MT_edit_curve_specials,
2340     VIEW3D_MT_edit_curve_showhide,
2341
2342     VIEW3D_MT_edit_surface,
2343
2344     VIEW3D_MT_edit_text,
2345     VIEW3D_MT_edit_text_chars,
2346
2347     VIEW3D_MT_edit_meta,
2348     VIEW3D_MT_edit_meta_showhide,
2349
2350     VIEW3D_MT_edit_lattice,
2351
2352     VIEW3D_MT_edit_armature,
2353     VIEW3D_MT_edit_armature_parent,
2354     VIEW3D_MT_edit_armature_roll,
2355
2356     VIEW3D_MT_armature_specials, # Only as a menu for keybindings
2357
2358    # Panels
2359     VIEW3D_PT_view3d_properties,
2360     VIEW3D_PT_view3d_display,
2361     VIEW3D_PT_view3d_name,
2362     VIEW3D_PT_view3d_meshdisplay,
2363     VIEW3D_PT_view3d_curvedisplay,
2364     VIEW3D_PT_background_image,
2365     VIEW3D_PT_transform_orientations,
2366     VIEW3D_PT_etch_a_ton,
2367     VIEW3D_PT_context_properties]
2368
2369
2370 def register():
2371     register = bpy.types.register
2372     for cls in classes:
2373         register(cls)
2374
2375
2376 def unregister():
2377     unregister = bpy.types.unregister
2378     for cls in classes:
2379         unregister(cls)
2380
2381 if __name__ == "__main__":
2382     register()