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