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