Skeleton Sketching bugfixes/tweaks
[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         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1864         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
1865
1866         layout.separator()
1867
1868         layout.operator("mesh.bevel")
1869         layout.operator("mesh.edge_split")
1870         layout.operator("mesh.bridge_edge_loops")
1871         layout.operator("mesh.sort_elements", text="Sort Edges").elements = {'EDGE'}
1872
1873         layout.separator()
1874
1875         layout.operator("transform.edge_slide")
1876         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1877         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1878         layout.operator("mesh.loop_to_region")
1879         layout.operator("mesh.region_to_loop")
1880
1881
1882 class VIEW3D_MT_edit_mesh_faces(Menu):
1883     bl_label = "Faces"
1884     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1885
1886     def draw(self, context):
1887         layout = self.layout
1888
1889         layout.operator_context = 'INVOKE_REGION_WIN'
1890
1891         layout.operator("mesh.flip_normals")
1892         layout.operator("mesh.edge_face_add")
1893         layout.operator("mesh.fill")
1894         layout.operator("mesh.beautify_fill")
1895         layout.operator("mesh.inset")
1896         layout.operator("mesh.bevel")
1897         layout.operator("mesh.solidify")
1898         layout.operator("mesh.wireframe")
1899         layout.operator("mesh.sort_elements", text="Sort Faces").elements = {'FACE'}
1900
1901         layout.separator()
1902
1903         layout.operator("mesh.quads_convert_to_tris")
1904         layout.operator("mesh.tris_convert_to_quads")
1905
1906         layout.separator()
1907
1908         layout.operator("mesh.faces_shade_smooth")
1909         layout.operator("mesh.faces_shade_flat")
1910
1911         layout.separator()
1912
1913         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1914
1915         layout.separator()
1916
1917         layout.operator("mesh.uvs_rotate")
1918         layout.operator("mesh.uvs_reverse")
1919         layout.operator("mesh.colors_rotate")
1920         layout.operator("mesh.colors_reverse")
1921
1922
1923 class VIEW3D_MT_edit_mesh_normals(Menu):
1924     bl_label = "Normals"
1925
1926     def draw(self, context):
1927         layout = self.layout
1928
1929         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1930         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1931
1932         layout.separator()
1933
1934         layout.operator("mesh.flip_normals")
1935
1936
1937 class VIEW3D_MT_edit_mesh_delete(Menu):
1938     bl_label = "Delete"
1939
1940     def draw(self, context):
1941         layout = self.layout
1942
1943         layout.operator_enum("mesh.delete", "type")
1944
1945         layout.separator()
1946
1947         layout.operator("mesh.dissolve")
1948         layout.operator("mesh.edge_collapse")
1949         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
1950
1951
1952 class VIEW3D_MT_edit_mesh_dissolve(Menu):
1953     bl_label = "Dissolve"
1954
1955     def draw(self, context):
1956         layout = self.layout
1957
1958         layout.operator("mesh.dissolve")
1959
1960         layout.separator()
1961
1962         layout.operator("mesh.dissolve_limited")
1963
1964
1965 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1966     _operator_name = "mesh"
1967
1968 # Edit Curve
1969 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1970
1971
1972 def draw_curve(self, context):
1973     layout = self.layout
1974
1975     toolsettings = context.tool_settings
1976
1977     layout.menu("VIEW3D_MT_transform")
1978     layout.menu("VIEW3D_MT_mirror")
1979     layout.menu("VIEW3D_MT_snap")
1980
1981     layout.separator()
1982
1983     layout.operator("curve.extrude_move")
1984     layout.operator("curve.duplicate_move")
1985     layout.operator("curve.separate")
1986     layout.operator("curve.make_segment")
1987     layout.operator("curve.cyclic_toggle")
1988     layout.operator("curve.delete", text="Delete...")
1989
1990     layout.separator()
1991
1992     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1993     layout.menu("VIEW3D_MT_edit_curve_segments")
1994
1995     layout.separator()
1996
1997     layout.prop_menu_enum(toolsettings, "proportional_edit")
1998     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1999
2000     layout.separator()
2001
2002     layout.menu("VIEW3D_MT_edit_curve_showhide")
2003
2004
2005 class VIEW3D_MT_edit_curve(Menu):
2006     bl_label = "Curve"
2007
2008     draw = draw_curve
2009
2010
2011 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
2012     bl_label = "Control Points"
2013
2014     def draw(self, context):
2015         layout = self.layout
2016
2017         edit_object = context.edit_object
2018
2019         if edit_object.type == 'CURVE':
2020             layout.operator("transform.tilt")
2021             layout.operator("curve.tilt_clear")
2022             layout.operator("curve.separate")
2023
2024             layout.separator()
2025
2026             layout.operator_menu_enum("curve.handle_type_set", "type")
2027
2028             layout.separator()
2029
2030         layout.menu("VIEW3D_MT_hook")
2031
2032
2033 class VIEW3D_MT_edit_curve_segments(Menu):
2034     bl_label = "Segments"
2035
2036     def draw(self, context):
2037         layout = self.layout
2038
2039         layout.operator("curve.subdivide")
2040         layout.operator("curve.switch_direction")
2041
2042
2043 class VIEW3D_MT_edit_curve_specials(Menu):
2044     bl_label = "Specials"
2045
2046     def draw(self, context):
2047         layout = self.layout
2048
2049         layout.operator("curve.subdivide")
2050         layout.operator("curve.switch_direction")
2051         layout.operator("curve.spline_weight_set")
2052         layout.operator("curve.radius_set")
2053         layout.operator("curve.smooth")
2054         layout.operator("curve.smooth_radius")
2055
2056
2057 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2058     _operator_name = "curve"
2059
2060
2061 class VIEW3D_MT_edit_surface(Menu):
2062     bl_label = "Surface"
2063
2064     draw = draw_curve
2065
2066
2067 class VIEW3D_MT_edit_font(Menu):
2068     bl_label = "Text"
2069
2070     def draw(self, context):
2071         layout = self.layout
2072
2073         layout.operator("font.file_paste")
2074
2075         layout.separator()
2076
2077         layout.menu("VIEW3D_MT_edit_text_chars")
2078
2079         layout.separator()
2080
2081         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2082         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2083         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2084         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2085
2086
2087 class VIEW3D_MT_edit_text_chars(Menu):
2088     bl_label = "Special Characters"
2089
2090     def draw(self, context):
2091         layout = self.layout
2092
2093         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2094         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2095
2096         layout.separator()
2097
2098         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2099         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2100         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2101         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2102         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2103         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2104         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2105         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2106         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2107
2108         layout.separator()
2109
2110         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2111         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2112         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2113
2114         layout.separator()
2115
2116         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2117         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2118         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2119
2120
2121 class VIEW3D_MT_edit_meta(Menu):
2122     bl_label = "Metaball"
2123
2124     def draw(self, context):
2125         layout = self.layout
2126
2127         toolsettings = context.tool_settings
2128
2129         layout.operator("ed.undo")
2130         layout.operator("ed.redo")
2131         layout.operator("ed.undo_history")
2132
2133         layout.separator()
2134
2135         layout.menu("VIEW3D_MT_transform")
2136         layout.menu("VIEW3D_MT_mirror")
2137         layout.menu("VIEW3D_MT_snap")
2138
2139         layout.separator()
2140
2141         layout.operator("mball.delete_metaelems", text="Delete...")
2142         layout.operator("mball.duplicate_metaelems")
2143
2144         layout.separator()
2145
2146         layout.prop_menu_enum(toolsettings, "proportional_edit")
2147         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2148
2149         layout.separator()
2150
2151         layout.menu("VIEW3D_MT_edit_meta_showhide")
2152
2153
2154 class VIEW3D_MT_edit_meta_showhide(Menu):
2155     bl_label = "Show/Hide"
2156
2157     def draw(self, context):
2158         layout = self.layout
2159
2160         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2161         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2162         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2163
2164
2165 class VIEW3D_MT_edit_lattice(Menu):
2166     bl_label = "Lattice"
2167
2168     def draw(self, context):
2169         layout = self.layout
2170
2171         toolsettings = context.tool_settings
2172
2173         layout.menu("VIEW3D_MT_transform")
2174         layout.menu("VIEW3D_MT_mirror")
2175         layout.menu("VIEW3D_MT_snap")
2176         layout.operator_menu_enum("lattice.flip", "axis")
2177
2178         layout.separator()
2179
2180         layout.operator("lattice.make_regular")
2181
2182         layout.separator()
2183
2184         layout.prop_menu_enum(toolsettings, "proportional_edit")
2185         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2186
2187
2188 class VIEW3D_MT_edit_armature(Menu):
2189     bl_label = "Armature"
2190
2191     def draw(self, context):
2192         layout = self.layout
2193
2194         edit_object = context.edit_object
2195         arm = edit_object.data
2196
2197         layout.menu("VIEW3D_MT_transform_armature")
2198         layout.menu("VIEW3D_MT_mirror")
2199         layout.menu("VIEW3D_MT_snap")
2200         layout.menu("VIEW3D_MT_edit_armature_roll")
2201
2202         layout.separator()
2203
2204         layout.operator("armature.extrude_move")
2205
2206         if arm.use_mirror_x:
2207             layout.operator("armature.extrude_forked")
2208
2209         layout.operator("armature.duplicate_move")
2210         layout.operator("armature.merge")
2211         layout.operator("armature.fill")
2212         layout.operator("armature.delete")
2213         layout.operator("armature.separate")
2214
2215         layout.separator()
2216
2217         layout.operator("armature.subdivide", text="Subdivide")
2218         layout.operator("armature.switch_direction", text="Switch Direction")
2219
2220         layout.separator()
2221
2222         layout.operator_context = 'EXEC_AREA'
2223         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2224         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2225         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2226         layout.operator("armature.flip_names")
2227
2228         layout.separator()
2229
2230         layout.operator_context = 'INVOKE_DEFAULT'
2231         layout.operator("armature.armature_layers")
2232         layout.operator("armature.bone_layers")
2233
2234         layout.separator()
2235
2236         layout.menu("VIEW3D_MT_edit_armature_parent")
2237
2238         layout.separator()
2239
2240         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2241
2242
2243 class VIEW3D_MT_armature_specials(Menu):
2244     bl_label = "Specials"
2245
2246     def draw(self, context):
2247         layout = self.layout
2248
2249         layout.operator_context = 'INVOKE_REGION_WIN'
2250
2251         layout.operator("armature.subdivide", text="Subdivide")
2252         layout.operator("armature.switch_direction", text="Switch Direction")
2253
2254         layout.separator()
2255
2256         layout.operator_context = 'EXEC_REGION_WIN'
2257         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2258         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2259         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2260         layout.operator("armature.flip_names", text="Flip Names")
2261
2262
2263 class VIEW3D_MT_edit_armature_parent(Menu):
2264     bl_label = "Parent"
2265
2266     def draw(self, context):
2267         layout = self.layout
2268
2269         layout.operator("armature.parent_set", text="Make")
2270         layout.operator("armature.parent_clear", text="Clear")
2271
2272
2273 class VIEW3D_MT_edit_armature_roll(Menu):
2274     bl_label = "Bone Roll"
2275
2276     def draw(self, context):
2277         layout = self.layout
2278
2279         layout.operator_menu_enum("armature.calculate_roll", "type")
2280
2281         layout.separator()
2282
2283         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2284
2285 # ********** Panel **********
2286
2287
2288 class VIEW3D_PT_view3d_properties(Panel):
2289     bl_space_type = 'VIEW_3D'
2290     bl_region_type = 'UI'
2291     bl_label = "View"
2292
2293     @classmethod
2294     def poll(cls, context):
2295         view = context.space_data
2296         return (view)
2297
2298     def draw(self, context):
2299         layout = self.layout
2300
2301         view = context.space_data
2302
2303         col = layout.column()
2304         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2305                           view.region_quadview)
2306         col.prop(view, "lens")
2307         col.label(text="Lock to Object:")
2308         col.prop(view, "lock_object", text="")
2309         lock_object = view.lock_object
2310         if lock_object:
2311             if lock_object.type == 'ARMATURE':
2312                 col.prop_search(view, "lock_bone", lock_object.data,
2313                                 "edit_bones" if lock_object.mode == 'EDIT'
2314                                 else "bones",
2315                                 text="")
2316         else:
2317             col.prop(view, "lock_cursor", text="Lock to Cursor")
2318
2319         col = layout.column()
2320         col.prop(view, "lock_camera")
2321
2322         col = layout.column(align=True)
2323         col.label(text="Clip:")
2324         col.prop(view, "clip_start", text="Start")
2325         col.prop(view, "clip_end", text="End")
2326
2327         subcol = col.column()
2328         subcol.enabled = not view.lock_camera_and_layers
2329         subcol.label(text="Local Camera:")
2330         subcol.prop(view, "camera", text="")
2331
2332         col = layout.column(align=True)
2333         col.prop(view, "use_render_border")
2334
2335
2336 class VIEW3D_PT_view3d_cursor(Panel):
2337     bl_space_type = 'VIEW_3D'
2338     bl_region_type = 'UI'
2339     bl_label = "3D Cursor"
2340
2341     @classmethod
2342     def poll(cls, context):
2343         view = context.space_data
2344         return (view is not None)
2345
2346     def draw(self, context):
2347         layout = self.layout
2348
2349         view = context.space_data
2350         layout.column().prop(view, "cursor_location", text="Location")
2351
2352
2353 class VIEW3D_PT_view3d_name(Panel):
2354     bl_space_type = 'VIEW_3D'
2355     bl_region_type = 'UI'
2356     bl_label = "Item"
2357
2358     @classmethod
2359     def poll(cls, context):
2360         return (context.space_data and context.active_object)
2361
2362     def draw(self, context):
2363         layout = self.layout
2364
2365         ob = context.active_object
2366         row = layout.row()
2367         row.label(text="", icon='OBJECT_DATA')
2368         row.prop(ob, "name", text="")
2369
2370         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2371             bone = context.active_bone
2372             if bone:
2373                 row = layout.row()
2374                 row.label(text="", icon='BONE_DATA')
2375                 row.prop(bone, "name", text="")
2376
2377
2378 class VIEW3D_PT_view3d_display(Panel):
2379     bl_space_type = 'VIEW_3D'
2380     bl_region_type = 'UI'
2381     bl_label = "Display"
2382     bl_options = {'DEFAULT_CLOSED'}
2383
2384     @classmethod
2385     def poll(cls, context):
2386         view = context.space_data
2387         return (view)
2388
2389     def draw(self, context):
2390         layout = self.layout
2391
2392         view = context.space_data
2393         scene = context.scene
2394         gs = scene.game_settings
2395         ob = context.object
2396
2397         col = layout.column()
2398         col.prop(view, "show_only_render")
2399
2400         col = layout.column()
2401         display_all = not view.show_only_render
2402         col.active = display_all
2403         col.prop(view, "show_outline_selected")
2404         col.prop(view, "show_all_objects_origin")
2405         col.prop(view, "show_relationship_lines")
2406
2407         col = layout.column()
2408         col.active = display_all
2409         split = col.split(percentage=0.55)
2410         split.prop(view, "show_floor", text="Grid Floor")
2411
2412         row = split.row(align=True)
2413         row.prop(view, "show_axis_x", text="X", toggle=True)
2414         row.prop(view, "show_axis_y", text="Y", toggle=True)
2415         row.prop(view, "show_axis_z", text="Z", toggle=True)
2416
2417         sub = col.column(align=True)
2418         sub.active = (display_all and view.show_floor)
2419         sub.prop(view, "grid_lines", text="Lines")
2420         sub.prop(view, "grid_scale", text="Scale")
2421         subsub = sub.column(align=True)
2422         subsub.active = scene.unit_settings.system == 'NONE'
2423         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2424
2425         if not scene.render.use_shading_nodes:
2426             col = layout.column()
2427             col.label(text="Shading:")
2428             col.prop(gs, "material_mode", text="")
2429             col.prop(view, "show_textured_solid")
2430         if view.viewport_shade == 'SOLID':
2431             col.prop(view, "use_matcap")
2432             if view.use_matcap:
2433                 col.template_icon_view(view, "matcap_icon")
2434         col.prop(view, "show_backface_culling")
2435
2436         layout.separator()
2437
2438         region = view.region_quadview
2439
2440         layout.operator("screen.region_quadview", text="Toggle Quad View")
2441
2442         if region:
2443             col = layout.column()
2444             col.prop(region, "lock_rotation")
2445             row = col.row()
2446             row.enabled = region.lock_rotation
2447             row.prop(region, "show_sync_view")
2448             row = col.row()
2449             row.enabled = region.lock_rotation and region.show_sync_view
2450             row.prop(region, "use_box_clip")
2451
2452
2453 class VIEW3D_PT_view3d_motion_tracking(Panel):
2454     bl_space_type = 'VIEW_3D'
2455     bl_region_type = 'UI'
2456     bl_label = "Motion Tracking"
2457     bl_options = {'DEFAULT_CLOSED'}
2458
2459     @classmethod
2460     def poll(cls, context):
2461         view = context.space_data
2462         return (view)
2463
2464     def draw_header(self, context):
2465         view = context.space_data
2466
2467         self.layout.prop(view, "show_reconstruction", text="")
2468
2469     def draw(self, context):
2470         layout = self.layout
2471
2472         view = context.space_data
2473
2474         col = layout.column()
2475         col.active = view.show_reconstruction
2476         col.prop(view, "show_bundle_names")
2477         col.prop(view, "show_camera_path")
2478         col.label(text="Tracks:")
2479         col.prop(view, "tracks_draw_type", text="")
2480         col.prop(view, "tracks_draw_size", text="Size")
2481
2482
2483 class VIEW3D_PT_view3d_meshdisplay(Panel):
2484     bl_space_type = 'VIEW_3D'
2485     bl_region_type = 'UI'
2486     bl_label = "Mesh Display"
2487
2488     @classmethod
2489     def poll(cls, context):
2490         # The active object check is needed because of local-mode
2491         return (context.active_object and (context.mode == 'EDIT_MESH'))
2492
2493     def draw(self, context):
2494         layout = self.layout
2495
2496         mesh = context.active_object.data
2497
2498         col = layout.column()
2499         col.label(text="Overlays:")
2500         col.prop(mesh, "show_edges", text="Edges")
2501         col.prop(mesh, "show_faces", text="Faces")
2502         col.prop(mesh, "show_edge_crease", text="Creases")
2503         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2504         col.prop(mesh, "show_edge_seams", text="Seams")
2505         col.prop(mesh, "show_edge_sharp", text="Sharp")
2506
2507         col.separator()
2508         col.label(text="Normals:")
2509         row = col.row()
2510         sub = row.row(align=True)
2511         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2512         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2513         row.prop(context.scene.tool_settings, "normal_size", text="Size")
2514
2515         col.separator()
2516         col.label(text="Numerics:")
2517         col.prop(mesh, "show_extra_edge_length")
2518         col.prop(mesh, "show_extra_face_angle")
2519         col.prop(mesh, "show_extra_face_area")
2520         if bpy.app.debug:
2521             col.prop(mesh, "show_extra_indices")
2522
2523
2524 class VIEW3D_PT_view3d_curvedisplay(Panel):
2525     bl_space_type = 'VIEW_3D'
2526     bl_region_type = 'UI'
2527     bl_label = "Curve Display"
2528
2529     @classmethod
2530     def poll(cls, context):
2531         editmesh = context.mode == 'EDIT_CURVE'
2532         return (editmesh)
2533
2534     def draw(self, context):
2535         layout = self.layout
2536
2537         curve = context.active_object.data
2538
2539         col = layout.column()
2540         col.label(text="Overlays:")
2541         col.prop(curve, "show_handles", text="Handles")
2542         col.prop(curve, "show_normal_face", text="Normals")
2543         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2544
2545
2546 class VIEW3D_PT_background_image(Panel):
2547     bl_space_type = 'VIEW_3D'
2548     bl_region_type = 'UI'
2549     bl_label = "Background Images"
2550     bl_options = {'DEFAULT_CLOSED'}
2551
2552     def draw_header(self, context):
2553         view = context.space_data
2554
2555         self.layout.prop(view, "show_background_images", text="")
2556
2557     def draw(self, context):
2558         layout = self.layout
2559
2560         view = context.space_data
2561
2562         col = layout.column()
2563         col.operator("view3d.background_image_add", text="Add Image")
2564
2565         for i, bg in enumerate(view.background_images):
2566             layout.active = view.show_background_images
2567             box = layout.box()
2568             row = box.row(align=True)
2569             row.prop(bg, "show_expanded", text="", emboss=False)
2570             if bg.source == 'IMAGE' and bg.image:
2571                 row.prop(bg.image, "name", text="", emboss=False)
2572             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2573                 row.prop(bg.clip, "name", text="", emboss=False)
2574             else:
2575                 row.label(text="Not Set")
2576
2577             if bg.show_background_image:
2578                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2579             else:
2580                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2581
2582             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2583
2584             box.prop(bg, "view_axis", text="Axis")
2585
2586             if bg.show_expanded:
2587                 row = box.row()
2588                 row.prop(bg, "source", expand=True)
2589
2590                 has_bg = False
2591                 if bg.source == 'IMAGE':
2592                     row = box.row()
2593                     row.template_ID(bg, "image", open="image.open")
2594                     if bg.image is not None:
2595                         box.template_image(bg, "image", bg.image_user, compact=True)
2596                         has_bg = True
2597
2598                 elif bg.source == 'MOVIE_CLIP':
2599                     box.prop(bg, "use_camera_clip")
2600
2601                     column = box.column()
2602                     column.active = not bg.use_camera_clip
2603                     column.template_ID(bg, "clip", open="clip.open")
2604
2605                     if bg.clip:
2606                         column.template_movieclip(bg, "clip", compact=True)
2607
2608                     if bg.use_camera_clip or bg.clip:
2609                         has_bg = True
2610
2611                     column = box.column()
2612                     column.active = has_bg
2613                     column.prop(bg.clip_user, "proxy_render_size", text="")
2614                     column.prop(bg.clip_user, "use_render_undistorted")
2615
2616                 if has_bg:
2617                     col = box.column()
2618                     col.prop(bg, "opacity", slider=True)
2619
2620                     rowsub = col.row()
2621                     rowsub.prop(bg, "draw_depth", expand=True)
2622
2623                     if bg.view_axis in {'CAMERA', 'ALL'}:
2624                         rowsub = col.row()
2625                         rowsub.prop(bg, "frame_method", expand=True)
2626
2627                     row = col.row(align=True)
2628                     row.prop(bg, "offset_x", text="X")
2629                     row.prop(bg, "offset_y", text="Y")
2630
2631                     if bg.view_axis != 'CAMERA':
2632                         col.prop(bg, "size")
2633
2634
2635 class VIEW3D_PT_transform_orientations(Panel):
2636     bl_space_type = 'VIEW_3D'
2637     bl_region_type = 'UI'
2638     bl_label = "Transform Orientations"
2639     bl_options = {'DEFAULT_CLOSED'}
2640
2641     @classmethod
2642     def poll(cls, context):
2643         view = context.space_data
2644         return (view)
2645
2646     def draw(self, context):
2647         layout = self.layout
2648
2649         view = context.space_data
2650         orientation = view.current_orientation
2651
2652         row = layout.row(align=True)
2653         row.prop(view, "transform_orientation", text="")
2654         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2655
2656         if orientation:
2657             row = layout.row(align=True)
2658             row.prop(orientation, "name", text="")
2659             row.operator("transform.delete_orientation", text="", icon="X")
2660
2661
2662 class VIEW3D_PT_etch_a_ton(Panel):
2663     bl_space_type = 'VIEW_3D'
2664     bl_region_type = 'UI'
2665     bl_label = "Skeleton Sketching"
2666     bl_options = {'DEFAULT_CLOSED'}
2667
2668     @classmethod
2669     def poll(cls, context):
2670         scene = context.space_data
2671         ob = context.active_object
2672         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2673
2674     def draw_header(self, context):
2675         layout = self.layout
2676         toolsettings = context.scene.tool_settings
2677
2678         layout.prop(toolsettings, "use_bone_sketching", text="")
2679
2680     def draw(self, context):
2681         layout = self.layout
2682
2683         toolsettings = context.scene.tool_settings
2684
2685         col = layout.column()
2686
2687         col.prop(toolsettings, "use_etch_quick")
2688         col.prop(toolsettings, "use_etch_overdraw")
2689
2690         col.separator()
2691
2692         col.prop(toolsettings, "etch_convert_mode")
2693
2694         if toolsettings.etch_convert_mode == 'LENGTH':
2695             col.prop(toolsettings, "etch_length_limit")
2696         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2697             col.prop(toolsettings, "etch_adaptive_limit")
2698         elif toolsettings.etch_convert_mode == 'FIXED':
2699             col.prop(toolsettings, "etch_subdivision_number")
2700         elif toolsettings.etch_convert_mode == 'RETARGET':
2701             col.prop(toolsettings, "etch_template")
2702             col.prop(toolsettings, "etch_roll_mode")
2703
2704             col.separator()
2705
2706             colsub = col.column(align=True)
2707             colsub.prop(toolsettings, "use_etch_autoname")
2708             sub = colsub.column() 
2709             sub.enabled = not toolsettings.use_etch_autoname
2710             sub.prop(toolsettings, "etch_number")
2711             sub.prop(toolsettings, "etch_side")
2712
2713         col.separator()
2714
2715         col.operator("sketch.convert", text="Convert to Bones")
2716         col.operator("sketch.delete", text="Delete Strokes")
2717
2718
2719 class VIEW3D_PT_context_properties(Panel):
2720     bl_space_type = 'VIEW_3D'
2721     bl_region_type = 'UI'
2722     bl_label = "Properties"
2723     bl_options = {'DEFAULT_CLOSED'}
2724
2725     def _active_context_member(context):
2726         obj = context.object
2727         if obj:
2728             mode = obj.mode
2729             if mode == 'POSE':
2730                 return "active_pose_bone"
2731             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2732                 return "active_bone"
2733             else:
2734                 return "object"
2735
2736         return ""
2737
2738     @classmethod
2739     def poll(cls, context):
2740         member = cls._active_context_member(context)
2741         if member:
2742             context_member = getattr(context, member)
2743             return context_member and context_member.keys()
2744
2745         return False
2746
2747     def draw(self, context):
2748         import rna_prop_ui
2749         member = VIEW3D_PT_context_properties._active_context_member(context)
2750
2751         if member:
2752             # Draw with no edit button
2753             rna_prop_ui.draw(self.layout, context, member, object, False)
2754
2755
2756 def register():
2757     bpy.utils.register_module(__name__)
2758
2759
2760 def unregister():
2761     bpy.utils.unregister_module(__name__)
2762
2763 if __name__ == "__main__":
2764     register()
2765
2766 if __name__ == "__main__":  # only for live edit.
2767     bpy.utils.register_module(__name__)