remove vertex selection check for weight paint mode so you can paint `through` the...
[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
1070         if(len(bpy.data.scenes) > 10):
1071             layout.operator_context = 'INVOKE_DEFAULT'
1072             layout.operator("object.make_links_scene", text="Objects to Scene...", icon='OUTLINER_OB_EMPTY')
1073         else:
1074             layout.operator_menu_enum("object.make_links_scene", "scene", text="Objects to Scene...")
1075
1076         layout.operator_enum("object.make_links_data", "type")  # inline
1077
1078         layout.operator("object.join_uvs")  # stupid place to add this!
1079
1080
1081 class VIEW3D_MT_object_game(Menu):
1082     bl_label = "Game"
1083
1084     def draw(self, context):
1085         layout = self.layout
1086
1087         layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks")
1088         layout.operator("object.game_physics_copy", text="Copy Physics Properties")
1089
1090         layout.separator()
1091
1092         layout.operator("object.game_property_copy", text="Replace Properties").operation = 'REPLACE'
1093         layout.operator("object.game_property_copy", text="Merge Properties").operation = 'MERGE'
1094         layout.operator_menu_enum("object.game_property_copy", "property", text="Copy Properties...")
1095
1096         layout.separator()
1097
1098         layout.operator("object.game_property_clear")
1099
1100
1101 # ********** Brush menu **********
1102 class VIEW3D_MT_brush(Menu):
1103     bl_label = "Brush"
1104
1105     def draw(self, context):
1106         layout = self.layout
1107
1108         settings = UnifiedPaintPanel.paint_settings(context)
1109         brush = settings.brush
1110
1111         ups = context.tool_settings.unified_paint_settings
1112         layout.prop(ups, "use_unified_size", text="Unified Size")
1113         layout.prop(ups, "use_unified_strength", text="Unified Strength")
1114         layout.separator()
1115
1116         # brush paint modes
1117         layout.menu("VIEW3D_MT_brush_paint_modes")
1118
1119         # brush tool
1120         if context.sculpt_object:
1121             layout.operator("brush.reset")
1122             layout.prop_menu_enum(brush, "sculpt_tool")
1123         elif context.image_paint_object:
1124             layout.prop_menu_enum(brush, "image_tool")
1125         elif context.vertex_paint_object or context.weight_paint_object:
1126             layout.prop_menu_enum(brush, "vertex_tool")
1127
1128         # skip if no active brush
1129         if not brush:
1130             return
1131
1132         # TODO: still missing a lot of brush options here
1133
1134         # sculpt options
1135         if context.sculpt_object:
1136
1137             sculpt_tool = brush.sculpt_tool
1138
1139             layout.separator()
1140             layout.operator_menu_enum("brush.curve_preset", "shape", text="Curve Preset")
1141             layout.separator()
1142
1143             if sculpt_tool != 'GRAB':
1144                 layout.prop_menu_enum(brush, "stroke_method")
1145
1146                 if sculpt_tool in {'DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'}:
1147                     layout.prop_menu_enum(brush, "direction")
1148
1149                 if sculpt_tool == 'LAYER':
1150                     layout.prop(brush, "use_persistent")
1151                     layout.operator("sculpt.set_persistent_base")
1152
1153
1154 class VIEW3D_MT_brush_paint_modes(Menu):
1155     bl_label = "Enabled Modes"
1156
1157     def draw(self, context):
1158         layout = self.layout
1159
1160         settings = UnifiedPaintPanel.paint_settings(context)
1161         brush = settings.brush
1162
1163         layout.prop(brush, "use_paint_sculpt", text="Sculpt")
1164         layout.prop(brush, "use_paint_vertex", text="Vertex Paint")
1165         layout.prop(brush, "use_paint_weight", text="Weight Paint")
1166         layout.prop(brush, "use_paint_image", text="Texture Paint")
1167
1168 # ********** Vertex paint menu **********
1169
1170
1171 class VIEW3D_MT_paint_vertex(Menu):
1172     bl_label = "Paint"
1173
1174     def draw(self, context):
1175         layout = self.layout
1176
1177         layout.operator("ed.undo")
1178         layout.operator("ed.redo")
1179
1180         layout.separator()
1181
1182         layout.operator("paint.vertex_color_set")
1183         layout.operator("paint.vertex_color_dirt")
1184
1185
1186 class VIEW3D_MT_hook(Menu):
1187     bl_label = "Hooks"
1188
1189     def draw(self, context):
1190         layout = self.layout
1191         layout.operator_context = 'EXEC_AREA'
1192         layout.operator("object.hook_add_newob")
1193         layout.operator("object.hook_add_selob").use_bone = False
1194         layout.operator("object.hook_add_selob", text="Hook to Selected Object Bone").use_bone = True
1195
1196         if [mod.type == 'HOOK' for mod in context.active_object.modifiers]:
1197             layout.separator()
1198             layout.operator_menu_enum("object.hook_assign", "modifier")
1199             layout.operator_menu_enum("object.hook_remove", "modifier")
1200             layout.separator()
1201             layout.operator_menu_enum("object.hook_select", "modifier")
1202             layout.operator_menu_enum("object.hook_reset", "modifier")
1203             layout.operator_menu_enum("object.hook_recenter", "modifier")
1204
1205
1206 class VIEW3D_MT_vertex_group(Menu):
1207     bl_label = "Vertex Groups"
1208
1209     def draw(self, context):
1210         layout = self.layout
1211
1212         layout.operator_context = 'EXEC_AREA'
1213         layout.operator("object.vertex_group_assign", text="Assign to New Group").new = True
1214
1215         ob = context.active_object
1216         if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex):
1217             if ob.vertex_groups.active:
1218                 layout.separator()
1219                 layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False
1220                 layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False
1221                 layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True
1222                 layout.separator()
1223
1224         if ob.vertex_groups.active:
1225             layout.operator_menu_enum("object.vertex_group_set_active", "group", text="Set Active Group")
1226             layout.operator("object.vertex_group_remove", text="Remove Active Group").all = False
1227             layout.operator("object.vertex_group_remove", text="Remove All Groups").all = True
1228
1229 # ********** Weight paint menu **********
1230
1231
1232 class VIEW3D_MT_paint_weight(Menu):
1233     bl_label = "Weights"
1234
1235     def draw(self, context):
1236         layout = self.layout
1237
1238         layout.operator("ed.undo")
1239         layout.operator("ed.redo")
1240         layout.operator("ed.undo_history")
1241
1242         layout.separator()
1243
1244         layout.operator("paint.weight_from_bones", text="Assign Automatic From Bones").type = 'AUTOMATIC'
1245         layout.operator("paint.weight_from_bones", text="Assign From Bone Envelopes").type = 'ENVELOPES'
1246
1247         layout.separator()
1248
1249         layout.operator("object.vertex_group_normalize_all", text="Normalize All")
1250         layout.operator("object.vertex_group_normalize", text="Normalize")
1251         layout.operator("object.vertex_group_mirror", text="Mirror")
1252         layout.operator("object.vertex_group_invert", text="Invert")
1253         layout.operator("object.vertex_group_clean", text="Clean")
1254         layout.operator("object.vertex_group_levels", text="Levels")
1255         layout.operator("object.vertex_group_blend", text="Blend")
1256         layout.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1257         layout.operator("object.vertex_group_limit_total", text="Limit Total")
1258         layout.operator("object.vertex_group_fix", text="Fix Deforms")
1259
1260         layout.separator()
1261
1262         layout.operator("paint.weight_set")
1263
1264 # ********** Sculpt menu **********
1265
1266
1267 class VIEW3D_MT_sculpt(Menu):
1268     bl_label = "Sculpt"
1269
1270     def draw(self, context):
1271         layout = self.layout
1272
1273         toolsettings = context.tool_settings
1274         sculpt = toolsettings.sculpt
1275
1276         layout.operator("ed.undo")
1277         layout.operator("ed.redo")
1278
1279         layout.separator()
1280
1281         layout.prop(sculpt, "use_symmetry_x")
1282         layout.prop(sculpt, "use_symmetry_y")
1283         layout.prop(sculpt, "use_symmetry_z")
1284         layout.separator()
1285         layout.prop(sculpt, "lock_x")
1286         layout.prop(sculpt, "lock_y")
1287         layout.prop(sculpt, "lock_z")
1288
1289         layout.separator()
1290         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
1291         layout.prop(sculpt, "show_low_resolution")
1292         layout.prop(sculpt, "show_brush")
1293         layout.prop(sculpt, "use_deform_only")
1294         layout.prop(sculpt, "show_diffuse_color")
1295
1296
1297 class VIEW3D_MT_hide_mask(Menu):
1298     bl_label = "Hide/Mask"
1299
1300     def draw(self, context):
1301         layout = self.layout
1302
1303         op = layout.operator("paint.hide_show", text="Show All")
1304         op.action = 'SHOW'
1305         op.area = 'ALL'
1306
1307         op = layout.operator("paint.hide_show", text="Hide Bounding Box")
1308         op.action = 'HIDE'
1309         op.area = 'INSIDE'
1310
1311         op = layout.operator("paint.hide_show", text="Show Bounding Box")
1312         op.action = 'SHOW'
1313         op.area = 'INSIDE'
1314
1315         op = layout.operator("paint.hide_show", text="Hide Masked")
1316         op.area = 'MASKED'
1317         op.action = 'HIDE'
1318
1319         layout.separator()
1320
1321         op = layout.operator("paint.mask_flood_fill", text="Invert Mask")
1322         op.mode = 'INVERT'
1323
1324         op = layout.operator("paint.mask_flood_fill", text="Fill Mask")
1325         op.mode = 'VALUE'
1326         op.value = 1
1327
1328         op = layout.operator("paint.mask_flood_fill", text="Clear Mask")
1329         op.mode = 'VALUE'
1330         op.value = 0
1331
1332
1333 # ********** Particle menu **********
1334
1335
1336 class VIEW3D_MT_particle(Menu):
1337     bl_label = "Particle"
1338
1339     def draw(self, context):
1340         layout = self.layout
1341
1342         particle_edit = context.tool_settings.particle_edit
1343
1344         layout.operator("ed.undo")
1345         layout.operator("ed.redo")
1346         layout.operator("ed.undo_history")
1347
1348         layout.separator()
1349
1350         layout.operator("particle.mirror")
1351
1352         layout.separator()
1353
1354         layout.operator("particle.remove_doubles")
1355         layout.operator("particle.delete")
1356
1357         if particle_edit.select_mode == 'POINT':
1358             layout.operator("particle.subdivide")
1359
1360         layout.operator("particle.rekey")
1361         layout.operator("particle.weight_set")
1362
1363         layout.separator()
1364
1365         layout.menu("VIEW3D_MT_particle_showhide")
1366
1367
1368 class VIEW3D_MT_particle_specials(Menu):
1369     bl_label = "Specials"
1370
1371     def draw(self, context):
1372         layout = self.layout
1373
1374         particle_edit = context.tool_settings.particle_edit
1375
1376         layout.operator("particle.rekey")
1377
1378         layout.separator()
1379         if particle_edit.select_mode == 'POINT':
1380             layout.operator("particle.subdivide")
1381             layout.operator("particle.select_roots")
1382             layout.operator("particle.select_tips")
1383
1384         layout.operator("particle.remove_doubles")
1385
1386
1387 class VIEW3D_MT_particle_showhide(ShowHideMenu, Menu):
1388     _operator_name = "particle"
1389
1390 # ********** Pose Menu **********
1391
1392
1393 class VIEW3D_MT_pose(Menu):
1394     bl_label = "Pose"
1395
1396     def draw(self, context):
1397         layout = self.layout
1398
1399         layout.operator("ed.undo")
1400         layout.operator("ed.redo")
1401         layout.operator("ed.undo_history")
1402
1403         layout.separator()
1404
1405         layout.menu("VIEW3D_MT_transform_armature")
1406
1407         layout.menu("VIEW3D_MT_pose_transform")
1408         layout.menu("VIEW3D_MT_pose_apply")
1409
1410         layout.menu("VIEW3D_MT_snap")
1411
1412         layout.separator()
1413
1414         layout.menu("VIEW3D_MT_object_animation")
1415
1416         layout.separator()
1417
1418         layout.menu("VIEW3D_MT_pose_slide")
1419         layout.menu("VIEW3D_MT_pose_propagate")
1420
1421         layout.separator()
1422
1423         layout.operator("pose.copy")
1424         layout.operator("pose.paste")
1425         layout.operator("pose.paste", text="Paste X-Flipped Pose").flipped = True
1426
1427         layout.separator()
1428
1429         layout.menu("VIEW3D_MT_pose_library")
1430         layout.menu("VIEW3D_MT_pose_motion")
1431         layout.menu("VIEW3D_MT_pose_group")
1432
1433         layout.separator()
1434
1435         layout.menu("VIEW3D_MT_object_parent")
1436         layout.menu("VIEW3D_MT_pose_ik")
1437         layout.menu("VIEW3D_MT_pose_constraints")
1438
1439         layout.separator()
1440
1441         layout.operator_context = 'EXEC_AREA'
1442         layout.operator("pose.autoside_names", text="AutoName Left/Right").axis = 'XAXIS'
1443         layout.operator("pose.autoside_names", text="AutoName Front/Back").axis = 'YAXIS'
1444         layout.operator("pose.autoside_names", text="AutoName Top/Bottom").axis = 'ZAXIS'
1445
1446         layout.operator("pose.flip_names")
1447
1448         layout.operator("pose.quaternions_flip")
1449
1450         layout.separator()
1451
1452         layout.operator_context = 'INVOKE_AREA'
1453         layout.operator("pose.armature_layers", text="Change Armature Layers...")
1454         layout.operator("pose.bone_layers", text="Change Bone Layers...")
1455
1456         layout.separator()
1457
1458         layout.menu("VIEW3D_MT_pose_showhide")
1459         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
1460
1461
1462 class VIEW3D_MT_pose_transform(Menu):
1463     bl_label = "Clear Transform"
1464
1465     def draw(self, context):
1466         layout = self.layout
1467
1468         layout.operator("pose.transforms_clear", text="All")
1469
1470         layout.separator()
1471
1472         layout.operator("pose.loc_clear", text="Location")
1473         layout.operator("pose.rot_clear", text="Rotation")
1474         layout.operator("pose.scale_clear", text="Scale")
1475
1476         layout.separator()
1477
1478         layout.operator("pose.user_transforms_clear", text="Reset unkeyed")
1479
1480
1481 class VIEW3D_MT_pose_slide(Menu):
1482     bl_label = "In-Betweens"
1483
1484     def draw(self, context):
1485         layout = self.layout
1486
1487         layout.operator("pose.push")
1488         layout.operator("pose.relax")
1489         layout.operator("pose.breakdown")
1490
1491
1492 class VIEW3D_MT_pose_propagate(Menu):
1493     bl_label = "Propagate"
1494
1495     def draw(self, context):
1496         layout = self.layout
1497
1498         layout.operator("pose.propagate").mode = 'WHILE_HELD'
1499
1500         layout.separator()
1501
1502         layout.operator("pose.propagate", text="To Next Keyframe").mode = 'NEXT_KEY'
1503         layout.operator("pose.propagate", text="To Last Keyframe (Make Cyclic)").mode = 'LAST_KEY'
1504
1505         layout.separator()
1506
1507         layout.operator("pose.propagate", text="On Selected Markers").mode = 'SELECTED_MARKERS'
1508
1509
1510 class VIEW3D_MT_pose_library(Menu):
1511     bl_label = "Pose Library"
1512
1513     def draw(self, context):
1514         layout = self.layout
1515
1516         layout.operator("poselib.browse_interactive", text="Browse Poses...")
1517
1518         layout.separator()
1519
1520         layout.operator("poselib.pose_add", text="Add Pose...")
1521         layout.operator("poselib.pose_rename", text="Rename Pose...")
1522         layout.operator("poselib.pose_remove", text="Remove Pose...")
1523
1524
1525 class VIEW3D_MT_pose_motion(Menu):
1526     bl_label = "Motion Paths"
1527
1528     def draw(self, context):
1529         layout = self.layout
1530
1531         layout.operator("pose.paths_calculate", text="Calculate")
1532         layout.operator("pose.paths_clear", text="Clear")
1533
1534
1535 class VIEW3D_MT_pose_group(Menu):
1536     bl_label = "Bone Groups"
1537
1538     def draw(self, context):
1539         layout = self.layout
1540         
1541         pose = context.active_object.pose
1542
1543         layout.operator_context = 'EXEC_AREA'
1544         layout.operator("pose.group_assign", text="Assign to New Group").type = 0
1545         if pose.bone_groups:
1546             active_group = pose.bone_groups.active_index + 1
1547             layout.operator("pose.group_assign", text="Assign to Group").type = active_group
1548
1549             layout.separator()
1550
1551             #layout.operator_context = 'INVOKE_AREA'
1552             layout.operator("pose.group_unassign")
1553             layout.operator("pose.group_remove")
1554
1555
1556 class VIEW3D_MT_pose_ik(Menu):
1557     bl_label = "Inverse Kinematics"
1558
1559     def draw(self, context):
1560         layout = self.layout
1561
1562         layout.operator("pose.ik_add")
1563         layout.operator("pose.ik_clear")
1564
1565
1566 class VIEW3D_MT_pose_constraints(Menu):
1567     bl_label = "Constraints"
1568
1569     def draw(self, context):
1570         layout = self.layout
1571
1572         layout.operator("pose.constraint_add_with_targets", text="Add (With Targets)...")
1573         layout.operator("pose.constraints_copy")
1574         layout.operator("pose.constraints_clear")
1575
1576
1577 class VIEW3D_MT_pose_showhide(ShowHideMenu, Menu):
1578     _operator_name = "pose"
1579
1580
1581 class VIEW3D_MT_pose_apply(Menu):
1582     bl_label = "Apply"
1583
1584     def draw(self, context):
1585         layout = self.layout
1586
1587         layout.operator("pose.armature_apply")
1588         layout.operator("pose.visual_transform_apply")
1589
1590
1591 class VIEW3D_MT_pose_specials(Menu):
1592     bl_label = "Specials"
1593
1594     def draw(self, context):
1595         layout = self.layout
1596         layout.operator("pose.select_constraint_target")
1597         layout.operator("pose.flip_names")
1598         layout.operator("pose.paths_calculate")
1599         layout.operator("pose.paths_clear")
1600         layout.operator("pose.user_transforms_clear")
1601         layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False
1602         layout.operator("pose.relax")
1603
1604         layout.separator()
1605
1606         layout.operator_menu_enum("pose.autoside_names", "axis")
1607
1608
1609 class BoneOptions:
1610     def draw(self, context):
1611         layout = self.layout
1612
1613         options = [
1614             "show_wire",
1615             "use_deform",
1616             "use_envelope_multiply",
1617             "use_inherit_rotation",
1618             "use_inherit_scale",
1619         ]
1620
1621         if context.mode == 'EDIT_ARMATURE':
1622             bone_props = bpy.types.EditBone.bl_rna.properties
1623             data_path_iter = "selected_bones"
1624             opt_suffix = ""
1625             options.append("lock")
1626         else:  # pose-mode
1627             bone_props = bpy.types.Bone.bl_rna.properties
1628             data_path_iter = "selected_pose_bones"
1629             opt_suffix = "bone."
1630
1631         for opt in options:
1632             props = layout.operator("wm.context_collection_boolean_set", text=bone_props[opt].name)
1633             props.data_path_iter = data_path_iter
1634             props.data_path_item = opt_suffix + opt
1635             props.type = self.type
1636
1637
1638 class VIEW3D_MT_bone_options_toggle(Menu, BoneOptions):
1639     bl_label = "Toggle Bone Options"
1640     type = 'TOGGLE'
1641
1642
1643 class VIEW3D_MT_bone_options_enable(Menu, BoneOptions):
1644     bl_label = "Enable Bone Options"
1645     type = 'ENABLE'
1646
1647
1648 class VIEW3D_MT_bone_options_disable(Menu, BoneOptions):
1649     bl_label = "Disable Bone Options"
1650     type = 'DISABLE'
1651
1652 # ********** Edit Menus, suffix from ob.type **********
1653
1654
1655 class VIEW3D_MT_edit_mesh(Menu):
1656     bl_label = "Mesh"
1657
1658     def draw(self, context):
1659         layout = self.layout
1660
1661         toolsettings = context.tool_settings
1662
1663         layout.operator("ed.undo")
1664         layout.operator("ed.redo")
1665         layout.operator("ed.undo_history")
1666
1667         layout.separator()
1668
1669         layout.menu("VIEW3D_MT_transform")
1670         layout.menu("VIEW3D_MT_mirror")
1671         layout.menu("VIEW3D_MT_snap")
1672
1673         layout.separator()
1674
1675         layout.menu("VIEW3D_MT_uv_map", text="UV Unwrap...")
1676
1677         layout.separator()
1678         layout.operator("mesh.symmetrize")
1679         layout.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
1680         layout.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
1681         layout.operator("mesh.duplicate_move")
1682         layout.menu("VIEW3D_MT_edit_mesh_delete")
1683         layout.menu("VIEW3D_MT_edit_mesh_dissolve")
1684
1685         layout.separator()
1686
1687         layout.menu("VIEW3D_MT_edit_mesh_vertices")
1688         layout.menu("VIEW3D_MT_edit_mesh_edges")
1689         layout.menu("VIEW3D_MT_edit_mesh_faces")
1690         layout.menu("VIEW3D_MT_edit_mesh_normals")
1691
1692         layout.separator()
1693
1694         layout.prop(toolsettings, "use_mesh_automerge")
1695         layout.prop_menu_enum(toolsettings, "proportional_edit")
1696         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1697
1698         layout.separator()
1699
1700         layout.menu("VIEW3D_MT_edit_mesh_showhide")
1701
1702
1703 class VIEW3D_MT_edit_mesh_specials(Menu):
1704     bl_label = "Specials"
1705
1706     def draw(self, context):
1707         layout = self.layout
1708
1709         layout.operator_context = 'INVOKE_REGION_WIN'
1710
1711         layout.operator("mesh.subdivide", text="Subdivide").smoothness = 0.0
1712         layout.operator("mesh.subdivide", text="Subdivide Smooth").smoothness = 1.0
1713         layout.operator("mesh.merge", text="Merge...")
1714         layout.operator("mesh.remove_doubles")
1715         layout.operator("mesh.hide", text="Hide").unselected = False
1716         layout.operator("mesh.reveal", text="Reveal")
1717         layout.operator("mesh.select_all", text="Select Inverse").action = 'INVERT'
1718         layout.operator("mesh.flip_normals")
1719         layout.operator("mesh.vertices_smooth", text="Smooth")
1720         layout.operator("mesh.vertices_smooth_laplacian", text="Laplacian Smooth")
1721         layout.operator("mesh.inset")
1722         layout.operator("mesh.bevel", text="Bevel")
1723         layout.operator("mesh.bridge_edge_loops")
1724         layout.operator("mesh.faces_shade_smooth")
1725         layout.operator("mesh.faces_shade_flat")
1726         layout.operator("mesh.blend_from_shape")
1727         layout.operator("mesh.shape_propagate_to_all")
1728         layout.operator("mesh.select_vertex_path")
1729         layout.operator("mesh.sort_elements")
1730         layout.operator("mesh.symmetrize")
1731
1732
1733 class VIEW3D_MT_edit_mesh_select_mode(Menu):
1734     bl_label = "Mesh Select Mode"
1735
1736     def draw(self, context):
1737         layout = self.layout
1738
1739         layout.operator_context = 'INVOKE_REGION_WIN'
1740         layout.operator("mesh.select_mode", text="Vertex", icon='VERTEXSEL').type = 'VERT'
1741         layout.operator("mesh.select_mode", text="Edge", icon='EDGESEL').type = 'EDGE'
1742         layout.operator("mesh.select_mode", text="Face", icon='FACESEL').type = 'FACE'
1743
1744
1745 class VIEW3D_MT_edit_mesh_extrude(Menu):
1746     bl_label = "Extrude"
1747
1748     _extrude_funcs = {
1749         'VERT': lambda layout: layout.operator("mesh.extrude_vertices_move", text="Vertices Only"),
1750         'EDGE': lambda layout: layout.operator("mesh.extrude_edges_move", text="Edges Only"),
1751         'FACE': lambda layout: layout.operator("mesh.extrude_faces_move", text="Individual Faces"),
1752         'REGION': lambda layout: layout.operator("view3d.edit_mesh_extrude_move_normal", text="Region"),
1753     }
1754
1755     @staticmethod
1756     def extrude_options(context):
1757         mesh = context.object.data
1758         select_mode = context.tool_settings.mesh_select_mode
1759
1760         menu = []
1761         if mesh.total_face_sel:
1762             menu += ['REGION', 'FACE']
1763         if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
1764             menu += ['EDGE']
1765         if mesh.total_vert_sel and select_mode[0]:
1766             menu += ['VERT']
1767
1768         # should never get here
1769         return menu
1770
1771     def draw(self, context):
1772         layout = self.layout
1773         layout.operator_context = 'INVOKE_REGION_WIN'
1774
1775         for menu_id in self.extrude_options(context):
1776             self._extrude_funcs[menu_id](layout)
1777
1778
1779 class VIEW3D_MT_edit_mesh_vertices(Menu):
1780     bl_label = "Vertices"
1781
1782     def draw(self, context):
1783         layout = self.layout
1784         layout.operator_context = 'INVOKE_REGION_WIN'
1785
1786         layout.operator("mesh.merge")
1787         layout.operator("mesh.rip_move")
1788         layout.operator("mesh.rip_move_fill")
1789         layout.operator("mesh.split")
1790         layout.operator_menu_enum("mesh.separate", "type")
1791         layout.operator("mesh.vert_connect")
1792         layout.operator("mesh.vert_slide")
1793
1794         layout.separator()
1795
1796         layout.operator("mesh.vertices_smooth")
1797         layout.operator("mesh.remove_doubles")
1798         layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {'VERT'}
1799
1800         layout.operator("mesh.select_vertex_path")
1801
1802         layout.operator("mesh.blend_from_shape")
1803
1804         layout.operator("object.vertex_group_blend")
1805         layout.operator("mesh.shape_propagate_to_all")
1806
1807         layout.separator()
1808
1809         layout.menu("VIEW3D_MT_vertex_group")
1810         layout.menu("VIEW3D_MT_hook")
1811
1812
1813 class VIEW3D_MT_edit_mesh_edges(Menu):
1814     bl_label = "Edges"
1815
1816     def draw(self, context):
1817         layout = self.layout
1818
1819         layout.operator_context = 'INVOKE_REGION_WIN'
1820
1821         layout.operator("mesh.edge_face_add")
1822         layout.operator("mesh.subdivide")
1823         layout.operator("mesh.unsubdivide")
1824
1825         layout.separator()
1826
1827         layout.operator("transform.edge_crease")
1828         layout.operator("transform.edge_bevelweight")
1829
1830         layout.separator()
1831
1832         layout.operator("mesh.mark_seam").clear = False
1833         layout.operator("mesh.mark_seam", text="Clear Seam").clear = True
1834
1835         layout.separator()
1836
1837         layout.operator("mesh.mark_sharp").clear = False
1838         layout.operator("mesh.mark_sharp", text="Clear Sharp").clear = True
1839
1840         layout.separator()
1841
1842         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1843         layout.operator("mesh.edge_rotate", text="Rotate Edge CCW").use_ccw = True
1844
1845         layout.separator()
1846
1847         layout.operator("mesh.bevel")
1848         layout.operator("mesh.edge_split")
1849         layout.operator("mesh.bridge_edge_loops")
1850         layout.operator("mesh.sort_elements", text="Sort Edges").elements = {'EDGE'}
1851
1852         layout.separator()
1853
1854         layout.operator("transform.edge_slide")
1855         layout.operator("mesh.loop_multi_select", text="Edge Loop").ring = False
1856         layout.operator("mesh.loop_multi_select", text="Edge Ring").ring = True
1857         layout.operator("mesh.loop_to_region")
1858         layout.operator("mesh.region_to_loop")
1859
1860
1861 class VIEW3D_MT_edit_mesh_faces(Menu):
1862     bl_label = "Faces"
1863     bl_idname = "VIEW3D_MT_edit_mesh_faces"
1864
1865     def draw(self, context):
1866         layout = self.layout
1867
1868         layout.operator_context = 'INVOKE_REGION_WIN'
1869
1870         layout.operator("mesh.flip_normals")
1871         layout.operator("mesh.edge_face_add")
1872         layout.operator("mesh.fill")
1873         layout.operator("mesh.beautify_fill")
1874         layout.operator("mesh.inset")
1875         layout.operator("mesh.bevel")
1876         layout.operator("mesh.solidify")
1877         layout.operator("mesh.wireframe")
1878         layout.operator("mesh.sort_elements", text="Sort Faces").elements = {'FACE'}
1879
1880         layout.separator()
1881
1882         layout.operator("mesh.quads_convert_to_tris")
1883         layout.operator("mesh.tris_convert_to_quads")
1884
1885         layout.separator()
1886
1887         layout.operator("mesh.faces_shade_smooth")
1888         layout.operator("mesh.faces_shade_flat")
1889
1890         layout.separator()
1891
1892         layout.operator("mesh.edge_rotate", text="Rotate Edge CW").use_ccw = False
1893
1894         layout.separator()
1895
1896         layout.operator("mesh.uvs_rotate")
1897         layout.operator("mesh.uvs_reverse")
1898         layout.operator("mesh.colors_rotate")
1899         layout.operator("mesh.colors_reverse")
1900
1901
1902 class VIEW3D_MT_edit_mesh_normals(Menu):
1903     bl_label = "Normals"
1904
1905     def draw(self, context):
1906         layout = self.layout
1907
1908         layout.operator("mesh.normals_make_consistent", text="Recalculate Outside").inside = False
1909         layout.operator("mesh.normals_make_consistent", text="Recalculate Inside").inside = True
1910
1911         layout.separator()
1912
1913         layout.operator("mesh.flip_normals")
1914
1915
1916 class VIEW3D_MT_edit_mesh_delete(Menu):
1917     bl_label = "Delete"
1918
1919     def draw(self, context):
1920         layout = self.layout
1921
1922         layout.operator_enum("mesh.delete", "type")
1923
1924         layout.separator()
1925
1926         layout.operator("mesh.dissolve")
1927         layout.operator("mesh.edge_collapse")
1928         layout.operator("mesh.delete_edgeloop", text="Edge Loop")
1929
1930
1931 class VIEW3D_MT_edit_mesh_dissolve(Menu):
1932     bl_label = "Dissolve"
1933
1934     def draw(self, context):
1935         layout = self.layout
1936
1937         layout.operator("mesh.dissolve")
1938
1939         layout.separator()
1940
1941         layout.operator("mesh.dissolve_limited")
1942
1943
1944 class VIEW3D_MT_edit_mesh_showhide(ShowHideMenu, Menu):
1945     _operator_name = "mesh"
1946
1947 # Edit Curve
1948 # draw_curve is used by VIEW3D_MT_edit_curve and VIEW3D_MT_edit_surface
1949
1950
1951 def draw_curve(self, context):
1952     layout = self.layout
1953
1954     toolsettings = context.tool_settings
1955
1956     layout.menu("VIEW3D_MT_transform")
1957     layout.menu("VIEW3D_MT_mirror")
1958     layout.menu("VIEW3D_MT_snap")
1959
1960     layout.separator()
1961
1962     layout.operator("curve.extrude_move")
1963     layout.operator("curve.duplicate_move")
1964     layout.operator("curve.separate")
1965     layout.operator("curve.make_segment")
1966     layout.operator("curve.cyclic_toggle")
1967     layout.operator("curve.delete", text="Delete...")
1968
1969     layout.separator()
1970
1971     layout.menu("VIEW3D_MT_edit_curve_ctrlpoints")
1972     layout.menu("VIEW3D_MT_edit_curve_segments")
1973
1974     layout.separator()
1975
1976     layout.prop_menu_enum(toolsettings, "proportional_edit")
1977     layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
1978
1979     layout.separator()
1980
1981     layout.menu("VIEW3D_MT_edit_curve_showhide")
1982
1983
1984 class VIEW3D_MT_edit_curve(Menu):
1985     bl_label = "Curve"
1986
1987     draw = draw_curve
1988
1989
1990 class VIEW3D_MT_edit_curve_ctrlpoints(Menu):
1991     bl_label = "Control Points"
1992
1993     def draw(self, context):
1994         layout = self.layout
1995
1996         edit_object = context.edit_object
1997
1998         if edit_object.type == 'CURVE':
1999             layout.operator("transform.tilt")
2000             layout.operator("curve.tilt_clear")
2001             layout.operator("curve.separate")
2002
2003             layout.separator()
2004
2005             layout.operator_menu_enum("curve.handle_type_set", "type")
2006
2007             layout.separator()
2008
2009         layout.menu("VIEW3D_MT_hook")
2010
2011
2012 class VIEW3D_MT_edit_curve_segments(Menu):
2013     bl_label = "Segments"
2014
2015     def draw(self, context):
2016         layout = self.layout
2017
2018         layout.operator("curve.subdivide")
2019         layout.operator("curve.switch_direction")
2020
2021
2022 class VIEW3D_MT_edit_curve_specials(Menu):
2023     bl_label = "Specials"
2024
2025     def draw(self, context):
2026         layout = self.layout
2027
2028         layout.operator("curve.subdivide")
2029         layout.operator("curve.switch_direction")
2030         layout.operator("curve.spline_weight_set")
2031         layout.operator("curve.radius_set")
2032         layout.operator("curve.smooth")
2033         layout.operator("curve.smooth_radius")
2034
2035
2036 class VIEW3D_MT_edit_curve_showhide(ShowHideMenu, Menu):
2037     _operator_name = "curve"
2038
2039
2040 class VIEW3D_MT_edit_surface(Menu):
2041     bl_label = "Surface"
2042
2043     draw = draw_curve
2044
2045
2046 class VIEW3D_MT_edit_font(Menu):
2047     bl_label = "Text"
2048
2049     def draw(self, context):
2050         layout = self.layout
2051
2052         layout.operator("font.file_paste")
2053
2054         layout.separator()
2055
2056         layout.menu("VIEW3D_MT_edit_text_chars")
2057
2058         layout.separator()
2059
2060         layout.operator("font.style_toggle", text="Toggle Bold").style = 'BOLD'
2061         layout.operator("font.style_toggle", text="Toggle Italic").style = 'ITALIC'
2062         layout.operator("font.style_toggle", text="Toggle Underline").style = 'UNDERLINE'
2063         layout.operator("font.style_toggle", text="Toggle Small Caps").style = 'SMALL_CAPS'
2064
2065
2066 class VIEW3D_MT_edit_text_chars(Menu):
2067     bl_label = "Special Characters"
2068
2069     def draw(self, context):
2070         layout = self.layout
2071
2072         layout.operator("font.text_insert", text="Copyright|Alt C").text = "\u00A9"
2073         layout.operator("font.text_insert", text="Registered Trademark|Alt R").text = "\u00AE"
2074
2075         layout.separator()
2076
2077         layout.operator("font.text_insert", text="Degree Sign|Alt G").text = "\u00B0"
2078         layout.operator("font.text_insert", text="Multiplication Sign|Alt x").text = "\u00D7"
2079         layout.operator("font.text_insert", text="Circle|Alt .").text = "\u008A"
2080         layout.operator("font.text_insert", text="Superscript 1|Alt 1").text = "\u00B9"
2081         layout.operator("font.text_insert", text="Superscript 2|Alt 2").text = "\u00B2"
2082         layout.operator("font.text_insert", text="Superscript 3|Alt 3").text = "\u00B3"
2083         layout.operator("font.text_insert", text="Double >>|Alt >").text = "\u00BB"
2084         layout.operator("font.text_insert", text="Double <<|Alt <").text = "\u00AB"
2085         layout.operator("font.text_insert", text="Promillage|Alt %").text = "\u2030"
2086
2087         layout.separator()
2088
2089         layout.operator("font.text_insert", text="Dutch Florin|Alt F").text = "\u00A4"
2090         layout.operator("font.text_insert", text="British Pound|Alt L").text = "\u00A3"
2091         layout.operator("font.text_insert", text="Japanese Yen|Alt Y").text = "\u00A5"
2092
2093         layout.separator()
2094
2095         layout.operator("font.text_insert", text="German S|Alt S").text = "\u00DF"
2096         layout.operator("font.text_insert", text="Spanish Question Mark|Alt ?").text = "\u00BF"
2097         layout.operator("font.text_insert", text="Spanish Exclamation Mark|Alt !").text = "\u00A1"
2098
2099
2100 class VIEW3D_MT_edit_meta(Menu):
2101     bl_label = "Metaball"
2102
2103     def draw(self, context):
2104         layout = self.layout
2105
2106         toolsettings = context.tool_settings
2107
2108         layout.operator("ed.undo")
2109         layout.operator("ed.redo")
2110         layout.operator("ed.undo_history")
2111
2112         layout.separator()
2113
2114         layout.menu("VIEW3D_MT_transform")
2115         layout.menu("VIEW3D_MT_mirror")
2116         layout.menu("VIEW3D_MT_snap")
2117
2118         layout.separator()
2119
2120         layout.operator("mball.delete_metaelems", text="Delete...")
2121         layout.operator("mball.duplicate_metaelems")
2122
2123         layout.separator()
2124
2125         layout.prop_menu_enum(toolsettings, "proportional_edit")
2126         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2127
2128         layout.separator()
2129
2130         layout.menu("VIEW3D_MT_edit_meta_showhide")
2131
2132
2133 class VIEW3D_MT_edit_meta_showhide(Menu):
2134     bl_label = "Show/Hide"
2135
2136     def draw(self, context):
2137         layout = self.layout
2138
2139         layout.operator("mball.reveal_metaelems", text="Show Hidden")
2140         layout.operator("mball.hide_metaelems", text="Hide Selected").unselected = False
2141         layout.operator("mball.hide_metaelems", text="Hide Unselected").unselected = True
2142
2143
2144 class VIEW3D_MT_edit_lattice(Menu):
2145     bl_label = "Lattice"
2146
2147     def draw(self, context):
2148         layout = self.layout
2149
2150         toolsettings = context.tool_settings
2151
2152         layout.menu("VIEW3D_MT_transform")
2153         layout.menu("VIEW3D_MT_mirror")
2154         layout.menu("VIEW3D_MT_snap")
2155         layout.operator_menu_enum("lattice.flip", "axis")
2156
2157         layout.separator()
2158
2159         layout.operator("lattice.make_regular")
2160
2161         layout.separator()
2162
2163         layout.prop_menu_enum(toolsettings, "proportional_edit")
2164         layout.prop_menu_enum(toolsettings, "proportional_edit_falloff")
2165
2166
2167 class VIEW3D_MT_edit_armature(Menu):
2168     bl_label = "Armature"
2169
2170     def draw(self, context):
2171         layout = self.layout
2172
2173         edit_object = context.edit_object
2174         arm = edit_object.data
2175
2176         layout.menu("VIEW3D_MT_transform_armature")
2177         layout.menu("VIEW3D_MT_mirror")
2178         layout.menu("VIEW3D_MT_snap")
2179         layout.menu("VIEW3D_MT_edit_armature_roll")
2180
2181         layout.separator()
2182
2183         layout.operator("armature.extrude_move")
2184
2185         if arm.use_mirror_x:
2186             layout.operator("armature.extrude_forked")
2187
2188         layout.operator("armature.duplicate_move")
2189         layout.operator("armature.merge")
2190         layout.operator("armature.fill")
2191         layout.operator("armature.delete")
2192         layout.operator("armature.separate")
2193
2194         layout.separator()
2195
2196         layout.operator("armature.subdivide", text="Subdivide")
2197         layout.operator("armature.switch_direction", text="Switch Direction")
2198
2199         layout.separator()
2200
2201         layout.operator_context = 'EXEC_AREA'
2202         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2203         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2204         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2205         layout.operator("armature.flip_names")
2206
2207         layout.separator()
2208
2209         layout.operator_context = 'INVOKE_DEFAULT'
2210         layout.operator("armature.armature_layers")
2211         layout.operator("armature.bone_layers")
2212
2213         layout.separator()
2214
2215         layout.menu("VIEW3D_MT_edit_armature_parent")
2216
2217         layout.separator()
2218
2219         layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
2220
2221
2222 class VIEW3D_MT_armature_specials(Menu):
2223     bl_label = "Specials"
2224
2225     def draw(self, context):
2226         layout = self.layout
2227
2228         layout.operator_context = 'INVOKE_REGION_WIN'
2229
2230         layout.operator("armature.subdivide", text="Subdivide")
2231         layout.operator("armature.switch_direction", text="Switch Direction")
2232
2233         layout.separator()
2234
2235         layout.operator_context = 'EXEC_REGION_WIN'
2236         layout.operator("armature.autoside_names", text="AutoName Left/Right").type = 'XAXIS'
2237         layout.operator("armature.autoside_names", text="AutoName Front/Back").type = 'YAXIS'
2238         layout.operator("armature.autoside_names", text="AutoName Top/Bottom").type = 'ZAXIS'
2239         layout.operator("armature.flip_names", text="Flip Names")
2240
2241
2242 class VIEW3D_MT_edit_armature_parent(Menu):
2243     bl_label = "Parent"
2244
2245     def draw(self, context):
2246         layout = self.layout
2247
2248         layout.operator("armature.parent_set", text="Make")
2249         layout.operator("armature.parent_clear", text="Clear")
2250
2251
2252 class VIEW3D_MT_edit_armature_roll(Menu):
2253     bl_label = "Bone Roll"
2254
2255     def draw(self, context):
2256         layout = self.layout
2257
2258         layout.operator_menu_enum("armature.calculate_roll", "type")
2259
2260         layout.separator()
2261
2262         layout.operator("transform.transform", text="Set Roll").mode = 'BONE_ROLL'
2263
2264 # ********** Panel **********
2265
2266
2267 class VIEW3D_PT_view3d_properties(Panel):
2268     bl_space_type = 'VIEW_3D'
2269     bl_region_type = 'UI'
2270     bl_label = "View"
2271
2272     @classmethod
2273     def poll(cls, context):
2274         view = context.space_data
2275         return (view)
2276
2277     def draw(self, context):
2278         layout = self.layout
2279
2280         view = context.space_data
2281
2282         col = layout.column()
2283         col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
2284                           view.region_quadview)
2285         col.prop(view, "lens")
2286         col.label(text="Lock to Object:")
2287         col.prop(view, "lock_object", text="")
2288         lock_object = view.lock_object
2289         if lock_object:
2290             if lock_object.type == 'ARMATURE':
2291                 col.prop_search(view, "lock_bone", lock_object.data,
2292                                 "edit_bones" if lock_object.mode == 'EDIT'
2293                                 else "bones",
2294                                 text="")
2295         else:
2296             col.prop(view, "lock_cursor", text="Lock to Cursor")
2297
2298         col = layout.column()
2299         col.prop(view, "lock_camera")
2300
2301         col = layout.column(align=True)
2302         col.label(text="Clip:")
2303         col.prop(view, "clip_start", text="Start")
2304         col.prop(view, "clip_end", text="End")
2305
2306         subcol = col.column()
2307         subcol.enabled = not view.lock_camera_and_layers
2308         subcol.label(text="Local Camera:")
2309         subcol.prop(view, "camera", text="")
2310
2311         col = layout.column(align=True)
2312         col.prop(view, "use_render_border")
2313
2314
2315 class VIEW3D_PT_view3d_cursor(Panel):
2316     bl_space_type = 'VIEW_3D'
2317     bl_region_type = 'UI'
2318     bl_label = "3D Cursor"
2319
2320     @classmethod
2321     def poll(cls, context):
2322         view = context.space_data
2323         return (view is not None)
2324
2325     def draw(self, context):
2326         layout = self.layout
2327
2328         view = context.space_data
2329         layout.column().prop(view, "cursor_location", text="Location")
2330
2331
2332 class VIEW3D_PT_view3d_name(Panel):
2333     bl_space_type = 'VIEW_3D'
2334     bl_region_type = 'UI'
2335     bl_label = "Item"
2336
2337     @classmethod
2338     def poll(cls, context):
2339         return (context.space_data and context.active_object)
2340
2341     def draw(self, context):
2342         layout = self.layout
2343
2344         ob = context.active_object
2345         row = layout.row()
2346         row.label(text="", icon='OBJECT_DATA')
2347         row.prop(ob, "name", text="")
2348
2349         if ob.type == 'ARMATURE' and ob.mode in {'EDIT', 'POSE'}:
2350             bone = context.active_bone
2351             if bone:
2352                 row = layout.row()
2353                 row.label(text="", icon='BONE_DATA')
2354                 row.prop(bone, "name", text="")
2355
2356
2357 class VIEW3D_PT_view3d_display(Panel):
2358     bl_space_type = 'VIEW_3D'
2359     bl_region_type = 'UI'
2360     bl_label = "Display"
2361     bl_options = {'DEFAULT_CLOSED'}
2362
2363     @classmethod
2364     def poll(cls, context):
2365         view = context.space_data
2366         return (view)
2367
2368     def draw(self, context):
2369         layout = self.layout
2370
2371         view = context.space_data
2372         scene = context.scene
2373         gs = scene.game_settings
2374         ob = context.object
2375
2376         col = layout.column()
2377         col.prop(view, "show_only_render")
2378
2379         col = layout.column()
2380         display_all = not view.show_only_render
2381         col.active = display_all
2382         col.prop(view, "show_outline_selected")
2383         col.prop(view, "show_all_objects_origin")
2384         col.prop(view, "show_relationship_lines")
2385         if ob and ob.type == 'MESH':
2386             mesh = ob.data
2387             col.prop(mesh, "show_all_edges")
2388
2389         col = layout.column()
2390         col.active = display_all
2391         split = col.split(percentage=0.55)
2392         split.prop(view, "show_floor", text="Grid Floor")
2393
2394         row = split.row(align=True)
2395         row.prop(view, "show_axis_x", text="X", toggle=True)
2396         row.prop(view, "show_axis_y", text="Y", toggle=True)
2397         row.prop(view, "show_axis_z", text="Z", toggle=True)
2398
2399         sub = col.column(align=True)
2400         sub.active = (display_all and view.show_floor)
2401         sub.prop(view, "grid_lines", text="Lines")
2402         sub.prop(view, "grid_scale", text="Scale")
2403         subsub = sub.column(align=True)
2404         subsub.active = scene.unit_settings.system == 'NONE'
2405         subsub.prop(view, "grid_subdivisions", text="Subdivisions")
2406
2407         if not scene.render.use_shading_nodes:
2408             col = layout.column()
2409             col.label(text="Shading:")
2410             col.prop(gs, "material_mode", text="")
2411             col.prop(view, "show_textured_solid")
2412
2413         col.prop(view, "show_backface_culling")
2414
2415         layout.separator()
2416
2417         region = view.region_quadview
2418
2419         layout.operator("screen.region_quadview", text="Toggle Quad View")
2420
2421         if region:
2422             col = layout.column()
2423             col.prop(region, "lock_rotation")
2424             row = col.row()
2425             row.enabled = region.lock_rotation
2426             row.prop(region, "show_sync_view")
2427             row = col.row()
2428             row.enabled = region.lock_rotation and region.show_sync_view
2429             row.prop(region, "use_box_clip")
2430
2431
2432 class VIEW3D_PT_view3d_motion_tracking(Panel):
2433     bl_space_type = 'VIEW_3D'
2434     bl_region_type = 'UI'
2435     bl_label = "Motion Tracking"
2436     bl_options = {'DEFAULT_CLOSED'}
2437
2438     @classmethod
2439     def poll(cls, context):
2440         view = context.space_data
2441         return (view)
2442
2443     def draw_header(self, context):
2444         view = context.space_data
2445
2446         self.layout.prop(view, "show_reconstruction", text="")
2447
2448     def draw(self, context):
2449         layout = self.layout
2450
2451         view = context.space_data
2452
2453         col = layout.column()
2454         col.active = view.show_reconstruction
2455         col.prop(view, "show_bundle_names")
2456         col.prop(view, "show_camera_path")
2457         col.label(text="Tracks:")
2458         col.prop(view, "tracks_draw_type", text="")
2459         col.prop(view, "tracks_draw_size", text="Size")
2460
2461
2462 class VIEW3D_PT_view3d_meshdisplay(Panel):
2463     bl_space_type = 'VIEW_3D'
2464     bl_region_type = 'UI'
2465     bl_label = "Mesh Display"
2466
2467     @classmethod
2468     def poll(cls, context):
2469         # The active object check is needed because of local-mode
2470         return (context.active_object and (context.mode == 'EDIT_MESH'))
2471
2472     def draw(self, context):
2473         layout = self.layout
2474
2475         mesh = context.active_object.data
2476
2477         col = layout.column()
2478         col.label(text="Overlays:")
2479         col.prop(mesh, "show_edges", text="Edges")
2480         col.prop(mesh, "show_faces", text="Faces")
2481         col.prop(mesh, "show_edge_crease", text="Creases")
2482         col.prop(mesh, "show_edge_bevel_weight", text="Bevel Weights")
2483         col.prop(mesh, "show_edge_seams", text="Seams")
2484         col.prop(mesh, "show_edge_sharp", text="Sharp")
2485
2486         col.separator()
2487         col.label(text="Normals:")
2488         row = col.row()
2489         sub = row.row(align=True)
2490         sub.prop(mesh, "show_normal_vertex", text="", icon='VERTEXSEL')
2491         sub.prop(mesh, "show_normal_face", text="", icon='FACESEL')
2492         row.prop(context.scene.tool_settings, "normal_size", text="Size")
2493
2494         col.separator()
2495         col.label(text="Numerics:")
2496         col.prop(mesh, "show_extra_edge_length")
2497         col.prop(mesh, "show_extra_face_angle")
2498         col.prop(mesh, "show_extra_face_area")
2499         if bpy.app.debug:
2500             col.prop(mesh, "show_extra_indices")
2501
2502
2503 class VIEW3D_PT_view3d_curvedisplay(Panel):
2504     bl_space_type = 'VIEW_3D'
2505     bl_region_type = 'UI'
2506     bl_label = "Curve Display"
2507
2508     @classmethod
2509     def poll(cls, context):
2510         editmesh = context.mode == 'EDIT_CURVE'
2511         return (editmesh)
2512
2513     def draw(self, context):
2514         layout = self.layout
2515
2516         curve = context.active_object.data
2517
2518         col = layout.column()
2519         col.label(text="Overlays:")
2520         col.prop(curve, "show_handles", text="Handles")
2521         col.prop(curve, "show_normal_face", text="Normals")
2522         col.prop(context.scene.tool_settings, "normal_size", text="Normal Size")
2523
2524
2525 class VIEW3D_PT_background_image(Panel):
2526     bl_space_type = 'VIEW_3D'
2527     bl_region_type = 'UI'
2528     bl_label = "Background Images"
2529     bl_options = {'DEFAULT_CLOSED'}
2530
2531     def draw_header(self, context):
2532         view = context.space_data
2533
2534         self.layout.prop(view, "show_background_images", text="")
2535
2536     def draw(self, context):
2537         layout = self.layout
2538
2539         view = context.space_data
2540
2541         col = layout.column()
2542         col.operator("view3d.background_image_add", text="Add Image")
2543
2544         for i, bg in enumerate(view.background_images):
2545             layout.active = view.show_background_images
2546             box = layout.box()
2547             row = box.row(align=True)
2548             row.prop(bg, "show_expanded", text="", emboss=False)
2549             if bg.source == 'IMAGE' and bg.image:
2550                 row.prop(bg.image, "name", text="", emboss=False)
2551             elif bg.source == 'MOVIE_CLIP' and bg.clip:
2552                 row.prop(bg.clip, "name", text="", emboss=False)
2553             else:
2554                 row.label(text="Not Set")
2555
2556             if bg.show_background_image:
2557                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_OFF')
2558             else:
2559                 row.prop(bg, "show_background_image", text="", emboss=False, icon='RESTRICT_VIEW_ON')
2560
2561             row.operator("view3d.background_image_remove", text="", emboss=False, icon='X').index = i
2562
2563             box.prop(bg, "view_axis", text="Axis")
2564
2565             if bg.show_expanded:
2566                 row = box.row()
2567                 row.prop(bg, "source", expand=True)
2568
2569                 has_bg = False
2570                 if bg.source == 'IMAGE':
2571                     row = box.row()
2572                     row.template_ID(bg, "image", open="image.open")
2573                     if bg.image is not None:
2574                         box.template_image(bg, "image", bg.image_user, compact=True)
2575                         has_bg = True
2576
2577                 elif bg.source == 'MOVIE_CLIP':
2578                     box.prop(bg, "use_camera_clip")
2579
2580                     column = box.column()
2581                     column.active = not bg.use_camera_clip
2582                     column.template_ID(bg, "clip", open="clip.open")
2583
2584                     if bg.clip:
2585                         column.template_movieclip(bg, "clip", compact=True)
2586
2587                     if bg.use_camera_clip or bg.clip:
2588                         has_bg = True
2589
2590                     column = box.column()
2591                     column.active = has_bg
2592                     column.prop(bg.clip_user, "proxy_render_size", text="")
2593                     column.prop(bg.clip_user, "use_render_undistorted")
2594
2595                 if has_bg:
2596                     col = box.column()
2597                     col.prop(bg, "opacity", slider=True)
2598
2599                     rowsub = col.row()
2600                     rowsub.prop(bg, "draw_depth", expand=True)
2601
2602                     if bg.view_axis in {'CAMERA', 'ALL'}:
2603                         rowsub = col.row()
2604                         rowsub.prop(bg, "frame_method", expand=True)
2605
2606                     row = col.row(align=True)
2607                     row.prop(bg, "offset_x", text="X")
2608                     row.prop(bg, "offset_y", text="Y")
2609
2610                     if bg.view_axis != 'CAMERA':
2611                         col.prop(bg, "size")
2612
2613
2614 class VIEW3D_PT_transform_orientations(Panel):
2615     bl_space_type = 'VIEW_3D'
2616     bl_region_type = 'UI'
2617     bl_label = "Transform Orientations"
2618     bl_options = {'DEFAULT_CLOSED'}
2619
2620     @classmethod
2621     def poll(cls, context):
2622         view = context.space_data
2623         return (view)
2624
2625     def draw(self, context):
2626         layout = self.layout
2627
2628         view = context.space_data
2629         orientation = view.current_orientation
2630
2631         row = layout.row(align=True)
2632         row.prop(view, "transform_orientation", text="")
2633         row.operator("transform.create_orientation", text="", icon='ZOOMIN')
2634
2635         if orientation:
2636             row = layout.row(align=True)
2637             row.prop(orientation, "name", text="")
2638             row.operator("transform.delete_orientation", text="", icon="X")
2639
2640
2641 class VIEW3D_PT_etch_a_ton(Panel):
2642     bl_space_type = 'VIEW_3D'
2643     bl_region_type = 'UI'
2644     bl_label = "Skeleton Sketching"
2645     bl_options = {'DEFAULT_CLOSED'}
2646
2647     @classmethod
2648     def poll(cls, context):
2649         scene = context.space_data
2650         ob = context.active_object
2651         return scene and ob and ob.type == 'ARMATURE' and ob.mode == 'EDIT'
2652
2653     def draw_header(self, context):
2654         layout = self.layout
2655         toolsettings = context.scene.tool_settings
2656
2657         layout.prop(toolsettings, "use_bone_sketching", text="")
2658
2659     def draw(self, context):
2660         layout = self.layout
2661
2662         toolsettings = context.scene.tool_settings
2663
2664         col = layout.column()
2665
2666         col.prop(toolsettings, "use_etch_quick")
2667         col.prop(toolsettings, "use_etch_overdraw")
2668
2669         col.prop(toolsettings, "etch_convert_mode")
2670
2671         if toolsettings.etch_convert_mode == 'LENGTH':
2672             col.prop(toolsettings, "etch_length_limit")
2673         elif toolsettings.etch_convert_mode == 'ADAPTIVE':
2674             col.prop(toolsettings, "etch_adaptive_limit")
2675         elif toolsettings.etch_convert_mode == 'FIXED':
2676             col.prop(toolsettings, "etch_subdivision_number")
2677         elif toolsettings.etch_convert_mode == 'RETARGET':
2678             col.prop(toolsettings, "etch_template")
2679             col.prop(toolsettings, "etch_roll_mode")
2680             col.prop(toolsettings, "use_etch_autoname")
2681             col.prop(toolsettings, "etch_number")
2682             col.prop(toolsettings, "etch_side")
2683
2684         col.operator("sketch.convert", text="Convert")
2685
2686
2687 class VIEW3D_PT_context_properties(Panel):
2688     bl_space_type = 'VIEW_3D'
2689     bl_region_type = 'UI'
2690     bl_label = "Properties"
2691     bl_options = {'DEFAULT_CLOSED'}
2692
2693     def _active_context_member(context):
2694         obj = context.object
2695         if obj:
2696             mode = obj.mode
2697             if mode == 'POSE':
2698                 return "active_pose_bone"
2699             elif mode == 'EDIT' and obj.type == 'ARMATURE':
2700                 return "active_bone"
2701             else:
2702                 return "object"
2703
2704         return ""
2705
2706     @classmethod
2707     def poll(cls, context):
2708         member = cls._active_context_member(context)
2709         if member:
2710             context_member = getattr(context, member)
2711             return context_member and context_member.keys()
2712
2713         return False
2714
2715     def draw(self, context):
2716         import rna_prop_ui
2717         member = VIEW3D_PT_context_properties._active_context_member(context)
2718
2719         if member:
2720             # Draw with no edit button
2721             rna_prop_ui.draw(self.layout, context, member, object, False)
2722
2723
2724 def register():
2725     bpy.utils.register_module(__name__)
2726
2727
2728 def unregister():
2729     bpy.utils.unregister_module(__name__)
2730
2731 if __name__ == "__main__":
2732     register()
2733
2734 if __name__ == "__main__":  # only for live edit.
2735     bpy.utils.register_module(__name__)