fix [#31083] "Hide Selected" through Menu Operation doesn't work well
[blender.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").unselected = False
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").unselected = False
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.inset")
1611         layout.operator("mesh.bevel", text="Bevel")
1612         layout.operator("mesh.bridge_edge_loops")
1613         layout.operator("mesh.faces_shade_smooth")
1614         layout.operator("mesh.faces_shade_flat")
1615         layout.operator("mesh.blend_from_shape")
1616         layout.operator("mesh.shape_propagate_to_all")
1617         layout.operator("mesh.select_vertex_path")
1618
1619
1620 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1621     bl_label = "Mesh Select Mode"
1622
1623     def draw(self, context):
1624         layout = self.layout
1625
1626         layout.operator_context = 'INVOKE_REGION_WIN'
1627
1628         props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL')
1629         props.value = "(True, False, False)"
1630         props.data_path = "tool_settings.mesh_select_mode"
1631
1632         props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL')
1633         props.value = "(False, True, False)"
1634         props.data_path = "tool_settings.mesh_select_mode"
1635
1636         props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL')
1637         props.value = "(False, False, True)"
1638         props.data_path = "tool_settings.mesh_select_mode"
1639
1640
1641 class VIEW3D_MT_edit_mesh_extrude(Menu):
1642     bl_label = "Extrude"
1643
1644     _extrude_funcs = {
1645         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1646         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1647         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1648         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1649     }
1650
1651     @staticmethod
1652     def extrude_options(context):
1653         mesh = context.object.data
1654         select_mode = context.tool_settings.mesh_select_mode
1655
1656         menu = []
1657         if mesh.total_face_sel:
1658             menu += ['REGION', 'FACE']
1659         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1660             menu += ['EDGE']
1661         if mesh.total_vert_sel and select_mode[0]:
1662             menu += ['VERT']
1663
1664         # should never get here
1665         return menu
1666
1667     def draw(self, context):
1668         layout = self.layout
1669         layout.operator_context = 'INVOKE_REGION_WIN'
1670
1671         for menu_id in self.extrude_options(context):
1672             self._extrude_funcs[menu_id](layout)
1673
1674
1675 class VIEW3D_MT_edit_mesh_vertices(Menu):
1676     bl_label = "Vertices"
1677
1678     def draw(self, context):
1679         layout = self.layout
1680         layout.operator_context = 'INVOKE_REGION_WIN'
1681
1682         layout.operator("mesh.merge")
1683         layout.operator("mesh.rip_move")
1684         layout.operator("mesh.split")
1685         layout.operator_menu_enum("mesh.separate", "type")
1686         layout.operator("mesh.vert_connect")
1687         layout.operator("mesh.vert_slide")
1688
1689         layout.separator()
1690
1691         layout.operator("mesh.vertices_smooth")
1692         layout.operator("mesh.remove_doubles")
1693         layout.operator("mesh.vertices_sort")
1694         layout.operator("mesh.vertices_randomize")
1695
1696         layout.operator("mesh.select_vertex_path")
1697
1698         layout.operator("mesh.blend_from_shape")
1699
1700         layout.operator("object.vertex_group_blend")
1701         layout.operator("mesh.shape_propagate_to_all")
1702
1703         layout.separator()
1704
1705         layout.menu("VIEW3D_MT_vertex_group")
1706         layout.menu("VIEW3D_MT_hook")
1707
1708
1709 class VIEW3D_MT_edit_mesh_edges(Menu):
1710     bl_label = "Edges"
1711
1712     def draw(self, context):
1713         layout = self.layout
1714         layout.operator_context = 'INVOKE_REGION_WIN'
1715
1716         layout.operator("mesh.edge_face_add")
1717         layout.operator("mesh.subdivide")
1718
1719         layout.separator()
1720
1721         layout.operator("mesh.mark_seam").clear = False
1722         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1723
1724         layout.separator()
1725
1726         layout.operator("mesh.mark_sharp").clear = False
1727         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1728
1729         layout.separator()
1730
1731         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1732         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").direction = 'CCW'
1733
1734         layout.separator()
1735
1736         layout.operator("mesh.bevel")
1737         layout.operator("mesh.edge_split")
1738         layout.operator("mesh.bridge_edge_loops")
1739
1740         layout.separator()
1741
1742         layout.operator("TRANSFORM_OT_edge_slide")
1743         layout.operator("TRANSFORM_OT_edge_crease")
1744         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1745
1746         #~ uiItemO(layout, "Loopcut", 0, "mesh.loop_cut"); // CutEdgeloop(em, 1);
1747         #~ uiItemO(layout, "Edge Slide", 0, "mesh.edge_slide"); // EdgeSlide(em, 0,0.0);
1748
1749         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1750
1751         layout.operator("mesh.loop_to_region")
1752         layout.operator("mesh.region_to_loop")
1753
1754
1755 class VIEW3D_MT_edit_mesh_faces(Menu):
1756     bl_label = "Faces"
1757     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1758
1759     def draw(self, context):
1760         layout = self.layout
1761         layout.operator_context = 'INVOKE_REGION_WIN'
1762
1763         layout.operator("mesh.flip_normals")
1764         layout.operator("mesh.edge_face_add")
1765         layout.operator("mesh.fill")
1766         layout.operator("mesh.beautify_fill")
1767         layout.operator("mesh.inset")
1768         layout.operator("mesh.bevel")
1769         layout.operator("mesh.solidify")
1770         layout.operator("mesh.sort_faces")
1771
1772         layout.separator()
1773
1774         layout.operator("mesh.quads_convert_to_tris")
1775         layout.operator("mesh.tris_convert_to_quads")
1776
1777         layout.separator()
1778
1779         layout.operator("mesh.faces_shade_smooth")
1780         layout.operator("mesh.faces_shade_flat")
1781
1782         layout.separator()
1783
1784         # uiItemO(layout, NULL, 0, "mesh.face_mode"); // mesh_set_face_flags(em, 1);
1785         # uiItemBooleanO(layout, NULL, 0, "mesh.face_mode", "clear", 1); // mesh_set_face_flags(em, 0);
1786
1787         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").direction = 'CW'
1788
1789         layout.separator()
1790
1791         layout.operator_menu_enum("mesh.uvs_rotate", "direction")
1792         layout.operator("mesh.uvs_reverse")
1793         layout.operator_menu_enum("mesh.colors_rotate", "direction")
1794         layout.operator("mesh.colors_reverse")
1795
1796
1797 class VIEW3D_MT_edit_mesh_normals(Menu):
1798     bl_label = "Normals"
1799
1800     def draw(self, context):
1801         layout = self.layout
1802
1803         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1804         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1805
1806         layout.separator()
1807
1808         layout.operator("mesh.flip_normals")
1809
1810
1811 class VIEW3D_MT_edit_mesh_delete(Menu):
1812     bl_label = "Delete"
1813
1814     def draw(self, context):
1815         layout = self.layout
1816
1817         layout.operator_enum("mesh.delete", "type")
1818
1819         layout.separator()
1820
1821         layout.operator("mesh.dissolve")
1822         layout.operator("mesh.edge_collapse")
1823         layout.operator("mesh.delete_edgeloop")
1824
1825
1826 class VIEW3D_MT_edit_mesh_dissolve(Menu):
1827     bl_label = "Dissolve"
1828
1829     def draw(self, context):
1830         layout = self.layout
1831
1832         layout.operator("mesh.dissolve")
1833
1834         layout.separator()
1835
1836         layout.operator_enum("mesh.dissolve", "type")
1837
1838         layout.separator()
1839
1840         layout.operator("mesh.dissolve_limited")
1841
1842
1843 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1844     _operator_name = "mesh"
1845
1846 # Edit Curve
1847 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1848
1849
1850 def draw_curve(self, context):
1851     layout = self.layout
1852
1853     toolsettings = context.tool_settings
1854
1855     layout.menu("VIEW3D_MT_transform")
1856     layout.menu("VIEW3D_MT_mirror")
1857     layout.menu("VIEW3D_MT_snap")
1858
1859     layout.separator()
1860
1861     layout.operator("curve.extrude")
1862     layout.operator("curve.duplicate")
1863     layout.operator("curve.separate")
1864     layout.operator("curve.make_segment")
1865     layout.operator("curve.cyclic_toggle")
1866     layout.operator("curve.delete", text="Delete...")
1867
1868     layout.separator()
1869
1870     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1871     layout.menu("VIEW3D_MT_edit_curve_segments")
1872
1873     layout.separator()
1874
1875     layout.prop_menu_enum(toolsettings, "proportional_edit")
1876     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1877
1878     layout.separator()
1879
1880     layout.menu("VIEW3D_MT_edit_curve_showhide")
1881
1882
1883 class VIEW3D_MT_edit_curve(Menu):
1884     bl_label = "Curve"
1885
1886     draw = draw_curve
1887
1888
1889 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1890     bl_label = "Control Points"
1891
1892     def draw(self, context):
1893         layout = self.layout
1894
1895         edit_object = context.edit_object
1896
1897         if edit_object.type == 'CURVE':
1898             layout.operator("transform.tilt")
1899             layout.operator("curve.tilt_clear")
1900             layout.operator("curve.separate")
1901
1902             layout.separator()
1903
1904             layout.operator_menu_enum("curve.handle_type_set", "type")
1905
1906             layout.separator()
1907
1908             layout.menu("VIEW3D_MT_hook")
1909
1910
1911 class VIEW3D_MT_edit_curve_segments(Menu):
1912     bl_label = "Segments"
1913
1914     def draw(self, context):
1915         layout = self.layout
1916
1917         layout.operator("curve.subdivide")
1918         layout.operator("curve.switch_direction")
1919
1920
1921 class VIEW3D_MT_edit_curve_specials(Menu):
1922     bl_label = "Specials"
1923
1924     def draw(self, context):
1925         layout = self.layout
1926
1927         layout.operator("curve.subdivide")
1928         layout.operator("curve.switch_direction")
1929         layout.operator("curve.spline_weight_set")
1930         layout.operator("curve.radius_set")
1931         layout.operator("curve.smooth")
1932         layout.operator("curve.smooth_radius")
1933
1934
1935 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
1936     _operator_name = "curve"
1937
1938
1939 class VIEW3D_MT_edit_surface(Menu):
1940     bl_label = "Surface"
1941
1942     draw = draw_curve
1943
1944
1945 class VIEW3D_MT_edit_font(Menu):
1946     bl_label = "Text"
1947
1948     def draw(self, context):
1949         layout = self.layout
1950
1951         layout.operator("font.file_paste")
1952
1953         layout.separator()
1954
1955         layout.menu("VIEW3D_MT_edit_text_chars")
1956
1957         layout.separator()
1958
1959         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
1960         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
1961         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
1962         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
1963
1964
1965 class VIEW3D_MT_edit_text_chars(Menu):
1966     bl_label = "Special Characters"
1967
1968     def draw(self, context):
1969         layout = self.layout
1970
1971         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
1972         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
1973
1974         layout.separator()
1975
1976         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
1977         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
1978         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
1979         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
1980         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
1981         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
1982         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
1983         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
1984         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
1985
1986         layout.separator()
1987
1988         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
1989         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
1990         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
1991
1992         layout.separator()
1993
1994         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
1995         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
1996         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
1997
1998
1999 class VIEW3D_MT_edit_meta(Menu):
2000     bl_label = "Metaball"
2001
2002     def draw(self, context):
2003         layout = self.layout
2004
2005         toolsettings = context.tool_settings
2006
2007         layout.operator("ed.undo")
2008         layout.operator("ed.redo")
2009         layout.operator("ed.undo_history")
2010
2011         layout.separator()
2012
2013         layout.menu("VIEW3D_MT_transform")
2014         layout.menu("VIEW3D_MT_mirror")
2015         layout.menu("VIEW3D_MT_snap")
2016
2017         layout.separator()
2018
2019         layout.operator("mball.delete_metaelems", text="Delete...")
2020         layout.operator("mball.duplicate_metaelems")
2021
2022         layout.separator()
2023
2024         layout.prop_menu_enum(toolsettings, "proportional_edit")
2025         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2026
2027         layout.separator()
2028
2029         layout.menu("VIEW3D_MT_edit_meta_showhide")
2030
2031
2032 class VIEW3D_MT_edit_meta_showhide(Menu):
2033     bl_label = "Show/Hide"
2034
2035     def draw(self, context):
2036         layout = self.layout
2037
2038         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2039         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2040         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2041
2042
2043 class VIEW3D_MT_edit_lattice(Menu):
2044     bl_label = "Lattice"
2045
2046     def draw(self, context):
2047         layout = self.layout
2048
2049         toolsettings = context.tool_settings
2050
2051         layout.menu("VIEW3D_MT_transform")
2052         layout.menu("VIEW3D_MT_mirror")
2053         layout.menu("VIEW3D_MT_snap")
2054
2055         layout.separator()
2056
2057         layout.operator("lattice.make_regular")
2058
2059         layout.separator()
2060
2061         layout.prop_menu_enum(toolsettings, "proportional_edit")
2062         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2063
2064
2065 class VIEW3D_MT_edit_armature(Menu):
2066     bl_label = "Armature"
2067
2068     def draw(self, context):
2069         layout = self.layout
2070
2071         edit_object = context.edit_object
2072         arm = edit_object.data
2073
2074         layout.menu("VIEW3D_MT_transform")
2075         layout.menu("VIEW3D_MT_mirror")
2076         layout.menu("VIEW3D_MT_snap")
2077         layout.menu("VIEW3D_MT_edit_armature_roll")
2078
2079         layout.separator()
2080
2081         layout.operator("armature.extrude_move")
2082
2083         if arm.use_mirror_x:
2084             layout.operator("armature.extrude_forked")
2085
2086         layout.operator("armature.duplicate_move")
2087         layout.operator("armature.merge")
2088         layout.operator("armature.fill")
2089         layout.operator("armature.delete")
2090         layout.operator("armature.separate")
2091
2092         layout.separator()
2093
2094         layout.operator("armature.subdivide", text="Subdivide")
2095         layout.operator("armature.switch_direction", text="Switch Direction")
2096
2097         layout.separator()
2098
2099         layout.operator_context = 'EXEC_AREA'
2100         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2101         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2102         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2103         layout.operator("armature.flip_names")
2104
2105         layout.separator()
2106
2107         layout.operator_context = 'INVOKE_DEFAULT'
2108         layout.operator("armature.armature_layers")
2109         layout.operator("armature.bone_layers")
2110
2111         layout.separator()
2112
2113         layout.menu("VIEW3D_MT_edit_armature_parent")
2114
2115         layout.separator()
2116
2117         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2118
2119
2120 class VIEW3D_MT_armature_specials(Menu):
2121     bl_label = "Specials"
2122
2123     def draw(self, context):
2124         layout = self.layout
2125
2126         layout.operator_context = 'INVOKE_REGION_WIN'
2127
2128         layout.operator("armature.subdivide", text="Subdivide")
2129         layout.operator("armature.switch_direction", text="Switch Direction")
2130
2131         layout.separator()
2132
2133         layout.operator_context = 'EXEC_REGION_WIN'
2134         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2135         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2136         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2137         layout.operator("armature.flip_names", text="Flip Names")
2138
2139
2140 class VIEW3D_MT_edit_armature_parent(Menu):
2141     bl_label = "Parent"
2142
2143     def draw(self, context):
2144         layout = self.layout
2145
2146         layout.operator("armature.parent_set", text="Make")
2147         layout.operator("armature.parent_clear", text="Clear")
2148
2149
2150 class VIEW3D_MT_edit_armature_roll(Menu):
2151     bl_label = "Bone Roll"
2152
2153     def draw(self, context):
2154         layout = self.layout
2155
2156         layout.operator_menu_enum("armature.calculate_roll", "type")
2157
2158         layout.separator()
2159
2160         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2161
2162 # ********** Panel **********
2163
2164
2165 class VIEW3D_PT_view3d_properties(Panel):
2166     bl_space_type = 'VIEW_3D'
2167     bl_region_type = 'UI'
2168     bl_label = "View"
2169
2170     @classmethod
2171     def poll(cls, context):
2172         view = context.space_data
2173         return (view)
2174
2175     def draw(self, context):
2176         layout = self.layout
2177
2178         view = context.space_data
2179
2180         col = layout.column()
2181         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2182                           view.region_quadview)
2183         col.prop(view, "lens")
2184         col.label(text="Lock to Object:")
2185         col.prop(view, "lock_object", text="")
2186         lock_object = view.lock_object
2187         if lock_object:
2188             if lock_object.type == 'ARMATURE':
2189                 col.prop_search(view, "lock_bone", lock_object.data,
2190                                 "edit_bones" if lock_object.mode == 'EDIT'
2191                                              else "bones",
2192                                 text="")
2193         else:
2194             col.prop(view, "lock_cursor", text="Lock to Cursor")
2195
2196         col = layout.column()
2197         col.prop(view, "lock_camera")
2198
2199         col = layout.column(align=True)
2200         col.label(text="Clip:")
2201         col.prop(view, "clip_start", text="Start")
2202         col.prop(view, "clip_end", text="End")
2203
2204         subcol = col.column()
2205         subcol.enabled = not view.lock_camera_and_layers
2206         subcol.label(text="Local Camera:")
2207         subcol.prop(view, "camera", text="")
2208
2209
2210 class VIEW3D_PT_view3d_cursor(Panel):
2211     bl_space_type = 'VIEW_3D'
2212     bl_region_type = 'UI'
2213     bl_label = "3D Cursor"
2214
2215     @classmethod
2216     def poll(cls, context):
2217         view = context.space_data
2218         return (view)
2219
2220     def draw(self, context):
2221         layout = self.layout
2222
2223         view = context.space_data
2224         layout.column().prop(view, "cursor_location", text="Location")
2225
2226
2227 class VIEW3D_PT_view3d_name(Panel):
2228     bl_space_type = 'VIEW_3D'
2229     bl_region_type = 'UI'
2230     bl_label = "Item"
2231
2232     @classmethod
2233     def poll(cls, context):
2234         return (context.space_data and context.active_object)
2235
2236     def draw(self, context):
2237         layout = self.layout
2238
2239         ob = context.active_object
2240         row = layout.row()
2241         row.label(text="", icon='OBJECT_DATA')
2242         row.prop(ob, "name", text="")
2243
2244         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2245             bone = context.active_bone
2246             if bone:
2247                 row = layout.row()
2248                 row.label(text="", icon='BONE_DATA')
2249                 row.prop(bone, "name", text="")
2250
2251
2252 class VIEW3D_PT_view3d_display(Panel):
2253     bl_space_type = 'VIEW_3D'
2254     bl_region_type = 'UI'
2255     bl_label = "Display"
2256     bl_options = {'DEFAULT_CLOSED'}
2257
2258     @classmethod
2259     def poll(cls, context):
2260         view = context.space_data
2261         return (view)
2262
2263     def draw(self, context):
2264         layout = self.layout
2265
2266         view = context.space_data
2267         scene = context.scene
2268         gs = scene.game_settings
2269         ob = context.object
2270
2271         col = layout.column()
2272         col.prop(view, "show_only_render")
2273
2274         col = layout.column()
2275         display_all = not view.show_only_render
2276         col.active = display_all
2277         col.prop(view, "show_outline_selected")
2278         col.prop(view, "show_all_objects_origin")
2279         col.prop(view, "show_relationship_lines")
2280         if ob and ob.type == 'MESH':
2281             mesh = ob.data
2282             col.prop(mesh, "show_all_edges")
2283
2284         col = layout.column()
2285         col.active = display_all
2286         split = col.split(percentage=0.55)
2287         split.prop(view, "show_floor", text="Grid Floor")
2288
2289         row = split.row(align=True)
2290         row.prop(view, "show_axis_x", text="X", toggle=True)
2291         row.prop(view, "show_axis_y", text="Y", toggle=True)
2292         row.prop(view, "show_axis_z", text="Z", toggle=True)
2293
2294         sub = col.column(align=True)
2295         sub.active = (display_all and view.show_floor)
2296         sub.prop(view, "grid_lines", text="Lines")
2297         sub.prop(view, "grid_scale", text="Scale")
2298         subsub = sub.column(align=True)
2299         subsub.active = scene.unit_settings.system == 'NONE'
2300         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2301
2302         if not scene.render.use_shading_nodes:
2303             col = layout.column()
2304             col.label(text="Shading:")
2305             col.prop(gs, "material_mode", text="")
2306             col.prop(view, "show_textured_solid")
2307
2308         layout.separator()
2309
2310         region = view.region_quadview
2311
2312         layout.operator("screen.region_quadview", text="Toggle Quad View")
2313
2314         if region:
2315             col = layout.column()
2316             col.prop(region, "lock_rotation")
2317             row = col.row()
2318             row.enabled = region.lock_rotation
2319             row.prop(region, "show_sync_view")
2320             row = col.row()
2321             row.enabled = region.lock_rotation and region.show_sync_view
2322             row.prop(region, "use_box_clip")
2323
2324
2325 class VIEW3D_PT_view3d_motion_tracking(Panel):
2326     bl_space_type = 'VIEW_3D'
2327     bl_region_type = 'UI'
2328     bl_label = "Motion Tracking"
2329     bl_options = {'DEFAULT_CLOSED'}
2330
2331     @classmethod
2332     def poll(cls, context):
2333         view = context.space_data
2334         return (view)
2335
2336     def draw_header(self, context):
2337         view = context.space_data
2338
2339         self.layout.prop(view, "show_reconstruction", text="")
2340
2341     def draw(self, context):
2342         layout = self.layout
2343
2344         view = context.space_data
2345
2346         col = layout.column()
2347         col.active = view.show_reconstruction
2348         col.prop(view, "show_bundle_names")
2349         col.prop(view, "show_camera_path")
2350         col.label(text="Tracks:")
2351         col.prop(view, "tracks_draw_type", text="")
2352         col.prop(view, "tracks_draw_size", text="Size")
2353
2354
2355 class VIEW3D_PT_view3d_meshdisplay(Panel):
2356     bl_space_type = 'VIEW_3D'
2357     bl_region_type = 'UI'
2358     bl_label = "Mesh Display"
2359
2360     @classmethod
2361     def poll(cls, context):
2362         # The active object check is needed because of local-mode
2363         return (context.active_object and (context.mode == 'EDIT_MESH'))
2364
2365     def draw(self, context):
2366         layout = self.layout
2367
2368         mesh = context.active_object.data
2369
2370         col = layout.column()
2371         col.label(text="Overlays:")
2372         col.prop(mesh, "show_edges", text="Edges")
2373         col.prop(mesh, "show_faces", text="Faces")
2374         col.prop(mesh, "show_edge_crease", text="Creases")
2375         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2376         col.prop(mesh, "show_edge_seams", text="Seams")
2377         col.prop(mesh, "show_edge_sharp", text="Sharp")
2378
2379         col.separator()
2380         col.label(text="Normals:")
2381         row = col.row(align=True)
2382         row.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2383         row.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2384         row.prop(context.scene.tool_settings, "normal_size", text="Size")
2385
2386         col.separator()
2387         col.label(text="Numerics:")
2388         col.prop(mesh, "show_extra_edge_length")
2389         col.prop(mesh, "show_extra_face_angle")
2390         col.prop(mesh, "show_extra_face_area")
2391         if bpy.app.debug:
2392             col.prop(mesh, "show_extra_indices")
2393
2394
2395 class VIEW3D_PT_view3d_curvedisplay(Panel):
2396     bl_space_type = 'VIEW_3D'
2397     bl_region_type = 'UI'
2398     bl_label = "Curve Display"
2399
2400     @classmethod
2401     def poll(cls, context):
2402         editmesh = context.mode == 'EDIT_CURVE'
2403         return (editmesh)
2404
2405     def draw(self, context):
2406         layout = self.layout
2407
2408         curve = context.active_object.data
2409
2410         col = layout.column()
2411         col.label(text="Overlays:")
2412         col.prop(curve, "show_handles", text="Handles")
2413         col.prop(curve, "show_normal_face", text="Normals")
2414         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2415
2416
2417 class VIEW3D_PT_background_image(Panel):
2418     bl_space_type = 'VIEW_3D'
2419     bl_region_type = 'UI'
2420     bl_label = "Background Images"
2421     bl_options = {'DEFAULT_CLOSED'}
2422
2423     def draw_header(self, context):
2424         view = context.space_data
2425
2426         self.layout.prop(view, "show_background_images", text="")
2427
2428     def draw(self, context):
2429         layout = self.layout
2430
2431         view = context.space_data
2432
2433         col = layout.column()
2434         col.operator("view3d.background_image_add", text="Add Image")
2435
2436         for i, bg in enumerate(view.background_images):
2437             layout.active = view.show_background_images
2438             box = layout.box()
2439             row = box.row(align=True)
2440             row.prop(bg, "show_expanded", text="", emboss=False)
2441             if bg.source == 'IMAGE' and bg.image:
2442                 row.prop(bg.image, "name", text="", emboss=False)
2443             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2444                 row.prop(bg.clip, "name", text="", emboss=False)
2445             else:
2446                 row.label(text="Not Set")
2447
2448             if bg.show_background_image:
2449                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2450             else:
2451                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2452
2453             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2454
2455             box.prop(bg, "view_axis", text="Axis")
2456
2457             if bg.show_expanded:
2458                 row = box.row()
2459                 row.prop(bg, "source", expand=True)
2460
2461                 has_bg = False
2462                 if bg.source == 'IMAGE':
2463                     row = box.row()
2464                     row.template_ID(bg, "image", open="image.open")
2465                     if (bg.image):
2466                         box.template_image(bg, "image", bg.image_user, compact=True)
2467                         has_bg = True
2468
2469                 elif bg.source == 'MOVIE_CLIP':
2470                     box.prop(bg, 'use_camera_clip')
2471
2472                     column = box.column()
2473                     column.active = not bg.use_camera_clip
2474                     column.template_ID(bg, "clip", open="clip.open")
2475
2476                     if bg.clip:
2477                         column.template_movieclip(bg, "clip", compact=True)
2478
2479                     if bg.use_camera_clip or bg.clip:
2480                         has_bg = True
2481
2482                     column = box.column()
2483                     column.active = has_bg
2484                     column.prop(bg.clip_user, "proxy_render_size", text="")
2485                     column.prop(bg.clip_user, "use_render_undistorted")
2486
2487                 if has_bg:
2488                     col = box.column()
2489                     col.prop(bg, "show_on_foreground")
2490                     col.prop(bg, "opacity", slider=True)
2491                     if bg.view_axis != 'CAMERA':
2492                         col.prop(bg, "size")
2493                         row = col.row(align=True)
2494                         row.prop(bg, "offset_x", text="X")
2495                         row.prop(bg, "offset_y", text="Y")
2496
2497
2498 class VIEW3D_PT_transform_orientations(Panel):
2499     bl_space_type = 'VIEW_3D'
2500     bl_region_type = 'UI'
2501     bl_label = "Transform Orientations"
2502     bl_options = {'DEFAULT_CLOSED'}
2503
2504     @classmethod
2505     def poll(cls, context):
2506         view = context.space_data
2507         return (view)
2508
2509     def draw(self, context):
2510         layout = self.layout
2511
2512         view = context.space_data
2513         orientation = view.current_orientation
2514
2515         row = layout.row(align=True)
2516         row.prop(view, "transform_orientation", text="")
2517         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2518
2519         if orientation:
2520             row = layout.row(align=True)
2521             row.prop(orientation, "name", text="")
2522             row.operator("transform.delete_orientation", text="", icon="X")
2523
2524
2525 class VIEW3D_PT_etch_a_ton(Panel):
2526     bl_space_type = 'VIEW_3D'
2527     bl_region_type = 'UI'
2528     bl_label = "Skeleton Sketching"
2529     bl_options = {'DEFAULT_CLOSED'}
2530
2531     @classmethod
2532     def poll(cls, context):
2533         scene = context.space_data
2534         ob = context.active_object
2535         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2536
2537     def draw_header(self, context):
2538         layout = self.layout
2539         toolsettings = context.scene.tool_settings
2540
2541         layout.prop(toolsettings, "use_bone_sketching", text="")
2542
2543     def draw(self, context):
2544         layout = self.layout
2545         toolsettings = context.scene.tool_settings
2546
2547         col = layout.column()
2548
2549         col.prop(toolsettings, "use_etch_quick")
2550         col.prop(toolsettings, "use_etch_overdraw")
2551
2552         col.prop(toolsettings, "etch_convert_mode")
2553
2554         if toolsettings.etch_convert_mode == 'LENGTH':
2555             col.prop(toolsettings, "etch_length_limit")
2556         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2557             col.prop(toolsettings, "etch_adaptive_limit")
2558         elif toolsettings.etch_convert_mode == 'FIXED':
2559             col.prop(toolsettings, "etch_subdivision_number")
2560         elif toolsettings.etch_convert_mode == 'RETARGET':
2561             col.prop(toolsettings, "etch_template")
2562             col.prop(toolsettings, "etch_roll_mode")
2563             col.prop(toolsettings, "use_etch_autoname")
2564             col.prop(toolsettings, "etch_number")
2565             col.prop(toolsettings, "etch_side")
2566
2567         col.operator("sketch.convert", text="Convert")
2568
2569
2570 class VIEW3D_PT_context_properties(Panel):
2571     bl_space_type = 'VIEW_3D'
2572     bl_region_type = 'UI'
2573     bl_label = "Properties"
2574     bl_options = {'DEFAULT_CLOSED'}
2575
2576     def _active_context_member(context):
2577         obj = context.object
2578         if obj:
2579             mode = obj.mode
2580             if mode == 'POSE':
2581                 return "active_pose_bone"
2582             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2583                 return "active_bone"
2584             else:
2585                 return "object"
2586
2587         return ""
2588
2589     @classmethod
2590     def poll(cls, context):
2591         member = cls._active_context_member(context)
2592         if member:
2593             context_member = getattr(context, member)
2594             return context_member and context_member.keys()
2595
2596         return False
2597
2598     def draw(self, context):
2599         import rna_prop_ui
2600         member = VIEW3D_PT_context_properties._active_context_member(context)
2601
2602         if member:
2603             # Draw with no edit button
2604             rna_prop_ui.draw(self.layout, context, member, object, False)
2605
2606
2607 def register():
2608     bpy.utils.register_module(__name__)
2609
2610
2611 def unregister():
2612     bpy.utils.unregister_module(__name__)
2613
2614 if __name__ == "__main__":
2615     register()
2616
2617 if __name__ == "__main__":  # only for live edit.
2618     bpy.utils.register_module(__name__)