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