- make ToolSettings.mesh_selection_mode into an array of 3 bools rather then an enum...
[blender-staging.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 import dynamic_menu
22
23
24 class VIEW3D_HT_header(bpy.types.Header):
25     bl_space_type = 'VIEW_3D'
26
27     def draw(self, context):
28         layout = self.layout
29
30         view = context.space_data
31         mode_string = context.mode
32         edit_object = context.edit_object
33         obj = context.active_object
34         toolsettings = context.scene.tool_settings
35
36         row = layout.row()
37         row.template_header()
38
39         sub = row.row(align=True)
40
41         # Menus
42         if context.area.show_menus:
43
44             sub.menu("VIEW3D_MT_view")
45
46             # Select Menu
47             if mode_string not in ('EDIT_TEXT', 'SCULPT', 'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'):
48                 sub.menu("VIEW3D_MT_select_%s" % mode_string.lower())
49
50             if edit_object:
51                 sub.menu("VIEW3D_MT_edit_%s" % edit_object.type.lower())
52             elif obj:
53                 if mode_string not in ('PAINT_WEIGHT', 'PAINT_TEXTURE'):
54                     sub.menu("VIEW3D_MT_%s" % mode_string.lower())
55             else:
56                 sub.menu("VIEW3D_MT_object")
57
58         row.template_header_3D()
59
60         # Particle edit
61         if obj and obj.mode == 'PARTICLE_EDIT':
62             row.prop(toolsettings.particle_edit, "selection_mode", text="", expand=True, toggle=True)
63
64         # Occlude geometry
65         if obj and view.viewport_shading in ('SOLID', 'SHADED', 'TEXTURED') and (obj.mode == 'PARTICLE_EDIT' or (obj.mode == 'EDIT' and obj.type == 'MESH')):
66             row.prop(view, "occlude_geometry", text="")
67
68         # Proportional editing
69         if obj and obj.mode in ('OBJECT', 'EDIT'):
70             row = layout.row(align=True)
71             row.prop(toolsettings, "proportional_editing", text="", icon_only=True)
72             if toolsettings.proportional_editing != 'DISABLED':
73                 row.prop(toolsettings, "proportional_editing_falloff", text="", icon_only=True)
74
75         # Snap
76         row = layout.row(align=True)
77         row.prop(toolsettings, "snap", text="")
78         row.prop(toolsettings, "snap_element", text="", icon_only=True)
79         if toolsettings.snap_element != 'INCREMENT':
80             row.prop(toolsettings, "snap_target", text="")
81             if obj and obj.mode == 'OBJECT':
82                 row.prop(toolsettings, "snap_align_rotation", text="")
83         if toolsettings.snap_element == 'VOLUME':
84             row.prop(toolsettings, "snap_peel_object", text="")
85         elif toolsettings.snap_element == 'FACE':
86             row.prop(toolsettings, "snap_project", text="")
87
88         # OpenGL render
89         row = layout.row(align=True)
90         row.operator("screen.opengl_render", text="", icon='RENDER_STILL')
91         props = row.operator("screen.opengl_render", text="", icon='RENDER_ANIMATION')
92         props.animation = True
93
94         # Pose
95         if obj and obj.mode == 'POSE':
96             row = layout.row(align=True)
97             row.operator("pose.copy", text="", icon='COPYDOWN')
98             row.operator("pose.paste", text="", icon='PASTEDOWN')
99             props = row.operator("pose.paste", text="", icon='PASTEFLIPDOWN')
100             props.flipped = 1
101
102
103 # ********** Menu **********
104
105 # ********** Utilities **********
106
107
108 class VIEW3D_MT_showhide(bpy.types.Menu):
109     bl_label = "Show/Hide"
110     _operator_name = ""
111
112     def draw(self, context):
113         layout = self.layout
114
115         layout.operator("%s.reveal" % self._operator_name, text="Show Hidden")
116         layout.operator("%s.hide" % self._operator_name, text="Hide Selected")
117         layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True
118
119
120 class VIEW3D_MT_transform(bpy.types.Menu):
121     bl_label = "Transform"
122
123     # TODO: get rid of the custom text strings?
124     def draw(self, context):
125         layout = self.layout
126
127         layout.operator("transform.translate", text="Grab/Move")
128         # TODO: sub-menu for grab per axis
129         layout.operator("transform.rotate", text="Rotate")
130         # TODO: sub-menu for rot per axis
131         layout.operator("transform.resize", text="Scale")
132         # TODO: sub-menu for scale per axis
133
134         layout.separator()
135
136         layout.operator("transform.tosphere", text="To Sphere")
137         layout.operator("transform.shear", text="Shear")
138         layout.operator("transform.warp", text="Warp")
139         layout.operator("transform.transform", text="Push/Pull").mode = 'PUSHPULL'
140         if context.edit_object and context.edit_object.type == 'ARMATURE':
141             layout.operator("armature.align")
142         else:
143             layout.operator_context = 'EXEC_REGION_WIN'
144             layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working
145
146         layout.separator()
147
148         layout.operator_context = 'EXEC_AREA'
149
150         layout.operator("object.origin_set", text="Geometry to Origin").type = 'GEOMETRY_ORIGIN'
151         layout.operator("object.origin_set", text="Origin to Geometry").type = 'ORIGIN_GEOMETRY'
152         layout.operator("object.origin_set", text="Origin to 3D Cursor").type = 'ORIGIN_CURSOR'
153
154
155 class VIEW3D_MT_mirror(bpy.types.Menu):
156     bl_label = "Mirror"
157
158     def draw(self, context):
159         layout = self.layout
160
161         layout.operator("transform.mirror", text="Interactive Mirror")
162
163         layout.separator()
164
165         layout.operator_context = 'INVOKE_REGION_WIN'
166
167         props = layout.operator("transform.mirror", text="X Global")
168         props.constraint_axis = (True, False, False)
169         props.constraint_orientation = 'GLOBAL'
170         props = layout.operator("transform.mirror", text="Y Global")
171         props.constraint_axis = (False, True, False)
172         props.constraint_orientation = 'GLOBAL'
173         props = layout.operator("transform.mirror", text="Z Global")
174         props.constraint_axis = (False, False, True)
175         props.constraint_orientation = 'GLOBAL'
176
177         if context.edit_object:
178             layout.separator()
179
180             props = layout.operator("transform.mirror", text="X Local")
181             props.constraint_axis = (True, False, False)
182             props.constraint_orientation = 'LOCAL'
183             props = layout.operator("transform.mirror", text="Y Local")
184             props.constraint_axis = (False, True, False)
185             props.constraint_orientation = 'LOCAL'
186             props = layout.operator("transform.mirror", text="Z Local")
187             props.constraint_axis = (False, False, True)
188             props.constraint_orientation = 'LOCAL'
189
190
191 class VIEW3D_MT_snap(bpy.types.Menu):
192     bl_label = "Snap"
193
194     def draw(self, context):
195         layout = self.layout
196
197         layout.operator("view3d.snap_selected_to_grid", text="Selection to Grid")
198         layout.operator("view3d.snap_selected_to_cursor", text="Selection to Cursor")
199         layout.operator("view3d.snap_selected_to_center", text="Selection to Origin")
200
201         layout.separator()
202
203         layout.operator("view3d.snap_cursor_to_selected", text="Cursor to Selected")
204         layout.operator("view3d.snap_cursor_to_grid", text="Cursor to Grid")
205         layout.operator("view3d.snap_cursor_to_active", text="Cursor to Active")
206
207
208 class VIEW3D_MT_uv_map(dynamic_menu.DynMenu):
209     bl_label = "UV Mapping"
210
211     def draw(self, context):
212         layout = self.layout
213
214         layout.operator("uv.unwrap")
215         layout.operator("uv.cube_project")
216         layout.operator("uv.cylinder_project")
217         layout.operator("uv.sphere_project")
218         layout.operator("uv.project_from_view")
219         layout.operator("uv.project_from_view", text="Project from View (Bounds)").scale_to_bounds = True
220
221         layout.separator()
222
223         layout.operator("uv.reset")
224
225 # ********** View menus **********
226
227
228 class VIEW3D_MT_view(bpy.types.Menu):
229     bl_label = "View"
230
231     def draw(self, context):
232         layout = self.layout
233
234         layout.operator("view3d.properties", icon='MENU_PANEL')
235         layout.operator("view3d.toolbar", icon='MENU_PANEL')
236
237         layout.separator()
238
239         layout.operator("view3d.viewnumpad", text="Camera").type = 'CAMERA'
240         layout.operator("view3d.viewnumpad", text="Top").type = 'TOP'
241         layout.operator("view3d.viewnumpad", text="Front").type = 'FRONT'
242         layout.operator("view3d.viewnumpad", text="Right").type = 'RIGHT'
243
244         layout.menu("VIEW3D_MT_view_cameras", text="Cameras")
245
246         layout.separator()
247
248         layout.operator("view3d.view_persportho")
249
250         layout.separator()
251
252         layout.menu("VIEW3D_MT_view_navigation")
253         layout.menu("VIEW3D_MT_view_align")
254
255         layout.separator()
256
257         layout.operator_context = 'INVOKE_REGION_WIN'
258
259         layout.operator("view3d.clip_border", text="Clipping Border...")
260         layout.operator("view3d.zoom_border", text="Zoom Border...")
261
262         layout.separator()
263
264         layout.operator("view3d.layers", text="Show All Layers").nr = 0
265
266         layout.separator()
267
268         layout.operator("view3d.localview", text="View Global/Local")
269         layout.operator("view3d.view_center")
270         layout.operator("view3d.view_all")
271
272         layout.separator()
273
274         layout.operator("screen.animation_play", text="Playback Animation")
275
276         layout.separator()
277
278         layout.operator("screen.area_dupli")
279         layout.operator("screen.region_quadview")
280         layout.operator("screen.screen_full_area")
281
282
283 class VIEW3D_MT_view_navigation(bpy.types.Menu):
284     bl_label = "Navigation"
285
286     def draw(self, context):
287         layout = self.layout
288
289         layout.operator_enums("view3d.view_orbit", "type")
290
291         layout.separator()
292
293         layout.operator_enums("view3d.view_pan", "type")
294
295         layout.separator()
296
297         layout.operator("view3d.zoom", text="Zoom In").delta = 1
298         layout.operator("view3d.zoom", text="Zoom Out").delta = -1
299
300         layout.separator()
301
302         layout.operator("view3d.fly")
303
304
305 class VIEW3D_MT_view_align(bpy.types.Menu):
306     bl_label = "Align View"
307
308     def draw(self, context):
309         layout = self.layout
310
311         layout.menu("VIEW3D_MT_view_align_selected")
312
313         layout.separator()
314
315         layout.operator("view3d.view_all", text="Center Cursor and View All").center = True
316         layout.operator("view3d.camera_to_view", text="Align Active Camera to View")
317         layout.operator("view3d.view_center")
318         layout.operator("view3d.view_center_cursor")
319
320
321 class VIEW3D_MT_view_align_selected(bpy.types.Menu):
322     bl_label = "Align View to Selected"
323
324     def draw(self, context):
325         layout = self.layout
326
327         props = layout.operator("view3d.viewnumpad", text="Top")
328         props.align_active = True
329         props.type = 'TOP'
330         props = layout.operator("view3d.viewnumpad", text="Bottom")
331         props.align_active = True
332         props.type = 'BOTTOM'
333         props = layout.operator("view3d.viewnumpad", text="Front")
334         props.align_active = True
335         props.type = 'FRONT'
336         props = layout.operator("view3d.viewnumpad", text="Back")
337         props.align_active = True
338         props.type = 'BACK'
339         props = layout.operator("view3d.viewnumpad", text="Right")
340         props.align_active = True
341         props.type = 'RIGHT'
342         props = layout.operator("view3d.viewnumpad", text="Left")
343         props.align_active = True
344         props.type = 'LEFT'
345
346
347 class VIEW3D_MT_view_cameras(bpy.types.Menu):
348     bl_label = "Cameras"
349
350     def draw(self, context):
351         layout = self.layout
352
353         layout.operator("view3d.object_as_camera")
354         layout.operator("view3d.viewnumpad", text="Active Camera").type = 'CAMERA'
355
356 # ********** Select menus, suffix from context.mode **********
357
358
359 class VIEW3D_MT_select_object(bpy.types.Menu):
360     bl_label = "Select"
361
362     def draw(self, context):
363         layout = self.layout
364
365         layout.operator("view3d.select_border")
366         layout.operator("view3d.select_circle")
367
368         layout.separator()
369
370         layout.operator("object.select_all", text="Select/Deselect All")
371         layout.operator("object.select_inverse", text="Inverse")
372         layout.operator("object.select_random", text="Random")
373         layout.operator("object.select_mirror", text="Mirror")
374         layout.operator("object.select_by_layer", text="Select All by Layer")
375         layout.operator_menu_enum("object.select_by_type", "type", "", text="Select All by Type...")
376
377         layout.separator()
378
379         layout.operator_menu_enum("object.select_grouped", "type", text="Grouped")
380         layout.operator_menu_enum("object.select_linked", "type", text="Linked")
381         layout.operator("object.select_pattern", text="Select Pattern...")
382
383
384 class VIEW3D_MT_select_pose(bpy.types.Menu):
385     bl_label = "Select"
386
387     def draw(self, context):
388         layout = self.layout
389
390         layout.operator("view3d.select_border")
391
392         layout.separator()
393
394         layout.operator("pose.select_all", text="Select/Deselect All")
395         layout.operator("pose.select_inverse", text="Inverse")
396         layout.operator("pose.select_constraint_target", text="Constraint Target")
397         layout.operator("pose.select_linked", text="Linked")
398
399         layout.separator()
400
401         layout.operator("pose.select_hierarchy", text="Parent").direction = 'PARENT'
402         layout.operator("pose.select_hierarchy", text="Child").direction = 'CHILD'
403
404         layout.separator()
405
406         props = layout.operator("pose.select_hierarchy", text="Extend Parent")
407         props.extend = True
408         props.direction = 'PARENT'
409
410         props = layout.operator("pose.select_hierarchy", text="Extend Child")
411         props.extend = True
412         props.direction = 'CHILD'
413
414         layout.operator("object.select_pattern", text="Select Pattern...")
415
416
417 class VIEW3D_MT_select_particle(bpy.types.Menu):
418     bl_label = "Select"
419
420     def draw(self, context):
421         layout = self.layout
422
423         layout.operator("view3d.select_border")
424
425         layout.separator()
426
427         layout.operator("particle.select_all", text="Select/Deselect All")
428         layout.operator("particle.select_linked")
429         layout.operator("particle.select_inverse")
430
431         layout.separator()
432
433         layout.operator("particle.select_more")
434         layout.operator("particle.select_less")
435
436         layout.separator()
437
438         layout.operator("particle.select_first", text="Roots")
439         layout.operator("particle.select_last", text="Tips")
440
441
442 class VIEW3D_MT_select_edit_mesh(bpy.types.Menu):
443     bl_label = "Select"
444
445     def draw(self, context):
446         layout = self.layout
447
448         layout.operator("view3d.select_border")
449         layout.operator("view3d.select_circle")
450
451         layout.separator()
452
453         layout.operator("mesh.select_all", text="Select/Deselect All")
454         layout.operator("mesh.select_inverse", text="Inverse")
455
456         layout.separator()
457
458         layout.operator("mesh.select_random", text="Random...")
459         layout.operator("mesh.edges_select_sharp", text="Sharp Edges")
460         layout.operator("mesh.faces_select_linked_flat", text="Linked Flat Faces")
461         layout.operator("mesh.faces_select_interior", text="Interior Faces")
462         layout.operator("mesh.select_axis", text="Side of Active")
463
464         layout.separator()
465
466         layout.operator("mesh.select_by_number_vertices", text="Triangles").type = 'TRIANGLES'
467         layout.operator("mesh.select_by_number_vertices", text="Quads").type = 'QUADS'
468         layout.operator("mesh.select_by_number_vertices", text="Loose Verts/Edges").type = 'OTHER'
469         layout.operator("mesh.select_similar", text="Similar...")
470
471         layout.separator()
472
473         layout.operator("mesh.select_less", text="Less")
474         layout.operator("mesh.select_more", text="More")
475
476         layout.separator()
477
478         layout.operator("mesh.select_mirror", text="Mirror")
479
480         layout.operator("mesh.select_linked", text="Linked")
481         layout.operator("mesh.select_vertex_path", text="Vertex Path")
482         layout.operator("mesh.loop_multi_select", text="Edge Loop")
483         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
484
485         layout.separator()
486
487         layout.operator("mesh.loop_to_region")
488         layout.operator("mesh.region_to_loop")
489
490
491 class VIEW3D_MT_select_edit_curve(bpy.types.Menu):
492     bl_label = "Select"
493
494     def draw(self, context):
495         layout = self.layout
496
497         layout.operator("view3d.select_border")
498         layout.operator("view3d.select_circle")
499
500         layout.separator()
501
502         layout.operator("curve.select_all", text="Select/Deselect All")
503         layout.operator("curve.select_inverse")
504         layout.operator("curve.select_random")
505         layout.operator("curve.select_every_nth")
506
507         layout.separator()
508
509         layout.operator("curve.de_select_first")
510         layout.operator("curve.de_select_last")
511         layout.operator("curve.select_next")
512         layout.operator("curve.select_previous")
513
514         layout.separator()
515
516         layout.operator("curve.select_more")
517         layout.operator("curve.select_less")
518
519
520 class VIEW3D_MT_select_edit_surface(bpy.types.Menu):
521     bl_label = "Select"
522
523     def draw(self, context):
524         layout = self.layout
525
526         layout.operator("view3d.select_border")
527         layout.operator("view3d.select_circle")
528
529         layout.separator()
530
531         layout.operator("curve.select_all", text="Select/Deselect All")
532         layout.operator("curve.select_inverse")
533         layout.operator("curve.select_random")
534         layout.operator("curve.select_every_nth")
535
536         layout.separator()
537
538         layout.operator("curve.select_row")
539
540         layout.separator()
541
542         layout.operator("curve.select_more")
543         layout.operator("curve.select_less")
544
545
546 class VIEW3D_MT_select_edit_metaball(bpy.types.Menu):
547     bl_label = "Select"
548
549     def draw(self, context):
550         layout = self.layout
551
552         layout.operator("view3d.select_border")
553
554         layout.separator()
555
556         layout.operator("mball.select_deselect_all_metaelems")
557         layout.operator("mball.select_inverse_metaelems")
558
559         layout.separator()
560
561         layout.operator("mball.select_random_metaelems")
562
563
564 class VIEW3D_MT_select_edit_lattice(bpy.types.Menu):
565     bl_label = "Select"
566
567     def draw(self, context):
568         layout = self.layout
569
570         layout.operator("view3d.select_border")
571
572         layout.separator()
573
574         layout.operator("lattice.select_all", text="Select/Deselect All")
575
576
577 class VIEW3D_MT_select_edit_armature(bpy.types.Menu):
578     bl_label = "Select"
579
580     def draw(self, context):
581         layout = self.layout
582
583         layout.operator("view3d.select_border")
584
585
586         layout.separator()
587
588         layout.operator("armature.select_all", text="Select/Deselect All")
589         layout.operator("armature.select_inverse", text="Inverse")
590
591         layout.separator()
592
593         layout.operator("armature.select_hierarchy", text="Parent").direction = 'PARENT'
594         layout.operator("armature.select_hierarchy", text="Child").direction = 'CHILD'
595
596         layout.separator()
597
598         props = layout.operator("armature.select_hierarchy", text="Extend Parent")
599         props.extend = True
600         props.direction = 'PARENT'
601
602         props = layout.operator("armature.select_hierarchy", text="Extend Child")
603         props.extend = True
604         props.direction = 'CHILD'
605
606         layout.operator("object.select_pattern", text="Select Pattern...")
607
608
609 class VIEW3D_MT_select_face(bpy.types.Menu):# XXX no matching enum
610     bl_label = "Select"
611
612     def draw(self, context):
613         layout = self.layout
614
615         # TODO
616         # see view3d_select_faceselmenu
617
618 # ********** Object menu **********
619
620
621 class VIEW3D_MT_object(bpy.types.Menu):
622     bl_context = "objectmode"
623     bl_label = "Object"
624
625     def draw(self, context):
626         layout = self.layout
627
628         layout.menu("VIEW3D_MT_transform")
629         layout.menu("VIEW3D_MT_mirror")
630         layout.menu("VIEW3D_MT_object_clear")
631         layout.menu("VIEW3D_MT_object_apply")
632         layout.menu("VIEW3D_MT_snap")
633
634         layout.separator()
635
636         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
637         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
638
639         layout.separator()
640
641         layout.operator("object.duplicate_move")
642         layout.operator("object.duplicate", text="Duplicate Linked").linked = True
643         layout.operator("object.delete", text="Delete...")
644         layout.operator("object.proxy_make", text="Make Proxy...")
645         layout.menu("VIEW3D_MT_make_links", text="Make Links...")
646         layout.operator_menu_enum("object.make_local", "type", text="Make Local...")
647         layout.menu("VIEW3D_MT_make_single_user")
648
649         layout.separator()
650
651         layout.menu("VIEW3D_MT_object_parent")
652         layout.menu("VIEW3D_MT_object_track")
653         layout.menu("VIEW3D_MT_object_group")
654         layout.menu("VIEW3D_MT_object_constraints")
655
656         layout.separator()
657
658         layout.operator("object.join_shapes")
659         layout.operator("object.join")
660
661         layout.separator()
662
663         layout.operator("object.move_to_layer", text="Move to Layer...")
664         layout.menu("VIEW3D_MT_object_showhide")
665
666         layout.operator_menu_enum("object.convert", "target")
667
668
669 class VIEW3D_MT_object_clear(bpy.types.Menu):
670     bl_label = "Clear"
671
672     def draw(self, context):
673         layout = self.layout
674
675         layout.operator("object.location_clear", text="Location")
676         layout.operator("object.rotation_clear", text="Rotation")
677         layout.operator("object.scale_clear", text="Scale")
678         layout.operator("object.origin_clear", text="Origin")
679
680
681 class VIEW3D_MT_object_apply(bpy.types.Menu):
682     bl_label = "Apply"
683
684     def draw(self, context):
685         layout = self.layout
686
687         layout.operator("object.location_apply", text="Location")
688         layout.operator("object.rotation_apply", text="Rotation")
689         layout.operator("object.scale_apply", text="Scale")
690         layout.separator()
691         layout.operator("object.visual_transform_apply", text="Visual Transform")
692         layout.operator("object.duplicates_make_real")
693
694
695 class VIEW3D_MT_object_parent(bpy.types.Menu):
696     bl_label = "Parent"
697
698     def draw(self, context):
699         layout = self.layout
700
701         layout.operator("object.parent_set", text="Set")
702         layout.operator("object.parent_clear", text="Clear")
703
704
705 class VIEW3D_MT_object_track(bpy.types.Menu):
706     bl_label = "Track"
707
708     def draw(self, context):
709         layout = self.layout
710
711         layout.operator("object.track_set", text="Set")
712         layout.operator("object.track_clear", text="Clear")
713
714
715 class VIEW3D_MT_object_group(bpy.types.Menu):
716     bl_label = "Group"
717
718     def draw(self, context):
719         layout = self.layout
720
721         layout.operator("group.create")
722         layout.operator("group.objects_remove")
723
724         layout.separator()
725
726         layout.operator("group.objects_add_active")
727         layout.operator("group.objects_remove_active")
728
729
730 class VIEW3D_MT_object_constraints(bpy.types.Menu):
731     bl_label = "Constraints"
732
733     def draw(self, context):
734         layout = self.layout
735
736         layout.operator("object.constraint_add_with_targets")
737         layout.operator("object.constraints_clear")
738
739
740 class VIEW3D_MT_object_showhide(bpy.types.Menu):
741     bl_label = "Show/Hide"
742
743     def draw(self, context):
744         layout = self.layout
745
746         layout.operator("object.restrictview_clear", text="Show Hidden")
747         layout.operator("object.restrictview_set", text="Hide Selected")
748         layout.operator("object.restrictview_set", text="Hide Unselected").unselected = True
749
750
751 class VIEW3D_MT_make_single_user(bpy.types.Menu):
752     bl_label = "Make Single User"
753
754     def draw(self, context):
755         layout = self.layout
756
757         props = layout.operator("object.make_single_user", text="Object")
758         props.object = True
759
760         props = layout.operator("object.make_single_user", text="Object & ObData")
761         props.object = props.obdata = True
762
763         props = layout.operator("object.make_single_user", text="Object & ObData & Materials+Tex")
764         props.object = props.obdata = props.material = props.texture = True
765
766         props = layout.operator("object.make_single_user", text="Materials+Tex")
767         props.material = props.texture = True
768
769         props = layout.operator("object.make_single_user", text="Animation")
770         props.animation = True
771
772
773 class VIEW3D_MT_make_links(bpy.types.Menu):
774     bl_label = "Make Links"
775
776     def draw(self, context):
777         layout = self.layout
778
779         layout.operator_menu_enum("object.make_links_scene", "type", text="Objects to Scene...")
780
781         layout.operator_enums("object.make_links_data", property="type") # inline
782
783
784 # ********** Vertex paint menu **********
785
786
787 class VIEW3D_MT_paint_vertex(bpy.types.Menu):
788     bl_label = "Paint"
789
790     def draw(self, context):
791         layout = self.layout
792
793         layout.operator("paint.vertex_color_set")
794         layout.operator("paint.vertex_color_set", text="Set Selected Vertex Colors").selected = True
795
796
797 class VIEW3D_MT_hook(bpy.types.Menu):
798     bl_label = "Hooks"
799
800     def draw(self, context):
801         layout = self.layout
802         layout.operator_context = 'EXEC_AREA'
803         layout.operator("object.hook_add_newob")
804         layout.operator("object.hook_add_selob")
805
806         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
807             layout.separator()
808             layout.operator_menu_enum("object.hook_assign", "modifier")
809             layout.operator_menu_enum("object.hook_remove", "modifier")
810             layout.separator()
811             layout.operator_menu_enum("object.hook_select", "modifier")
812             layout.operator_menu_enum("object.hook_reset", "modifier")
813             layout.operator_menu_enum("object.hook_recenter", "modifier")
814
815
816 class VIEW3D_MT_vertex_group(bpy.types.Menu):
817     bl_label = "Vertex Groups"
818
819     def draw(self, context):
820         layout = self.layout
821         layout.operator_context = 'EXEC_AREA'
822         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
823
824         ob = context.active_object
825         if ob.mode == 'EDIT':
826             if ob.vertex_groups and ob.active_vertex_group:
827                 layout.separator()
828                 layout.operator("object.vertex_group_assign", text="Assign to Active Group")
829                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group")
830                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
831                 layout.separator()
832
833         if ob.vertex_groups and ob.active_vertex_group:
834             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
835             layout.operator("object.vertex_group_remove", text="Remove Active Group")
836             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
837
838
839 # ********** Sculpt menu **********
840
841
842 class VIEW3D_MT_sculpt(bpy.types.Menu):
843     bl_label = "Sculpt"
844
845     def draw(self, context):
846         layout = self.layout
847
848         sculpt = context.tool_settings.sculpt
849         brush = context.tool_settings.sculpt.brush
850
851         layout.prop(sculpt, "symmetry_x")
852         layout.prop(sculpt, "symmetry_y")
853         layout.prop(sculpt, "symmetry_z")
854         layout.separator()
855         layout.prop(sculpt, "lock_x")
856         layout.prop(sculpt, "lock_y")
857         layout.prop(sculpt, "lock_z")
858         layout.separator()
859         layout.operator_menu_enum("brush.curve_preset", property="shape")
860         layout.separator()
861
862         sculpt_tool = brush.sculpt_tool
863
864         if sculpt_tool != 'GRAB':
865             layout.prop(brush, "use_airbrush")
866
867             if sculpt_tool != 'LAYER':
868                 layout.prop(brush, "use_anchor")
869
870             if sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
871                 layout.prop(brush, "flip_direction")
872
873             if sculpt_tool == 'LAYER':
874                 layout.prop(brush, "use_persistent")
875                 layout.operator("sculpt.set_persistent_base")
876
877 # ********** Particle menu **********
878
879
880 class VIEW3D_MT_particle(bpy.types.Menu):
881     bl_label = "Particle"
882
883     def draw(self, context):
884         layout = self.layout
885
886         particle_edit = context.tool_settings.particle_edit
887
888         layout.operator("particle.mirror")
889
890         layout.separator()
891
892         layout.operator("particle.remove_doubles")
893         layout.operator("particle.delete")
894
895         if particle_edit.selection_mode == 'POINT':
896             layout.operator("particle.subdivide")
897
898         layout.operator("particle.rekey")
899
900         layout.separator()
901
902         layout.menu("VIEW3D_MT_particle_showhide")
903
904
905 class VIEW3D_MT_particle_showhide(VIEW3D_MT_showhide):
906     _operator_name = "particle"
907
908 # ********** Pose Menu **********
909
910
911 class VIEW3D_MT_pose(bpy.types.Menu):
912     bl_label = "Pose"
913
914     def draw(self, context):
915         layout = self.layout
916
917         arm = context.active_object.data
918
919         layout.menu("VIEW3D_MT_transform")
920         layout.menu("VIEW3D_MT_snap")
921         if arm.drawtype in ('BBONE', 'ENVELOPE'):
922             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
923
924         layout.menu("VIEW3D_MT_pose_transform")
925
926         layout.separator()
927
928         layout.operator("anim.keyframe_insert_menu", text="Insert Keyframe...")
929         layout.operator("anim.keyframe_delete_v3d", text="Delete Keyframe...")
930
931         layout.separator()
932
933         layout.operator("pose.apply")
934         layout.operator("pose.relax")
935
936         layout.separator()
937
938         layout.operator("pose.copy")
939         layout.operator("pose.paste")
940         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
941
942         layout.separator()
943
944         layout.menu("VIEW3D_MT_pose_pose")
945         layout.menu("VIEW3D_MT_pose_motion")
946         layout.menu("VIEW3D_MT_pose_group")
947
948         layout.separator()
949
950         layout.menu("VIEW3D_MT_pose_ik")
951         layout.menu("VIEW3D_MT_pose_constraints")
952
953         layout.separator()
954
955         layout.operator_context = 'EXEC_AREA'
956         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
957         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
958         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
959
960         layout.operator("pose.flip_names")
961
962         layout.separator()
963
964         layout.operator_context = 'INVOKE_AREA'
965         layout.operator("pose.armature_layers", text="Change Armature Layers...")
966         layout.operator("pose.bone_layers", text="Change Bone Layers...")
967
968         layout.separator()
969
970         layout.menu("VIEW3D_MT_pose_showhide")
971         layout.operator_menu_enum("pose.flags_set", 'mode', text="Bone Settings")
972
973
974 class VIEW3D_MT_pose_transform(bpy.types.Menu):
975     bl_label = "Clear Transform"
976
977     def draw(self, context):
978         layout = self.layout
979
980         layout.label(text="User Transform")
981
982         layout.operator("pose.loc_clear", text="Location")
983         layout.operator("pose.rot_clear", text="Rotation")
984         layout.operator("pose.scale_clear", text="Scale")
985
986         layout.label(text="Origin")
987
988
989 class VIEW3D_MT_pose_pose(bpy.types.Menu):
990     bl_label = "Pose Library"
991
992     def draw(self, context):
993         layout = self.layout
994
995         layout.operator("poselib.browse_interactive", text="Browse Poses...")
996
997         layout.separator()
998
999         layout.operator("poselib.pose_add", text="Add Pose...")
1000         layout.operator("poselib.pose_rename", text="Rename Pose...")
1001         layout.operator("poselib.pose_remove", text="Remove Pose...")
1002
1003
1004 class VIEW3D_MT_pose_motion(bpy.types.Menu):
1005     bl_label = "Motion Paths"
1006
1007     def draw(self, context):
1008         layout = self.layout
1009
1010         layout.operator("pose.paths_calculate", text="Calculate")
1011         layout.operator("pose.paths_clear", text="Clear")
1012
1013
1014 class VIEW3D_MT_pose_group(bpy.types.Menu):
1015     bl_label = "Bone Groups"
1016
1017     def draw(self, context):
1018         layout = self.layout
1019         layout.operator("pose.group_add")
1020         layout.operator("pose.group_remove")
1021
1022         layout.separator()
1023
1024         layout.operator("pose.group_assign")
1025         layout.operator("pose.group_unassign")
1026
1027
1028 class VIEW3D_MT_pose_ik(bpy.types.Menu):
1029     bl_label = "Inverse Kinematics"
1030
1031     def draw(self, context):
1032         layout = self.layout
1033
1034         layout.operator("pose.ik_add")
1035         layout.operator("pose.ik_clear")
1036
1037
1038 class VIEW3D_MT_pose_constraints(bpy.types.Menu):
1039     bl_label = "Constraints"
1040
1041     def draw(self, context):
1042         layout = self.layout
1043
1044         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1045         layout.operator("pose.constraints_clear")
1046
1047
1048 class VIEW3D_MT_pose_showhide(VIEW3D_MT_showhide):
1049     _operator_name = "pose"
1050
1051 # ********** Edit Menus, suffix from ob.type **********
1052
1053
1054 class VIEW3D_MT_edit_mesh(bpy.types.Menu):
1055     bl_label = "Mesh"
1056
1057     def draw(self, context):
1058         layout = self.layout
1059
1060         settings = context.tool_settings
1061
1062         layout.operator("ed.undo")
1063         layout.operator("ed.redo")
1064
1065         layout.separator()
1066
1067         layout.menu("VIEW3D_MT_transform")
1068         layout.menu("VIEW3D_MT_mirror")
1069         layout.menu("VIEW3D_MT_snap")
1070
1071         layout.separator()
1072
1073         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1074
1075         layout.separator()
1076
1077         layout.operator("mesh.extrude_move")
1078         layout.operator("mesh.duplicate_move")
1079         layout.operator("mesh.delete", text="Delete...")
1080
1081         layout.separator()
1082
1083         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1084         layout.menu("VIEW3D_MT_edit_mesh_edges")
1085         layout.menu("VIEW3D_MT_edit_mesh_faces")
1086         layout.menu("VIEW3D_MT_edit_mesh_normals")
1087
1088         layout.separator()
1089
1090         layout.prop(settings, "automerge_editing")
1091         layout.prop_menu_enum(settings, "proportional_editing")
1092         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1093
1094         layout.separator()
1095
1096         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1097
1098
1099 class VIEW3D_MT_edit_mesh_specials(bpy.types.Menu):
1100     bl_label = "Specials"
1101
1102     def draw(self, context):
1103         layout = self.layout
1104
1105         layout.operator_context = 'INVOKE_REGION_WIN'
1106
1107         layout.operator("mesh.subdivide", text="Subdivide")
1108         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1109         layout.operator("mesh.merge", text="Merge...")
1110         layout.operator("mesh.remove_doubles")
1111         layout.operator("mesh.hide", text="Hide")
1112         layout.operator("mesh.reveal", text="Reveal")
1113         layout.operator("mesh.select_inverse")
1114         layout.operator("mesh.flip_normals")
1115         layout.operator("mesh.vertices_smooth", text="Smooth")
1116         # layout.operator("mesh.bevel", text="Bevel")
1117         layout.operator("mesh.faces_shade_smooth")
1118         layout.operator("mesh.faces_shade_flat")
1119         layout.operator("mesh.blend_from_shape")
1120         layout.operator("mesh.shape_propagate_to_all")
1121         layout.operator("mesh.select_vertex_path")
1122
1123
1124 class VIEW3D_MT_edit_mesh_selection_mode(bpy.types.Menu):
1125     bl_label = "Mesh Select Mode"
1126
1127     def draw(self, context):
1128         layout = self.layout
1129
1130         layout.operator_context = 'INVOKE_REGION_WIN'
1131         path = "tool_settings.edit_select_vertex;tool_settings.edit_select_edge;tool_settings.edit_select_face"
1132
1133         prop = layout.operator("wm.context_set_value", text="Vertex")
1134         prop.value = "(True, False, False)"
1135         prop.path = "tool_settings.mesh_selection_mode"
1136
1137         prop = layout.operator("wm.context_set_value", text="Edge")
1138         prop.value = "(False, True, False)"
1139         prop.path = "tool_settings.mesh_selection_mode"
1140
1141         prop = layout.operator("wm.context_set_value", text="Face")
1142         prop.value = "(False, False, True)"
1143         prop.path = "tool_settings.mesh_selection_mode"
1144
1145
1146 class VIEW3D_MT_edit_mesh_vertices(bpy.types.Menu):
1147     bl_label = "Vertices"
1148
1149     def draw(self, context):
1150         layout = self.layout
1151         layout.operator_context = 'INVOKE_REGION_WIN'
1152
1153         layout.operator("mesh.merge")
1154         layout.operator("mesh.rip")
1155         layout.operator("mesh.split")
1156         layout.operator("mesh.separate")
1157
1158         layout.separator()
1159
1160         layout.operator("mesh.vertices_smooth")
1161         layout.operator("mesh.remove_doubles")
1162
1163         layout.operator("mesh.select_vertex_path")
1164
1165         layout.operator("mesh.blend_from_shape")
1166
1167         layout.operator("object.vertex_group_blend")
1168         layout.operator("mesh.shape_propagate_to_all")
1169
1170         layout.separator()
1171
1172         layout.menu("VIEW3D_MT_vertex_group")
1173         layout.menu("VIEW3D_MT_hook")
1174
1175
1176 class VIEW3D_MT_edit_mesh_edges(bpy.types.Menu):
1177     bl_label = "Edges"
1178
1179     def draw(self, context):
1180         layout = self.layout
1181         layout.operator_context = 'INVOKE_REGION_WIN'
1182
1183         layout.operator("mesh.edge_face_add")
1184         layout.operator("mesh.subdivide")
1185
1186         layout.separator()
1187
1188         layout.operator("mesh.mark_seam")
1189         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1190
1191         layout.separator()
1192
1193         layout.operator("mesh.mark_sharp")
1194         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1195
1196         layout.separator()
1197
1198         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1199         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1200
1201         layout.separator()
1202
1203         layout.operator("TRANSFORM_OT_edge_slide", text="Edge Slide")
1204         layout.operator("mesh.loop_multi_select", text="Edge Loop")
1205
1206         # uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1207         # uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1208
1209         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1210
1211         layout.operator("mesh.loop_to_region")
1212         layout.operator("mesh.region_to_loop")
1213
1214
1215 class VIEW3D_MT_edit_mesh_faces(dynamic_menu.DynMenu):
1216     bl_label = "Faces"
1217     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1218
1219     def draw(self, context):
1220         layout = self.layout
1221         layout.operator_context = 'INVOKE_REGION_WIN'
1222
1223         # layout.operator("mesh.bevel")
1224         # layout.operator("mesh.bevel")
1225         layout.operator("mesh.edge_face_add")
1226         layout.operator("mesh.fill")
1227         layout.operator("mesh.beauty_fill")
1228         layout.operator("mesh.solidify")
1229
1230         layout.separator()
1231
1232         layout.operator("mesh.quads_convert_to_tris")
1233         layout.operator("mesh.tris_convert_to_quads")
1234         layout.operator("mesh.edge_flip")
1235
1236         layout.separator()
1237
1238         layout.operator("mesh.faces_shade_smooth")
1239         layout.operator("mesh.faces_shade_flat")
1240
1241         layout.separator()
1242
1243         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1244         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1245
1246         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1247
1248         layout.separator()
1249
1250         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1251         layout.operator_menu_enum("mesh.uvs_mirror", "axis")
1252         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1253         layout.operator_menu_enum("mesh.colors_mirror", "axis")
1254
1255
1256 class VIEW3D_MT_edit_mesh_normals(bpy.types.Menu):
1257     bl_label = "Normals"
1258
1259     def draw(self, context):
1260         layout = self.layout
1261
1262         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside")
1263         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1264
1265         layout.separator()
1266
1267         layout.operator("mesh.flip_normals")
1268
1269
1270 class VIEW3D_MT_edit_mesh_showhide(VIEW3D_MT_showhide):
1271     _operator_name = "mesh"
1272
1273 # Edit Curve
1274 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1275
1276
1277 def draw_curve(self, context):
1278     layout = self.layout
1279
1280     settings = context.tool_settings
1281
1282     layout.menu("VIEW3D_MT_transform")
1283     layout.menu("VIEW3D_MT_mirror")
1284     layout.menu("VIEW3D_MT_snap")
1285
1286     layout.separator()
1287
1288     layout.operator("curve.extrude")
1289     layout.operator("curve.duplicate")
1290     layout.operator("curve.separate")
1291     layout.operator("curve.make_segment")
1292     layout.operator("curve.cyclic_toggle")
1293     layout.operator("curve.delete", text="Delete...")
1294
1295     layout.separator()
1296
1297     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1298     layout.menu("VIEW3D_MT_edit_curve_segments")
1299
1300     layout.separator()
1301
1302     layout.prop_menu_enum(settings, "proportional_editing")
1303     layout.prop_menu_enum(settings, "proportional_editing_falloff")
1304
1305     layout.separator()
1306
1307     layout.menu("VIEW3D_MT_edit_curve_showhide")
1308
1309
1310 class VIEW3D_MT_edit_curve(bpy.types.Menu):
1311     bl_label = "Curve"
1312
1313     draw = draw_curve
1314
1315
1316 class VIEW3D_MT_edit_curve_ctrlpoints(bpy.types.Menu):
1317     bl_label = "Control Points"
1318
1319     def draw(self, context):
1320         layout = self.layout
1321
1322         edit_object = context.edit_object
1323
1324         if edit_object.type == 'CURVE':
1325             layout.operator("transform.transform").mode = 'TILT'
1326             layout.operator("curve.tilt_clear")
1327             layout.operator("curve.separate")
1328
1329             layout.separator()
1330
1331             layout.operator_menu_enum("curve.handle_type_set", "type")
1332
1333             layout.separator()
1334
1335             layout.menu("VIEW3D_MT_hook")
1336
1337
1338 class VIEW3D_MT_edit_curve_segments(bpy.types.Menu):
1339     bl_label = "Segments"
1340
1341     def draw(self, context):
1342         layout = self.layout
1343
1344         layout.operator("curve.subdivide")
1345         layout.operator("curve.switch_direction")
1346
1347
1348 class VIEW3D_MT_edit_curve_showhide(VIEW3D_MT_showhide):
1349     _operator_name = "curve"
1350
1351
1352 class VIEW3D_MT_edit_surface(bpy.types.Menu):
1353     bl_label = "Surface"
1354
1355     draw = draw_curve
1356
1357
1358 class VIEW3D_MT_edit_text(bpy.types.Menu):
1359     bl_label = "Text"
1360
1361     def draw(self, context):
1362         layout = self.layout
1363
1364         layout.operator("font.file_paste")
1365
1366         layout.separator()
1367
1368         layout.menu("VIEW3D_MT_edit_text_chars")
1369
1370
1371 class VIEW3D_MT_edit_text_chars(bpy.types.Menu):
1372     bl_label = "Special Characters"
1373
1374     def draw(self, context):
1375         layout = self.layout
1376
1377         layout.operator("font.text_insert", text="Copyright|Alt C").text = b'\xC2\xA9'.decode()
1378         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = b'\xC2\xAE'.decode()
1379
1380         layout.separator()
1381
1382         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = b'\xC2\xB0'.decode()
1383         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = b'\xC3\x97'.decode()
1384         layout.operator("font.text_insert", text="Circle|Alt .").text = b'\xC2\x8A'.decode()
1385         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = b'\xC2\xB9'.decode()
1386         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = b'\xC2\xB2'.decode()
1387         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = b'\xC2\xB3'.decode()
1388         layout.operator("font.text_insert", text="Double >>|Alt >").text = b'\xC2\xBB'.decode()
1389         layout.operator("font.text_insert", text="Double <<|Alt <").text = b'\xC2\xAB'.decode()
1390         layout.operator("font.text_insert", text="Promillage|Alt %").text = b'\xE2\x80\xB0'.decode()
1391
1392         layout.separator()
1393
1394         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = b'\xC2\xA4'.decode()
1395         layout.operator("font.text_insert", text="British Pound|Alt L").text = b'\xC2\xA3'.decode()
1396         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = b'\xC2\xA5'.decode()
1397
1398         layout.separator()
1399
1400         layout.operator("font.text_insert", text="German S|Alt S").text = b'\xC3\x9F'.decode()
1401         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = b'\xC2\xBF'.decode()
1402         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = b'\xC2\xA1'.decode()
1403
1404
1405 class VIEW3D_MT_edit_meta(bpy.types.Menu):
1406     bl_label = "Metaball"
1407
1408     def draw(self, context):
1409         layout = self.layout
1410
1411         settings = context.tool_settings
1412
1413         layout.operator("ed.undo")
1414         layout.operator("ed.redo")
1415
1416         layout.separator()
1417
1418         layout.menu("VIEW3D_MT_transform")
1419         layout.menu("VIEW3D_MT_mirror")
1420         layout.menu("VIEW3D_MT_snap")
1421
1422         layout.separator()
1423
1424         layout.operator("mball.delete_metaelems", text="Delete...")
1425         layout.operator("mball.duplicate_metaelems")
1426
1427         layout.separator()
1428
1429         layout.prop_menu_enum(settings, "proportional_editing")
1430         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1431
1432         layout.separator()
1433
1434         layout.menu("VIEW3D_MT_edit_meta_showhide")
1435
1436
1437 class VIEW3D_MT_edit_meta_showhide(bpy.types.Menu):
1438     bl_label = "Show/Hide"
1439
1440     def draw(self, context):
1441         layout = self.layout
1442
1443         layout.operator("mball.reveal_metaelems", text="Show Hidden")
1444         layout.operator("mball.hide_metaelems", text="Hide Selected")
1445         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
1446
1447
1448 class VIEW3D_MT_edit_lattice(bpy.types.Menu):
1449     bl_label = "Lattice"
1450
1451     def draw(self, context):
1452         layout = self.layout
1453
1454         settings = context.tool_settings
1455
1456         layout.menu("VIEW3D_MT_transform")
1457         layout.menu("VIEW3D_MT_mirror")
1458         layout.menu("VIEW3D_MT_snap")
1459
1460         layout.separator()
1461
1462         layout.operator("lattice.make_regular")
1463
1464         layout.separator()
1465
1466         layout.prop_menu_enum(settings, "proportional_editing")
1467         layout.prop_menu_enum(settings, "proportional_editing_falloff")
1468
1469
1470 class VIEW3D_MT_edit_armature(bpy.types.Menu):
1471     bl_label = "Armature"
1472
1473     def draw(self, context):
1474         layout = self.layout
1475
1476         edit_object = context.edit_object
1477         arm = edit_object.data
1478
1479         layout.menu("VIEW3D_MT_transform")
1480         layout.menu("VIEW3D_MT_mirror")
1481         layout.menu("VIEW3D_MT_snap")
1482         layout.menu("VIEW3D_MT_edit_armature_roll")
1483
1484         if arm.drawtype == 'ENVELOPE':
1485             layout.operator("transform.transform", text="Scale Envelope Distance").mode = 'BONESIZE'
1486         else:
1487             layout.operator("transform.transform", text="Scale B-Bone Width").mode = 'BONESIZE'
1488
1489         layout.separator()
1490
1491         layout.operator("armature.extrude_move")
1492
1493         if arm.x_axis_mirror:
1494             layout.operator("armature.extrude_forked")
1495
1496         layout.operator("armature.duplicate_move")
1497         layout.operator("armature.merge")
1498         layout.operator("armature.fill")
1499         layout.operator("armature.delete")
1500         layout.operator("armature.separate")
1501
1502         layout.separator()
1503
1504         layout.operator("armature.subdivide_multi", text="Subdivide")
1505         layout.operator("armature.switch_direction", text="Switch Direction")
1506
1507         layout.separator()
1508
1509         layout.operator_context = 'EXEC_AREA'
1510         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1511         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1512         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1513         layout.operator("armature.flip_names")
1514
1515         layout.separator()
1516
1517         layout.operator_context = 'INVOKE_DEFAULT'
1518         layout.operator("armature.armature_layers")
1519         layout.operator("armature.bone_layers")
1520
1521         layout.separator()
1522
1523         layout.menu("VIEW3D_MT_edit_armature_parent")
1524
1525         layout.separator()
1526
1527         layout.operator_menu_enum("armature.flags_set", "mode", text="Bone Settings")
1528
1529
1530 class VIEW3D_MT_armature_specials(bpy.types.Menu):
1531     bl_label = "Specials"
1532
1533     def draw(self, context):
1534         layout = self.layout
1535
1536         layout.operator_context = 'INVOKE_REGION_WIN'
1537
1538         layout.operator("armature.subdivide_multi", text="Subdivide")
1539         layout.operator("armature.switch_direction", text="Switch Direction")
1540
1541         layout.separator()
1542
1543         layout.operator_context = 'EXEC_REGION_WIN'
1544         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
1545         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
1546         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
1547         layout.operator("armature.flip_names", text="Flip Names")
1548
1549
1550 class VIEW3D_MT_edit_armature_parent(bpy.types.Menu):
1551     bl_label = "Parent"
1552
1553     def draw(self, context):
1554         layout = self.layout
1555
1556         layout.operator("armature.parent_set", text="Make")
1557         layout.operator("armature.parent_clear", text="Clear")
1558
1559
1560 class VIEW3D_MT_edit_armature_roll(bpy.types.Menu):
1561     bl_label = "Bone Roll"
1562
1563     def draw(self, context):
1564         layout = self.layout
1565
1566         layout.operator("armature.calculate_roll", text="Clear Roll (Z-Axis Up)").type = 'GLOBALUP'
1567         layout.operator("armature.calculate_roll", text="Roll to Cursor").type = 'CURSOR'
1568
1569         layout.separator()
1570
1571         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
1572
1573 # ********** Panel **********
1574
1575
1576 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
1577     bl_space_type = 'VIEW_3D'
1578     bl_region_type = 'UI'
1579     bl_label = "View"
1580
1581     def poll(self, context):
1582         view = context.space_data
1583         return (view)
1584
1585     def draw(self, context):
1586         layout = self.layout
1587
1588         view = context.space_data
1589         scene = context.scene
1590
1591         col = layout.column()
1592         col.label(text="Camera:")
1593         col.prop(view, "camera", text="")
1594         col.prop(view, "lens")
1595         col.label(text="Lock to Object:")
1596         col.prop(view, "lock_object", text="")
1597         if view.lock_object and view.lock_object.type == 'ARMATURE':
1598             col.prop_object(view, "lock_bone", view.lock_object.data, "bones", text="")
1599
1600         col = layout.column(align=True)
1601         col.label(text="Clip:")
1602         col.prop(view, "clip_start", text="Start")
1603         col.prop(view, "clip_end", text="End")
1604
1605         layout.column().prop(scene, "cursor_location", text="3D Cursor:")
1606
1607
1608 class VIEW3D_PT_3dview_name(bpy.types.Panel):
1609     bl_space_type = 'VIEW_3D'
1610     bl_region_type = 'UI'
1611     bl_label = "Item"
1612
1613     def poll(self, context):
1614         return (context.space_data and context.active_object)
1615
1616     def draw(self, context):
1617         layout = self.layout
1618
1619         ob = context.active_object
1620         row = layout.row()
1621         row.label(text="", icon='OBJECT_DATA')
1622         row.prop(ob, "name", text="")
1623
1624         if ob.type == 'ARMATURE' and ob.mode in ('EDIT', 'POSE'):
1625             bone = context.active_bone
1626             if bone:
1627                 row = layout.row()
1628                 row.label(text="", icon='BONE_DATA')
1629                 row.prop(bone, "name", text="")
1630
1631
1632 class VIEW3D_PT_3dview_display(bpy.types.Panel):
1633     bl_space_type = 'VIEW_3D'
1634     bl_region_type = 'UI'
1635     bl_label = "Display"
1636     bl_default_closed = True
1637
1638     def poll(self, context):
1639         view = context.space_data
1640         return (view)
1641
1642     def draw(self, context):
1643         layout = self.layout
1644
1645         view = context.space_data
1646         gs = context.scene.game_data
1647         ob = context.object
1648
1649         col = layout.column()
1650         col.prop(view, "display_x_axis", text="X Axis")
1651         col.prop(view, "display_y_axis", text="Y Axis")
1652         col.prop(view, "display_z_axis", text="Z Axis")
1653         col.prop(view, "outline_selected")
1654         col.prop(view, "all_object_origins")
1655         col.prop(view, "relationship_lines")
1656         if ob and ob.type == 'MESH':
1657             mesh = ob.data
1658             col.prop(mesh, "all_edges")
1659
1660         col = layout.column()
1661         col.prop(view, "display_floor", text="Grid Floor")
1662         sub = col.column(align=True)
1663         sub.active = view.display_floor
1664         sub.prop(view, "grid_lines", text="Lines")
1665         sub.prop(view, "grid_spacing", text="Spacing")
1666         sub.prop(view, "grid_subdivisions", text="Subdivisions")
1667
1668         col = layout.column()
1669         col.label(text="Shading:")
1670         col.prop(gs, "material_mode", text="")
1671         col.prop(view, "textured_solid")
1672
1673 # XXX - the Quad View options don't work yet
1674 #               layout.separator()
1675 #
1676 #               layout.operator("screen.region_foursplit", text="Toggle Quad View")
1677 #               col = layout.column()
1678 #               col.prop(view, "lock_rotation")
1679 #               col.prop(view, "box_preview")
1680 #               col.prop(view, "box_clip")
1681
1682
1683 class VIEW3D_PT_3dview_meshdisplay(bpy.types.Panel):
1684     bl_space_type = 'VIEW_3D'
1685     bl_region_type = 'UI'
1686     bl_label = "Mesh Display"
1687
1688     def poll(self, context):
1689         # The active object check is needed because of localmode
1690         return (context.active_object and (context.mode == 'EDIT_MESH'))
1691
1692     def draw(self, context):
1693         layout = self.layout
1694
1695         mesh = context.active_object.data
1696
1697         col = layout.column()
1698         col.label(text="Overlays:")
1699         col.prop(mesh, "draw_edges", text="Edges")
1700         col.prop(mesh, "draw_faces", text="Faces")
1701         col.prop(mesh, "draw_creases", text="Creases")
1702         col.prop(mesh, "draw_bevel_weights", text="Bevel Weights")
1703         col.prop(mesh, "draw_seams", text="Seams")
1704         col.prop(mesh, "draw_sharp", text="Sharp")
1705
1706         col.separator()
1707         col.label(text="Normals:")
1708         col.prop(mesh, "draw_normals", text="Face")
1709         col.prop(mesh, "draw_vertex_normals", text="Vertex")
1710         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1711
1712         col.separator()
1713         col.label(text="Numerics:")
1714         col.prop(mesh, "draw_edge_lenght")
1715         col.prop(mesh, "draw_edge_angle")
1716         col.prop(mesh, "draw_face_area")
1717
1718
1719 class VIEW3D_PT_3dview_curvedisplay(bpy.types.Panel):
1720     bl_space_type = 'VIEW_3D'
1721     bl_region_type = 'UI'
1722     bl_label = "Curve Display"
1723
1724     def poll(self, context):
1725         editmesh = context.mode == 'EDIT_CURVE'
1726         return (editmesh)
1727
1728     def draw(self, context):
1729         layout = self.layout
1730
1731         curve = context.active_object.data
1732
1733         col = layout.column()
1734         col.label(text="Overlays:")
1735         col.prop(curve, "draw_handles", text="Handles")
1736         col.prop(curve, "draw_normals", text="Normals")
1737         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
1738
1739
1740 class VIEW3D_PT_background_image(bpy.types.Panel):
1741     bl_space_type = 'VIEW_3D'
1742     bl_region_type = 'UI'
1743     bl_label = "Background Image"
1744     bl_default_closed = True
1745
1746     def poll(self, context):
1747         view = context.space_data
1748         # bg = context.space_data.background_image
1749         return (view)
1750
1751     def draw_header(self, context):
1752         layout = self.layout
1753         view = context.space_data
1754
1755         layout.prop(view, "display_background_image", text="")
1756
1757     def draw(self, context):
1758         layout = self.layout
1759
1760         view = context.space_data
1761         bg = view.background_image
1762
1763         if bg:
1764             layout.active = view.display_background_image
1765
1766             col = layout.column()
1767             col.template_ID(bg, "image", open="image.open")
1768             col.prop(bg, "size")
1769             col.prop(bg, "transparency", slider=True)
1770
1771
1772             col = layout.column(align=True)
1773             col.label(text="Offset:")
1774             col.prop(bg, "offset_x", text="X")
1775             col.prop(bg, "offset_y", text="Y")
1776
1777
1778 class VIEW3D_PT_transform_orientations(bpy.types.Panel):
1779     bl_space_type = 'VIEW_3D'
1780     bl_region_type = 'UI'
1781     bl_label = "Transform Orientations"
1782     bl_default_closed = True
1783
1784     def poll(self, context):
1785         view = context.space_data
1786         return (view)
1787
1788     def draw(self, context):
1789         layout = self.layout
1790
1791         view = context.space_data
1792
1793         col = layout.column()
1794
1795         col.prop(view, "transform_orientation")
1796         col.operator("transform.create_orientation", text="Create")
1797
1798         orientation = view.current_orientation
1799
1800         if orientation:
1801             col.prop(orientation, "name")
1802             col.operator("transform.delete_orientation", text="Delete")
1803
1804
1805 class VIEW3D_PT_etch_a_ton(bpy.types.Panel):
1806     bl_space_type = 'VIEW_3D'
1807     bl_region_type = 'UI'
1808     bl_label = "Skeleton Sketching"
1809     bl_default_closed = True
1810
1811     def poll(self, context):
1812         scene = context.space_data
1813         ob = context.active_object
1814         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
1815
1816     def draw_header(self, context):
1817         layout = self.layout
1818         toolsettings = context.scene.tool_settings
1819
1820         layout.prop(toolsettings, "bone_sketching", text="")
1821
1822     def draw(self, context):
1823         layout = self.layout
1824         toolsettings = context.scene.tool_settings
1825
1826         col = layout.column()
1827
1828         col.prop(toolsettings, "etch_quick")
1829         col.prop(toolsettings, "etch_overdraw")
1830
1831         col.prop(toolsettings, "etch_convert_mode")
1832
1833         if toolsettings.etch_convert_mode == 'LENGTH':
1834             col.prop(toolsettings, "etch_length_limit")
1835         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
1836             col.prop(toolsettings, "etch_adaptive_limit")
1837         elif toolsettings.etch_convert_mode == 'FIXED':
1838             col.prop(toolsettings, "etch_subdivision_number")
1839         elif toolsettings.etch_convert_mode == 'RETARGET':
1840             col.prop(toolsettings, "etch_template")
1841             col.prop(toolsettings, "etch_roll_mode")
1842             col.prop(toolsettings, "etch_autoname")
1843             col.prop(toolsettings, "etch_number")
1844             col.prop(toolsettings, "etch_side")
1845
1846
1847 class VIEW3D_PT_context_properties(bpy.types.Panel):
1848     bl_space_type = 'VIEW_3D'
1849     bl_region_type = 'UI'
1850     bl_label = "Properties"
1851     bl_default_closed = True
1852
1853     def _active_context_member(self, context):
1854         obj = context.object
1855         if obj:
1856             mode = obj.mode
1857             if mode == 'POSE':
1858                 return "active_pose_bone"
1859             elif mode == 'EDIT' and obj.type == 'ARMATURE':
1860                 return "active_bone"
1861             else:
1862                 return "object"
1863
1864         return ""
1865
1866     def poll(self, context):
1867         member = self._active_context_member(context)
1868         if member:
1869             context_member = getattr(context, member)
1870             return context_member and context_member.keys()
1871
1872         return False
1873
1874     def draw(self, context):
1875         import rna_prop_ui
1876         # reload(rna_prop_ui)
1877         member = self._active_context_member(context)
1878
1879         if member:
1880             # Draw with no edit button
1881             rna_prop_ui.draw(self.layout, context, member, False)
1882
1883
1884 bpy.types.register(VIEW3D_HT_header) # Header
1885
1886 bpy.types.register(VIEW3D_MT_view) #View Menus
1887 bpy.types.register(VIEW3D_MT_view_navigation)
1888 bpy.types.register(VIEW3D_MT_view_align)
1889 bpy.types.register(VIEW3D_MT_view_align_selected)
1890 bpy.types.register(VIEW3D_MT_view_cameras)
1891
1892 bpy.types.register(VIEW3D_MT_select_object) # Select Menus
1893 bpy.types.register(VIEW3D_MT_select_pose)
1894 bpy.types.register(VIEW3D_MT_select_particle)
1895 bpy.types.register(VIEW3D_MT_select_edit_mesh)
1896 bpy.types.register(VIEW3D_MT_select_edit_curve)
1897 bpy.types.register(VIEW3D_MT_select_edit_surface)
1898 bpy.types.register(VIEW3D_MT_select_edit_metaball)
1899 bpy.types.register(VIEW3D_MT_select_edit_lattice)
1900 bpy.types.register(VIEW3D_MT_select_edit_armature)
1901 bpy.types.register(VIEW3D_MT_select_face) # XXX todo
1902
1903 bpy.types.register(VIEW3D_MT_transform) # Object/Edit Menus
1904 bpy.types.register(VIEW3D_MT_mirror) # Object/Edit Menus
1905 bpy.types.register(VIEW3D_MT_snap) # Object/Edit Menus
1906 bpy.types.register(VIEW3D_MT_uv_map) # Edit Menus
1907
1908 bpy.types.register(VIEW3D_MT_object) # Object Menu
1909 bpy.types.register(VIEW3D_MT_object_apply)
1910 bpy.types.register(VIEW3D_MT_object_clear)
1911 bpy.types.register(VIEW3D_MT_object_parent)
1912 bpy.types.register(VIEW3D_MT_object_track)
1913 bpy.types.register(VIEW3D_MT_object_group)
1914 bpy.types.register(VIEW3D_MT_object_constraints)
1915 bpy.types.register(VIEW3D_MT_object_showhide)
1916 bpy.types.register(VIEW3D_MT_make_single_user)
1917 bpy.types.register(VIEW3D_MT_make_links)
1918
1919 bpy.types.register(VIEW3D_MT_hook)
1920 bpy.types.register(VIEW3D_MT_vertex_group)
1921
1922 bpy.types.register(VIEW3D_MT_sculpt) # Sculpt Menu
1923
1924 bpy.types.register(VIEW3D_MT_paint_vertex)
1925
1926 bpy.types.register(VIEW3D_MT_particle) # Particle Menu
1927 bpy.types.register(VIEW3D_MT_particle_showhide)
1928
1929 bpy.types.register(VIEW3D_MT_pose) # POSE Menu
1930 bpy.types.register(VIEW3D_MT_pose_transform)
1931 bpy.types.register(VIEW3D_MT_pose_pose)
1932 bpy.types.register(VIEW3D_MT_pose_motion)
1933 bpy.types.register(VIEW3D_MT_pose_group)
1934 bpy.types.register(VIEW3D_MT_pose_ik)
1935 bpy.types.register(VIEW3D_MT_pose_constraints)
1936 bpy.types.register(VIEW3D_MT_pose_showhide)
1937
1938 bpy.types.register(VIEW3D_MT_edit_mesh)
1939 bpy.types.register(VIEW3D_MT_edit_mesh_specials) # Only as a menu for keybindings
1940 bpy.types.register(VIEW3D_MT_edit_mesh_selection_mode) # Only as a menu for keybindings
1941 bpy.types.register(VIEW3D_MT_edit_mesh_vertices)
1942 bpy.types.register(VIEW3D_MT_edit_mesh_edges)
1943 bpy.types.register(VIEW3D_MT_edit_mesh_faces)
1944 bpy.types.register(VIEW3D_MT_edit_mesh_normals)
1945 bpy.types.register(VIEW3D_MT_edit_mesh_showhide)
1946
1947 bpy.types.register(VIEW3D_MT_edit_curve)
1948 bpy.types.register(VIEW3D_MT_edit_curve_ctrlpoints)
1949 bpy.types.register(VIEW3D_MT_edit_curve_segments)
1950 bpy.types.register(VIEW3D_MT_edit_curve_showhide)
1951
1952 bpy.types.register(VIEW3D_MT_edit_surface)
1953
1954 bpy.types.register(VIEW3D_MT_edit_text)
1955 bpy.types.register(VIEW3D_MT_edit_text_chars)
1956
1957 bpy.types.register(VIEW3D_MT_edit_meta)
1958 bpy.types.register(VIEW3D_MT_edit_meta_showhide)
1959
1960 bpy.types.register(VIEW3D_MT_edit_lattice)
1961
1962 bpy.types.register(VIEW3D_MT_edit_armature)
1963 bpy.types.register(VIEW3D_MT_edit_armature_parent)
1964 bpy.types.register(VIEW3D_MT_edit_armature_roll)
1965
1966 bpy.types.register(VIEW3D_MT_armature_specials) # Only as a menu for keybindings
1967
1968  # Panels
1969 bpy.types.register(VIEW3D_PT_3dview_properties)
1970 bpy.types.register(VIEW3D_PT_3dview_display)
1971 bpy.types.register(VIEW3D_PT_3dview_name)
1972 bpy.types.register(VIEW3D_PT_3dview_meshdisplay)
1973 bpy.types.register(VIEW3D_PT_3dview_curvedisplay)
1974 bpy.types.register(VIEW3D_PT_background_image)
1975 bpy.types.register(VIEW3D_PT_transform_orientations)
1976 bpy.types.register(VIEW3D_PT_etch_a_ton)
1977
1978 bpy.types.register(VIEW3D_PT_context_properties)