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