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