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