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