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