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